babylon.module.d.ts 5.5 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module "babylonjs/Misc/observable" {
  50. import { Nullable } from "babylonjs/types";
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. }
  94. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */
  111. _willBeUnregistered: boolean;
  112. /**
  113. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  114. */
  115. unregisterOnNextCall: boolean;
  116. /**
  117. * Creates a new observer
  118. * @param callback defines the callback to call when the observer is notified
  119. * @param mask defines the mask of the observer (used to filter notifications)
  120. * @param scope defines the current scope used to restore the JS context
  121. */
  122. constructor(
  123. /**
  124. * Defines the callback to call when the observer is notified
  125. */
  126. callback: (eventData: T, eventState: EventState) => void,
  127. /**
  128. * Defines the mask of the observer (used to filter notifications)
  129. */
  130. mask: number,
  131. /**
  132. * Defines the current scope used to restore the JS context
  133. */
  134. scope?: any);
  135. }
  136. /**
  137. * Represent a list of observers registered to multiple Observables object.
  138. */
  139. export class MultiObserver<T> {
  140. private _observers;
  141. private _observables;
  142. /**
  143. * Release associated resources
  144. */
  145. dispose(): void;
  146. /**
  147. * Raise a callback when one of the observable will notify
  148. * @param observables defines a list of observables to watch
  149. * @param callback defines the callback to call on notification
  150. * @param mask defines the mask used to filter notifications
  151. * @param scope defines the current scope used to restore the JS context
  152. * @returns the new MultiObserver
  153. */
  154. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  155. }
  156. /**
  157. * The Observable class is a simple implementation of the Observable pattern.
  158. *
  159. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  160. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  161. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  162. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  163. */
  164. export class Observable<T> {
  165. private _observers;
  166. private _eventState;
  167. private _onObserverAdded;
  168. /**
  169. * Gets the list of observers
  170. */
  171. readonly observers: Array<Observer<T>>;
  172. /**
  173. * Creates a new observable
  174. * @param onObserverAdded defines a callback to call when a new observer is added
  175. */
  176. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  177. /**
  178. * Create a new Observer with the specified callback
  179. * @param callback the callback that will be executed for that Observer
  180. * @param mask the mask used to filter observers
  181. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  182. * @param scope optional scope for the callback to be called from
  183. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  184. * @returns the new observer created for the callback
  185. */
  186. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  187. /**
  188. * Create a new Observer with the specified callback and unregisters after the next notification
  189. * @param callback the callback that will be executed for that Observer
  190. * @returns the new observer created for the callback
  191. */
  192. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  193. /**
  194. * Remove an Observer from the Observable object
  195. * @param observer the instance of the Observer to remove
  196. * @returns false if it doesn't belong to this Observable
  197. */
  198. remove(observer: Nullable<Observer<T>>): boolean;
  199. /**
  200. * Remove a callback from the Observable object
  201. * @param callback the callback to remove
  202. * @param scope optional scope. If used only the callbacks with this scope will be removed
  203. * @returns false if it doesn't belong to this Observable
  204. */
  205. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  206. private _deferUnregister;
  207. private _remove;
  208. /**
  209. * Moves the observable to the top of the observer list making it get called first when notified
  210. * @param observer the observer to move
  211. */
  212. makeObserverTopPriority(observer: Observer<T>): void;
  213. /**
  214. * Moves the observable to the bottom of the observer list making it get called last when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverBottomPriority(observer: Observer<T>): void;
  218. /**
  219. * Notify all Observers by calling their respective callback with the given data
  220. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  221. * @param eventData defines the data to send to all observers
  222. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  223. * @param target defines the original target of the state
  224. * @param currentTarget defines the current target of the state
  225. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  226. */
  227. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  228. /**
  229. * Calling this will execute each callback, expecting it to be a promise or return a value.
  230. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  231. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  232. * and it is crucial that all callbacks will be executed.
  233. * The order of the callbacks is kept, callbacks are not executed parallel.
  234. *
  235. * @param eventData The data to be sent to each callback
  236. * @param mask is used to filter observers defaults to -1
  237. * @param target defines the callback target (see EventState)
  238. * @param currentTarget defines he current object in the bubbling phase
  239. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  240. */
  241. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  242. /**
  243. * Notify a specific observer
  244. * @param observer defines the observer to notify
  245. * @param eventData defines the data to be sent to each callback
  246. * @param mask is used to filter observers defaults to -1
  247. */
  248. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  249. /**
  250. * Gets a boolean indicating if the observable has at least one observer
  251. * @returns true is the Observable has at least one Observer registered
  252. */
  253. hasObservers(): boolean;
  254. /**
  255. * Clear the list of observers
  256. */
  257. clear(): void;
  258. /**
  259. * Clone the current observable
  260. * @returns a new observable
  261. */
  262. clone(): Observable<T>;
  263. /**
  264. * Does this observable handles observer registered with a given mask
  265. * @param mask defines the mask to be tested
  266. * @return whether or not one observer registered with the given mask is handeled
  267. **/
  268. hasSpecificMask(mask?: number): boolean;
  269. }
  270. }
  271. declare module "babylonjs/Misc/domManagement" {
  272. /**
  273. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  274. * Babylon.js
  275. */
  276. export class DomManagement {
  277. /**
  278. * Checks if the window object exists
  279. * @returns true if the window object exists
  280. */
  281. static IsWindowObjectExist(): boolean;
  282. /**
  283. * Checks if the navigator object exists
  284. * @returns true if the navigator object exists
  285. */
  286. static IsNavigatorAvailable(): boolean;
  287. /**
  288. * Extracts text content from a DOM element hierarchy
  289. * @param element defines the root element
  290. * @returns a string
  291. */
  292. static GetDOMTextContent(element: HTMLElement): string;
  293. }
  294. }
  295. declare module "babylonjs/Misc/logger" {
  296. /**
  297. * Logger used througouht the application to allow configuration of
  298. * the log level required for the messages.
  299. */
  300. export class Logger {
  301. /**
  302. * No log
  303. */
  304. static readonly NoneLogLevel: number;
  305. /**
  306. * Only message logs
  307. */
  308. static readonly MessageLogLevel: number;
  309. /**
  310. * Only warning logs
  311. */
  312. static readonly WarningLogLevel: number;
  313. /**
  314. * Only error logs
  315. */
  316. static readonly ErrorLogLevel: number;
  317. /**
  318. * All logs
  319. */
  320. static readonly AllLogLevel: number;
  321. private static _LogCache;
  322. /**
  323. * Gets a value indicating the number of loading errors
  324. * @ignorenaming
  325. */
  326. static errorsCount: number;
  327. /**
  328. * Callback called when a new log is added
  329. */
  330. static OnNewCacheEntry: (entry: string) => void;
  331. private static _AddLogEntry;
  332. private static _FormatMessage;
  333. private static _LogDisabled;
  334. private static _LogEnabled;
  335. private static _WarnDisabled;
  336. private static _WarnEnabled;
  337. private static _ErrorDisabled;
  338. private static _ErrorEnabled;
  339. /**
  340. * Log a message to the console
  341. */
  342. static Log: (message: string) => void;
  343. /**
  344. * Write a warning message to the console
  345. */
  346. static Warn: (message: string) => void;
  347. /**
  348. * Write an error message to the console
  349. */
  350. static Error: (message: string) => void;
  351. /**
  352. * Gets current log cache (list of logs)
  353. */
  354. static readonly LogCache: string;
  355. /**
  356. * Clears the log cache
  357. */
  358. static ClearLogCache(): void;
  359. /**
  360. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  361. */
  362. static LogLevels: number;
  363. }
  364. }
  365. declare module "babylonjs/Misc/typeStore" {
  366. /** @hidden */
  367. export class _TypeStore {
  368. /** @hidden */
  369. static RegisteredTypes: {
  370. [key: string]: Object;
  371. };
  372. /** @hidden */
  373. static GetClass(fqdn: string): any;
  374. }
  375. }
  376. declare module "babylonjs/Misc/deepCopier" {
  377. /**
  378. * Class containing a set of static utilities functions for deep copy.
  379. */
  380. export class DeepCopier {
  381. /**
  382. * Tries to copy an object by duplicating every property
  383. * @param source defines the source object
  384. * @param destination defines the target object
  385. * @param doNotCopyList defines a list of properties to avoid
  386. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  387. */
  388. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  389. }
  390. }
  391. declare module "babylonjs/Misc/precisionDate" {
  392. /**
  393. * Class containing a set of static utilities functions for precision date
  394. */
  395. export class PrecisionDate {
  396. /**
  397. * Gets either window.performance.now() if supported or Date.now() else
  398. */
  399. static readonly Now: number;
  400. }
  401. }
  402. declare module "babylonjs/Misc/devTools" {
  403. /** @hidden */
  404. export class _DevTools {
  405. static WarnImport(name: string): string;
  406. }
  407. }
  408. declare module "babylonjs/Misc/webRequest" {
  409. /**
  410. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  411. */
  412. export class WebRequest {
  413. private _xhr;
  414. /**
  415. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  416. * i.e. when loading files, where the server/service expects an Authorization header
  417. */
  418. static CustomRequestHeaders: {
  419. [key: string]: string;
  420. };
  421. /**
  422. * Add callback functions in this array to update all the requests before they get sent to the network
  423. */
  424. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  425. private _injectCustomRequestHeaders;
  426. /**
  427. * Gets or sets a function to be called when loading progress changes
  428. */
  429. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  430. /**
  431. * Returns client's state
  432. */
  433. readonly readyState: number;
  434. /**
  435. * Returns client's status
  436. */
  437. readonly status: number;
  438. /**
  439. * Returns client's status as a text
  440. */
  441. readonly statusText: string;
  442. /**
  443. * Returns client's response
  444. */
  445. readonly response: any;
  446. /**
  447. * Returns client's response url
  448. */
  449. readonly responseURL: string;
  450. /**
  451. * Returns client's response as text
  452. */
  453. readonly responseText: string;
  454. /**
  455. * Gets or sets the expected response type
  456. */
  457. responseType: XMLHttpRequestResponseType;
  458. /** @hidden */
  459. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  460. /** @hidden */
  461. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  462. /**
  463. * Cancels any network activity
  464. */
  465. abort(): void;
  466. /**
  467. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  468. * @param body defines an optional request body
  469. */
  470. send(body?: Document | BodyInit | null): void;
  471. /**
  472. * Sets the request method, request URL
  473. * @param method defines the method to use (GET, POST, etc..)
  474. * @param url defines the url to connect with
  475. */
  476. open(method: string, url: string): void;
  477. }
  478. }
  479. declare module "babylonjs/Misc/fileRequest" {
  480. import { Observable } from "babylonjs/Misc/observable";
  481. /**
  482. * File request interface
  483. */
  484. export interface IFileRequest {
  485. /**
  486. * Raised when the request is complete (success or error).
  487. */
  488. onCompleteObservable: Observable<IFileRequest>;
  489. /**
  490. * Aborts the request for a file.
  491. */
  492. abort: () => void;
  493. }
  494. }
  495. declare module "babylonjs/Misc/performanceMonitor" {
  496. /**
  497. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  498. */
  499. export class PerformanceMonitor {
  500. private _enabled;
  501. private _rollingFrameTime;
  502. private _lastFrameTimeMs;
  503. /**
  504. * constructor
  505. * @param frameSampleSize The number of samples required to saturate the sliding window
  506. */
  507. constructor(frameSampleSize?: number);
  508. /**
  509. * Samples current frame
  510. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  511. */
  512. sampleFrame(timeMs?: number): void;
  513. /**
  514. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  515. */
  516. readonly averageFrameTime: number;
  517. /**
  518. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  519. */
  520. readonly averageFrameTimeVariance: number;
  521. /**
  522. * Returns the frame time of the most recent frame
  523. */
  524. readonly instantaneousFrameTime: number;
  525. /**
  526. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  527. */
  528. readonly averageFPS: number;
  529. /**
  530. * Returns the average framerate in frames per second using the most recent frame time
  531. */
  532. readonly instantaneousFPS: number;
  533. /**
  534. * Returns true if enough samples have been taken to completely fill the sliding window
  535. */
  536. readonly isSaturated: boolean;
  537. /**
  538. * Enables contributions to the sliding window sample set
  539. */
  540. enable(): void;
  541. /**
  542. * Disables contributions to the sliding window sample set
  543. * Samples will not be interpolated over the disabled period
  544. */
  545. disable(): void;
  546. /**
  547. * Returns true if sampling is enabled
  548. */
  549. readonly isEnabled: boolean;
  550. /**
  551. * Resets performance monitor
  552. */
  553. reset(): void;
  554. }
  555. /**
  556. * RollingAverage
  557. *
  558. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  559. */
  560. export class RollingAverage {
  561. /**
  562. * Current average
  563. */
  564. average: number;
  565. /**
  566. * Current variance
  567. */
  568. variance: number;
  569. protected _samples: Array<number>;
  570. protected _sampleCount: number;
  571. protected _pos: number;
  572. protected _m2: number;
  573. /**
  574. * constructor
  575. * @param length The number of samples required to saturate the sliding window
  576. */
  577. constructor(length: number);
  578. /**
  579. * Adds a sample to the sample set
  580. * @param v The sample value
  581. */
  582. add(v: number): void;
  583. /**
  584. * Returns previously added values or null if outside of history or outside the sliding window domain
  585. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  586. * @return Value previously recorded with add() or null if outside of range
  587. */
  588. history(i: number): number;
  589. /**
  590. * Returns true if enough samples have been taken to completely fill the sliding window
  591. * @return true if sample-set saturated
  592. */
  593. isSaturated(): boolean;
  594. /**
  595. * Resets the rolling average (equivalent to 0 samples taken so far)
  596. */
  597. reset(): void;
  598. /**
  599. * Wraps a value around the sample range boundaries
  600. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  601. * @return Wrapped position in sample range
  602. */
  603. protected _wrapPosition(i: number): number;
  604. }
  605. }
  606. declare module "babylonjs/Misc/stringDictionary" {
  607. import { Nullable } from "babylonjs/types";
  608. /**
  609. * This class implement a typical dictionary using a string as key and the generic type T as value.
  610. * The underlying implementation relies on an associative array to ensure the best performances.
  611. * The value can be anything including 'null' but except 'undefined'
  612. */
  613. export class StringDictionary<T> {
  614. /**
  615. * This will clear this dictionary and copy the content from the 'source' one.
  616. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  617. * @param source the dictionary to take the content from and copy to this dictionary
  618. */
  619. copyFrom(source: StringDictionary<T>): void;
  620. /**
  621. * Get a value based from its key
  622. * @param key the given key to get the matching value from
  623. * @return the value if found, otherwise undefined is returned
  624. */
  625. get(key: string): T | undefined;
  626. /**
  627. * Get a value from its key or add it if it doesn't exist.
  628. * This method will ensure you that a given key/data will be present in the dictionary.
  629. * @param key the given key to get the matching value from
  630. * @param factory the factory that will create the value if the key is not present in the dictionary.
  631. * The factory will only be invoked if there's no data for the given key.
  632. * @return the value corresponding to the key.
  633. */
  634. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  635. /**
  636. * Get a value from its key if present in the dictionary otherwise add it
  637. * @param key the key to get the value from
  638. * @param val if there's no such key/value pair in the dictionary add it with this value
  639. * @return the value corresponding to the key
  640. */
  641. getOrAdd(key: string, val: T): T;
  642. /**
  643. * Check if there's a given key in the dictionary
  644. * @param key the key to check for
  645. * @return true if the key is present, false otherwise
  646. */
  647. contains(key: string): boolean;
  648. /**
  649. * Add a new key and its corresponding value
  650. * @param key the key to add
  651. * @param value the value corresponding to the key
  652. * @return true if the operation completed successfully, false if we couldn't insert the key/value because there was already this key in the dictionary
  653. */
  654. add(key: string, value: T): boolean;
  655. /**
  656. * Update a specific value associated to a key
  657. * @param key defines the key to use
  658. * @param value defines the value to store
  659. * @returns true if the value was updated (or false if the key was not found)
  660. */
  661. set(key: string, value: T): boolean;
  662. /**
  663. * Get the element of the given key and remove it from the dictionary
  664. * @param key defines the key to search
  665. * @returns the value associated with the key or null if not found
  666. */
  667. getAndRemove(key: string): Nullable<T>;
  668. /**
  669. * Remove a key/value from the dictionary.
  670. * @param key the key to remove
  671. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  672. */
  673. remove(key: string): boolean;
  674. /**
  675. * Clear the whole content of the dictionary
  676. */
  677. clear(): void;
  678. /**
  679. * Gets the current count
  680. */
  681. readonly count: number;
  682. /**
  683. * Execute a callback on each key/val of the dictionary.
  684. * Note that you can remove any element in this dictionary in the callback implementation
  685. * @param callback the callback to execute on a given key/value pair
  686. */
  687. forEach(callback: (key: string, val: T) => void): void;
  688. /**
  689. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  690. * If the callback returns null or undefined the method will iterate to the next key/value pair
  691. * Note that you can remove any element in this dictionary in the callback implementation
  692. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  693. * @returns the first item
  694. */
  695. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  696. private _count;
  697. private _data;
  698. }
  699. }
  700. declare module "babylonjs/Meshes/dataBuffer" {
  701. /**
  702. * Class used to store gfx data (like WebGLBuffer)
  703. */
  704. export class DataBuffer {
  705. /**
  706. * Gets or sets the number of objects referencing this buffer
  707. */
  708. references: number;
  709. /** Gets or sets the size of the underlying buffer */
  710. capacity: number;
  711. /**
  712. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  713. */
  714. is32Bits: boolean;
  715. /**
  716. * Gets the underlying buffer
  717. */
  718. readonly underlyingResource: any;
  719. }
  720. }
  721. declare module "babylonjs/Meshes/buffer" {
  722. import { Nullable, DataArray } from "babylonjs/types";
  723. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  724. /**
  725. * Class used to store data that will be store in GPU memory
  726. */
  727. export class Buffer {
  728. private _engine;
  729. private _buffer;
  730. /** @hidden */
  731. _data: Nullable<DataArray>;
  732. private _updatable;
  733. private _instanced;
  734. /**
  735. * Gets the byte stride.
  736. */
  737. readonly byteStride: number;
  738. /**
  739. * Constructor
  740. * @param engine the engine
  741. * @param data the data to use for this buffer
  742. * @param updatable whether the data is updatable
  743. * @param stride the stride (optional)
  744. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  745. * @param instanced whether the buffer is instanced (optional)
  746. * @param useBytes set to true if the stride in in bytes (optional)
  747. */
  748. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  749. /**
  750. * Create a new VertexBuffer based on the current buffer
  751. * @param kind defines the vertex buffer kind (position, normal, etc.)
  752. * @param offset defines offset in the buffer (0 by default)
  753. * @param size defines the size in floats of attributes (position is 3 for instance)
  754. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  755. * @param instanced defines if the vertex buffer contains indexed data
  756. * @param useBytes defines if the offset and stride are in bytes
  757. * @returns the new vertex buffer
  758. */
  759. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  760. /**
  761. * Gets a boolean indicating if the Buffer is updatable?
  762. * @returns true if the buffer is updatable
  763. */
  764. isUpdatable(): boolean;
  765. /**
  766. * Gets current buffer's data
  767. * @returns a DataArray or null
  768. */
  769. getData(): Nullable<DataArray>;
  770. /**
  771. * Gets underlying native buffer
  772. * @returns underlying native buffer
  773. */
  774. getBuffer(): Nullable<DataBuffer>;
  775. /**
  776. * Gets the stride in float32 units (i.e. byte stride / 4).
  777. * May not be an integer if the byte stride is not divisible by 4.
  778. * DEPRECATED. Use byteStride instead.
  779. * @returns the stride in float32 units
  780. */
  781. getStrideSize(): number;
  782. /**
  783. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  784. * @param data defines the data to store
  785. */
  786. create(data?: Nullable<DataArray>): void;
  787. /** @hidden */
  788. _rebuild(): void;
  789. /**
  790. * Update current buffer data
  791. * @param data defines the data to store
  792. */
  793. update(data: DataArray): void;
  794. /**
  795. * Updates the data directly.
  796. * @param data the new data
  797. * @param offset the new offset
  798. * @param vertexCount the vertex count (optional)
  799. * @param useBytes set to true if the offset is in bytes
  800. */
  801. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  802. /**
  803. * Release all resources
  804. */
  805. dispose(): void;
  806. }
  807. /**
  808. * Specialized buffer used to store vertex data
  809. */
  810. export class VertexBuffer {
  811. /** @hidden */
  812. _buffer: Buffer;
  813. private _kind;
  814. private _size;
  815. private _ownsBuffer;
  816. private _instanced;
  817. private _instanceDivisor;
  818. /**
  819. * The byte type.
  820. */
  821. static readonly BYTE: number;
  822. /**
  823. * The unsigned byte type.
  824. */
  825. static readonly UNSIGNED_BYTE: number;
  826. /**
  827. * The short type.
  828. */
  829. static readonly SHORT: number;
  830. /**
  831. * The unsigned short type.
  832. */
  833. static readonly UNSIGNED_SHORT: number;
  834. /**
  835. * The integer type.
  836. */
  837. static readonly INT: number;
  838. /**
  839. * The unsigned integer type.
  840. */
  841. static readonly UNSIGNED_INT: number;
  842. /**
  843. * The float type.
  844. */
  845. static readonly FLOAT: number;
  846. /**
  847. * Gets or sets the instance divisor when in instanced mode
  848. */
  849. instanceDivisor: number;
  850. /**
  851. * Gets the byte stride.
  852. */
  853. readonly byteStride: number;
  854. /**
  855. * Gets the byte offset.
  856. */
  857. readonly byteOffset: number;
  858. /**
  859. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  860. */
  861. readonly normalized: boolean;
  862. /**
  863. * Gets the data type of each component in the array.
  864. */
  865. readonly type: number;
  866. /**
  867. * Constructor
  868. * @param engine the engine
  869. * @param data the data to use for this vertex buffer
  870. * @param kind the vertex buffer kind
  871. * @param updatable whether the data is updatable
  872. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  873. * @param stride the stride (optional)
  874. * @param instanced whether the buffer is instanced (optional)
  875. * @param offset the offset of the data (optional)
  876. * @param size the number of components (optional)
  877. * @param type the type of the component (optional)
  878. * @param normalized whether the data contains normalized data (optional)
  879. * @param useBytes set to true if stride and offset are in bytes (optional)
  880. */
  881. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean);
  882. /** @hidden */
  883. _rebuild(): void;
  884. /**
  885. * Returns the kind of the VertexBuffer (string)
  886. * @returns a string
  887. */
  888. getKind(): string;
  889. /**
  890. * Gets a boolean indicating if the VertexBuffer is updatable?
  891. * @returns true if the buffer is updatable
  892. */
  893. isUpdatable(): boolean;
  894. /**
  895. * Gets current buffer's data
  896. * @returns a DataArray or null
  897. */
  898. getData(): Nullable<DataArray>;
  899. /**
  900. * Gets underlying native buffer
  901. * @returns underlying native buffer
  902. */
  903. getBuffer(): Nullable<DataBuffer>;
  904. /**
  905. * Gets the stride in float32 units (i.e. byte stride / 4).
  906. * May not be an integer if the byte stride is not divisible by 4.
  907. * DEPRECATED. Use byteStride instead.
  908. * @returns the stride in float32 units
  909. */
  910. getStrideSize(): number;
  911. /**
  912. * Returns the offset as a multiple of the type byte length.
  913. * DEPRECATED. Use byteOffset instead.
  914. * @returns the offset in bytes
  915. */
  916. getOffset(): number;
  917. /**
  918. * Returns the number of components per vertex attribute (integer)
  919. * @returns the size in float
  920. */
  921. getSize(): number;
  922. /**
  923. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  924. * @returns true if this buffer is instanced
  925. */
  926. getIsInstanced(): boolean;
  927. /**
  928. * Returns the instancing divisor, zero for non-instanced (integer).
  929. * @returns a number
  930. */
  931. getInstanceDivisor(): number;
  932. /**
  933. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  934. * @param data defines the data to store
  935. */
  936. create(data?: DataArray): void;
  937. /**
  938. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  939. * This function will create a new buffer if the current one is not updatable
  940. * @param data defines the data to store
  941. */
  942. update(data: DataArray): void;
  943. /**
  944. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  945. * Returns the directly updated WebGLBuffer.
  946. * @param data the new data
  947. * @param offset the new offset
  948. * @param useBytes set to true if the offset is in bytes
  949. */
  950. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  951. /**
  952. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  953. */
  954. dispose(): void;
  955. /**
  956. * Enumerates each value of this vertex buffer as numbers.
  957. * @param count the number of values to enumerate
  958. * @param callback the callback function called for each value
  959. */
  960. forEach(count: number, callback: (value: number, index: number) => void): void;
  961. /**
  962. * Positions
  963. */
  964. static readonly PositionKind: string;
  965. /**
  966. * Normals
  967. */
  968. static readonly NormalKind: string;
  969. /**
  970. * Tangents
  971. */
  972. static readonly TangentKind: string;
  973. /**
  974. * Texture coordinates
  975. */
  976. static readonly UVKind: string;
  977. /**
  978. * Texture coordinates 2
  979. */
  980. static readonly UV2Kind: string;
  981. /**
  982. * Texture coordinates 3
  983. */
  984. static readonly UV3Kind: string;
  985. /**
  986. * Texture coordinates 4
  987. */
  988. static readonly UV4Kind: string;
  989. /**
  990. * Texture coordinates 5
  991. */
  992. static readonly UV5Kind: string;
  993. /**
  994. * Texture coordinates 6
  995. */
  996. static readonly UV6Kind: string;
  997. /**
  998. * Colors
  999. */
  1000. static readonly ColorKind: string;
  1001. /**
  1002. * Matrix indices (for bones)
  1003. */
  1004. static readonly MatricesIndicesKind: string;
  1005. /**
  1006. * Matrix weights (for bones)
  1007. */
  1008. static readonly MatricesWeightsKind: string;
  1009. /**
  1010. * Additional matrix indices (for bones)
  1011. */
  1012. static readonly MatricesIndicesExtraKind: string;
  1013. /**
  1014. * Additional matrix weights (for bones)
  1015. */
  1016. static readonly MatricesWeightsExtraKind: string;
  1017. /**
  1018. * Deduces the stride given a kind.
  1019. * @param kind The kind string to deduce
  1020. * @returns The deduced stride
  1021. */
  1022. static DeduceStride(kind: string): number;
  1023. /**
  1024. * Gets the byte length of the given type.
  1025. * @param type the type
  1026. * @returns the number of bytes
  1027. */
  1028. static GetTypeByteLength(type: number): number;
  1029. /**
  1030. * Enumerates each value of the given parameters as numbers.
  1031. * @param data the data to enumerate
  1032. * @param byteOffset the byte offset of the data
  1033. * @param byteStride the byte stride of the data
  1034. * @param componentCount the number of components per element
  1035. * @param componentType the type of the component
  1036. * @param count the number of values to enumerate
  1037. * @param normalized whether the data is normalized
  1038. * @param callback the callback function called for each value
  1039. */
  1040. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  1041. private static _GetFloatValue;
  1042. }
  1043. }
  1044. declare module "babylonjs/Maths/math.scalar" {
  1045. /**
  1046. * Scalar computation library
  1047. */
  1048. export class Scalar {
  1049. /**
  1050. * Two pi constants convenient for computation.
  1051. */
  1052. static TwoPi: number;
  1053. /**
  1054. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1055. * @param a number
  1056. * @param b number
  1057. * @param epsilon (default = 1.401298E-45)
  1058. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1059. */
  1060. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1061. /**
  1062. * Returns a string : the upper case translation of the number i to hexadecimal.
  1063. * @param i number
  1064. * @returns the upper case translation of the number i to hexadecimal.
  1065. */
  1066. static ToHex(i: number): string;
  1067. /**
  1068. * Returns -1 if value is negative and +1 is value is positive.
  1069. * @param value the value
  1070. * @returns the value itself if it's equal to zero.
  1071. */
  1072. static Sign(value: number): number;
  1073. /**
  1074. * Returns the value itself if it's between min and max.
  1075. * Returns min if the value is lower than min.
  1076. * Returns max if the value is greater than max.
  1077. * @param value the value to clmap
  1078. * @param min the min value to clamp to (default: 0)
  1079. * @param max the max value to clamp to (default: 1)
  1080. * @returns the clamped value
  1081. */
  1082. static Clamp(value: number, min?: number, max?: number): number;
  1083. /**
  1084. * the log2 of value.
  1085. * @param value the value to compute log2 of
  1086. * @returns the log2 of value.
  1087. */
  1088. static Log2(value: number): number;
  1089. /**
  1090. * Loops the value, so that it is never larger than length and never smaller than 0.
  1091. *
  1092. * This is similar to the modulo operator but it works with floating point numbers.
  1093. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1094. * With t = 5 and length = 2.5, the result would be 0.0.
  1095. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1096. * @param value the value
  1097. * @param length the length
  1098. * @returns the looped value
  1099. */
  1100. static Repeat(value: number, length: number): number;
  1101. /**
  1102. * Normalize the value between 0.0 and 1.0 using min and max values
  1103. * @param value value to normalize
  1104. * @param min max to normalize between
  1105. * @param max min to normalize between
  1106. * @returns the normalized value
  1107. */
  1108. static Normalize(value: number, min: number, max: number): number;
  1109. /**
  1110. * Denormalize the value from 0.0 and 1.0 using min and max values
  1111. * @param normalized value to denormalize
  1112. * @param min max to denormalize between
  1113. * @param max min to denormalize between
  1114. * @returns the denormalized value
  1115. */
  1116. static Denormalize(normalized: number, min: number, max: number): number;
  1117. /**
  1118. * Calculates the shortest difference between two given angles given in degrees.
  1119. * @param current current angle in degrees
  1120. * @param target target angle in degrees
  1121. * @returns the delta
  1122. */
  1123. static DeltaAngle(current: number, target: number): number;
  1124. /**
  1125. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1126. * @param tx value
  1127. * @param length length
  1128. * @returns The returned value will move back and forth between 0 and length
  1129. */
  1130. static PingPong(tx: number, length: number): number;
  1131. /**
  1132. * Interpolates between min and max with smoothing at the limits.
  1133. *
  1134. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1135. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1136. * @param from from
  1137. * @param to to
  1138. * @param tx value
  1139. * @returns the smooth stepped value
  1140. */
  1141. static SmoothStep(from: number, to: number, tx: number): number;
  1142. /**
  1143. * Moves a value current towards target.
  1144. *
  1145. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1146. * Negative values of maxDelta pushes the value away from target.
  1147. * @param current current value
  1148. * @param target target value
  1149. * @param maxDelta max distance to move
  1150. * @returns resulting value
  1151. */
  1152. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1153. /**
  1154. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1155. *
  1156. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1157. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1158. * @param current current value
  1159. * @param target target value
  1160. * @param maxDelta max distance to move
  1161. * @returns resulting angle
  1162. */
  1163. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1164. /**
  1165. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1166. * @param start start value
  1167. * @param end target value
  1168. * @param amount amount to lerp between
  1169. * @returns the lerped value
  1170. */
  1171. static Lerp(start: number, end: number, amount: number): number;
  1172. /**
  1173. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1174. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1175. * @param start start value
  1176. * @param end target value
  1177. * @param amount amount to lerp between
  1178. * @returns the lerped value
  1179. */
  1180. static LerpAngle(start: number, end: number, amount: number): number;
  1181. /**
  1182. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1183. * @param a start value
  1184. * @param b target value
  1185. * @param value value between a and b
  1186. * @returns the inverseLerp value
  1187. */
  1188. static InverseLerp(a: number, b: number, value: number): number;
  1189. /**
  1190. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1191. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1192. * @param value1 spline value
  1193. * @param tangent1 spline value
  1194. * @param value2 spline value
  1195. * @param tangent2 spline value
  1196. * @param amount input value
  1197. * @returns hermite result
  1198. */
  1199. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1200. /**
  1201. * Returns a random float number between and min and max values
  1202. * @param min min value of random
  1203. * @param max max value of random
  1204. * @returns random value
  1205. */
  1206. static RandomRange(min: number, max: number): number;
  1207. /**
  1208. * This function returns percentage of a number in a given range.
  1209. *
  1210. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1211. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1212. * @param number to convert to percentage
  1213. * @param min min range
  1214. * @param max max range
  1215. * @returns the percentage
  1216. */
  1217. static RangeToPercent(number: number, min: number, max: number): number;
  1218. /**
  1219. * This function returns number that corresponds to the percentage in a given range.
  1220. *
  1221. * PercentToRange(0.34,0,100) will return 34.
  1222. * @param percent to convert to number
  1223. * @param min min range
  1224. * @param max max range
  1225. * @returns the number
  1226. */
  1227. static PercentToRange(percent: number, min: number, max: number): number;
  1228. /**
  1229. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1230. * @param angle The angle to normalize in radian.
  1231. * @return The converted angle.
  1232. */
  1233. static NormalizeRadians(angle: number): number;
  1234. }
  1235. }
  1236. declare module "babylonjs/Maths/math.constants" {
  1237. /**
  1238. * Constant used to convert a value to gamma space
  1239. * @ignorenaming
  1240. */
  1241. export const ToGammaSpace: number;
  1242. /**
  1243. * Constant used to convert a value to linear space
  1244. * @ignorenaming
  1245. */
  1246. export const ToLinearSpace = 2.2;
  1247. /**
  1248. * Constant used to define the minimal number value in Babylon.js
  1249. * @ignorenaming
  1250. */
  1251. let Epsilon: number;
  1252. export { Epsilon };
  1253. }
  1254. declare module "babylonjs/Maths/math.viewport" {
  1255. /**
  1256. * Class used to represent a viewport on screen
  1257. */
  1258. export class Viewport {
  1259. /** viewport left coordinate */
  1260. x: number;
  1261. /** viewport top coordinate */
  1262. y: number;
  1263. /**viewport width */
  1264. width: number;
  1265. /** viewport height */
  1266. height: number;
  1267. /**
  1268. * Creates a Viewport object located at (x, y) and sized (width, height)
  1269. * @param x defines viewport left coordinate
  1270. * @param y defines viewport top coordinate
  1271. * @param width defines the viewport width
  1272. * @param height defines the viewport height
  1273. */
  1274. constructor(
  1275. /** viewport left coordinate */
  1276. x: number,
  1277. /** viewport top coordinate */
  1278. y: number,
  1279. /**viewport width */
  1280. width: number,
  1281. /** viewport height */
  1282. height: number);
  1283. /**
  1284. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1285. * @param renderWidth defines the rendering width
  1286. * @param renderHeight defines the rendering height
  1287. * @returns a new Viewport
  1288. */
  1289. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1290. /**
  1291. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1292. * @param renderWidth defines the rendering width
  1293. * @param renderHeight defines the rendering height
  1294. * @param ref defines the target viewport
  1295. * @returns the current viewport
  1296. */
  1297. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1298. /**
  1299. * Returns a new Viewport copied from the current one
  1300. * @returns a new Viewport
  1301. */
  1302. clone(): Viewport;
  1303. }
  1304. }
  1305. declare module "babylonjs/Misc/arrayTools" {
  1306. /**
  1307. * Class containing a set of static utilities functions for arrays.
  1308. */
  1309. export class ArrayTools {
  1310. /**
  1311. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1312. * @param size the number of element to construct and put in the array
  1313. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1314. * @returns a new array filled with new objects
  1315. */
  1316. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1317. }
  1318. }
  1319. declare module "babylonjs/Maths/math.like" {
  1320. import { float, int, DeepImmutable } from "babylonjs/types";
  1321. /**
  1322. * @hidden
  1323. */
  1324. export interface IColor4Like {
  1325. r: float;
  1326. g: float;
  1327. b: float;
  1328. a: float;
  1329. }
  1330. /**
  1331. * @hidden
  1332. */
  1333. export interface IColor3Like {
  1334. r: float;
  1335. g: float;
  1336. b: float;
  1337. }
  1338. /**
  1339. * @hidden
  1340. */
  1341. export interface IVector4Like {
  1342. x: float;
  1343. y: float;
  1344. z: float;
  1345. w: float;
  1346. }
  1347. /**
  1348. * @hidden
  1349. */
  1350. export interface IVector3Like {
  1351. x: float;
  1352. y: float;
  1353. z: float;
  1354. }
  1355. /**
  1356. * @hidden
  1357. */
  1358. export interface IVector2Like {
  1359. x: float;
  1360. y: float;
  1361. }
  1362. /**
  1363. * @hidden
  1364. */
  1365. export interface IMatrixLike {
  1366. toArray(): DeepImmutable<Float32Array>;
  1367. updateFlag: int;
  1368. }
  1369. /**
  1370. * @hidden
  1371. */
  1372. export interface IViewportLike {
  1373. x: float;
  1374. y: float;
  1375. width: float;
  1376. height: float;
  1377. }
  1378. /**
  1379. * @hidden
  1380. */
  1381. export interface IPlaneLike {
  1382. normal: IVector3Like;
  1383. d: float;
  1384. normalize(): void;
  1385. }
  1386. }
  1387. declare module "babylonjs/Maths/math.vector" {
  1388. import { Viewport } from "babylonjs/Maths/math.viewport";
  1389. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1390. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1391. /**
  1392. * Class representing a vector containing 2 coordinates
  1393. */
  1394. export class Vector2 {
  1395. /** defines the first coordinate */
  1396. x: number;
  1397. /** defines the second coordinate */
  1398. y: number;
  1399. /**
  1400. * Creates a new Vector2 from the given x and y coordinates
  1401. * @param x defines the first coordinate
  1402. * @param y defines the second coordinate
  1403. */
  1404. constructor(
  1405. /** defines the first coordinate */
  1406. x?: number,
  1407. /** defines the second coordinate */
  1408. y?: number);
  1409. /**
  1410. * Gets a string with the Vector2 coordinates
  1411. * @returns a string with the Vector2 coordinates
  1412. */
  1413. toString(): string;
  1414. /**
  1415. * Gets class name
  1416. * @returns the string "Vector2"
  1417. */
  1418. getClassName(): string;
  1419. /**
  1420. * Gets current vector hash code
  1421. * @returns the Vector2 hash code as a number
  1422. */
  1423. getHashCode(): number;
  1424. /**
  1425. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1426. * @param array defines the source array
  1427. * @param index defines the offset in source array
  1428. * @returns the current Vector2
  1429. */
  1430. toArray(array: FloatArray, index?: number): Vector2;
  1431. /**
  1432. * Copy the current vector to an array
  1433. * @returns a new array with 2 elements: the Vector2 coordinates.
  1434. */
  1435. asArray(): number[];
  1436. /**
  1437. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1438. * @param source defines the source Vector2
  1439. * @returns the current updated Vector2
  1440. */
  1441. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1442. /**
  1443. * Sets the Vector2 coordinates with the given floats
  1444. * @param x defines the first coordinate
  1445. * @param y defines the second coordinate
  1446. * @returns the current updated Vector2
  1447. */
  1448. copyFromFloats(x: number, y: number): Vector2;
  1449. /**
  1450. * Sets the Vector2 coordinates with the given floats
  1451. * @param x defines the first coordinate
  1452. * @param y defines the second coordinate
  1453. * @returns the current updated Vector2
  1454. */
  1455. set(x: number, y: number): Vector2;
  1456. /**
  1457. * Add another vector with the current one
  1458. * @param otherVector defines the other vector
  1459. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1460. */
  1461. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1462. /**
  1463. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1464. * @param otherVector defines the other vector
  1465. * @param result defines the target vector
  1466. * @returns the unmodified current Vector2
  1467. */
  1468. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1469. /**
  1470. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1471. * @param otherVector defines the other vector
  1472. * @returns the current updated Vector2
  1473. */
  1474. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1475. /**
  1476. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1477. * @param otherVector defines the other vector
  1478. * @returns a new Vector2
  1479. */
  1480. addVector3(otherVector: Vector3): Vector2;
  1481. /**
  1482. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1483. * @param otherVector defines the other vector
  1484. * @returns a new Vector2
  1485. */
  1486. subtract(otherVector: Vector2): Vector2;
  1487. /**
  1488. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1489. * @param otherVector defines the other vector
  1490. * @param result defines the target vector
  1491. * @returns the unmodified current Vector2
  1492. */
  1493. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1494. /**
  1495. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  1496. * @param otherVector defines the other vector
  1497. * @returns the current updated Vector2
  1498. */
  1499. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1500. /**
  1501. * Multiplies in place the current Vector2 coordinates by the given ones
  1502. * @param otherVector defines the other vector
  1503. * @returns the current updated Vector2
  1504. */
  1505. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1506. /**
  1507. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  1508. * @param otherVector defines the other vector
  1509. * @returns a new Vector2
  1510. */
  1511. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  1512. /**
  1513. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  1514. * @param otherVector defines the other vector
  1515. * @param result defines the target vector
  1516. * @returns the unmodified current Vector2
  1517. */
  1518. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1519. /**
  1520. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  1521. * @param x defines the first coordinate
  1522. * @param y defines the second coordinate
  1523. * @returns a new Vector2
  1524. */
  1525. multiplyByFloats(x: number, y: number): Vector2;
  1526. /**
  1527. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  1528. * @param otherVector defines the other vector
  1529. * @returns a new Vector2
  1530. */
  1531. divide(otherVector: Vector2): Vector2;
  1532. /**
  1533. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  1534. * @param otherVector defines the other vector
  1535. * @param result defines the target vector
  1536. * @returns the unmodified current Vector2
  1537. */
  1538. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1539. /**
  1540. * Divides the current Vector2 coordinates by the given ones
  1541. * @param otherVector defines the other vector
  1542. * @returns the current updated Vector2
  1543. */
  1544. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1545. /**
  1546. * Gets a new Vector2 with current Vector2 negated coordinates
  1547. * @returns a new Vector2
  1548. */
  1549. negate(): Vector2;
  1550. /**
  1551. * Multiply the Vector2 coordinates by scale
  1552. * @param scale defines the scaling factor
  1553. * @returns the current updated Vector2
  1554. */
  1555. scaleInPlace(scale: number): Vector2;
  1556. /**
  1557. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1558. * @param scale defines the scaling factor
  1559. * @returns a new Vector2
  1560. */
  1561. scale(scale: number): Vector2;
  1562. /**
  1563. * Scale the current Vector2 values by a factor to a given Vector2
  1564. * @param scale defines the scale factor
  1565. * @param result defines the Vector2 object where to store the result
  1566. * @returns the unmodified current Vector2
  1567. */
  1568. scaleToRef(scale: number, result: Vector2): Vector2;
  1569. /**
  1570. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1571. * @param scale defines the scale factor
  1572. * @param result defines the Vector2 object where to store the result
  1573. * @returns the unmodified current Vector2
  1574. */
  1575. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1576. /**
  1577. * Gets a boolean if two vectors are equals
  1578. * @param otherVector defines the other vector
  1579. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1580. */
  1581. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1582. /**
  1583. * Gets a boolean if two vectors are equals (using an epsilon value)
  1584. * @param otherVector defines the other vector
  1585. * @param epsilon defines the minimal distance to consider equality
  1586. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1587. */
  1588. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1589. /**
  1590. * Gets a new Vector2 from current Vector2 floored values
  1591. * @returns a new Vector2
  1592. */
  1593. floor(): Vector2;
  1594. /**
  1595. * Gets a new Vector2 from current Vector2 floored values
  1596. * @returns a new Vector2
  1597. */
  1598. fract(): Vector2;
  1599. /**
  1600. * Gets the length of the vector
  1601. * @returns the vector length (float)
  1602. */
  1603. length(): number;
  1604. /**
  1605. * Gets the vector squared length
  1606. * @returns the vector squared length (float)
  1607. */
  1608. lengthSquared(): number;
  1609. /**
  1610. * Normalize the vector
  1611. * @returns the current updated Vector2
  1612. */
  1613. normalize(): Vector2;
  1614. /**
  1615. * Gets a new Vector2 copied from the Vector2
  1616. * @returns a new Vector2
  1617. */
  1618. clone(): Vector2;
  1619. /**
  1620. * Gets a new Vector2(0, 0)
  1621. * @returns a new Vector2
  1622. */
  1623. static Zero(): Vector2;
  1624. /**
  1625. * Gets a new Vector2(1, 1)
  1626. * @returns a new Vector2
  1627. */
  1628. static One(): Vector2;
  1629. /**
  1630. * Gets a new Vector2 set from the given index element of the given array
  1631. * @param array defines the data source
  1632. * @param offset defines the offset in the data source
  1633. * @returns a new Vector2
  1634. */
  1635. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1636. /**
  1637. * Sets "result" from the given index element of the given array
  1638. * @param array defines the data source
  1639. * @param offset defines the offset in the data source
  1640. * @param result defines the target vector
  1641. */
  1642. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1643. /**
  1644. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1645. * @param value1 defines 1st point of control
  1646. * @param value2 defines 2nd point of control
  1647. * @param value3 defines 3rd point of control
  1648. * @param value4 defines 4th point of control
  1649. * @param amount defines the interpolation factor
  1650. * @returns a new Vector2
  1651. */
  1652. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1653. /**
  1654. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  1655. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1656. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1657. * @param value defines the value to clamp
  1658. * @param min defines the lower limit
  1659. * @param max defines the upper limit
  1660. * @returns a new Vector2
  1661. */
  1662. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1663. /**
  1664. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1665. * @param value1 defines the 1st control point
  1666. * @param tangent1 defines the outgoing tangent
  1667. * @param value2 defines the 2nd control point
  1668. * @param tangent2 defines the incoming tangent
  1669. * @param amount defines the interpolation factor
  1670. * @returns a new Vector2
  1671. */
  1672. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1673. /**
  1674. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1675. * @param start defines the start vector
  1676. * @param end defines the end vector
  1677. * @param amount defines the interpolation factor
  1678. * @returns a new Vector2
  1679. */
  1680. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1681. /**
  1682. * Gets the dot product of the vector "left" and the vector "right"
  1683. * @param left defines first vector
  1684. * @param right defines second vector
  1685. * @returns the dot product (float)
  1686. */
  1687. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1688. /**
  1689. * Returns a new Vector2 equal to the normalized given vector
  1690. * @param vector defines the vector to normalize
  1691. * @returns a new Vector2
  1692. */
  1693. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1694. /**
  1695. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1696. * @param left defines 1st vector
  1697. * @param right defines 2nd vector
  1698. * @returns a new Vector2
  1699. */
  1700. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1701. /**
  1702. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1703. * @param left defines 1st vector
  1704. * @param right defines 2nd vector
  1705. * @returns a new Vector2
  1706. */
  1707. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1708. /**
  1709. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1710. * @param vector defines the vector to transform
  1711. * @param transformation defines the matrix to apply
  1712. * @returns a new Vector2
  1713. */
  1714. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1715. /**
  1716. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1717. * @param vector defines the vector to transform
  1718. * @param transformation defines the matrix to apply
  1719. * @param result defines the target vector
  1720. */
  1721. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1722. /**
  1723. * Determines if a given vector is included in a triangle
  1724. * @param p defines the vector to test
  1725. * @param p0 defines 1st triangle point
  1726. * @param p1 defines 2nd triangle point
  1727. * @param p2 defines 3rd triangle point
  1728. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1729. */
  1730. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1731. /**
  1732. * Gets the distance between the vectors "value1" and "value2"
  1733. * @param value1 defines first vector
  1734. * @param value2 defines second vector
  1735. * @returns the distance between vectors
  1736. */
  1737. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1738. /**
  1739. * Returns the squared distance between the vectors "value1" and "value2"
  1740. * @param value1 defines first vector
  1741. * @param value2 defines second vector
  1742. * @returns the squared distance between vectors
  1743. */
  1744. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1745. /**
  1746. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1747. * @param value1 defines first vector
  1748. * @param value2 defines second vector
  1749. * @returns a new Vector2
  1750. */
  1751. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1752. /**
  1753. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1754. * @param p defines the middle point
  1755. * @param segA defines one point of the segment
  1756. * @param segB defines the other point of the segment
  1757. * @returns the shortest distance
  1758. */
  1759. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1760. }
  1761. /**
  1762. * Classed used to store (x,y,z) vector representation
  1763. * A Vector3 is the main object used in 3D geometry
  1764. * It can represent etiher the coordinates of a point the space, either a direction
  1765. * Reminder: js uses a left handed forward facing system
  1766. */
  1767. export class Vector3 {
  1768. /**
  1769. * Defines the first coordinates (on X axis)
  1770. */
  1771. x: number;
  1772. /**
  1773. * Defines the second coordinates (on Y axis)
  1774. */
  1775. y: number;
  1776. /**
  1777. * Defines the third coordinates (on Z axis)
  1778. */
  1779. z: number;
  1780. private static _UpReadOnly;
  1781. private static _ZeroReadOnly;
  1782. /**
  1783. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1784. * @param x defines the first coordinates (on X axis)
  1785. * @param y defines the second coordinates (on Y axis)
  1786. * @param z defines the third coordinates (on Z axis)
  1787. */
  1788. constructor(
  1789. /**
  1790. * Defines the first coordinates (on X axis)
  1791. */
  1792. x?: number,
  1793. /**
  1794. * Defines the second coordinates (on Y axis)
  1795. */
  1796. y?: number,
  1797. /**
  1798. * Defines the third coordinates (on Z axis)
  1799. */
  1800. z?: number);
  1801. /**
  1802. * Creates a string representation of the Vector3
  1803. * @returns a string with the Vector3 coordinates.
  1804. */
  1805. toString(): string;
  1806. /**
  1807. * Gets the class name
  1808. * @returns the string "Vector3"
  1809. */
  1810. getClassName(): string;
  1811. /**
  1812. * Creates the Vector3 hash code
  1813. * @returns a number which tends to be unique between Vector3 instances
  1814. */
  1815. getHashCode(): number;
  1816. /**
  1817. * Creates an array containing three elements : the coordinates of the Vector3
  1818. * @returns a new array of numbers
  1819. */
  1820. asArray(): number[];
  1821. /**
  1822. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1823. * @param array defines the destination array
  1824. * @param index defines the offset in the destination array
  1825. * @returns the current Vector3
  1826. */
  1827. toArray(array: FloatArray, index?: number): Vector3;
  1828. /**
  1829. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1830. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1831. */
  1832. toQuaternion(): Quaternion;
  1833. /**
  1834. * Adds the given vector to the current Vector3
  1835. * @param otherVector defines the second operand
  1836. * @returns the current updated Vector3
  1837. */
  1838. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1839. /**
  1840. * Adds the given coordinates to the current Vector3
  1841. * @param x defines the x coordinate of the operand
  1842. * @param y defines the y coordinate of the operand
  1843. * @param z defines the z coordinate of the operand
  1844. * @returns the current updated Vector3
  1845. */
  1846. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1847. /**
  1848. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1849. * @param otherVector defines the second operand
  1850. * @returns the resulting Vector3
  1851. */
  1852. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1853. /**
  1854. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1855. * @param otherVector defines the second operand
  1856. * @param result defines the Vector3 object where to store the result
  1857. * @returns the current Vector3
  1858. */
  1859. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1860. /**
  1861. * Subtract the given vector from the current Vector3
  1862. * @param otherVector defines the second operand
  1863. * @returns the current updated Vector3
  1864. */
  1865. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1866. /**
  1867. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1868. * @param otherVector defines the second operand
  1869. * @returns the resulting Vector3
  1870. */
  1871. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1872. /**
  1873. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1874. * @param otherVector defines the second operand
  1875. * @param result defines the Vector3 object where to store the result
  1876. * @returns the current Vector3
  1877. */
  1878. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1879. /**
  1880. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1881. * @param x defines the x coordinate of the operand
  1882. * @param y defines the y coordinate of the operand
  1883. * @param z defines the z coordinate of the operand
  1884. * @returns the resulting Vector3
  1885. */
  1886. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1887. /**
  1888. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1889. * @param x defines the x coordinate of the operand
  1890. * @param y defines the y coordinate of the operand
  1891. * @param z defines the z coordinate of the operand
  1892. * @param result defines the Vector3 object where to store the result
  1893. * @returns the current Vector3
  1894. */
  1895. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1896. /**
  1897. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1898. * @returns a new Vector3
  1899. */
  1900. negate(): Vector3;
  1901. /**
  1902. * Multiplies the Vector3 coordinates by the float "scale"
  1903. * @param scale defines the multiplier factor
  1904. * @returns the current updated Vector3
  1905. */
  1906. scaleInPlace(scale: number): Vector3;
  1907. /**
  1908. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1909. * @param scale defines the multiplier factor
  1910. * @returns a new Vector3
  1911. */
  1912. scale(scale: number): Vector3;
  1913. /**
  1914. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1915. * @param scale defines the multiplier factor
  1916. * @param result defines the Vector3 object where to store the result
  1917. * @returns the current Vector3
  1918. */
  1919. scaleToRef(scale: number, result: Vector3): Vector3;
  1920. /**
  1921. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1922. * @param scale defines the scale factor
  1923. * @param result defines the Vector3 object where to store the result
  1924. * @returns the unmodified current Vector3
  1925. */
  1926. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1927. /**
  1928. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1929. * @param otherVector defines the second operand
  1930. * @returns true if both vectors are equals
  1931. */
  1932. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1933. /**
  1934. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1935. * @param otherVector defines the second operand
  1936. * @param epsilon defines the minimal distance to define values as equals
  1937. * @returns true if both vectors are distant less than epsilon
  1938. */
  1939. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1940. /**
  1941. * Returns true if the current Vector3 coordinates equals the given floats
  1942. * @param x defines the x coordinate of the operand
  1943. * @param y defines the y coordinate of the operand
  1944. * @param z defines the z coordinate of the operand
  1945. * @returns true if both vectors are equals
  1946. */
  1947. equalsToFloats(x: number, y: number, z: number): boolean;
  1948. /**
  1949. * Multiplies the current Vector3 coordinates by the given ones
  1950. * @param otherVector defines the second operand
  1951. * @returns the current updated Vector3
  1952. */
  1953. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1954. /**
  1955. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1956. * @param otherVector defines the second operand
  1957. * @returns the new Vector3
  1958. */
  1959. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1960. /**
  1961. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1962. * @param otherVector defines the second operand
  1963. * @param result defines the Vector3 object where to store the result
  1964. * @returns the current Vector3
  1965. */
  1966. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1967. /**
  1968. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1969. * @param x defines the x coordinate of the operand
  1970. * @param y defines the y coordinate of the operand
  1971. * @param z defines the z coordinate of the operand
  1972. * @returns the new Vector3
  1973. */
  1974. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1975. /**
  1976. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1977. * @param otherVector defines the second operand
  1978. * @returns the new Vector3
  1979. */
  1980. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1981. /**
  1982. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1983. * @param otherVector defines the second operand
  1984. * @param result defines the Vector3 object where to store the result
  1985. * @returns the current Vector3
  1986. */
  1987. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1988. /**
  1989. * Divides the current Vector3 coordinates by the given ones.
  1990. * @param otherVector defines the second operand
  1991. * @returns the current updated Vector3
  1992. */
  1993. divideInPlace(otherVector: Vector3): Vector3;
  1994. /**
  1995. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1996. * @param other defines the second operand
  1997. * @returns the current updated Vector3
  1998. */
  1999. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2000. /**
  2001. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2002. * @param other defines the second operand
  2003. * @returns the current updated Vector3
  2004. */
  2005. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2006. /**
  2007. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2008. * @param x defines the x coordinate of the operand
  2009. * @param y defines the y coordinate of the operand
  2010. * @param z defines the z coordinate of the operand
  2011. * @returns the current updated Vector3
  2012. */
  2013. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2014. /**
  2015. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2016. * @param x defines the x coordinate of the operand
  2017. * @param y defines the y coordinate of the operand
  2018. * @param z defines the z coordinate of the operand
  2019. * @returns the current updated Vector3
  2020. */
  2021. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2022. /**
  2023. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2024. * Check if is non uniform within a certain amount of decimal places to account for this
  2025. * @param epsilon the amount the values can differ
  2026. * @returns if the the vector is non uniform to a certain number of decimal places
  2027. */
  2028. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2029. /**
  2030. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2031. */
  2032. readonly isNonUniform: boolean;
  2033. /**
  2034. * Gets a new Vector3 from current Vector3 floored values
  2035. * @returns a new Vector3
  2036. */
  2037. floor(): Vector3;
  2038. /**
  2039. * Gets a new Vector3 from current Vector3 floored values
  2040. * @returns a new Vector3
  2041. */
  2042. fract(): Vector3;
  2043. /**
  2044. * Gets the length of the Vector3
  2045. * @returns the length of the Vector3
  2046. */
  2047. length(): number;
  2048. /**
  2049. * Gets the squared length of the Vector3
  2050. * @returns squared length of the Vector3
  2051. */
  2052. lengthSquared(): number;
  2053. /**
  2054. * Normalize the current Vector3.
  2055. * Please note that this is an in place operation.
  2056. * @returns the current updated Vector3
  2057. */
  2058. normalize(): Vector3;
  2059. /**
  2060. * Reorders the x y z properties of the vector in place
  2061. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2062. * @returns the current updated vector
  2063. */
  2064. reorderInPlace(order: string): this;
  2065. /**
  2066. * Rotates the vector around 0,0,0 by a quaternion
  2067. * @param quaternion the rotation quaternion
  2068. * @param result vector to store the result
  2069. * @returns the resulting vector
  2070. */
  2071. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2072. /**
  2073. * Rotates a vector around a given point
  2074. * @param quaternion the rotation quaternion
  2075. * @param point the point to rotate around
  2076. * @param result vector to store the result
  2077. * @returns the resulting vector
  2078. */
  2079. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2080. /**
  2081. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2082. * The cross product is then orthogonal to both current and "other"
  2083. * @param other defines the right operand
  2084. * @returns the cross product
  2085. */
  2086. cross(other: Vector3): Vector3;
  2087. /**
  2088. * Normalize the current Vector3 with the given input length.
  2089. * Please note that this is an in place operation.
  2090. * @param len the length of the vector
  2091. * @returns the current updated Vector3
  2092. */
  2093. normalizeFromLength(len: number): Vector3;
  2094. /**
  2095. * Normalize the current Vector3 to a new vector
  2096. * @returns the new Vector3
  2097. */
  2098. normalizeToNew(): Vector3;
  2099. /**
  2100. * Normalize the current Vector3 to the reference
  2101. * @param reference define the Vector3 to update
  2102. * @returns the updated Vector3
  2103. */
  2104. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2105. /**
  2106. * Creates a new Vector3 copied from the current Vector3
  2107. * @returns the new Vector3
  2108. */
  2109. clone(): Vector3;
  2110. /**
  2111. * Copies the given vector coordinates to the current Vector3 ones
  2112. * @param source defines the source Vector3
  2113. * @returns the current updated Vector3
  2114. */
  2115. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2116. /**
  2117. * Copies the given floats to the current Vector3 coordinates
  2118. * @param x defines the x coordinate of the operand
  2119. * @param y defines the y coordinate of the operand
  2120. * @param z defines the z coordinate of the operand
  2121. * @returns the current updated Vector3
  2122. */
  2123. copyFromFloats(x: number, y: number, z: number): Vector3;
  2124. /**
  2125. * Copies the given floats to the current Vector3 coordinates
  2126. * @param x defines the x coordinate of the operand
  2127. * @param y defines the y coordinate of the operand
  2128. * @param z defines the z coordinate of the operand
  2129. * @returns the current updated Vector3
  2130. */
  2131. set(x: number, y: number, z: number): Vector3;
  2132. /**
  2133. * Copies the given float to the current Vector3 coordinates
  2134. * @param v defines the x, y and z coordinates of the operand
  2135. * @returns the current updated Vector3
  2136. */
  2137. setAll(v: number): Vector3;
  2138. /**
  2139. * Get the clip factor between two vectors
  2140. * @param vector0 defines the first operand
  2141. * @param vector1 defines the second operand
  2142. * @param axis defines the axis to use
  2143. * @param size defines the size along the axis
  2144. * @returns the clip factor
  2145. */
  2146. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2147. /**
  2148. * Get angle between two vectors
  2149. * @param vector0 angle between vector0 and vector1
  2150. * @param vector1 angle between vector0 and vector1
  2151. * @param normal direction of the normal
  2152. * @return the angle between vector0 and vector1
  2153. */
  2154. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2155. /**
  2156. * Returns a new Vector3 set from the index "offset" of the given array
  2157. * @param array defines the source array
  2158. * @param offset defines the offset in the source array
  2159. * @returns the new Vector3
  2160. */
  2161. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2162. /**
  2163. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2164. * This function is deprecated. Use FromArray instead
  2165. * @param array defines the source array
  2166. * @param offset defines the offset in the source array
  2167. * @returns the new Vector3
  2168. */
  2169. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2170. /**
  2171. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2172. * @param array defines the source array
  2173. * @param offset defines the offset in the source array
  2174. * @param result defines the Vector3 where to store the result
  2175. */
  2176. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2177. /**
  2178. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2179. * This function is deprecated. Use FromArrayToRef instead.
  2180. * @param array defines the source array
  2181. * @param offset defines the offset in the source array
  2182. * @param result defines the Vector3 where to store the result
  2183. */
  2184. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2185. /**
  2186. * Sets the given vector "result" with the given floats.
  2187. * @param x defines the x coordinate of the source
  2188. * @param y defines the y coordinate of the source
  2189. * @param z defines the z coordinate of the source
  2190. * @param result defines the Vector3 where to store the result
  2191. */
  2192. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2193. /**
  2194. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2195. * @returns a new empty Vector3
  2196. */
  2197. static Zero(): Vector3;
  2198. /**
  2199. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2200. * @returns a new unit Vector3
  2201. */
  2202. static One(): Vector3;
  2203. /**
  2204. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2205. * @returns a new up Vector3
  2206. */
  2207. static Up(): Vector3;
  2208. /**
  2209. * Gets a up Vector3 that must not be updated
  2210. */
  2211. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2212. /**
  2213. * Gets a zero Vector3 that must not be updated
  2214. */
  2215. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2216. /**
  2217. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2218. * @returns a new down Vector3
  2219. */
  2220. static Down(): Vector3;
  2221. /**
  2222. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2223. * @returns a new forward Vector3
  2224. */
  2225. static Forward(): Vector3;
  2226. /**
  2227. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2228. * @returns a new forward Vector3
  2229. */
  2230. static Backward(): Vector3;
  2231. /**
  2232. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2233. * @returns a new right Vector3
  2234. */
  2235. static Right(): Vector3;
  2236. /**
  2237. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2238. * @returns a new left Vector3
  2239. */
  2240. static Left(): Vector3;
  2241. /**
  2242. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2243. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2244. * @param vector defines the Vector3 to transform
  2245. * @param transformation defines the transformation matrix
  2246. * @returns the transformed Vector3
  2247. */
  2248. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2249. /**
  2250. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2251. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2252. * @param vector defines the Vector3 to transform
  2253. * @param transformation defines the transformation matrix
  2254. * @param result defines the Vector3 where to store the result
  2255. */
  2256. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2257. /**
  2258. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2259. * This method computes tranformed coordinates only, not transformed direction vectors
  2260. * @param x define the x coordinate of the source vector
  2261. * @param y define the y coordinate of the source vector
  2262. * @param z define the z coordinate of the source vector
  2263. * @param transformation defines the transformation matrix
  2264. * @param result defines the Vector3 where to store the result
  2265. */
  2266. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2267. /**
  2268. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2269. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2270. * @param vector defines the Vector3 to transform
  2271. * @param transformation defines the transformation matrix
  2272. * @returns the new Vector3
  2273. */
  2274. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2275. /**
  2276. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2277. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2278. * @param vector defines the Vector3 to transform
  2279. * @param transformation defines the transformation matrix
  2280. * @param result defines the Vector3 where to store the result
  2281. */
  2282. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2283. /**
  2284. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2285. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2286. * @param x define the x coordinate of the source vector
  2287. * @param y define the y coordinate of the source vector
  2288. * @param z define the z coordinate of the source vector
  2289. * @param transformation defines the transformation matrix
  2290. * @param result defines the Vector3 where to store the result
  2291. */
  2292. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2293. /**
  2294. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2295. * @param value1 defines the first control point
  2296. * @param value2 defines the second control point
  2297. * @param value3 defines the third control point
  2298. * @param value4 defines the fourth control point
  2299. * @param amount defines the amount on the spline to use
  2300. * @returns the new Vector3
  2301. */
  2302. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2303. /**
  2304. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2305. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2306. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2307. * @param value defines the current value
  2308. * @param min defines the lower range value
  2309. * @param max defines the upper range value
  2310. * @returns the new Vector3
  2311. */
  2312. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2313. /**
  2314. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2315. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2316. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2317. * @param value defines the current value
  2318. * @param min defines the lower range value
  2319. * @param max defines the upper range value
  2320. * @param result defines the Vector3 where to store the result
  2321. */
  2322. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2323. /**
  2324. * Checks if a given vector is inside a specific range
  2325. * @param v defines the vector to test
  2326. * @param min defines the minimum range
  2327. * @param max defines the maximum range
  2328. */
  2329. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2330. /**
  2331. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2332. * @param value1 defines the first control point
  2333. * @param tangent1 defines the first tangent vector
  2334. * @param value2 defines the second control point
  2335. * @param tangent2 defines the second tangent vector
  2336. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2337. * @returns the new Vector3
  2338. */
  2339. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2340. /**
  2341. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2342. * @param start defines the start value
  2343. * @param end defines the end value
  2344. * @param amount max defines amount between both (between 0 and 1)
  2345. * @returns the new Vector3
  2346. */
  2347. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2348. /**
  2349. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2350. * @param start defines the start value
  2351. * @param end defines the end value
  2352. * @param amount max defines amount between both (between 0 and 1)
  2353. * @param result defines the Vector3 where to store the result
  2354. */
  2355. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2356. /**
  2357. * Returns the dot product (float) between the vectors "left" and "right"
  2358. * @param left defines the left operand
  2359. * @param right defines the right operand
  2360. * @returns the dot product
  2361. */
  2362. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2363. /**
  2364. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2365. * The cross product is then orthogonal to both "left" and "right"
  2366. * @param left defines the left operand
  2367. * @param right defines the right operand
  2368. * @returns the cross product
  2369. */
  2370. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2371. /**
  2372. * Sets the given vector "result" with the cross product of "left" and "right"
  2373. * The cross product is then orthogonal to both "left" and "right"
  2374. * @param left defines the left operand
  2375. * @param right defines the right operand
  2376. * @param result defines the Vector3 where to store the result
  2377. */
  2378. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2379. /**
  2380. * Returns a new Vector3 as the normalization of the given vector
  2381. * @param vector defines the Vector3 to normalize
  2382. * @returns the new Vector3
  2383. */
  2384. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2385. /**
  2386. * Sets the given vector "result" with the normalization of the given first vector
  2387. * @param vector defines the Vector3 to normalize
  2388. * @param result defines the Vector3 where to store the result
  2389. */
  2390. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2391. /**
  2392. * Project a Vector3 onto screen space
  2393. * @param vector defines the Vector3 to project
  2394. * @param world defines the world matrix to use
  2395. * @param transform defines the transform (view x projection) matrix to use
  2396. * @param viewport defines the screen viewport to use
  2397. * @returns the new Vector3
  2398. */
  2399. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2400. /** @hidden */
  2401. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2402. /**
  2403. * Unproject from screen space to object space
  2404. * @param source defines the screen space Vector3 to use
  2405. * @param viewportWidth defines the current width of the viewport
  2406. * @param viewportHeight defines the current height of the viewport
  2407. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2408. * @param transform defines the transform (view x projection) matrix to use
  2409. * @returns the new Vector3
  2410. */
  2411. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2412. /**
  2413. * Unproject from screen space to object space
  2414. * @param source defines the screen space Vector3 to use
  2415. * @param viewportWidth defines the current width of the viewport
  2416. * @param viewportHeight defines the current height of the viewport
  2417. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2418. * @param view defines the view matrix to use
  2419. * @param projection defines the projection matrix to use
  2420. * @returns the new Vector3
  2421. */
  2422. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2423. /**
  2424. * Unproject from screen space to object space
  2425. * @param source defines the screen space Vector3 to use
  2426. * @param viewportWidth defines the current width of the viewport
  2427. * @param viewportHeight defines the current height of the viewport
  2428. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2429. * @param view defines the view matrix to use
  2430. * @param projection defines the projection matrix to use
  2431. * @param result defines the Vector3 where to store the result
  2432. */
  2433. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2434. /**
  2435. * Unproject from screen space to object space
  2436. * @param sourceX defines the screen space x coordinate to use
  2437. * @param sourceY defines the screen space y coordinate to use
  2438. * @param sourceZ defines the screen space z coordinate to use
  2439. * @param viewportWidth defines the current width of the viewport
  2440. * @param viewportHeight defines the current height of the viewport
  2441. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2442. * @param view defines the view matrix to use
  2443. * @param projection defines the projection matrix to use
  2444. * @param result defines the Vector3 where to store the result
  2445. */
  2446. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2447. /**
  2448. * Gets the minimal coordinate values between two Vector3
  2449. * @param left defines the first operand
  2450. * @param right defines the second operand
  2451. * @returns the new Vector3
  2452. */
  2453. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2454. /**
  2455. * Gets the maximal coordinate values between two Vector3
  2456. * @param left defines the first operand
  2457. * @param right defines the second operand
  2458. * @returns the new Vector3
  2459. */
  2460. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2461. /**
  2462. * Returns the distance between the vectors "value1" and "value2"
  2463. * @param value1 defines the first operand
  2464. * @param value2 defines the second operand
  2465. * @returns the distance
  2466. */
  2467. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2468. /**
  2469. * Returns the squared distance between the vectors "value1" and "value2"
  2470. * @param value1 defines the first operand
  2471. * @param value2 defines the second operand
  2472. * @returns the squared distance
  2473. */
  2474. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2475. /**
  2476. * Returns a new Vector3 located at the center between "value1" and "value2"
  2477. * @param value1 defines the first operand
  2478. * @param value2 defines the second operand
  2479. * @returns the new Vector3
  2480. */
  2481. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  2482. /**
  2483. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  2484. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  2485. * to something in order to rotate it from its local system to the given target system
  2486. * Note: axis1, axis2 and axis3 are normalized during this operation
  2487. * @param axis1 defines the first axis
  2488. * @param axis2 defines the second axis
  2489. * @param axis3 defines the third axis
  2490. * @returns a new Vector3
  2491. */
  2492. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  2493. /**
  2494. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  2495. * @param axis1 defines the first axis
  2496. * @param axis2 defines the second axis
  2497. * @param axis3 defines the third axis
  2498. * @param ref defines the Vector3 where to store the result
  2499. */
  2500. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  2501. }
  2502. /**
  2503. * Vector4 class created for EulerAngle class conversion to Quaternion
  2504. */
  2505. export class Vector4 {
  2506. /** x value of the vector */
  2507. x: number;
  2508. /** y value of the vector */
  2509. y: number;
  2510. /** z value of the vector */
  2511. z: number;
  2512. /** w value of the vector */
  2513. w: number;
  2514. /**
  2515. * Creates a Vector4 object from the given floats.
  2516. * @param x x value of the vector
  2517. * @param y y value of the vector
  2518. * @param z z value of the vector
  2519. * @param w w value of the vector
  2520. */
  2521. constructor(
  2522. /** x value of the vector */
  2523. x: number,
  2524. /** y value of the vector */
  2525. y: number,
  2526. /** z value of the vector */
  2527. z: number,
  2528. /** w value of the vector */
  2529. w: number);
  2530. /**
  2531. * Returns the string with the Vector4 coordinates.
  2532. * @returns a string containing all the vector values
  2533. */
  2534. toString(): string;
  2535. /**
  2536. * Returns the string "Vector4".
  2537. * @returns "Vector4"
  2538. */
  2539. getClassName(): string;
  2540. /**
  2541. * Returns the Vector4 hash code.
  2542. * @returns a unique hash code
  2543. */
  2544. getHashCode(): number;
  2545. /**
  2546. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  2547. * @returns the resulting array
  2548. */
  2549. asArray(): number[];
  2550. /**
  2551. * Populates the given array from the given index with the Vector4 coordinates.
  2552. * @param array array to populate
  2553. * @param index index of the array to start at (default: 0)
  2554. * @returns the Vector4.
  2555. */
  2556. toArray(array: FloatArray, index?: number): Vector4;
  2557. /**
  2558. * Adds the given vector to the current Vector4.
  2559. * @param otherVector the vector to add
  2560. * @returns the updated Vector4.
  2561. */
  2562. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2563. /**
  2564. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2565. * @param otherVector the vector to add
  2566. * @returns the resulting vector
  2567. */
  2568. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2569. /**
  2570. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2571. * @param otherVector the vector to add
  2572. * @param result the vector to store the result
  2573. * @returns the current Vector4.
  2574. */
  2575. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2576. /**
  2577. * Subtract in place the given vector from the current Vector4.
  2578. * @param otherVector the vector to subtract
  2579. * @returns the updated Vector4.
  2580. */
  2581. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2582. /**
  2583. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2584. * @param otherVector the vector to add
  2585. * @returns the new vector with the result
  2586. */
  2587. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2588. /**
  2589. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2590. * @param otherVector the vector to subtract
  2591. * @param result the vector to store the result
  2592. * @returns the current Vector4.
  2593. */
  2594. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2595. /**
  2596. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2597. */
  2598. /**
  2599. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2600. * @param x value to subtract
  2601. * @param y value to subtract
  2602. * @param z value to subtract
  2603. * @param w value to subtract
  2604. * @returns new vector containing the result
  2605. */
  2606. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2607. /**
  2608. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2609. * @param x value to subtract
  2610. * @param y value to subtract
  2611. * @param z value to subtract
  2612. * @param w value to subtract
  2613. * @param result the vector to store the result in
  2614. * @returns the current Vector4.
  2615. */
  2616. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2617. /**
  2618. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2619. * @returns a new vector with the negated values
  2620. */
  2621. negate(): Vector4;
  2622. /**
  2623. * Multiplies the current Vector4 coordinates by scale (float).
  2624. * @param scale the number to scale with
  2625. * @returns the updated Vector4.
  2626. */
  2627. scaleInPlace(scale: number): Vector4;
  2628. /**
  2629. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2630. * @param scale the number to scale with
  2631. * @returns a new vector with the result
  2632. */
  2633. scale(scale: number): Vector4;
  2634. /**
  2635. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2636. * @param scale the number to scale with
  2637. * @param result a vector to store the result in
  2638. * @returns the current Vector4.
  2639. */
  2640. scaleToRef(scale: number, result: Vector4): Vector4;
  2641. /**
  2642. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2643. * @param scale defines the scale factor
  2644. * @param result defines the Vector4 object where to store the result
  2645. * @returns the unmodified current Vector4
  2646. */
  2647. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2648. /**
  2649. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2650. * @param otherVector the vector to compare against
  2651. * @returns true if they are equal
  2652. */
  2653. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2654. /**
  2655. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2656. * @param otherVector vector to compare against
  2657. * @param epsilon (Default: very small number)
  2658. * @returns true if they are equal
  2659. */
  2660. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2661. /**
  2662. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2663. * @param x x value to compare against
  2664. * @param y y value to compare against
  2665. * @param z z value to compare against
  2666. * @param w w value to compare against
  2667. * @returns true if equal
  2668. */
  2669. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2670. /**
  2671. * Multiplies in place the current Vector4 by the given one.
  2672. * @param otherVector vector to multiple with
  2673. * @returns the updated Vector4.
  2674. */
  2675. multiplyInPlace(otherVector: Vector4): Vector4;
  2676. /**
  2677. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2678. * @param otherVector vector to multiple with
  2679. * @returns resulting new vector
  2680. */
  2681. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2682. /**
  2683. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2684. * @param otherVector vector to multiple with
  2685. * @param result vector to store the result
  2686. * @returns the current Vector4.
  2687. */
  2688. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2689. /**
  2690. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2691. * @param x x value multiply with
  2692. * @param y y value multiply with
  2693. * @param z z value multiply with
  2694. * @param w w value multiply with
  2695. * @returns resulting new vector
  2696. */
  2697. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2698. /**
  2699. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2700. * @param otherVector vector to devide with
  2701. * @returns resulting new vector
  2702. */
  2703. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2704. /**
  2705. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2706. * @param otherVector vector to devide with
  2707. * @param result vector to store the result
  2708. * @returns the current Vector4.
  2709. */
  2710. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2711. /**
  2712. * Divides the current Vector3 coordinates by the given ones.
  2713. * @param otherVector vector to devide with
  2714. * @returns the updated Vector3.
  2715. */
  2716. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2717. /**
  2718. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2719. * @param other defines the second operand
  2720. * @returns the current updated Vector4
  2721. */
  2722. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2723. /**
  2724. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2725. * @param other defines the second operand
  2726. * @returns the current updated Vector4
  2727. */
  2728. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2729. /**
  2730. * Gets a new Vector4 from current Vector4 floored values
  2731. * @returns a new Vector4
  2732. */
  2733. floor(): Vector4;
  2734. /**
  2735. * Gets a new Vector4 from current Vector3 floored values
  2736. * @returns a new Vector4
  2737. */
  2738. fract(): Vector4;
  2739. /**
  2740. * Returns the Vector4 length (float).
  2741. * @returns the length
  2742. */
  2743. length(): number;
  2744. /**
  2745. * Returns the Vector4 squared length (float).
  2746. * @returns the length squared
  2747. */
  2748. lengthSquared(): number;
  2749. /**
  2750. * Normalizes in place the Vector4.
  2751. * @returns the updated Vector4.
  2752. */
  2753. normalize(): Vector4;
  2754. /**
  2755. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2756. * @returns this converted to a new vector3
  2757. */
  2758. toVector3(): Vector3;
  2759. /**
  2760. * Returns a new Vector4 copied from the current one.
  2761. * @returns the new cloned vector
  2762. */
  2763. clone(): Vector4;
  2764. /**
  2765. * Updates the current Vector4 with the given one coordinates.
  2766. * @param source the source vector to copy from
  2767. * @returns the updated Vector4.
  2768. */
  2769. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2770. /**
  2771. * Updates the current Vector4 coordinates with the given floats.
  2772. * @param x float to copy from
  2773. * @param y float to copy from
  2774. * @param z float to copy from
  2775. * @param w float to copy from
  2776. * @returns the updated Vector4.
  2777. */
  2778. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2779. /**
  2780. * Updates the current Vector4 coordinates with the given floats.
  2781. * @param x float to set from
  2782. * @param y float to set from
  2783. * @param z float to set from
  2784. * @param w float to set from
  2785. * @returns the updated Vector4.
  2786. */
  2787. set(x: number, y: number, z: number, w: number): Vector4;
  2788. /**
  2789. * Copies the given float to the current Vector3 coordinates
  2790. * @param v defines the x, y, z and w coordinates of the operand
  2791. * @returns the current updated Vector3
  2792. */
  2793. setAll(v: number): Vector4;
  2794. /**
  2795. * Returns a new Vector4 set from the starting index of the given array.
  2796. * @param array the array to pull values from
  2797. * @param offset the offset into the array to start at
  2798. * @returns the new vector
  2799. */
  2800. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2801. /**
  2802. * Updates the given vector "result" from the starting index of the given array.
  2803. * @param array the array to pull values from
  2804. * @param offset the offset into the array to start at
  2805. * @param result the vector to store the result in
  2806. */
  2807. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2808. /**
  2809. * Updates the given vector "result" from the starting index of the given Float32Array.
  2810. * @param array the array to pull values from
  2811. * @param offset the offset into the array to start at
  2812. * @param result the vector to store the result in
  2813. */
  2814. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2815. /**
  2816. * Updates the given vector "result" coordinates from the given floats.
  2817. * @param x float to set from
  2818. * @param y float to set from
  2819. * @param z float to set from
  2820. * @param w float to set from
  2821. * @param result the vector to the floats in
  2822. */
  2823. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2824. /**
  2825. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2826. * @returns the new vector
  2827. */
  2828. static Zero(): Vector4;
  2829. /**
  2830. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2831. * @returns the new vector
  2832. */
  2833. static One(): Vector4;
  2834. /**
  2835. * Returns a new normalized Vector4 from the given one.
  2836. * @param vector the vector to normalize
  2837. * @returns the vector
  2838. */
  2839. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2840. /**
  2841. * Updates the given vector "result" from the normalization of the given one.
  2842. * @param vector the vector to normalize
  2843. * @param result the vector to store the result in
  2844. */
  2845. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2846. /**
  2847. * Returns a vector with the minimum values from the left and right vectors
  2848. * @param left left vector to minimize
  2849. * @param right right vector to minimize
  2850. * @returns a new vector with the minimum of the left and right vector values
  2851. */
  2852. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2853. /**
  2854. * Returns a vector with the maximum values from the left and right vectors
  2855. * @param left left vector to maximize
  2856. * @param right right vector to maximize
  2857. * @returns a new vector with the maximum of the left and right vector values
  2858. */
  2859. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2860. /**
  2861. * Returns the distance (float) between the vectors "value1" and "value2".
  2862. * @param value1 value to calulate the distance between
  2863. * @param value2 value to calulate the distance between
  2864. * @return the distance between the two vectors
  2865. */
  2866. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2867. /**
  2868. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2869. * @param value1 value to calulate the distance between
  2870. * @param value2 value to calulate the distance between
  2871. * @return the distance between the two vectors squared
  2872. */
  2873. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2874. /**
  2875. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2876. * @param value1 value to calulate the center between
  2877. * @param value2 value to calulate the center between
  2878. * @return the center between the two vectors
  2879. */
  2880. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2881. /**
  2882. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2883. * This methods computes transformed normalized direction vectors only.
  2884. * @param vector the vector to transform
  2885. * @param transformation the transformation matrix to apply
  2886. * @returns the new vector
  2887. */
  2888. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2889. /**
  2890. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2891. * This methods computes transformed normalized direction vectors only.
  2892. * @param vector the vector to transform
  2893. * @param transformation the transformation matrix to apply
  2894. * @param result the vector to store the result in
  2895. */
  2896. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2897. /**
  2898. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2899. * This methods computes transformed normalized direction vectors only.
  2900. * @param x value to transform
  2901. * @param y value to transform
  2902. * @param z value to transform
  2903. * @param w value to transform
  2904. * @param transformation the transformation matrix to apply
  2905. * @param result the vector to store the results in
  2906. */
  2907. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2908. /**
  2909. * Creates a new Vector4 from a Vector3
  2910. * @param source defines the source data
  2911. * @param w defines the 4th component (default is 0)
  2912. * @returns a new Vector4
  2913. */
  2914. static FromVector3(source: Vector3, w?: number): Vector4;
  2915. }
  2916. /**
  2917. * Class used to store quaternion data
  2918. * @see https://en.wikipedia.org/wiki/Quaternion
  2919. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2920. */
  2921. export class Quaternion {
  2922. /** defines the first component (0 by default) */
  2923. x: number;
  2924. /** defines the second component (0 by default) */
  2925. y: number;
  2926. /** defines the third component (0 by default) */
  2927. z: number;
  2928. /** defines the fourth component (1.0 by default) */
  2929. w: number;
  2930. /**
  2931. * Creates a new Quaternion from the given floats
  2932. * @param x defines the first component (0 by default)
  2933. * @param y defines the second component (0 by default)
  2934. * @param z defines the third component (0 by default)
  2935. * @param w defines the fourth component (1.0 by default)
  2936. */
  2937. constructor(
  2938. /** defines the first component (0 by default) */
  2939. x?: number,
  2940. /** defines the second component (0 by default) */
  2941. y?: number,
  2942. /** defines the third component (0 by default) */
  2943. z?: number,
  2944. /** defines the fourth component (1.0 by default) */
  2945. w?: number);
  2946. /**
  2947. * Gets a string representation for the current quaternion
  2948. * @returns a string with the Quaternion coordinates
  2949. */
  2950. toString(): string;
  2951. /**
  2952. * Gets the class name of the quaternion
  2953. * @returns the string "Quaternion"
  2954. */
  2955. getClassName(): string;
  2956. /**
  2957. * Gets a hash code for this quaternion
  2958. * @returns the quaternion hash code
  2959. */
  2960. getHashCode(): number;
  2961. /**
  2962. * Copy the quaternion to an array
  2963. * @returns a new array populated with 4 elements from the quaternion coordinates
  2964. */
  2965. asArray(): number[];
  2966. /**
  2967. * Check if two quaternions are equals
  2968. * @param otherQuaternion defines the second operand
  2969. * @return true if the current quaternion and the given one coordinates are strictly equals
  2970. */
  2971. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2972. /**
  2973. * Clone the current quaternion
  2974. * @returns a new quaternion copied from the current one
  2975. */
  2976. clone(): Quaternion;
  2977. /**
  2978. * Copy a quaternion to the current one
  2979. * @param other defines the other quaternion
  2980. * @returns the updated current quaternion
  2981. */
  2982. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2983. /**
  2984. * Updates the current quaternion with the given float coordinates
  2985. * @param x defines the x coordinate
  2986. * @param y defines the y coordinate
  2987. * @param z defines the z coordinate
  2988. * @param w defines the w coordinate
  2989. * @returns the updated current quaternion
  2990. */
  2991. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2992. /**
  2993. * Updates the current quaternion from the given float coordinates
  2994. * @param x defines the x coordinate
  2995. * @param y defines the y coordinate
  2996. * @param z defines the z coordinate
  2997. * @param w defines the w coordinate
  2998. * @returns the updated current quaternion
  2999. */
  3000. set(x: number, y: number, z: number, w: number): Quaternion;
  3001. /**
  3002. * Adds two quaternions
  3003. * @param other defines the second operand
  3004. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3005. */
  3006. add(other: DeepImmutable<Quaternion>): Quaternion;
  3007. /**
  3008. * Add a quaternion to the current one
  3009. * @param other defines the quaternion to add
  3010. * @returns the current quaternion
  3011. */
  3012. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3013. /**
  3014. * Subtract two quaternions
  3015. * @param other defines the second operand
  3016. * @returns a new quaternion as the subtraction result of the given one from the current one
  3017. */
  3018. subtract(other: Quaternion): Quaternion;
  3019. /**
  3020. * Multiplies the current quaternion by a scale factor
  3021. * @param value defines the scale factor
  3022. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3023. */
  3024. scale(value: number): Quaternion;
  3025. /**
  3026. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3027. * @param scale defines the scale factor
  3028. * @param result defines the Quaternion object where to store the result
  3029. * @returns the unmodified current quaternion
  3030. */
  3031. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3032. /**
  3033. * Multiplies in place the current quaternion by a scale factor
  3034. * @param value defines the scale factor
  3035. * @returns the current modified quaternion
  3036. */
  3037. scaleInPlace(value: number): Quaternion;
  3038. /**
  3039. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3040. * @param scale defines the scale factor
  3041. * @param result defines the Quaternion object where to store the result
  3042. * @returns the unmodified current quaternion
  3043. */
  3044. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3045. /**
  3046. * Multiplies two quaternions
  3047. * @param q1 defines the second operand
  3048. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3049. */
  3050. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3051. /**
  3052. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3053. * @param q1 defines the second operand
  3054. * @param result defines the target quaternion
  3055. * @returns the current quaternion
  3056. */
  3057. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3058. /**
  3059. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3060. * @param q1 defines the second operand
  3061. * @returns the currentupdated quaternion
  3062. */
  3063. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3064. /**
  3065. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3066. * @param ref defines the target quaternion
  3067. * @returns the current quaternion
  3068. */
  3069. conjugateToRef(ref: Quaternion): Quaternion;
  3070. /**
  3071. * Conjugates in place (1-q) the current quaternion
  3072. * @returns the current updated quaternion
  3073. */
  3074. conjugateInPlace(): Quaternion;
  3075. /**
  3076. * Conjugates in place (1-q) the current quaternion
  3077. * @returns a new quaternion
  3078. */
  3079. conjugate(): Quaternion;
  3080. /**
  3081. * Gets length of current quaternion
  3082. * @returns the quaternion length (float)
  3083. */
  3084. length(): number;
  3085. /**
  3086. * Normalize in place the current quaternion
  3087. * @returns the current updated quaternion
  3088. */
  3089. normalize(): Quaternion;
  3090. /**
  3091. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3092. * @param order is a reserved parameter and is ignore for now
  3093. * @returns a new Vector3 containing the Euler angles
  3094. */
  3095. toEulerAngles(order?: string): Vector3;
  3096. /**
  3097. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3098. * @param result defines the vector which will be filled with the Euler angles
  3099. * @param order is a reserved parameter and is ignore for now
  3100. * @returns the current unchanged quaternion
  3101. */
  3102. toEulerAnglesToRef(result: Vector3): Quaternion;
  3103. /**
  3104. * Updates the given rotation matrix with the current quaternion values
  3105. * @param result defines the target matrix
  3106. * @returns the current unchanged quaternion
  3107. */
  3108. toRotationMatrix(result: Matrix): Quaternion;
  3109. /**
  3110. * Updates the current quaternion from the given rotation matrix values
  3111. * @param matrix defines the source matrix
  3112. * @returns the current updated quaternion
  3113. */
  3114. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3115. /**
  3116. * Creates a new quaternion from a rotation matrix
  3117. * @param matrix defines the source matrix
  3118. * @returns a new quaternion created from the given rotation matrix values
  3119. */
  3120. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3121. /**
  3122. * Updates the given quaternion with the given rotation matrix values
  3123. * @param matrix defines the source matrix
  3124. * @param result defines the target quaternion
  3125. */
  3126. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3127. /**
  3128. * Returns the dot product (float) between the quaternions "left" and "right"
  3129. * @param left defines the left operand
  3130. * @param right defines the right operand
  3131. * @returns the dot product
  3132. */
  3133. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3134. /**
  3135. * Checks if the two quaternions are close to each other
  3136. * @param quat0 defines the first quaternion to check
  3137. * @param quat1 defines the second quaternion to check
  3138. * @returns true if the two quaternions are close to each other
  3139. */
  3140. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3141. /**
  3142. * Creates an empty quaternion
  3143. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3144. */
  3145. static Zero(): Quaternion;
  3146. /**
  3147. * Inverse a given quaternion
  3148. * @param q defines the source quaternion
  3149. * @returns a new quaternion as the inverted current quaternion
  3150. */
  3151. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3152. /**
  3153. * Inverse a given quaternion
  3154. * @param q defines the source quaternion
  3155. * @param result the quaternion the result will be stored in
  3156. * @returns the result quaternion
  3157. */
  3158. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3159. /**
  3160. * Creates an identity quaternion
  3161. * @returns the identity quaternion
  3162. */
  3163. static Identity(): Quaternion;
  3164. /**
  3165. * Gets a boolean indicating if the given quaternion is identity
  3166. * @param quaternion defines the quaternion to check
  3167. * @returns true if the quaternion is identity
  3168. */
  3169. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3170. /**
  3171. * Creates a quaternion from a rotation around an axis
  3172. * @param axis defines the axis to use
  3173. * @param angle defines the angle to use
  3174. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3175. */
  3176. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3177. /**
  3178. * Creates a rotation around an axis and stores it into the given quaternion
  3179. * @param axis defines the axis to use
  3180. * @param angle defines the angle to use
  3181. * @param result defines the target quaternion
  3182. * @returns the target quaternion
  3183. */
  3184. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3185. /**
  3186. * Creates a new quaternion from data stored into an array
  3187. * @param array defines the data source
  3188. * @param offset defines the offset in the source array where the data starts
  3189. * @returns a new quaternion
  3190. */
  3191. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3192. /**
  3193. * Create a quaternion from Euler rotation angles
  3194. * @param x Pitch
  3195. * @param y Yaw
  3196. * @param z Roll
  3197. * @returns the new Quaternion
  3198. */
  3199. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3200. /**
  3201. * Updates a quaternion from Euler rotation angles
  3202. * @param x Pitch
  3203. * @param y Yaw
  3204. * @param z Roll
  3205. * @param result the quaternion to store the result
  3206. * @returns the updated quaternion
  3207. */
  3208. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3209. /**
  3210. * Create a quaternion from Euler rotation vector
  3211. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3212. * @returns the new Quaternion
  3213. */
  3214. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3215. /**
  3216. * Updates a quaternion from Euler rotation vector
  3217. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3218. * @param result the quaternion to store the result
  3219. * @returns the updated quaternion
  3220. */
  3221. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3222. /**
  3223. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3224. * @param yaw defines the rotation around Y axis
  3225. * @param pitch defines the rotation around X axis
  3226. * @param roll defines the rotation around Z axis
  3227. * @returns the new quaternion
  3228. */
  3229. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3230. /**
  3231. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3232. * @param yaw defines the rotation around Y axis
  3233. * @param pitch defines the rotation around X axis
  3234. * @param roll defines the rotation around Z axis
  3235. * @param result defines the target quaternion
  3236. */
  3237. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3238. /**
  3239. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3240. * @param alpha defines the rotation around first axis
  3241. * @param beta defines the rotation around second axis
  3242. * @param gamma defines the rotation around third axis
  3243. * @returns the new quaternion
  3244. */
  3245. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3246. /**
  3247. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3248. * @param alpha defines the rotation around first axis
  3249. * @param beta defines the rotation around second axis
  3250. * @param gamma defines the rotation around third axis
  3251. * @param result defines the target quaternion
  3252. */
  3253. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3254. /**
  3255. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  3256. * @param axis1 defines the first axis
  3257. * @param axis2 defines the second axis
  3258. * @param axis3 defines the third axis
  3259. * @returns the new quaternion
  3260. */
  3261. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3262. /**
  3263. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  3264. * @param axis1 defines the first axis
  3265. * @param axis2 defines the second axis
  3266. * @param axis3 defines the third axis
  3267. * @param ref defines the target quaternion
  3268. */
  3269. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3270. /**
  3271. * Interpolates between two quaternions
  3272. * @param left defines first quaternion
  3273. * @param right defines second quaternion
  3274. * @param amount defines the gradient to use
  3275. * @returns the new interpolated quaternion
  3276. */
  3277. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3278. /**
  3279. * Interpolates between two quaternions and stores it into a target quaternion
  3280. * @param left defines first quaternion
  3281. * @param right defines second quaternion
  3282. * @param amount defines the gradient to use
  3283. * @param result defines the target quaternion
  3284. */
  3285. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3286. /**
  3287. * Interpolate between two quaternions using Hermite interpolation
  3288. * @param value1 defines first quaternion
  3289. * @param tangent1 defines the incoming tangent
  3290. * @param value2 defines second quaternion
  3291. * @param tangent2 defines the outgoing tangent
  3292. * @param amount defines the target quaternion
  3293. * @returns the new interpolated quaternion
  3294. */
  3295. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3296. }
  3297. /**
  3298. * Class used to store matrix data (4x4)
  3299. */
  3300. export class Matrix {
  3301. private static _updateFlagSeed;
  3302. private static _identityReadOnly;
  3303. private _isIdentity;
  3304. private _isIdentityDirty;
  3305. private _isIdentity3x2;
  3306. private _isIdentity3x2Dirty;
  3307. /**
  3308. * Gets the update flag of the matrix which is an unique number for the matrix.
  3309. * It will be incremented every time the matrix data change.
  3310. * You can use it to speed the comparison between two versions of the same matrix.
  3311. */
  3312. updateFlag: number;
  3313. private readonly _m;
  3314. /**
  3315. * Gets the internal data of the matrix
  3316. */
  3317. readonly m: DeepImmutable<Float32Array>;
  3318. /** @hidden */
  3319. _markAsUpdated(): void;
  3320. /** @hidden */
  3321. private _updateIdentityStatus;
  3322. /**
  3323. * Creates an empty matrix (filled with zeros)
  3324. */
  3325. constructor();
  3326. /**
  3327. * Check if the current matrix is identity
  3328. * @returns true is the matrix is the identity matrix
  3329. */
  3330. isIdentity(): boolean;
  3331. /**
  3332. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3333. * @returns true is the matrix is the identity matrix
  3334. */
  3335. isIdentityAs3x2(): boolean;
  3336. /**
  3337. * Gets the determinant of the matrix
  3338. * @returns the matrix determinant
  3339. */
  3340. determinant(): number;
  3341. /**
  3342. * Returns the matrix as a Float32Array
  3343. * @returns the matrix underlying array
  3344. */
  3345. toArray(): DeepImmutable<Float32Array>;
  3346. /**
  3347. * Returns the matrix as a Float32Array
  3348. * @returns the matrix underlying array.
  3349. */
  3350. asArray(): DeepImmutable<Float32Array>;
  3351. /**
  3352. * Inverts the current matrix in place
  3353. * @returns the current inverted matrix
  3354. */
  3355. invert(): Matrix;
  3356. /**
  3357. * Sets all the matrix elements to zero
  3358. * @returns the current matrix
  3359. */
  3360. reset(): Matrix;
  3361. /**
  3362. * Adds the current matrix with a second one
  3363. * @param other defines the matrix to add
  3364. * @returns a new matrix as the addition of the current matrix and the given one
  3365. */
  3366. add(other: DeepImmutable<Matrix>): Matrix;
  3367. /**
  3368. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3369. * @param other defines the matrix to add
  3370. * @param result defines the target matrix
  3371. * @returns the current matrix
  3372. */
  3373. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3374. /**
  3375. * Adds in place the given matrix to the current matrix
  3376. * @param other defines the second operand
  3377. * @returns the current updated matrix
  3378. */
  3379. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3380. /**
  3381. * Sets the given matrix to the current inverted Matrix
  3382. * @param other defines the target matrix
  3383. * @returns the unmodified current matrix
  3384. */
  3385. invertToRef(other: Matrix): Matrix;
  3386. /**
  3387. * add a value at the specified position in the current Matrix
  3388. * @param index the index of the value within the matrix. between 0 and 15.
  3389. * @param value the value to be added
  3390. * @returns the current updated matrix
  3391. */
  3392. addAtIndex(index: number, value: number): Matrix;
  3393. /**
  3394. * mutiply the specified position in the current Matrix by a value
  3395. * @param index the index of the value within the matrix. between 0 and 15.
  3396. * @param value the value to be added
  3397. * @returns the current updated matrix
  3398. */
  3399. multiplyAtIndex(index: number, value: number): Matrix;
  3400. /**
  3401. * Inserts the translation vector (using 3 floats) in the current matrix
  3402. * @param x defines the 1st component of the translation
  3403. * @param y defines the 2nd component of the translation
  3404. * @param z defines the 3rd component of the translation
  3405. * @returns the current updated matrix
  3406. */
  3407. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3408. /**
  3409. * Adds the translation vector (using 3 floats) in the current matrix
  3410. * @param x defines the 1st component of the translation
  3411. * @param y defines the 2nd component of the translation
  3412. * @param z defines the 3rd component of the translation
  3413. * @returns the current updated matrix
  3414. */
  3415. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3416. /**
  3417. * Inserts the translation vector in the current matrix
  3418. * @param vector3 defines the translation to insert
  3419. * @returns the current updated matrix
  3420. */
  3421. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3422. /**
  3423. * Gets the translation value of the current matrix
  3424. * @returns a new Vector3 as the extracted translation from the matrix
  3425. */
  3426. getTranslation(): Vector3;
  3427. /**
  3428. * Fill a Vector3 with the extracted translation from the matrix
  3429. * @param result defines the Vector3 where to store the translation
  3430. * @returns the current matrix
  3431. */
  3432. getTranslationToRef(result: Vector3): Matrix;
  3433. /**
  3434. * Remove rotation and scaling part from the matrix
  3435. * @returns the updated matrix
  3436. */
  3437. removeRotationAndScaling(): Matrix;
  3438. /**
  3439. * Multiply two matrices
  3440. * @param other defines the second operand
  3441. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3442. */
  3443. multiply(other: DeepImmutable<Matrix>): Matrix;
  3444. /**
  3445. * Copy the current matrix from the given one
  3446. * @param other defines the source matrix
  3447. * @returns the current updated matrix
  3448. */
  3449. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3450. /**
  3451. * Populates the given array from the starting index with the current matrix values
  3452. * @param array defines the target array
  3453. * @param offset defines the offset in the target array where to start storing values
  3454. * @returns the current matrix
  3455. */
  3456. copyToArray(array: Float32Array, offset?: number): Matrix;
  3457. /**
  3458. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3459. * @param other defines the second operand
  3460. * @param result defines the matrix where to store the multiplication
  3461. * @returns the current matrix
  3462. */
  3463. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3464. /**
  3465. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3466. * @param other defines the second operand
  3467. * @param result defines the array where to store the multiplication
  3468. * @param offset defines the offset in the target array where to start storing values
  3469. * @returns the current matrix
  3470. */
  3471. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3472. /**
  3473. * Check equality between this matrix and a second one
  3474. * @param value defines the second matrix to compare
  3475. * @returns true is the current matrix and the given one values are strictly equal
  3476. */
  3477. equals(value: DeepImmutable<Matrix>): boolean;
  3478. /**
  3479. * Clone the current matrix
  3480. * @returns a new matrix from the current matrix
  3481. */
  3482. clone(): Matrix;
  3483. /**
  3484. * Returns the name of the current matrix class
  3485. * @returns the string "Matrix"
  3486. */
  3487. getClassName(): string;
  3488. /**
  3489. * Gets the hash code of the current matrix
  3490. * @returns the hash code
  3491. */
  3492. getHashCode(): number;
  3493. /**
  3494. * Decomposes the current Matrix into a translation, rotation and scaling components
  3495. * @param scale defines the scale vector3 given as a reference to update
  3496. * @param rotation defines the rotation quaternion given as a reference to update
  3497. * @param translation defines the translation vector3 given as a reference to update
  3498. * @returns true if operation was successful
  3499. */
  3500. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3501. /**
  3502. * Gets specific row of the matrix
  3503. * @param index defines the number of the row to get
  3504. * @returns the index-th row of the current matrix as a new Vector4
  3505. */
  3506. getRow(index: number): Nullable<Vector4>;
  3507. /**
  3508. * Sets the index-th row of the current matrix to the vector4 values
  3509. * @param index defines the number of the row to set
  3510. * @param row defines the target vector4
  3511. * @returns the updated current matrix
  3512. */
  3513. setRow(index: number, row: Vector4): Matrix;
  3514. /**
  3515. * Compute the transpose of the matrix
  3516. * @returns the new transposed matrix
  3517. */
  3518. transpose(): Matrix;
  3519. /**
  3520. * Compute the transpose of the matrix and store it in a given matrix
  3521. * @param result defines the target matrix
  3522. * @returns the current matrix
  3523. */
  3524. transposeToRef(result: Matrix): Matrix;
  3525. /**
  3526. * Sets the index-th row of the current matrix with the given 4 x float values
  3527. * @param index defines the row index
  3528. * @param x defines the x component to set
  3529. * @param y defines the y component to set
  3530. * @param z defines the z component to set
  3531. * @param w defines the w component to set
  3532. * @returns the updated current matrix
  3533. */
  3534. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3535. /**
  3536. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3537. * @param scale defines the scale factor
  3538. * @returns a new matrix
  3539. */
  3540. scale(scale: number): Matrix;
  3541. /**
  3542. * Scale the current matrix values by a factor to a given result matrix
  3543. * @param scale defines the scale factor
  3544. * @param result defines the matrix to store the result
  3545. * @returns the current matrix
  3546. */
  3547. scaleToRef(scale: number, result: Matrix): Matrix;
  3548. /**
  3549. * Scale the current matrix values by a factor and add the result to a given matrix
  3550. * @param scale defines the scale factor
  3551. * @param result defines the Matrix to store the result
  3552. * @returns the current matrix
  3553. */
  3554. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3555. /**
  3556. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3557. * @param ref matrix to store the result
  3558. */
  3559. toNormalMatrix(ref: Matrix): void;
  3560. /**
  3561. * Gets only rotation part of the current matrix
  3562. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3563. */
  3564. getRotationMatrix(): Matrix;
  3565. /**
  3566. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3567. * @param result defines the target matrix to store data to
  3568. * @returns the current matrix
  3569. */
  3570. getRotationMatrixToRef(result: Matrix): Matrix;
  3571. /**
  3572. * Toggles model matrix from being right handed to left handed in place and vice versa
  3573. */
  3574. toggleModelMatrixHandInPlace(): void;
  3575. /**
  3576. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3577. */
  3578. toggleProjectionMatrixHandInPlace(): void;
  3579. /**
  3580. * Creates a matrix from an array
  3581. * @param array defines the source array
  3582. * @param offset defines an offset in the source array
  3583. * @returns a new Matrix set from the starting index of the given array
  3584. */
  3585. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3586. /**
  3587. * Copy the content of an array into a given matrix
  3588. * @param array defines the source array
  3589. * @param offset defines an offset in the source array
  3590. * @param result defines the target matrix
  3591. */
  3592. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3593. /**
  3594. * Stores an array into a matrix after having multiplied each component by a given factor
  3595. * @param array defines the source array
  3596. * @param offset defines the offset in the source array
  3597. * @param scale defines the scaling factor
  3598. * @param result defines the target matrix
  3599. */
  3600. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3601. /**
  3602. * Gets an identity matrix that must not be updated
  3603. */
  3604. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3605. /**
  3606. * Stores a list of values (16) inside a given matrix
  3607. * @param initialM11 defines 1st value of 1st row
  3608. * @param initialM12 defines 2nd value of 1st row
  3609. * @param initialM13 defines 3rd value of 1st row
  3610. * @param initialM14 defines 4th value of 1st row
  3611. * @param initialM21 defines 1st value of 2nd row
  3612. * @param initialM22 defines 2nd value of 2nd row
  3613. * @param initialM23 defines 3rd value of 2nd row
  3614. * @param initialM24 defines 4th value of 2nd row
  3615. * @param initialM31 defines 1st value of 3rd row
  3616. * @param initialM32 defines 2nd value of 3rd row
  3617. * @param initialM33 defines 3rd value of 3rd row
  3618. * @param initialM34 defines 4th value of 3rd row
  3619. * @param initialM41 defines 1st value of 4th row
  3620. * @param initialM42 defines 2nd value of 4th row
  3621. * @param initialM43 defines 3rd value of 4th row
  3622. * @param initialM44 defines 4th value of 4th row
  3623. * @param result defines the target matrix
  3624. */
  3625. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  3626. /**
  3627. * Creates new matrix from a list of values (16)
  3628. * @param initialM11 defines 1st value of 1st row
  3629. * @param initialM12 defines 2nd value of 1st row
  3630. * @param initialM13 defines 3rd value of 1st row
  3631. * @param initialM14 defines 4th value of 1st row
  3632. * @param initialM21 defines 1st value of 2nd row
  3633. * @param initialM22 defines 2nd value of 2nd row
  3634. * @param initialM23 defines 3rd value of 2nd row
  3635. * @param initialM24 defines 4th value of 2nd row
  3636. * @param initialM31 defines 1st value of 3rd row
  3637. * @param initialM32 defines 2nd value of 3rd row
  3638. * @param initialM33 defines 3rd value of 3rd row
  3639. * @param initialM34 defines 4th value of 3rd row
  3640. * @param initialM41 defines 1st value of 4th row
  3641. * @param initialM42 defines 2nd value of 4th row
  3642. * @param initialM43 defines 3rd value of 4th row
  3643. * @param initialM44 defines 4th value of 4th row
  3644. * @returns the new matrix
  3645. */
  3646. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  3647. /**
  3648. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3649. * @param scale defines the scale vector3
  3650. * @param rotation defines the rotation quaternion
  3651. * @param translation defines the translation vector3
  3652. * @returns a new matrix
  3653. */
  3654. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3655. /**
  3656. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3657. * @param scale defines the scale vector3
  3658. * @param rotation defines the rotation quaternion
  3659. * @param translation defines the translation vector3
  3660. * @param result defines the target matrix
  3661. */
  3662. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3663. /**
  3664. * Creates a new identity matrix
  3665. * @returns a new identity matrix
  3666. */
  3667. static Identity(): Matrix;
  3668. /**
  3669. * Creates a new identity matrix and stores the result in a given matrix
  3670. * @param result defines the target matrix
  3671. */
  3672. static IdentityToRef(result: Matrix): void;
  3673. /**
  3674. * Creates a new zero matrix
  3675. * @returns a new zero matrix
  3676. */
  3677. static Zero(): Matrix;
  3678. /**
  3679. * Creates a new rotation matrix for "angle" radians around the X axis
  3680. * @param angle defines the angle (in radians) to use
  3681. * @return the new matrix
  3682. */
  3683. static RotationX(angle: number): Matrix;
  3684. /**
  3685. * Creates a new matrix as the invert of a given matrix
  3686. * @param source defines the source matrix
  3687. * @returns the new matrix
  3688. */
  3689. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3690. /**
  3691. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3692. * @param angle defines the angle (in radians) to use
  3693. * @param result defines the target matrix
  3694. */
  3695. static RotationXToRef(angle: number, result: Matrix): void;
  3696. /**
  3697. * Creates a new rotation matrix for "angle" radians around the Y axis
  3698. * @param angle defines the angle (in radians) to use
  3699. * @return the new matrix
  3700. */
  3701. static RotationY(angle: number): Matrix;
  3702. /**
  3703. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3704. * @param angle defines the angle (in radians) to use
  3705. * @param result defines the target matrix
  3706. */
  3707. static RotationYToRef(angle: number, result: Matrix): void;
  3708. /**
  3709. * Creates a new rotation matrix for "angle" radians around the Z axis
  3710. * @param angle defines the angle (in radians) to use
  3711. * @return the new matrix
  3712. */
  3713. static RotationZ(angle: number): Matrix;
  3714. /**
  3715. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3716. * @param angle defines the angle (in radians) to use
  3717. * @param result defines the target matrix
  3718. */
  3719. static RotationZToRef(angle: number, result: Matrix): void;
  3720. /**
  3721. * Creates a new rotation matrix for "angle" radians around the given axis
  3722. * @param axis defines the axis to use
  3723. * @param angle defines the angle (in radians) to use
  3724. * @return the new matrix
  3725. */
  3726. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3727. /**
  3728. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3729. * @param axis defines the axis to use
  3730. * @param angle defines the angle (in radians) to use
  3731. * @param result defines the target matrix
  3732. */
  3733. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3734. /**
  3735. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3736. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3737. * @param from defines the vector to align
  3738. * @param to defines the vector to align to
  3739. * @param result defines the target matrix
  3740. */
  3741. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3742. /**
  3743. * Creates a rotation matrix
  3744. * @param yaw defines the yaw angle in radians (Y axis)
  3745. * @param pitch defines the pitch angle in radians (X axis)
  3746. * @param roll defines the roll angle in radians (X axis)
  3747. * @returns the new rotation matrix
  3748. */
  3749. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3750. /**
  3751. * Creates a rotation matrix and stores it in a given matrix
  3752. * @param yaw defines the yaw angle in radians (Y axis)
  3753. * @param pitch defines the pitch angle in radians (X axis)
  3754. * @param roll defines the roll angle in radians (X axis)
  3755. * @param result defines the target matrix
  3756. */
  3757. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3758. /**
  3759. * Creates a scaling matrix
  3760. * @param x defines the scale factor on X axis
  3761. * @param y defines the scale factor on Y axis
  3762. * @param z defines the scale factor on Z axis
  3763. * @returns the new matrix
  3764. */
  3765. static Scaling(x: number, y: number, z: number): Matrix;
  3766. /**
  3767. * Creates a scaling matrix and stores it in a given matrix
  3768. * @param x defines the scale factor on X axis
  3769. * @param y defines the scale factor on Y axis
  3770. * @param z defines the scale factor on Z axis
  3771. * @param result defines the target matrix
  3772. */
  3773. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3774. /**
  3775. * Creates a translation matrix
  3776. * @param x defines the translation on X axis
  3777. * @param y defines the translation on Y axis
  3778. * @param z defines the translationon Z axis
  3779. * @returns the new matrix
  3780. */
  3781. static Translation(x: number, y: number, z: number): Matrix;
  3782. /**
  3783. * Creates a translation matrix and stores it in a given matrix
  3784. * @param x defines the translation on X axis
  3785. * @param y defines the translation on Y axis
  3786. * @param z defines the translationon Z axis
  3787. * @param result defines the target matrix
  3788. */
  3789. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3790. /**
  3791. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3792. * @param startValue defines the start value
  3793. * @param endValue defines the end value
  3794. * @param gradient defines the gradient factor
  3795. * @returns the new matrix
  3796. */
  3797. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3798. /**
  3799. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3800. * @param startValue defines the start value
  3801. * @param endValue defines the end value
  3802. * @param gradient defines the gradient factor
  3803. * @param result defines the Matrix object where to store data
  3804. */
  3805. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3806. /**
  3807. * Builds a new matrix whose values are computed by:
  3808. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3809. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3810. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3811. * @param startValue defines the first matrix
  3812. * @param endValue defines the second matrix
  3813. * @param gradient defines the gradient between the two matrices
  3814. * @returns the new matrix
  3815. */
  3816. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3817. /**
  3818. * Update a matrix to values which are computed by:
  3819. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3820. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3821. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3822. * @param startValue defines the first matrix
  3823. * @param endValue defines the second matrix
  3824. * @param gradient defines the gradient between the two matrices
  3825. * @param result defines the target matrix
  3826. */
  3827. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3828. /**
  3829. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3830. * This function works in left handed mode
  3831. * @param eye defines the final position of the entity
  3832. * @param target defines where the entity should look at
  3833. * @param up defines the up vector for the entity
  3834. * @returns the new matrix
  3835. */
  3836. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3837. /**
  3838. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3839. * This function works in left handed mode
  3840. * @param eye defines the final position of the entity
  3841. * @param target defines where the entity should look at
  3842. * @param up defines the up vector for the entity
  3843. * @param result defines the target matrix
  3844. */
  3845. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3846. /**
  3847. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3848. * This function works in right handed mode
  3849. * @param eye defines the final position of the entity
  3850. * @param target defines where the entity should look at
  3851. * @param up defines the up vector for the entity
  3852. * @returns the new matrix
  3853. */
  3854. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3855. /**
  3856. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3857. * This function works in right handed mode
  3858. * @param eye defines the final position of the entity
  3859. * @param target defines where the entity should look at
  3860. * @param up defines the up vector for the entity
  3861. * @param result defines the target matrix
  3862. */
  3863. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3864. /**
  3865. * Create a left-handed orthographic projection matrix
  3866. * @param width defines the viewport width
  3867. * @param height defines the viewport height
  3868. * @param znear defines the near clip plane
  3869. * @param zfar defines the far clip plane
  3870. * @returns a new matrix as a left-handed orthographic projection matrix
  3871. */
  3872. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3873. /**
  3874. * Store a left-handed orthographic projection to a given matrix
  3875. * @param width defines the viewport width
  3876. * @param height defines the viewport height
  3877. * @param znear defines the near clip plane
  3878. * @param zfar defines the far clip plane
  3879. * @param result defines the target matrix
  3880. */
  3881. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3882. /**
  3883. * Create a left-handed orthographic projection matrix
  3884. * @param left defines the viewport left coordinate
  3885. * @param right defines the viewport right coordinate
  3886. * @param bottom defines the viewport bottom coordinate
  3887. * @param top defines the viewport top coordinate
  3888. * @param znear defines the near clip plane
  3889. * @param zfar defines the far clip plane
  3890. * @returns a new matrix as a left-handed orthographic projection matrix
  3891. */
  3892. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3893. /**
  3894. * Stores a left-handed orthographic projection into a given matrix
  3895. * @param left defines the viewport left coordinate
  3896. * @param right defines the viewport right coordinate
  3897. * @param bottom defines the viewport bottom coordinate
  3898. * @param top defines the viewport top coordinate
  3899. * @param znear defines the near clip plane
  3900. * @param zfar defines the far clip plane
  3901. * @param result defines the target matrix
  3902. */
  3903. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3904. /**
  3905. * Creates a right-handed orthographic projection matrix
  3906. * @param left defines the viewport left coordinate
  3907. * @param right defines the viewport right coordinate
  3908. * @param bottom defines the viewport bottom coordinate
  3909. * @param top defines the viewport top coordinate
  3910. * @param znear defines the near clip plane
  3911. * @param zfar defines the far clip plane
  3912. * @returns a new matrix as a right-handed orthographic projection matrix
  3913. */
  3914. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3915. /**
  3916. * Stores a right-handed orthographic projection into a given matrix
  3917. * @param left defines the viewport left coordinate
  3918. * @param right defines the viewport right coordinate
  3919. * @param bottom defines the viewport bottom coordinate
  3920. * @param top defines the viewport top coordinate
  3921. * @param znear defines the near clip plane
  3922. * @param zfar defines the far clip plane
  3923. * @param result defines the target matrix
  3924. */
  3925. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3926. /**
  3927. * Creates a left-handed perspective projection matrix
  3928. * @param width defines the viewport width
  3929. * @param height defines the viewport height
  3930. * @param znear defines the near clip plane
  3931. * @param zfar defines the far clip plane
  3932. * @returns a new matrix as a left-handed perspective projection matrix
  3933. */
  3934. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3935. /**
  3936. * Creates a left-handed perspective projection matrix
  3937. * @param fov defines the horizontal field of view
  3938. * @param aspect defines the aspect ratio
  3939. * @param znear defines the near clip plane
  3940. * @param zfar defines the far clip plane
  3941. * @returns a new matrix as a left-handed perspective projection matrix
  3942. */
  3943. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3944. /**
  3945. * Stores a left-handed perspective projection into a given matrix
  3946. * @param fov defines the horizontal field of view
  3947. * @param aspect defines the aspect ratio
  3948. * @param znear defines the near clip plane
  3949. * @param zfar defines the far clip plane
  3950. * @param result defines the target matrix
  3951. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3952. */
  3953. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3954. /**
  3955. * Creates a right-handed perspective projection matrix
  3956. * @param fov defines the horizontal field of view
  3957. * @param aspect defines the aspect ratio
  3958. * @param znear defines the near clip plane
  3959. * @param zfar defines the far clip plane
  3960. * @returns a new matrix as a right-handed perspective projection matrix
  3961. */
  3962. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3963. /**
  3964. * Stores a right-handed perspective projection into a given matrix
  3965. * @param fov defines the horizontal field of view
  3966. * @param aspect defines the aspect ratio
  3967. * @param znear defines the near clip plane
  3968. * @param zfar defines the far clip plane
  3969. * @param result defines the target matrix
  3970. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3971. */
  3972. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3973. /**
  3974. * Stores a perspective projection for WebVR info a given matrix
  3975. * @param fov defines the field of view
  3976. * @param znear defines the near clip plane
  3977. * @param zfar defines the far clip plane
  3978. * @param result defines the target matrix
  3979. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3980. */
  3981. static PerspectiveFovWebVRToRef(fov: {
  3982. upDegrees: number;
  3983. downDegrees: number;
  3984. leftDegrees: number;
  3985. rightDegrees: number;
  3986. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3987. /**
  3988. * Computes a complete transformation matrix
  3989. * @param viewport defines the viewport to use
  3990. * @param world defines the world matrix
  3991. * @param view defines the view matrix
  3992. * @param projection defines the projection matrix
  3993. * @param zmin defines the near clip plane
  3994. * @param zmax defines the far clip plane
  3995. * @returns the transformation matrix
  3996. */
  3997. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3998. /**
  3999. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4000. * @param matrix defines the matrix to use
  4001. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4002. */
  4003. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4004. /**
  4005. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4006. * @param matrix defines the matrix to use
  4007. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4008. */
  4009. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4010. /**
  4011. * Compute the transpose of a given matrix
  4012. * @param matrix defines the matrix to transpose
  4013. * @returns the new matrix
  4014. */
  4015. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4016. /**
  4017. * Compute the transpose of a matrix and store it in a target matrix
  4018. * @param matrix defines the matrix to transpose
  4019. * @param result defines the target matrix
  4020. */
  4021. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4022. /**
  4023. * Computes a reflection matrix from a plane
  4024. * @param plane defines the reflection plane
  4025. * @returns a new matrix
  4026. */
  4027. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4028. /**
  4029. * Computes a reflection matrix from a plane
  4030. * @param plane defines the reflection plane
  4031. * @param result defines the target matrix
  4032. */
  4033. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4034. /**
  4035. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4036. * @param xaxis defines the value of the 1st axis
  4037. * @param yaxis defines the value of the 2nd axis
  4038. * @param zaxis defines the value of the 3rd axis
  4039. * @param result defines the target matrix
  4040. */
  4041. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4042. /**
  4043. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4044. * @param quat defines the quaternion to use
  4045. * @param result defines the target matrix
  4046. */
  4047. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4048. }
  4049. /**
  4050. * @hidden
  4051. */
  4052. export class TmpVectors {
  4053. static Vector2: Vector2[];
  4054. static Vector3: Vector3[];
  4055. static Vector4: Vector4[];
  4056. static Quaternion: Quaternion[];
  4057. static Matrix: Matrix[];
  4058. }
  4059. }
  4060. declare module "babylonjs/Engines/constants" {
  4061. /** Defines the cross module used constants to avoid circular dependncies */
  4062. export class Constants {
  4063. /** Defines that alpha blending is disabled */
  4064. static readonly ALPHA_DISABLE: number;
  4065. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4066. static readonly ALPHA_ADD: number;
  4067. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4068. static readonly ALPHA_COMBINE: number;
  4069. /** Defines that alpha blending to DEST - SRC * DEST */
  4070. static readonly ALPHA_SUBTRACT: number;
  4071. /** Defines that alpha blending to SRC * DEST */
  4072. static readonly ALPHA_MULTIPLY: number;
  4073. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4074. static readonly ALPHA_MAXIMIZED: number;
  4075. /** Defines that alpha blending to SRC + DEST */
  4076. static readonly ALPHA_ONEONE: number;
  4077. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4078. static readonly ALPHA_PREMULTIPLIED: number;
  4079. /**
  4080. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4081. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4082. */
  4083. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4084. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4085. static readonly ALPHA_INTERPOLATE: number;
  4086. /**
  4087. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4088. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4089. */
  4090. static readonly ALPHA_SCREENMODE: number;
  4091. /** Defines that the ressource is not delayed*/
  4092. static readonly DELAYLOADSTATE_NONE: number;
  4093. /** Defines that the ressource was successfully delay loaded */
  4094. static readonly DELAYLOADSTATE_LOADED: number;
  4095. /** Defines that the ressource is currently delay loading */
  4096. static readonly DELAYLOADSTATE_LOADING: number;
  4097. /** Defines that the ressource is delayed and has not started loading */
  4098. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4099. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4100. static readonly NEVER: number;
  4101. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  4102. static readonly ALWAYS: number;
  4103. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4104. static readonly LESS: number;
  4105. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4106. static readonly EQUAL: number;
  4107. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  4108. static readonly LEQUAL: number;
  4109. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4110. static readonly GREATER: number;
  4111. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  4112. static readonly GEQUAL: number;
  4113. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  4114. static readonly NOTEQUAL: number;
  4115. /** Passed to stencilOperation to specify that stencil value must be kept */
  4116. static readonly KEEP: number;
  4117. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4118. static readonly REPLACE: number;
  4119. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4120. static readonly INCR: number;
  4121. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4122. static readonly DECR: number;
  4123. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4124. static readonly INVERT: number;
  4125. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4126. static readonly INCR_WRAP: number;
  4127. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4128. static readonly DECR_WRAP: number;
  4129. /** Texture is not repeating outside of 0..1 UVs */
  4130. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4131. /** Texture is repeating outside of 0..1 UVs */
  4132. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4133. /** Texture is repeating and mirrored */
  4134. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4135. /** ALPHA */
  4136. static readonly TEXTUREFORMAT_ALPHA: number;
  4137. /** LUMINANCE */
  4138. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4139. /** LUMINANCE_ALPHA */
  4140. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4141. /** RGB */
  4142. static readonly TEXTUREFORMAT_RGB: number;
  4143. /** RGBA */
  4144. static readonly TEXTUREFORMAT_RGBA: number;
  4145. /** RED */
  4146. static readonly TEXTUREFORMAT_RED: number;
  4147. /** RED (2nd reference) */
  4148. static readonly TEXTUREFORMAT_R: number;
  4149. /** RG */
  4150. static readonly TEXTUREFORMAT_RG: number;
  4151. /** RED_INTEGER */
  4152. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4153. /** RED_INTEGER (2nd reference) */
  4154. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4155. /** RG_INTEGER */
  4156. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4157. /** RGB_INTEGER */
  4158. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4159. /** RGBA_INTEGER */
  4160. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4161. /** UNSIGNED_BYTE */
  4162. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4163. /** UNSIGNED_BYTE (2nd reference) */
  4164. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4165. /** FLOAT */
  4166. static readonly TEXTURETYPE_FLOAT: number;
  4167. /** HALF_FLOAT */
  4168. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4169. /** BYTE */
  4170. static readonly TEXTURETYPE_BYTE: number;
  4171. /** SHORT */
  4172. static readonly TEXTURETYPE_SHORT: number;
  4173. /** UNSIGNED_SHORT */
  4174. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4175. /** INT */
  4176. static readonly TEXTURETYPE_INT: number;
  4177. /** UNSIGNED_INT */
  4178. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4179. /** UNSIGNED_SHORT_4_4_4_4 */
  4180. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4181. /** UNSIGNED_SHORT_5_5_5_1 */
  4182. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4183. /** UNSIGNED_SHORT_5_6_5 */
  4184. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4185. /** UNSIGNED_INT_2_10_10_10_REV */
  4186. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4187. /** UNSIGNED_INT_24_8 */
  4188. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4189. /** UNSIGNED_INT_10F_11F_11F_REV */
  4190. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4191. /** UNSIGNED_INT_5_9_9_9_REV */
  4192. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4193. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4194. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4195. /** nearest is mag = nearest and min = nearest and mip = linear */
  4196. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4197. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4198. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4199. /** Trilinear is mag = linear and min = linear and mip = linear */
  4200. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4201. /** nearest is mag = nearest and min = nearest and mip = linear */
  4202. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4203. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4204. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4205. /** Trilinear is mag = linear and min = linear and mip = linear */
  4206. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4207. /** mag = nearest and min = nearest and mip = nearest */
  4208. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4209. /** mag = nearest and min = linear and mip = nearest */
  4210. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4211. /** mag = nearest and min = linear and mip = linear */
  4212. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4213. /** mag = nearest and min = linear and mip = none */
  4214. static readonly TEXTURE_NEAREST_LINEAR: number;
  4215. /** mag = nearest and min = nearest and mip = none */
  4216. static readonly TEXTURE_NEAREST_NEAREST: number;
  4217. /** mag = linear and min = nearest and mip = nearest */
  4218. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4219. /** mag = linear and min = nearest and mip = linear */
  4220. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4221. /** mag = linear and min = linear and mip = none */
  4222. static readonly TEXTURE_LINEAR_LINEAR: number;
  4223. /** mag = linear and min = nearest and mip = none */
  4224. static readonly TEXTURE_LINEAR_NEAREST: number;
  4225. /** Explicit coordinates mode */
  4226. static readonly TEXTURE_EXPLICIT_MODE: number;
  4227. /** Spherical coordinates mode */
  4228. static readonly TEXTURE_SPHERICAL_MODE: number;
  4229. /** Planar coordinates mode */
  4230. static readonly TEXTURE_PLANAR_MODE: number;
  4231. /** Cubic coordinates mode */
  4232. static readonly TEXTURE_CUBIC_MODE: number;
  4233. /** Projection coordinates mode */
  4234. static readonly TEXTURE_PROJECTION_MODE: number;
  4235. /** Skybox coordinates mode */
  4236. static readonly TEXTURE_SKYBOX_MODE: number;
  4237. /** Inverse Cubic coordinates mode */
  4238. static readonly TEXTURE_INVCUBIC_MODE: number;
  4239. /** Equirectangular coordinates mode */
  4240. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4241. /** Equirectangular Fixed coordinates mode */
  4242. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4243. /** Equirectangular Fixed Mirrored coordinates mode */
  4244. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4245. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4246. static readonly SCALEMODE_FLOOR: number;
  4247. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4248. static readonly SCALEMODE_NEAREST: number;
  4249. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4250. static readonly SCALEMODE_CEILING: number;
  4251. /**
  4252. * The dirty texture flag value
  4253. */
  4254. static readonly MATERIAL_TextureDirtyFlag: number;
  4255. /**
  4256. * The dirty light flag value
  4257. */
  4258. static readonly MATERIAL_LightDirtyFlag: number;
  4259. /**
  4260. * The dirty fresnel flag value
  4261. */
  4262. static readonly MATERIAL_FresnelDirtyFlag: number;
  4263. /**
  4264. * The dirty attribute flag value
  4265. */
  4266. static readonly MATERIAL_AttributesDirtyFlag: number;
  4267. /**
  4268. * The dirty misc flag value
  4269. */
  4270. static readonly MATERIAL_MiscDirtyFlag: number;
  4271. /**
  4272. * The all dirty flag value
  4273. */
  4274. static readonly MATERIAL_AllDirtyFlag: number;
  4275. /**
  4276. * Returns the triangle fill mode
  4277. */
  4278. static readonly MATERIAL_TriangleFillMode: number;
  4279. /**
  4280. * Returns the wireframe mode
  4281. */
  4282. static readonly MATERIAL_WireFrameFillMode: number;
  4283. /**
  4284. * Returns the point fill mode
  4285. */
  4286. static readonly MATERIAL_PointFillMode: number;
  4287. /**
  4288. * Returns the point list draw mode
  4289. */
  4290. static readonly MATERIAL_PointListDrawMode: number;
  4291. /**
  4292. * Returns the line list draw mode
  4293. */
  4294. static readonly MATERIAL_LineListDrawMode: number;
  4295. /**
  4296. * Returns the line loop draw mode
  4297. */
  4298. static readonly MATERIAL_LineLoopDrawMode: number;
  4299. /**
  4300. * Returns the line strip draw mode
  4301. */
  4302. static readonly MATERIAL_LineStripDrawMode: number;
  4303. /**
  4304. * Returns the triangle strip draw mode
  4305. */
  4306. static readonly MATERIAL_TriangleStripDrawMode: number;
  4307. /**
  4308. * Returns the triangle fan draw mode
  4309. */
  4310. static readonly MATERIAL_TriangleFanDrawMode: number;
  4311. /**
  4312. * Stores the clock-wise side orientation
  4313. */
  4314. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4315. /**
  4316. * Stores the counter clock-wise side orientation
  4317. */
  4318. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4319. /**
  4320. * Nothing
  4321. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4322. */
  4323. static readonly ACTION_NothingTrigger: number;
  4324. /**
  4325. * On pick
  4326. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4327. */
  4328. static readonly ACTION_OnPickTrigger: number;
  4329. /**
  4330. * On left pick
  4331. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4332. */
  4333. static readonly ACTION_OnLeftPickTrigger: number;
  4334. /**
  4335. * On right pick
  4336. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4337. */
  4338. static readonly ACTION_OnRightPickTrigger: number;
  4339. /**
  4340. * On center pick
  4341. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4342. */
  4343. static readonly ACTION_OnCenterPickTrigger: number;
  4344. /**
  4345. * On pick down
  4346. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4347. */
  4348. static readonly ACTION_OnPickDownTrigger: number;
  4349. /**
  4350. * On double pick
  4351. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4352. */
  4353. static readonly ACTION_OnDoublePickTrigger: number;
  4354. /**
  4355. * On pick up
  4356. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4357. */
  4358. static readonly ACTION_OnPickUpTrigger: number;
  4359. /**
  4360. * On pick out.
  4361. * This trigger will only be raised if you also declared a OnPickDown
  4362. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4363. */
  4364. static readonly ACTION_OnPickOutTrigger: number;
  4365. /**
  4366. * On long press
  4367. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4368. */
  4369. static readonly ACTION_OnLongPressTrigger: number;
  4370. /**
  4371. * On pointer over
  4372. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4373. */
  4374. static readonly ACTION_OnPointerOverTrigger: number;
  4375. /**
  4376. * On pointer out
  4377. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4378. */
  4379. static readonly ACTION_OnPointerOutTrigger: number;
  4380. /**
  4381. * On every frame
  4382. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4383. */
  4384. static readonly ACTION_OnEveryFrameTrigger: number;
  4385. /**
  4386. * On intersection enter
  4387. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4388. */
  4389. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4390. /**
  4391. * On intersection exit
  4392. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4393. */
  4394. static readonly ACTION_OnIntersectionExitTrigger: number;
  4395. /**
  4396. * On key down
  4397. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4398. */
  4399. static readonly ACTION_OnKeyDownTrigger: number;
  4400. /**
  4401. * On key up
  4402. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4403. */
  4404. static readonly ACTION_OnKeyUpTrigger: number;
  4405. /**
  4406. * Billboard mode will only apply to Y axis
  4407. */
  4408. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4409. /**
  4410. * Billboard mode will apply to all axes
  4411. */
  4412. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4413. /**
  4414. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4415. */
  4416. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4417. /**
  4418. * Gets or sets base Assets URL
  4419. */
  4420. static PARTICLES_BaseAssetsUrl: string;
  4421. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4422. * Test order :
  4423. * Is the bounding sphere outside the frustum ?
  4424. * If not, are the bounding box vertices outside the frustum ?
  4425. * It not, then the cullable object is in the frustum.
  4426. */
  4427. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4428. /** Culling strategy : Bounding Sphere Only.
  4429. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4430. * It's also less accurate than the standard because some not visible objects can still be selected.
  4431. * Test : is the bounding sphere outside the frustum ?
  4432. * If not, then the cullable object is in the frustum.
  4433. */
  4434. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4435. /** Culling strategy : Optimistic Inclusion.
  4436. * This in an inclusion test first, then the standard exclusion test.
  4437. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4438. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  4439. * Anyway, it's as accurate as the standard strategy.
  4440. * Test :
  4441. * Is the cullable object bounding sphere center in the frustum ?
  4442. * If not, apply the default culling strategy.
  4443. */
  4444. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4445. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4446. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4447. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4448. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  4449. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4450. * Test :
  4451. * Is the cullable object bounding sphere center in the frustum ?
  4452. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4453. */
  4454. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4455. /**
  4456. * No logging while loading
  4457. */
  4458. static readonly SCENELOADER_NO_LOGGING: number;
  4459. /**
  4460. * Minimal logging while loading
  4461. */
  4462. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4463. /**
  4464. * Summary logging while loading
  4465. */
  4466. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4467. /**
  4468. * Detailled logging while loading
  4469. */
  4470. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4471. }
  4472. }
  4473. declare module "babylonjs/Engines/IPipelineContext" {
  4474. /**
  4475. * Class used to store and describe the pipeline context associated with an effect
  4476. */
  4477. export interface IPipelineContext {
  4478. /**
  4479. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  4480. */
  4481. isAsync: boolean;
  4482. /**
  4483. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  4484. */
  4485. isReady: boolean;
  4486. /** @hidden */
  4487. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  4488. }
  4489. }
  4490. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  4491. /** @hidden */
  4492. export interface IShaderProcessor {
  4493. attributeProcessor?: (attribute: string) => string;
  4494. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  4495. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  4496. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  4497. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  4498. lineProcessor?: (line: string, isFragment: boolean) => string;
  4499. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4500. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4501. }
  4502. }
  4503. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  4504. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  4505. /** @hidden */
  4506. export interface ProcessingOptions {
  4507. defines: string[];
  4508. indexParameters: any;
  4509. isFragment: boolean;
  4510. shouldUseHighPrecisionShader: boolean;
  4511. supportsUniformBuffers: boolean;
  4512. shadersRepository: string;
  4513. includesShadersStore: {
  4514. [key: string]: string;
  4515. };
  4516. processor?: IShaderProcessor;
  4517. version: string;
  4518. platformName: string;
  4519. lookForClosingBracketForUniformBuffer?: boolean;
  4520. }
  4521. }
  4522. declare module "babylonjs/Misc/stringTools" {
  4523. /**
  4524. * Helper to manipulate strings
  4525. */
  4526. export class StringTools {
  4527. /**
  4528. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  4529. * @param str Source string
  4530. * @param suffix Suffix to search for in the source string
  4531. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4532. */
  4533. static EndsWith(str: string, suffix: string): boolean;
  4534. /**
  4535. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  4536. * @param str Source string
  4537. * @param suffix Suffix to search for in the source string
  4538. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4539. */
  4540. static StartsWith(str: string, suffix: string): boolean;
  4541. }
  4542. }
  4543. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  4544. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4545. /** @hidden */
  4546. export class ShaderCodeNode {
  4547. line: string;
  4548. children: ShaderCodeNode[];
  4549. additionalDefineKey?: string;
  4550. additionalDefineValue?: string;
  4551. isValid(preprocessors: {
  4552. [key: string]: string;
  4553. }): boolean;
  4554. process(preprocessors: {
  4555. [key: string]: string;
  4556. }, options: ProcessingOptions): string;
  4557. }
  4558. }
  4559. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  4560. /** @hidden */
  4561. export class ShaderCodeCursor {
  4562. private _lines;
  4563. lineIndex: number;
  4564. readonly currentLine: string;
  4565. readonly canRead: boolean;
  4566. lines: string[];
  4567. }
  4568. }
  4569. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  4570. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  4571. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4572. /** @hidden */
  4573. export class ShaderCodeConditionNode extends ShaderCodeNode {
  4574. process(preprocessors: {
  4575. [key: string]: string;
  4576. }, options: ProcessingOptions): string;
  4577. }
  4578. }
  4579. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  4580. /** @hidden */
  4581. export class ShaderDefineExpression {
  4582. isTrue(preprocessors: {
  4583. [key: string]: string;
  4584. }): boolean;
  4585. }
  4586. }
  4587. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  4588. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  4589. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4590. /** @hidden */
  4591. export class ShaderCodeTestNode extends ShaderCodeNode {
  4592. testExpression: ShaderDefineExpression;
  4593. isValid(preprocessors: {
  4594. [key: string]: string;
  4595. }): boolean;
  4596. }
  4597. }
  4598. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  4599. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4600. /** @hidden */
  4601. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  4602. define: string;
  4603. not: boolean;
  4604. constructor(define: string, not?: boolean);
  4605. isTrue(preprocessors: {
  4606. [key: string]: string;
  4607. }): boolean;
  4608. }
  4609. }
  4610. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  4611. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4612. /** @hidden */
  4613. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  4614. leftOperand: ShaderDefineExpression;
  4615. rightOperand: ShaderDefineExpression;
  4616. isTrue(preprocessors: {
  4617. [key: string]: string;
  4618. }): boolean;
  4619. }
  4620. }
  4621. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  4622. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4623. /** @hidden */
  4624. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  4625. leftOperand: ShaderDefineExpression;
  4626. rightOperand: ShaderDefineExpression;
  4627. isTrue(preprocessors: {
  4628. [key: string]: string;
  4629. }): boolean;
  4630. }
  4631. }
  4632. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  4633. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4634. /** @hidden */
  4635. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  4636. define: string;
  4637. operand: string;
  4638. testValue: string;
  4639. constructor(define: string, operand: string, testValue: string);
  4640. isTrue(preprocessors: {
  4641. [key: string]: string;
  4642. }): boolean;
  4643. }
  4644. }
  4645. declare module "babylonjs/Misc/loadFileError" {
  4646. import { WebRequest } from "babylonjs/Misc/webRequest";
  4647. /**
  4648. * @ignore
  4649. * Application error to support additional information when loading a file
  4650. */
  4651. export class LoadFileError extends Error {
  4652. /** defines the optional web request */
  4653. request?: WebRequest | undefined;
  4654. private static _setPrototypeOf;
  4655. /**
  4656. * Creates a new LoadFileError
  4657. * @param message defines the message of the error
  4658. * @param request defines the optional web request
  4659. */
  4660. constructor(message: string,
  4661. /** defines the optional web request */
  4662. request?: WebRequest | undefined);
  4663. }
  4664. }
  4665. declare module "babylonjs/Offline/IOfflineProvider" {
  4666. /**
  4667. * Class used to enable access to offline support
  4668. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4669. */
  4670. export interface IOfflineProvider {
  4671. /**
  4672. * Gets a boolean indicating if scene must be saved in the database
  4673. */
  4674. enableSceneOffline: boolean;
  4675. /**
  4676. * Gets a boolean indicating if textures must be saved in the database
  4677. */
  4678. enableTexturesOffline: boolean;
  4679. /**
  4680. * Open the offline support and make it available
  4681. * @param successCallback defines the callback to call on success
  4682. * @param errorCallback defines the callback to call on error
  4683. */
  4684. open(successCallback: () => void, errorCallback: () => void): void;
  4685. /**
  4686. * Loads an image from the offline support
  4687. * @param url defines the url to load from
  4688. * @param image defines the target DOM image
  4689. */
  4690. loadImage(url: string, image: HTMLImageElement): void;
  4691. /**
  4692. * Loads a file from offline support
  4693. * @param url defines the URL to load from
  4694. * @param sceneLoaded defines a callback to call on success
  4695. * @param progressCallBack defines a callback to call when progress changed
  4696. * @param errorCallback defines a callback to call on error
  4697. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4698. */
  4699. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4700. }
  4701. }
  4702. declare module "babylonjs/Misc/filesInputStore" {
  4703. /**
  4704. * Class used to help managing file picking and drag'n'drop
  4705. * File Storage
  4706. */
  4707. export class FilesInputStore {
  4708. /**
  4709. * List of files ready to be loaded
  4710. */
  4711. static FilesToLoad: {
  4712. [key: string]: File;
  4713. };
  4714. }
  4715. }
  4716. declare module "babylonjs/Misc/retryStrategy" {
  4717. import { WebRequest } from "babylonjs/Misc/webRequest";
  4718. /**
  4719. * Class used to define a retry strategy when error happens while loading assets
  4720. */
  4721. export class RetryStrategy {
  4722. /**
  4723. * Function used to defines an exponential back off strategy
  4724. * @param maxRetries defines the maximum number of retries (3 by default)
  4725. * @param baseInterval defines the interval between retries
  4726. * @returns the strategy function to use
  4727. */
  4728. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  4729. }
  4730. }
  4731. declare module "babylonjs/Misc/fileTools" {
  4732. import { WebRequest } from "babylonjs/Misc/webRequest";
  4733. import { Nullable } from "babylonjs/types";
  4734. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  4735. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  4736. /**
  4737. * @hidden
  4738. */
  4739. export class FileTools {
  4740. /**
  4741. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  4742. */
  4743. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  4744. /**
  4745. * Gets or sets the base URL to use to load assets
  4746. */
  4747. static BaseUrl: string;
  4748. /**
  4749. * Default behaviour for cors in the application.
  4750. * It can be a string if the expected behavior is identical in the entire app.
  4751. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  4752. */
  4753. static CorsBehavior: string | ((url: string | string[]) => string);
  4754. /**
  4755. * Gets or sets a function used to pre-process url before using them to load assets
  4756. */
  4757. static PreprocessUrl: (url: string) => string;
  4758. /**
  4759. * Removes unwanted characters from an url
  4760. * @param url defines the url to clean
  4761. * @returns the cleaned url
  4762. */
  4763. private static _CleanUrl;
  4764. /**
  4765. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  4766. * @param url define the url we are trying
  4767. * @param element define the dom element where to configure the cors policy
  4768. */
  4769. static SetCorsBehavior(url: string | string[], element: {
  4770. crossOrigin: string | null;
  4771. }): void;
  4772. /**
  4773. * Loads an image as an HTMLImageElement.
  4774. * @param input url string, ArrayBuffer, or Blob to load
  4775. * @param onLoad callback called when the image successfully loads
  4776. * @param onError callback called when the image fails to load
  4777. * @param offlineProvider offline provider for caching
  4778. * @returns the HTMLImageElement of the loaded image
  4779. */
  4780. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  4781. /**
  4782. * Loads a file
  4783. * @param fileToLoad defines the file to load
  4784. * @param callback defines the callback to call when data is loaded
  4785. * @param progressCallBack defines the callback to call during loading process
  4786. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  4787. * @returns a file request object
  4788. */
  4789. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  4790. /**
  4791. * Loads a file
  4792. * @param url url string, ArrayBuffer, or Blob to load
  4793. * @param onSuccess callback called when the file successfully loads
  4794. * @param onProgress callback called while file is loading (if the server supports this mode)
  4795. * @param offlineProvider defines the offline provider for caching
  4796. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  4797. * @param onError callback called when the file fails to load
  4798. * @returns a file request object
  4799. */
  4800. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  4801. /**
  4802. * Checks if the loaded document was accessed via `file:`-Protocol.
  4803. * @returns boolean
  4804. */
  4805. static IsFileURL(): boolean;
  4806. }
  4807. }
  4808. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  4809. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4810. /** @hidden */
  4811. export class ShaderProcessor {
  4812. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  4813. private static _ProcessPrecision;
  4814. private static _ExtractOperation;
  4815. private static _BuildSubExpression;
  4816. private static _BuildExpression;
  4817. private static _MoveCursorWithinIf;
  4818. private static _MoveCursor;
  4819. private static _EvaluatePreProcessors;
  4820. private static _PreparePreProcessors;
  4821. private static _ProcessShaderConversion;
  4822. private static _ProcessIncludes;
  4823. }
  4824. }
  4825. declare module "babylonjs/Maths/math.color" {
  4826. import { DeepImmutable, FloatArray } from "babylonjs/types";
  4827. /**
  4828. * Class used to hold a RBG color
  4829. */
  4830. export class Color3 {
  4831. /**
  4832. * Defines the red component (between 0 and 1, default is 0)
  4833. */
  4834. r: number;
  4835. /**
  4836. * Defines the green component (between 0 and 1, default is 0)
  4837. */
  4838. g: number;
  4839. /**
  4840. * Defines the blue component (between 0 and 1, default is 0)
  4841. */
  4842. b: number;
  4843. /**
  4844. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  4845. * @param r defines the red component (between 0 and 1, default is 0)
  4846. * @param g defines the green component (between 0 and 1, default is 0)
  4847. * @param b defines the blue component (between 0 and 1, default is 0)
  4848. */
  4849. constructor(
  4850. /**
  4851. * Defines the red component (between 0 and 1, default is 0)
  4852. */
  4853. r?: number,
  4854. /**
  4855. * Defines the green component (between 0 and 1, default is 0)
  4856. */
  4857. g?: number,
  4858. /**
  4859. * Defines the blue component (between 0 and 1, default is 0)
  4860. */
  4861. b?: number);
  4862. /**
  4863. * Creates a string with the Color3 current values
  4864. * @returns the string representation of the Color3 object
  4865. */
  4866. toString(): string;
  4867. /**
  4868. * Returns the string "Color3"
  4869. * @returns "Color3"
  4870. */
  4871. getClassName(): string;
  4872. /**
  4873. * Compute the Color3 hash code
  4874. * @returns an unique number that can be used to hash Color3 objects
  4875. */
  4876. getHashCode(): number;
  4877. /**
  4878. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  4879. * @param array defines the array where to store the r,g,b components
  4880. * @param index defines an optional index in the target array to define where to start storing values
  4881. * @returns the current Color3 object
  4882. */
  4883. toArray(array: FloatArray, index?: number): Color3;
  4884. /**
  4885. * Returns a new Color4 object from the current Color3 and the given alpha
  4886. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  4887. * @returns a new Color4 object
  4888. */
  4889. toColor4(alpha?: number): Color4;
  4890. /**
  4891. * Returns a new array populated with 3 numeric elements : red, green and blue values
  4892. * @returns the new array
  4893. */
  4894. asArray(): number[];
  4895. /**
  4896. * Returns the luminance value
  4897. * @returns a float value
  4898. */
  4899. toLuminance(): number;
  4900. /**
  4901. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  4902. * @param otherColor defines the second operand
  4903. * @returns the new Color3 object
  4904. */
  4905. multiply(otherColor: DeepImmutable<Color3>): Color3;
  4906. /**
  4907. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  4908. * @param otherColor defines the second operand
  4909. * @param result defines the Color3 object where to store the result
  4910. * @returns the current Color3
  4911. */
  4912. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4913. /**
  4914. * Determines equality between Color3 objects
  4915. * @param otherColor defines the second operand
  4916. * @returns true if the rgb values are equal to the given ones
  4917. */
  4918. equals(otherColor: DeepImmutable<Color3>): boolean;
  4919. /**
  4920. * Determines equality between the current Color3 object and a set of r,b,g values
  4921. * @param r defines the red component to check
  4922. * @param g defines the green component to check
  4923. * @param b defines the blue component to check
  4924. * @returns true if the rgb values are equal to the given ones
  4925. */
  4926. equalsFloats(r: number, g: number, b: number): boolean;
  4927. /**
  4928. * Multiplies in place each rgb value by scale
  4929. * @param scale defines the scaling factor
  4930. * @returns the updated Color3
  4931. */
  4932. scale(scale: number): Color3;
  4933. /**
  4934. * Multiplies the rgb values by scale and stores the result into "result"
  4935. * @param scale defines the scaling factor
  4936. * @param result defines the Color3 object where to store the result
  4937. * @returns the unmodified current Color3
  4938. */
  4939. scaleToRef(scale: number, result: Color3): Color3;
  4940. /**
  4941. * Scale the current Color3 values by a factor and add the result to a given Color3
  4942. * @param scale defines the scale factor
  4943. * @param result defines color to store the result into
  4944. * @returns the unmodified current Color3
  4945. */
  4946. scaleAndAddToRef(scale: number, result: Color3): Color3;
  4947. /**
  4948. * Clamps the rgb values by the min and max values and stores the result into "result"
  4949. * @param min defines minimum clamping value (default is 0)
  4950. * @param max defines maximum clamping value (default is 1)
  4951. * @param result defines color to store the result into
  4952. * @returns the original Color3
  4953. */
  4954. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  4955. /**
  4956. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  4957. * @param otherColor defines the second operand
  4958. * @returns the new Color3
  4959. */
  4960. add(otherColor: DeepImmutable<Color3>): Color3;
  4961. /**
  4962. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  4963. * @param otherColor defines the second operand
  4964. * @param result defines Color3 object to store the result into
  4965. * @returns the unmodified current Color3
  4966. */
  4967. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4968. /**
  4969. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  4970. * @param otherColor defines the second operand
  4971. * @returns the new Color3
  4972. */
  4973. subtract(otherColor: DeepImmutable<Color3>): Color3;
  4974. /**
  4975. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  4976. * @param otherColor defines the second operand
  4977. * @param result defines Color3 object to store the result into
  4978. * @returns the unmodified current Color3
  4979. */
  4980. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4981. /**
  4982. * Copy the current object
  4983. * @returns a new Color3 copied the current one
  4984. */
  4985. clone(): Color3;
  4986. /**
  4987. * Copies the rgb values from the source in the current Color3
  4988. * @param source defines the source Color3 object
  4989. * @returns the updated Color3 object
  4990. */
  4991. copyFrom(source: DeepImmutable<Color3>): Color3;
  4992. /**
  4993. * Updates the Color3 rgb values from the given floats
  4994. * @param r defines the red component to read from
  4995. * @param g defines the green component to read from
  4996. * @param b defines the blue component to read from
  4997. * @returns the current Color3 object
  4998. */
  4999. copyFromFloats(r: number, g: number, b: number): Color3;
  5000. /**
  5001. * Updates the Color3 rgb values from the given floats
  5002. * @param r defines the red component to read from
  5003. * @param g defines the green component to read from
  5004. * @param b defines the blue component to read from
  5005. * @returns the current Color3 object
  5006. */
  5007. set(r: number, g: number, b: number): Color3;
  5008. /**
  5009. * Compute the Color3 hexadecimal code as a string
  5010. * @returns a string containing the hexadecimal representation of the Color3 object
  5011. */
  5012. toHexString(): string;
  5013. /**
  5014. * Computes a new Color3 converted from the current one to linear space
  5015. * @returns a new Color3 object
  5016. */
  5017. toLinearSpace(): Color3;
  5018. /**
  5019. * Converts current color in rgb space to HSV values
  5020. * @returns a new color3 representing the HSV values
  5021. */
  5022. toHSV(): Color3;
  5023. /**
  5024. * Converts current color in rgb space to HSV values
  5025. * @param result defines the Color3 where to store the HSV values
  5026. */
  5027. toHSVToRef(result: Color3): void;
  5028. /**
  5029. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5030. * @param convertedColor defines the Color3 object where to store the linear space version
  5031. * @returns the unmodified Color3
  5032. */
  5033. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5034. /**
  5035. * Computes a new Color3 converted from the current one to gamma space
  5036. * @returns a new Color3 object
  5037. */
  5038. toGammaSpace(): Color3;
  5039. /**
  5040. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5041. * @param convertedColor defines the Color3 object where to store the gamma space version
  5042. * @returns the unmodified Color3
  5043. */
  5044. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5045. private static _BlackReadOnly;
  5046. /**
  5047. * Convert Hue, saturation and value to a Color3 (RGB)
  5048. * @param hue defines the hue
  5049. * @param saturation defines the saturation
  5050. * @param value defines the value
  5051. * @param result defines the Color3 where to store the RGB values
  5052. */
  5053. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5054. /**
  5055. * Creates a new Color3 from the string containing valid hexadecimal values
  5056. * @param hex defines a string containing valid hexadecimal values
  5057. * @returns a new Color3 object
  5058. */
  5059. static FromHexString(hex: string): Color3;
  5060. /**
  5061. * Creates a new Color3 from the starting index of the given array
  5062. * @param array defines the source array
  5063. * @param offset defines an offset in the source array
  5064. * @returns a new Color3 object
  5065. */
  5066. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5067. /**
  5068. * Creates a new Color3 from integer values (< 256)
  5069. * @param r defines the red component to read from (value between 0 and 255)
  5070. * @param g defines the green component to read from (value between 0 and 255)
  5071. * @param b defines the blue component to read from (value between 0 and 255)
  5072. * @returns a new Color3 object
  5073. */
  5074. static FromInts(r: number, g: number, b: number): Color3;
  5075. /**
  5076. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5077. * @param start defines the start Color3 value
  5078. * @param end defines the end Color3 value
  5079. * @param amount defines the gradient value between start and end
  5080. * @returns a new Color3 object
  5081. */
  5082. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5083. /**
  5084. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5085. * @param left defines the start value
  5086. * @param right defines the end value
  5087. * @param amount defines the gradient factor
  5088. * @param result defines the Color3 object where to store the result
  5089. */
  5090. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5091. /**
  5092. * Returns a Color3 value containing a red color
  5093. * @returns a new Color3 object
  5094. */
  5095. static Red(): Color3;
  5096. /**
  5097. * Returns a Color3 value containing a green color
  5098. * @returns a new Color3 object
  5099. */
  5100. static Green(): Color3;
  5101. /**
  5102. * Returns a Color3 value containing a blue color
  5103. * @returns a new Color3 object
  5104. */
  5105. static Blue(): Color3;
  5106. /**
  5107. * Returns a Color3 value containing a black color
  5108. * @returns a new Color3 object
  5109. */
  5110. static Black(): Color3;
  5111. /**
  5112. * Gets a Color3 value containing a black color that must not be updated
  5113. */
  5114. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5115. /**
  5116. * Returns a Color3 value containing a white color
  5117. * @returns a new Color3 object
  5118. */
  5119. static White(): Color3;
  5120. /**
  5121. * Returns a Color3 value containing a purple color
  5122. * @returns a new Color3 object
  5123. */
  5124. static Purple(): Color3;
  5125. /**
  5126. * Returns a Color3 value containing a magenta color
  5127. * @returns a new Color3 object
  5128. */
  5129. static Magenta(): Color3;
  5130. /**
  5131. * Returns a Color3 value containing a yellow color
  5132. * @returns a new Color3 object
  5133. */
  5134. static Yellow(): Color3;
  5135. /**
  5136. * Returns a Color3 value containing a gray color
  5137. * @returns a new Color3 object
  5138. */
  5139. static Gray(): Color3;
  5140. /**
  5141. * Returns a Color3 value containing a teal color
  5142. * @returns a new Color3 object
  5143. */
  5144. static Teal(): Color3;
  5145. /**
  5146. * Returns a Color3 value containing a random color
  5147. * @returns a new Color3 object
  5148. */
  5149. static Random(): Color3;
  5150. }
  5151. /**
  5152. * Class used to hold a RBGA color
  5153. */
  5154. export class Color4 {
  5155. /**
  5156. * Defines the red component (between 0 and 1, default is 0)
  5157. */
  5158. r: number;
  5159. /**
  5160. * Defines the green component (between 0 and 1, default is 0)
  5161. */
  5162. g: number;
  5163. /**
  5164. * Defines the blue component (between 0 and 1, default is 0)
  5165. */
  5166. b: number;
  5167. /**
  5168. * Defines the alpha component (between 0 and 1, default is 1)
  5169. */
  5170. a: number;
  5171. /**
  5172. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5173. * @param r defines the red component (between 0 and 1, default is 0)
  5174. * @param g defines the green component (between 0 and 1, default is 0)
  5175. * @param b defines the blue component (between 0 and 1, default is 0)
  5176. * @param a defines the alpha component (between 0 and 1, default is 1)
  5177. */
  5178. constructor(
  5179. /**
  5180. * Defines the red component (between 0 and 1, default is 0)
  5181. */
  5182. r?: number,
  5183. /**
  5184. * Defines the green component (between 0 and 1, default is 0)
  5185. */
  5186. g?: number,
  5187. /**
  5188. * Defines the blue component (between 0 and 1, default is 0)
  5189. */
  5190. b?: number,
  5191. /**
  5192. * Defines the alpha component (between 0 and 1, default is 1)
  5193. */
  5194. a?: number);
  5195. /**
  5196. * Adds in place the given Color4 values to the current Color4 object
  5197. * @param right defines the second operand
  5198. * @returns the current updated Color4 object
  5199. */
  5200. addInPlace(right: DeepImmutable<Color4>): Color4;
  5201. /**
  5202. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5203. * @returns the new array
  5204. */
  5205. asArray(): number[];
  5206. /**
  5207. * Stores from the starting index in the given array the Color4 successive values
  5208. * @param array defines the array where to store the r,g,b components
  5209. * @param index defines an optional index in the target array to define where to start storing values
  5210. * @returns the current Color4 object
  5211. */
  5212. toArray(array: number[], index?: number): Color4;
  5213. /**
  5214. * Determines equality between Color4 objects
  5215. * @param otherColor defines the second operand
  5216. * @returns true if the rgba values are equal to the given ones
  5217. */
  5218. equals(otherColor: DeepImmutable<Color4>): boolean;
  5219. /**
  5220. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5221. * @param right defines the second operand
  5222. * @returns a new Color4 object
  5223. */
  5224. add(right: DeepImmutable<Color4>): Color4;
  5225. /**
  5226. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5227. * @param right defines the second operand
  5228. * @returns a new Color4 object
  5229. */
  5230. subtract(right: DeepImmutable<Color4>): Color4;
  5231. /**
  5232. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5233. * @param right defines the second operand
  5234. * @param result defines the Color4 object where to store the result
  5235. * @returns the current Color4 object
  5236. */
  5237. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5238. /**
  5239. * Creates a new Color4 with the current Color4 values multiplied by scale
  5240. * @param scale defines the scaling factor to apply
  5241. * @returns a new Color4 object
  5242. */
  5243. scale(scale: number): Color4;
  5244. /**
  5245. * Multiplies the current Color4 values by scale and stores the result in "result"
  5246. * @param scale defines the scaling factor to apply
  5247. * @param result defines the Color4 object where to store the result
  5248. * @returns the current unmodified Color4
  5249. */
  5250. scaleToRef(scale: number, result: Color4): Color4;
  5251. /**
  5252. * Scale the current Color4 values by a factor and add the result to a given Color4
  5253. * @param scale defines the scale factor
  5254. * @param result defines the Color4 object where to store the result
  5255. * @returns the unmodified current Color4
  5256. */
  5257. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5258. /**
  5259. * Clamps the rgb values by the min and max values and stores the result into "result"
  5260. * @param min defines minimum clamping value (default is 0)
  5261. * @param max defines maximum clamping value (default is 1)
  5262. * @param result defines color to store the result into.
  5263. * @returns the cuurent Color4
  5264. */
  5265. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5266. /**
  5267. * Multipy an Color4 value by another and return a new Color4 object
  5268. * @param color defines the Color4 value to multiply by
  5269. * @returns a new Color4 object
  5270. */
  5271. multiply(color: Color4): Color4;
  5272. /**
  5273. * Multipy a Color4 value by another and push the result in a reference value
  5274. * @param color defines the Color4 value to multiply by
  5275. * @param result defines the Color4 to fill the result in
  5276. * @returns the result Color4
  5277. */
  5278. multiplyToRef(color: Color4, result: Color4): Color4;
  5279. /**
  5280. * Creates a string with the Color4 current values
  5281. * @returns the string representation of the Color4 object
  5282. */
  5283. toString(): string;
  5284. /**
  5285. * Returns the string "Color4"
  5286. * @returns "Color4"
  5287. */
  5288. getClassName(): string;
  5289. /**
  5290. * Compute the Color4 hash code
  5291. * @returns an unique number that can be used to hash Color4 objects
  5292. */
  5293. getHashCode(): number;
  5294. /**
  5295. * Creates a new Color4 copied from the current one
  5296. * @returns a new Color4 object
  5297. */
  5298. clone(): Color4;
  5299. /**
  5300. * Copies the given Color4 values into the current one
  5301. * @param source defines the source Color4 object
  5302. * @returns the current updated Color4 object
  5303. */
  5304. copyFrom(source: Color4): Color4;
  5305. /**
  5306. * Copies the given float values into the current one
  5307. * @param r defines the red component to read from
  5308. * @param g defines the green component to read from
  5309. * @param b defines the blue component to read from
  5310. * @param a defines the alpha component to read from
  5311. * @returns the current updated Color4 object
  5312. */
  5313. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5314. /**
  5315. * Copies the given float values into the current one
  5316. * @param r defines the red component to read from
  5317. * @param g defines the green component to read from
  5318. * @param b defines the blue component to read from
  5319. * @param a defines the alpha component to read from
  5320. * @returns the current updated Color4 object
  5321. */
  5322. set(r: number, g: number, b: number, a: number): Color4;
  5323. /**
  5324. * Compute the Color4 hexadecimal code as a string
  5325. * @returns a string containing the hexadecimal representation of the Color4 object
  5326. */
  5327. toHexString(): string;
  5328. /**
  5329. * Computes a new Color4 converted from the current one to linear space
  5330. * @returns a new Color4 object
  5331. */
  5332. toLinearSpace(): Color4;
  5333. /**
  5334. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5335. * @param convertedColor defines the Color4 object where to store the linear space version
  5336. * @returns the unmodified Color4
  5337. */
  5338. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5339. /**
  5340. * Computes a new Color4 converted from the current one to gamma space
  5341. * @returns a new Color4 object
  5342. */
  5343. toGammaSpace(): Color4;
  5344. /**
  5345. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5346. * @param convertedColor defines the Color4 object where to store the gamma space version
  5347. * @returns the unmodified Color4
  5348. */
  5349. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5350. /**
  5351. * Creates a new Color4 from the string containing valid hexadecimal values
  5352. * @param hex defines a string containing valid hexadecimal values
  5353. * @returns a new Color4 object
  5354. */
  5355. static FromHexString(hex: string): Color4;
  5356. /**
  5357. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5358. * @param left defines the start value
  5359. * @param right defines the end value
  5360. * @param amount defines the gradient factor
  5361. * @returns a new Color4 object
  5362. */
  5363. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5364. /**
  5365. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5366. * @param left defines the start value
  5367. * @param right defines the end value
  5368. * @param amount defines the gradient factor
  5369. * @param result defines the Color4 object where to store data
  5370. */
  5371. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5372. /**
  5373. * Creates a new Color4 from a Color3 and an alpha value
  5374. * @param color3 defines the source Color3 to read from
  5375. * @param alpha defines the alpha component (1.0 by default)
  5376. * @returns a new Color4 object
  5377. */
  5378. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5379. /**
  5380. * Creates a new Color4 from the starting index element of the given array
  5381. * @param array defines the source array to read from
  5382. * @param offset defines the offset in the source array
  5383. * @returns a new Color4 object
  5384. */
  5385. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5386. /**
  5387. * Creates a new Color3 from integer values (< 256)
  5388. * @param r defines the red component to read from (value between 0 and 255)
  5389. * @param g defines the green component to read from (value between 0 and 255)
  5390. * @param b defines the blue component to read from (value between 0 and 255)
  5391. * @param a defines the alpha component to read from (value between 0 and 255)
  5392. * @returns a new Color3 object
  5393. */
  5394. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5395. /**
  5396. * Check the content of a given array and convert it to an array containing RGBA data
  5397. * If the original array was already containing count * 4 values then it is returned directly
  5398. * @param colors defines the array to check
  5399. * @param count defines the number of RGBA data to expect
  5400. * @returns an array containing count * 4 values (RGBA)
  5401. */
  5402. static CheckColors4(colors: number[], count: number): number[];
  5403. }
  5404. /**
  5405. * @hidden
  5406. */
  5407. export class TmpColors {
  5408. static Color3: Color3[];
  5409. static Color4: Color4[];
  5410. }
  5411. }
  5412. declare module "babylonjs/Maths/sphericalPolynomial" {
  5413. import { Vector3 } from "babylonjs/Maths/math.vector";
  5414. import { Color3 } from "babylonjs/Maths/math.color";
  5415. /**
  5416. * Class representing spherical harmonics coefficients to the 3rd degree
  5417. */
  5418. export class SphericalHarmonics {
  5419. /**
  5420. * Defines whether or not the harmonics have been prescaled for rendering.
  5421. */
  5422. preScaled: boolean;
  5423. /**
  5424. * The l0,0 coefficients of the spherical harmonics
  5425. */
  5426. l00: Vector3;
  5427. /**
  5428. * The l1,-1 coefficients of the spherical harmonics
  5429. */
  5430. l1_1: Vector3;
  5431. /**
  5432. * The l1,0 coefficients of the spherical harmonics
  5433. */
  5434. l10: Vector3;
  5435. /**
  5436. * The l1,1 coefficients of the spherical harmonics
  5437. */
  5438. l11: Vector3;
  5439. /**
  5440. * The l2,-2 coefficients of the spherical harmonics
  5441. */
  5442. l2_2: Vector3;
  5443. /**
  5444. * The l2,-1 coefficients of the spherical harmonics
  5445. */
  5446. l2_1: Vector3;
  5447. /**
  5448. * The l2,0 coefficients of the spherical harmonics
  5449. */
  5450. l20: Vector3;
  5451. /**
  5452. * The l2,1 coefficients of the spherical harmonics
  5453. */
  5454. l21: Vector3;
  5455. /**
  5456. * The l2,2 coefficients of the spherical harmonics
  5457. */
  5458. l22: Vector3;
  5459. /**
  5460. * Adds a light to the spherical harmonics
  5461. * @param direction the direction of the light
  5462. * @param color the color of the light
  5463. * @param deltaSolidAngle the delta solid angle of the light
  5464. */
  5465. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5466. /**
  5467. * Scales the spherical harmonics by the given amount
  5468. * @param scale the amount to scale
  5469. */
  5470. scaleInPlace(scale: number): void;
  5471. /**
  5472. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5473. *
  5474. * ```
  5475. * E_lm = A_l * L_lm
  5476. * ```
  5477. *
  5478. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5479. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5480. * the scaling factors are given in equation 9.
  5481. */
  5482. convertIncidentRadianceToIrradiance(): void;
  5483. /**
  5484. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5485. *
  5486. * ```
  5487. * L = (1/pi) * E * rho
  5488. * ```
  5489. *
  5490. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5491. */
  5492. convertIrradianceToLambertianRadiance(): void;
  5493. /**
  5494. * Integrates the reconstruction coefficients directly in to the SH preventing further
  5495. * required operations at run time.
  5496. *
  5497. * This is simply done by scaling back the SH with Ylm constants parameter.
  5498. * The trigonometric part being applied by the shader at run time.
  5499. */
  5500. preScaleForRendering(): void;
  5501. /**
  5502. * Constructs a spherical harmonics from an array.
  5503. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5504. * @returns the spherical harmonics
  5505. */
  5506. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5507. /**
  5508. * Gets the spherical harmonics from polynomial
  5509. * @param polynomial the spherical polynomial
  5510. * @returns the spherical harmonics
  5511. */
  5512. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5513. }
  5514. /**
  5515. * Class representing spherical polynomial coefficients to the 3rd degree
  5516. */
  5517. export class SphericalPolynomial {
  5518. private _harmonics;
  5519. /**
  5520. * The spherical harmonics used to create the polynomials.
  5521. */
  5522. readonly preScaledHarmonics: SphericalHarmonics;
  5523. /**
  5524. * The x coefficients of the spherical polynomial
  5525. */
  5526. x: Vector3;
  5527. /**
  5528. * The y coefficients of the spherical polynomial
  5529. */
  5530. y: Vector3;
  5531. /**
  5532. * The z coefficients of the spherical polynomial
  5533. */
  5534. z: Vector3;
  5535. /**
  5536. * The xx coefficients of the spherical polynomial
  5537. */
  5538. xx: Vector3;
  5539. /**
  5540. * The yy coefficients of the spherical polynomial
  5541. */
  5542. yy: Vector3;
  5543. /**
  5544. * The zz coefficients of the spherical polynomial
  5545. */
  5546. zz: Vector3;
  5547. /**
  5548. * The xy coefficients of the spherical polynomial
  5549. */
  5550. xy: Vector3;
  5551. /**
  5552. * The yz coefficients of the spherical polynomial
  5553. */
  5554. yz: Vector3;
  5555. /**
  5556. * The zx coefficients of the spherical polynomial
  5557. */
  5558. zx: Vector3;
  5559. /**
  5560. * Adds an ambient color to the spherical polynomial
  5561. * @param color the color to add
  5562. */
  5563. addAmbient(color: Color3): void;
  5564. /**
  5565. * Scales the spherical polynomial by the given amount
  5566. * @param scale the amount to scale
  5567. */
  5568. scaleInPlace(scale: number): void;
  5569. /**
  5570. * Gets the spherical polynomial from harmonics
  5571. * @param harmonics the spherical harmonics
  5572. * @returns the spherical polynomial
  5573. */
  5574. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5575. /**
  5576. * Constructs a spherical polynomial from an array.
  5577. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5578. * @returns the spherical polynomial
  5579. */
  5580. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5581. }
  5582. }
  5583. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  5584. /**
  5585. * Define options used to create a render target texture
  5586. */
  5587. export class RenderTargetCreationOptions {
  5588. /**
  5589. * Specifies is mipmaps must be generated
  5590. */
  5591. generateMipMaps?: boolean;
  5592. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5593. generateDepthBuffer?: boolean;
  5594. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5595. generateStencilBuffer?: boolean;
  5596. /** Defines texture type (int by default) */
  5597. type?: number;
  5598. /** Defines sampling mode (trilinear by default) */
  5599. samplingMode?: number;
  5600. /** Defines format (RGBA by default) */
  5601. format?: number;
  5602. }
  5603. }
  5604. declare module "babylonjs/States/alphaCullingState" {
  5605. /**
  5606. * @hidden
  5607. **/
  5608. export class _AlphaState {
  5609. private _isAlphaBlendDirty;
  5610. private _isBlendFunctionParametersDirty;
  5611. private _isBlendEquationParametersDirty;
  5612. private _isBlendConstantsDirty;
  5613. private _alphaBlend;
  5614. private _blendFunctionParameters;
  5615. private _blendEquationParameters;
  5616. private _blendConstants;
  5617. /**
  5618. * Initializes the state.
  5619. */
  5620. constructor();
  5621. readonly isDirty: boolean;
  5622. alphaBlend: boolean;
  5623. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  5624. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  5625. setAlphaEquationParameters(rgb: number, alpha: number): void;
  5626. reset(): void;
  5627. apply(gl: WebGLRenderingContext): void;
  5628. }
  5629. }
  5630. declare module "babylonjs/States/depthCullingState" {
  5631. import { Nullable } from "babylonjs/types";
  5632. /**
  5633. * @hidden
  5634. **/
  5635. export class _DepthCullingState {
  5636. private _isDepthTestDirty;
  5637. private _isDepthMaskDirty;
  5638. private _isDepthFuncDirty;
  5639. private _isCullFaceDirty;
  5640. private _isCullDirty;
  5641. private _isZOffsetDirty;
  5642. private _isFrontFaceDirty;
  5643. private _depthTest;
  5644. private _depthMask;
  5645. private _depthFunc;
  5646. private _cull;
  5647. private _cullFace;
  5648. private _zOffset;
  5649. private _frontFace;
  5650. /**
  5651. * Initializes the state.
  5652. */
  5653. constructor();
  5654. readonly isDirty: boolean;
  5655. zOffset: number;
  5656. cullFace: Nullable<number>;
  5657. cull: Nullable<boolean>;
  5658. depthFunc: Nullable<number>;
  5659. depthMask: boolean;
  5660. depthTest: boolean;
  5661. frontFace: Nullable<number>;
  5662. reset(): void;
  5663. apply(gl: WebGLRenderingContext): void;
  5664. }
  5665. }
  5666. declare module "babylonjs/States/stencilState" {
  5667. /**
  5668. * @hidden
  5669. **/
  5670. export class _StencilState {
  5671. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  5672. static readonly ALWAYS: number;
  5673. /** Passed to stencilOperation to specify that stencil value must be kept */
  5674. static readonly KEEP: number;
  5675. /** Passed to stencilOperation to specify that stencil value must be replaced */
  5676. static readonly REPLACE: number;
  5677. private _isStencilTestDirty;
  5678. private _isStencilMaskDirty;
  5679. private _isStencilFuncDirty;
  5680. private _isStencilOpDirty;
  5681. private _stencilTest;
  5682. private _stencilMask;
  5683. private _stencilFunc;
  5684. private _stencilFuncRef;
  5685. private _stencilFuncMask;
  5686. private _stencilOpStencilFail;
  5687. private _stencilOpDepthFail;
  5688. private _stencilOpStencilDepthPass;
  5689. readonly isDirty: boolean;
  5690. stencilFunc: number;
  5691. stencilFuncRef: number;
  5692. stencilFuncMask: number;
  5693. stencilOpStencilFail: number;
  5694. stencilOpDepthFail: number;
  5695. stencilOpStencilDepthPass: number;
  5696. stencilMask: number;
  5697. stencilTest: boolean;
  5698. constructor();
  5699. reset(): void;
  5700. apply(gl: WebGLRenderingContext): void;
  5701. }
  5702. }
  5703. declare module "babylonjs/States/index" {
  5704. export * from "babylonjs/States/alphaCullingState";
  5705. export * from "babylonjs/States/depthCullingState";
  5706. export * from "babylonjs/States/stencilState";
  5707. }
  5708. declare module "babylonjs/Instrumentation/timeToken" {
  5709. import { Nullable } from "babylonjs/types";
  5710. /**
  5711. * @hidden
  5712. **/
  5713. export class _TimeToken {
  5714. _startTimeQuery: Nullable<WebGLQuery>;
  5715. _endTimeQuery: Nullable<WebGLQuery>;
  5716. _timeElapsedQuery: Nullable<WebGLQuery>;
  5717. _timeElapsedQueryEnded: boolean;
  5718. }
  5719. }
  5720. declare module "babylonjs/Misc/andOrNotEvaluator" {
  5721. /**
  5722. * Class used to evalaute queries containing `and` and `or` operators
  5723. */
  5724. export class AndOrNotEvaluator {
  5725. /**
  5726. * Evaluate a query
  5727. * @param query defines the query to evaluate
  5728. * @param evaluateCallback defines the callback used to filter result
  5729. * @returns true if the query matches
  5730. */
  5731. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5732. private static _HandleParenthesisContent;
  5733. private static _SimplifyNegation;
  5734. }
  5735. }
  5736. declare module "babylonjs/Misc/tags" {
  5737. /**
  5738. * Class used to store custom tags
  5739. */
  5740. export class Tags {
  5741. /**
  5742. * Adds support for tags on the given object
  5743. * @param obj defines the object to use
  5744. */
  5745. static EnableFor(obj: any): void;
  5746. /**
  5747. * Removes tags support
  5748. * @param obj defines the object to use
  5749. */
  5750. static DisableFor(obj: any): void;
  5751. /**
  5752. * Gets a boolean indicating if the given object has tags
  5753. * @param obj defines the object to use
  5754. * @returns a boolean
  5755. */
  5756. static HasTags(obj: any): boolean;
  5757. /**
  5758. * Gets the tags available on a given object
  5759. * @param obj defines the object to use
  5760. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5761. * @returns the tags
  5762. */
  5763. static GetTags(obj: any, asString?: boolean): any;
  5764. /**
  5765. * Adds tags to an object
  5766. * @param obj defines the object to use
  5767. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5768. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5769. */
  5770. static AddTagsTo(obj: any, tagsString: string): void;
  5771. /**
  5772. * @hidden
  5773. */
  5774. static _AddTagTo(obj: any, tag: string): void;
  5775. /**
  5776. * Removes specific tags from a specific object
  5777. * @param obj defines the object to use
  5778. * @param tagsString defines the tags to remove
  5779. */
  5780. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5781. /**
  5782. * @hidden
  5783. */
  5784. static _RemoveTagFrom(obj: any, tag: string): void;
  5785. /**
  5786. * Defines if tags hosted on an object match a given query
  5787. * @param obj defines the object to use
  5788. * @param tagsQuery defines the tag query
  5789. * @returns a boolean
  5790. */
  5791. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5792. }
  5793. }
  5794. declare module "babylonjs/Maths/math.path" {
  5795. import { DeepImmutable, Nullable } from "babylonjs/types";
  5796. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  5797. /**
  5798. * Defines potential orientation for back face culling
  5799. */
  5800. export enum Orientation {
  5801. /**
  5802. * Clockwise
  5803. */
  5804. CW = 0,
  5805. /** Counter clockwise */
  5806. CCW = 1
  5807. }
  5808. /** Class used to represent a Bezier curve */
  5809. export class BezierCurve {
  5810. /**
  5811. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5812. * @param t defines the time
  5813. * @param x1 defines the left coordinate on X axis
  5814. * @param y1 defines the left coordinate on Y axis
  5815. * @param x2 defines the right coordinate on X axis
  5816. * @param y2 defines the right coordinate on Y axis
  5817. * @returns the interpolated value
  5818. */
  5819. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5820. }
  5821. /**
  5822. * Defines angle representation
  5823. */
  5824. export class Angle {
  5825. private _radians;
  5826. /**
  5827. * Creates an Angle object of "radians" radians (float).
  5828. * @param radians the angle in radians
  5829. */
  5830. constructor(radians: number);
  5831. /**
  5832. * Get value in degrees
  5833. * @returns the Angle value in degrees (float)
  5834. */
  5835. degrees(): number;
  5836. /**
  5837. * Get value in radians
  5838. * @returns the Angle value in radians (float)
  5839. */
  5840. radians(): number;
  5841. /**
  5842. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  5843. * @param a defines first vector
  5844. * @param b defines second vector
  5845. * @returns a new Angle
  5846. */
  5847. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5848. /**
  5849. * Gets a new Angle object from the given float in radians
  5850. * @param radians defines the angle value in radians
  5851. * @returns a new Angle
  5852. */
  5853. static FromRadians(radians: number): Angle;
  5854. /**
  5855. * Gets a new Angle object from the given float in degrees
  5856. * @param degrees defines the angle value in degrees
  5857. * @returns a new Angle
  5858. */
  5859. static FromDegrees(degrees: number): Angle;
  5860. }
  5861. /**
  5862. * This represents an arc in a 2d space.
  5863. */
  5864. export class Arc2 {
  5865. /** Defines the start point of the arc */
  5866. startPoint: Vector2;
  5867. /** Defines the mid point of the arc */
  5868. midPoint: Vector2;
  5869. /** Defines the end point of the arc */
  5870. endPoint: Vector2;
  5871. /**
  5872. * Defines the center point of the arc.
  5873. */
  5874. centerPoint: Vector2;
  5875. /**
  5876. * Defines the radius of the arc.
  5877. */
  5878. radius: number;
  5879. /**
  5880. * Defines the angle of the arc (from mid point to end point).
  5881. */
  5882. angle: Angle;
  5883. /**
  5884. * Defines the start angle of the arc (from start point to middle point).
  5885. */
  5886. startAngle: Angle;
  5887. /**
  5888. * Defines the orientation of the arc (clock wise/counter clock wise).
  5889. */
  5890. orientation: Orientation;
  5891. /**
  5892. * Creates an Arc object from the three given points : start, middle and end.
  5893. * @param startPoint Defines the start point of the arc
  5894. * @param midPoint Defines the midlle point of the arc
  5895. * @param endPoint Defines the end point of the arc
  5896. */
  5897. constructor(
  5898. /** Defines the start point of the arc */
  5899. startPoint: Vector2,
  5900. /** Defines the mid point of the arc */
  5901. midPoint: Vector2,
  5902. /** Defines the end point of the arc */
  5903. endPoint: Vector2);
  5904. }
  5905. /**
  5906. * Represents a 2D path made up of multiple 2D points
  5907. */
  5908. export class Path2 {
  5909. private _points;
  5910. private _length;
  5911. /**
  5912. * If the path start and end point are the same
  5913. */
  5914. closed: boolean;
  5915. /**
  5916. * Creates a Path2 object from the starting 2D coordinates x and y.
  5917. * @param x the starting points x value
  5918. * @param y the starting points y value
  5919. */
  5920. constructor(x: number, y: number);
  5921. /**
  5922. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5923. * @param x the added points x value
  5924. * @param y the added points y value
  5925. * @returns the updated Path2.
  5926. */
  5927. addLineTo(x: number, y: number): Path2;
  5928. /**
  5929. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  5930. * @param midX middle point x value
  5931. * @param midY middle point y value
  5932. * @param endX end point x value
  5933. * @param endY end point y value
  5934. * @param numberOfSegments (default: 36)
  5935. * @returns the updated Path2.
  5936. */
  5937. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5938. /**
  5939. * Closes the Path2.
  5940. * @returns the Path2.
  5941. */
  5942. close(): Path2;
  5943. /**
  5944. * Gets the sum of the distance between each sequential point in the path
  5945. * @returns the Path2 total length (float).
  5946. */
  5947. length(): number;
  5948. /**
  5949. * Gets the points which construct the path
  5950. * @returns the Path2 internal array of points.
  5951. */
  5952. getPoints(): Vector2[];
  5953. /**
  5954. * Retreives the point at the distance aways from the starting point
  5955. * @param normalizedLengthPosition the length along the path to retreive the point from
  5956. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5957. */
  5958. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5959. /**
  5960. * Creates a new path starting from an x and y position
  5961. * @param x starting x value
  5962. * @param y starting y value
  5963. * @returns a new Path2 starting at the coordinates (x, y).
  5964. */
  5965. static StartingAt(x: number, y: number): Path2;
  5966. }
  5967. /**
  5968. * Represents a 3D path made up of multiple 3D points
  5969. */
  5970. export class Path3D {
  5971. /**
  5972. * an array of Vector3, the curve axis of the Path3D
  5973. */
  5974. path: Vector3[];
  5975. private _curve;
  5976. private _distances;
  5977. private _tangents;
  5978. private _normals;
  5979. private _binormals;
  5980. private _raw;
  5981. /**
  5982. * new Path3D(path, normal, raw)
  5983. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5984. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5985. * @param path an array of Vector3, the curve axis of the Path3D
  5986. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5987. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5988. */
  5989. constructor(
  5990. /**
  5991. * an array of Vector3, the curve axis of the Path3D
  5992. */
  5993. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  5994. /**
  5995. * Returns the Path3D array of successive Vector3 designing its curve.
  5996. * @returns the Path3D array of successive Vector3 designing its curve.
  5997. */
  5998. getCurve(): Vector3[];
  5999. /**
  6000. * Returns an array populated with tangent vectors on each Path3D curve point.
  6001. * @returns an array populated with tangent vectors on each Path3D curve point.
  6002. */
  6003. getTangents(): Vector3[];
  6004. /**
  6005. * Returns an array populated with normal vectors on each Path3D curve point.
  6006. * @returns an array populated with normal vectors on each Path3D curve point.
  6007. */
  6008. getNormals(): Vector3[];
  6009. /**
  6010. * Returns an array populated with binormal vectors on each Path3D curve point.
  6011. * @returns an array populated with binormal vectors on each Path3D curve point.
  6012. */
  6013. getBinormals(): Vector3[];
  6014. /**
  6015. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  6016. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  6017. */
  6018. getDistances(): number[];
  6019. /**
  6020. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  6021. * @param path path which all values are copied into the curves points
  6022. * @param firstNormal which should be projected onto the curve
  6023. * @returns the same object updated.
  6024. */
  6025. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  6026. private _compute;
  6027. private _getFirstNonNullVector;
  6028. private _getLastNonNullVector;
  6029. private _normalVector;
  6030. }
  6031. /**
  6032. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  6033. * A Curve3 is designed from a series of successive Vector3.
  6034. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  6035. */
  6036. export class Curve3 {
  6037. private _points;
  6038. private _length;
  6039. /**
  6040. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  6041. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  6042. * @param v1 (Vector3) the control point
  6043. * @param v2 (Vector3) the end point of the Quadratic Bezier
  6044. * @param nbPoints (integer) the wanted number of points in the curve
  6045. * @returns the created Curve3
  6046. */
  6047. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6048. /**
  6049. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  6050. * @param v0 (Vector3) the origin point of the Cubic Bezier
  6051. * @param v1 (Vector3) the first control point
  6052. * @param v2 (Vector3) the second control point
  6053. * @param v3 (Vector3) the end point of the Cubic Bezier
  6054. * @param nbPoints (integer) the wanted number of points in the curve
  6055. * @returns the created Curve3
  6056. */
  6057. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6058. /**
  6059. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  6060. * @param p1 (Vector3) the origin point of the Hermite Spline
  6061. * @param t1 (Vector3) the tangent vector at the origin point
  6062. * @param p2 (Vector3) the end point of the Hermite Spline
  6063. * @param t2 (Vector3) the tangent vector at the end point
  6064. * @param nbPoints (integer) the wanted number of points in the curve
  6065. * @returns the created Curve3
  6066. */
  6067. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6068. /**
  6069. * Returns a Curve3 object along a CatmullRom Spline curve :
  6070. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  6071. * @param nbPoints (integer) the wanted number of points between each curve control points
  6072. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  6073. * @returns the created Curve3
  6074. */
  6075. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  6076. /**
  6077. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  6078. * A Curve3 is designed from a series of successive Vector3.
  6079. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  6080. * @param points points which make up the curve
  6081. */
  6082. constructor(points: Vector3[]);
  6083. /**
  6084. * @returns the Curve3 stored array of successive Vector3
  6085. */
  6086. getPoints(): Vector3[];
  6087. /**
  6088. * @returns the computed length (float) of the curve.
  6089. */
  6090. length(): number;
  6091. /**
  6092. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  6093. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  6094. * curveA and curveB keep unchanged.
  6095. * @param curve the curve to continue from this curve
  6096. * @returns the newly constructed curve
  6097. */
  6098. continue(curve: DeepImmutable<Curve3>): Curve3;
  6099. private _computeLength;
  6100. }
  6101. }
  6102. declare module "babylonjs/Animations/easing" {
  6103. /**
  6104. * This represents the main contract an easing function should follow.
  6105. * Easing functions are used throughout the animation system.
  6106. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6107. */
  6108. export interface IEasingFunction {
  6109. /**
  6110. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6111. * of the easing function.
  6112. * The link below provides some of the most common examples of easing functions.
  6113. * @see https://easings.net/
  6114. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6115. * @returns the corresponding value on the curve defined by the easing function
  6116. */
  6117. ease(gradient: number): number;
  6118. }
  6119. /**
  6120. * Base class used for every default easing function.
  6121. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6122. */
  6123. export class EasingFunction implements IEasingFunction {
  6124. /**
  6125. * Interpolation follows the mathematical formula associated with the easing function.
  6126. */
  6127. static readonly EASINGMODE_EASEIN: number;
  6128. /**
  6129. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6130. */
  6131. static readonly EASINGMODE_EASEOUT: number;
  6132. /**
  6133. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6134. */
  6135. static readonly EASINGMODE_EASEINOUT: number;
  6136. private _easingMode;
  6137. /**
  6138. * Sets the easing mode of the current function.
  6139. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6140. */
  6141. setEasingMode(easingMode: number): void;
  6142. /**
  6143. * Gets the current easing mode.
  6144. * @returns the easing mode
  6145. */
  6146. getEasingMode(): number;
  6147. /**
  6148. * @hidden
  6149. */
  6150. easeInCore(gradient: number): number;
  6151. /**
  6152. * Given an input gradient between 0 and 1, this returns the corresponding value
  6153. * of the easing function.
  6154. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6155. * @returns the corresponding value on the curve defined by the easing function
  6156. */
  6157. ease(gradient: number): number;
  6158. }
  6159. /**
  6160. * Easing function with a circle shape (see link below).
  6161. * @see https://easings.net/#easeInCirc
  6162. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6163. */
  6164. export class CircleEase extends EasingFunction implements IEasingFunction {
  6165. /** @hidden */
  6166. easeInCore(gradient: number): number;
  6167. }
  6168. /**
  6169. * Easing function with a ease back shape (see link below).
  6170. * @see https://easings.net/#easeInBack
  6171. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6172. */
  6173. export class BackEase extends EasingFunction implements IEasingFunction {
  6174. /** Defines the amplitude of the function */
  6175. amplitude: number;
  6176. /**
  6177. * Instantiates a back ease easing
  6178. * @see https://easings.net/#easeInBack
  6179. * @param amplitude Defines the amplitude of the function
  6180. */
  6181. constructor(
  6182. /** Defines the amplitude of the function */
  6183. amplitude?: number);
  6184. /** @hidden */
  6185. easeInCore(gradient: number): number;
  6186. }
  6187. /**
  6188. * Easing function with a bouncing shape (see link below).
  6189. * @see https://easings.net/#easeInBounce
  6190. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6191. */
  6192. export class BounceEase extends EasingFunction implements IEasingFunction {
  6193. /** Defines the number of bounces */
  6194. bounces: number;
  6195. /** Defines the amplitude of the bounce */
  6196. bounciness: number;
  6197. /**
  6198. * Instantiates a bounce easing
  6199. * @see https://easings.net/#easeInBounce
  6200. * @param bounces Defines the number of bounces
  6201. * @param bounciness Defines the amplitude of the bounce
  6202. */
  6203. constructor(
  6204. /** Defines the number of bounces */
  6205. bounces?: number,
  6206. /** Defines the amplitude of the bounce */
  6207. bounciness?: number);
  6208. /** @hidden */
  6209. easeInCore(gradient: number): number;
  6210. }
  6211. /**
  6212. * Easing function with a power of 3 shape (see link below).
  6213. * @see https://easings.net/#easeInCubic
  6214. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6215. */
  6216. export class CubicEase extends EasingFunction implements IEasingFunction {
  6217. /** @hidden */
  6218. easeInCore(gradient: number): number;
  6219. }
  6220. /**
  6221. * Easing function with an elastic shape (see link below).
  6222. * @see https://easings.net/#easeInElastic
  6223. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6224. */
  6225. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6226. /** Defines the number of oscillations*/
  6227. oscillations: number;
  6228. /** Defines the amplitude of the oscillations*/
  6229. springiness: number;
  6230. /**
  6231. * Instantiates an elastic easing function
  6232. * @see https://easings.net/#easeInElastic
  6233. * @param oscillations Defines the number of oscillations
  6234. * @param springiness Defines the amplitude of the oscillations
  6235. */
  6236. constructor(
  6237. /** Defines the number of oscillations*/
  6238. oscillations?: number,
  6239. /** Defines the amplitude of the oscillations*/
  6240. springiness?: number);
  6241. /** @hidden */
  6242. easeInCore(gradient: number): number;
  6243. }
  6244. /**
  6245. * Easing function with an exponential shape (see link below).
  6246. * @see https://easings.net/#easeInExpo
  6247. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6248. */
  6249. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6250. /** Defines the exponent of the function */
  6251. exponent: number;
  6252. /**
  6253. * Instantiates an exponential easing function
  6254. * @see https://easings.net/#easeInExpo
  6255. * @param exponent Defines the exponent of the function
  6256. */
  6257. constructor(
  6258. /** Defines the exponent of the function */
  6259. exponent?: number);
  6260. /** @hidden */
  6261. easeInCore(gradient: number): number;
  6262. }
  6263. /**
  6264. * Easing function with a power shape (see link below).
  6265. * @see https://easings.net/#easeInQuad
  6266. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6267. */
  6268. export class PowerEase extends EasingFunction implements IEasingFunction {
  6269. /** Defines the power of the function */
  6270. power: number;
  6271. /**
  6272. * Instantiates an power base easing function
  6273. * @see https://easings.net/#easeInQuad
  6274. * @param power Defines the power of the function
  6275. */
  6276. constructor(
  6277. /** Defines the power of the function */
  6278. power?: number);
  6279. /** @hidden */
  6280. easeInCore(gradient: number): number;
  6281. }
  6282. /**
  6283. * Easing function with a power of 2 shape (see link below).
  6284. * @see https://easings.net/#easeInQuad
  6285. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6286. */
  6287. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6288. /** @hidden */
  6289. easeInCore(gradient: number): number;
  6290. }
  6291. /**
  6292. * Easing function with a power of 4 shape (see link below).
  6293. * @see https://easings.net/#easeInQuart
  6294. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6295. */
  6296. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6297. /** @hidden */
  6298. easeInCore(gradient: number): number;
  6299. }
  6300. /**
  6301. * Easing function with a power of 5 shape (see link below).
  6302. * @see https://easings.net/#easeInQuint
  6303. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6304. */
  6305. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6306. /** @hidden */
  6307. easeInCore(gradient: number): number;
  6308. }
  6309. /**
  6310. * Easing function with a sin shape (see link below).
  6311. * @see https://easings.net/#easeInSine
  6312. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6313. */
  6314. export class SineEase extends EasingFunction implements IEasingFunction {
  6315. /** @hidden */
  6316. easeInCore(gradient: number): number;
  6317. }
  6318. /**
  6319. * Easing function with a bezier shape (see link below).
  6320. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6321. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6322. */
  6323. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6324. /** Defines the x component of the start tangent in the bezier curve */
  6325. x1: number;
  6326. /** Defines the y component of the start tangent in the bezier curve */
  6327. y1: number;
  6328. /** Defines the x component of the end tangent in the bezier curve */
  6329. x2: number;
  6330. /** Defines the y component of the end tangent in the bezier curve */
  6331. y2: number;
  6332. /**
  6333. * Instantiates a bezier function
  6334. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6335. * @param x1 Defines the x component of the start tangent in the bezier curve
  6336. * @param y1 Defines the y component of the start tangent in the bezier curve
  6337. * @param x2 Defines the x component of the end tangent in the bezier curve
  6338. * @param y2 Defines the y component of the end tangent in the bezier curve
  6339. */
  6340. constructor(
  6341. /** Defines the x component of the start tangent in the bezier curve */
  6342. x1?: number,
  6343. /** Defines the y component of the start tangent in the bezier curve */
  6344. y1?: number,
  6345. /** Defines the x component of the end tangent in the bezier curve */
  6346. x2?: number,
  6347. /** Defines the y component of the end tangent in the bezier curve */
  6348. y2?: number);
  6349. /** @hidden */
  6350. easeInCore(gradient: number): number;
  6351. }
  6352. }
  6353. declare module "babylonjs/Animations/animationKey" {
  6354. /**
  6355. * Defines an interface which represents an animation key frame
  6356. */
  6357. export interface IAnimationKey {
  6358. /**
  6359. * Frame of the key frame
  6360. */
  6361. frame: number;
  6362. /**
  6363. * Value at the specifies key frame
  6364. */
  6365. value: any;
  6366. /**
  6367. * The input tangent for the cubic hermite spline
  6368. */
  6369. inTangent?: any;
  6370. /**
  6371. * The output tangent for the cubic hermite spline
  6372. */
  6373. outTangent?: any;
  6374. /**
  6375. * The animation interpolation type
  6376. */
  6377. interpolation?: AnimationKeyInterpolation;
  6378. }
  6379. /**
  6380. * Enum for the animation key frame interpolation type
  6381. */
  6382. export enum AnimationKeyInterpolation {
  6383. /**
  6384. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6385. */
  6386. STEP = 1
  6387. }
  6388. }
  6389. declare module "babylonjs/Animations/animationRange" {
  6390. /**
  6391. * Represents the range of an animation
  6392. */
  6393. export class AnimationRange {
  6394. /**The name of the animation range**/
  6395. name: string;
  6396. /**The starting frame of the animation */
  6397. from: number;
  6398. /**The ending frame of the animation*/
  6399. to: number;
  6400. /**
  6401. * Initializes the range of an animation
  6402. * @param name The name of the animation range
  6403. * @param from The starting frame of the animation
  6404. * @param to The ending frame of the animation
  6405. */
  6406. constructor(
  6407. /**The name of the animation range**/
  6408. name: string,
  6409. /**The starting frame of the animation */
  6410. from: number,
  6411. /**The ending frame of the animation*/
  6412. to: number);
  6413. /**
  6414. * Makes a copy of the animation range
  6415. * @returns A copy of the animation range
  6416. */
  6417. clone(): AnimationRange;
  6418. }
  6419. }
  6420. declare module "babylonjs/Animations/animationEvent" {
  6421. /**
  6422. * Composed of a frame, and an action function
  6423. */
  6424. export class AnimationEvent {
  6425. /** The frame for which the event is triggered **/
  6426. frame: number;
  6427. /** The event to perform when triggered **/
  6428. action: (currentFrame: number) => void;
  6429. /** Specifies if the event should be triggered only once**/
  6430. onlyOnce?: boolean | undefined;
  6431. /**
  6432. * Specifies if the animation event is done
  6433. */
  6434. isDone: boolean;
  6435. /**
  6436. * Initializes the animation event
  6437. * @param frame The frame for which the event is triggered
  6438. * @param action The event to perform when triggered
  6439. * @param onlyOnce Specifies if the event should be triggered only once
  6440. */
  6441. constructor(
  6442. /** The frame for which the event is triggered **/
  6443. frame: number,
  6444. /** The event to perform when triggered **/
  6445. action: (currentFrame: number) => void,
  6446. /** Specifies if the event should be triggered only once**/
  6447. onlyOnce?: boolean | undefined);
  6448. /** @hidden */
  6449. _clone(): AnimationEvent;
  6450. }
  6451. }
  6452. declare module "babylonjs/Behaviors/behavior" {
  6453. import { Nullable } from "babylonjs/types";
  6454. /**
  6455. * Interface used to define a behavior
  6456. */
  6457. export interface Behavior<T> {
  6458. /** gets or sets behavior's name */
  6459. name: string;
  6460. /**
  6461. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6462. */
  6463. init(): void;
  6464. /**
  6465. * Called when the behavior is attached to a target
  6466. * @param target defines the target where the behavior is attached to
  6467. */
  6468. attach(target: T): void;
  6469. /**
  6470. * Called when the behavior is detached from its target
  6471. */
  6472. detach(): void;
  6473. }
  6474. /**
  6475. * Interface implemented by classes supporting behaviors
  6476. */
  6477. export interface IBehaviorAware<T> {
  6478. /**
  6479. * Attach a behavior
  6480. * @param behavior defines the behavior to attach
  6481. * @returns the current host
  6482. */
  6483. addBehavior(behavior: Behavior<T>): T;
  6484. /**
  6485. * Remove a behavior from the current object
  6486. * @param behavior defines the behavior to detach
  6487. * @returns the current host
  6488. */
  6489. removeBehavior(behavior: Behavior<T>): T;
  6490. /**
  6491. * Gets a behavior using its name to search
  6492. * @param name defines the name to search
  6493. * @returns the behavior or null if not found
  6494. */
  6495. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6496. }
  6497. }
  6498. declare module "babylonjs/Misc/smartArray" {
  6499. /**
  6500. * Defines an array and its length.
  6501. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6502. */
  6503. export interface ISmartArrayLike<T> {
  6504. /**
  6505. * The data of the array.
  6506. */
  6507. data: Array<T>;
  6508. /**
  6509. * The active length of the array.
  6510. */
  6511. length: number;
  6512. }
  6513. /**
  6514. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6515. */
  6516. export class SmartArray<T> implements ISmartArrayLike<T> {
  6517. /**
  6518. * The full set of data from the array.
  6519. */
  6520. data: Array<T>;
  6521. /**
  6522. * The active length of the array.
  6523. */
  6524. length: number;
  6525. protected _id: number;
  6526. /**
  6527. * Instantiates a Smart Array.
  6528. * @param capacity defines the default capacity of the array.
  6529. */
  6530. constructor(capacity: number);
  6531. /**
  6532. * Pushes a value at the end of the active data.
  6533. * @param value defines the object to push in the array.
  6534. */
  6535. push(value: T): void;
  6536. /**
  6537. * Iterates over the active data and apply the lambda to them.
  6538. * @param func defines the action to apply on each value.
  6539. */
  6540. forEach(func: (content: T) => void): void;
  6541. /**
  6542. * Sorts the full sets of data.
  6543. * @param compareFn defines the comparison function to apply.
  6544. */
  6545. sort(compareFn: (a: T, b: T) => number): void;
  6546. /**
  6547. * Resets the active data to an empty array.
  6548. */
  6549. reset(): void;
  6550. /**
  6551. * Releases all the data from the array as well as the array.
  6552. */
  6553. dispose(): void;
  6554. /**
  6555. * Concats the active data with a given array.
  6556. * @param array defines the data to concatenate with.
  6557. */
  6558. concat(array: any): void;
  6559. /**
  6560. * Returns the position of a value in the active data.
  6561. * @param value defines the value to find the index for
  6562. * @returns the index if found in the active data otherwise -1
  6563. */
  6564. indexOf(value: T): number;
  6565. /**
  6566. * Returns whether an element is part of the active data.
  6567. * @param value defines the value to look for
  6568. * @returns true if found in the active data otherwise false
  6569. */
  6570. contains(value: T): boolean;
  6571. private static _GlobalId;
  6572. }
  6573. /**
  6574. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6575. * The data in this array can only be present once
  6576. */
  6577. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6578. private _duplicateId;
  6579. /**
  6580. * Pushes a value at the end of the active data.
  6581. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6582. * @param value defines the object to push in the array.
  6583. */
  6584. push(value: T): void;
  6585. /**
  6586. * Pushes a value at the end of the active data.
  6587. * If the data is already present, it won t be added again
  6588. * @param value defines the object to push in the array.
  6589. * @returns true if added false if it was already present
  6590. */
  6591. pushNoDuplicate(value: T): boolean;
  6592. /**
  6593. * Resets the active data to an empty array.
  6594. */
  6595. reset(): void;
  6596. /**
  6597. * Concats the active data with a given array.
  6598. * This ensures no dupplicate will be present in the result.
  6599. * @param array defines the data to concatenate with.
  6600. */
  6601. concatWithNoDuplicate(array: any): void;
  6602. }
  6603. }
  6604. declare module "babylonjs/Cameras/cameraInputsManager" {
  6605. import { Nullable } from "babylonjs/types";
  6606. import { Camera } from "babylonjs/Cameras/camera";
  6607. /**
  6608. * @ignore
  6609. * This is a list of all the different input types that are available in the application.
  6610. * Fo instance: ArcRotateCameraGamepadInput...
  6611. */
  6612. export var CameraInputTypes: {};
  6613. /**
  6614. * This is the contract to implement in order to create a new input class.
  6615. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6616. */
  6617. export interface ICameraInput<TCamera extends Camera> {
  6618. /**
  6619. * Defines the camera the input is attached to.
  6620. */
  6621. camera: Nullable<TCamera>;
  6622. /**
  6623. * Gets the class name of the current intput.
  6624. * @returns the class name
  6625. */
  6626. getClassName(): string;
  6627. /**
  6628. * Get the friendly name associated with the input class.
  6629. * @returns the input friendly name
  6630. */
  6631. getSimpleName(): string;
  6632. /**
  6633. * Attach the input controls to a specific dom element to get the input from.
  6634. * @param element Defines the element the controls should be listened from
  6635. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6636. */
  6637. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6638. /**
  6639. * Detach the current controls from the specified dom element.
  6640. * @param element Defines the element to stop listening the inputs from
  6641. */
  6642. detachControl(element: Nullable<HTMLElement>): void;
  6643. /**
  6644. * Update the current camera state depending on the inputs that have been used this frame.
  6645. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6646. */
  6647. checkInputs?: () => void;
  6648. }
  6649. /**
  6650. * Represents a map of input types to input instance or input index to input instance.
  6651. */
  6652. export interface CameraInputsMap<TCamera extends Camera> {
  6653. /**
  6654. * Accessor to the input by input type.
  6655. */
  6656. [name: string]: ICameraInput<TCamera>;
  6657. /**
  6658. * Accessor to the input by input index.
  6659. */
  6660. [idx: number]: ICameraInput<TCamera>;
  6661. }
  6662. /**
  6663. * This represents the input manager used within a camera.
  6664. * It helps dealing with all the different kind of input attached to a camera.
  6665. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6666. */
  6667. export class CameraInputsManager<TCamera extends Camera> {
  6668. /**
  6669. * Defines the list of inputs attahed to the camera.
  6670. */
  6671. attached: CameraInputsMap<TCamera>;
  6672. /**
  6673. * Defines the dom element the camera is collecting inputs from.
  6674. * This is null if the controls have not been attached.
  6675. */
  6676. attachedElement: Nullable<HTMLElement>;
  6677. /**
  6678. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6679. */
  6680. noPreventDefault: boolean;
  6681. /**
  6682. * Defined the camera the input manager belongs to.
  6683. */
  6684. camera: TCamera;
  6685. /**
  6686. * Update the current camera state depending on the inputs that have been used this frame.
  6687. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6688. */
  6689. checkInputs: () => void;
  6690. /**
  6691. * Instantiate a new Camera Input Manager.
  6692. * @param camera Defines the camera the input manager blongs to
  6693. */
  6694. constructor(camera: TCamera);
  6695. /**
  6696. * Add an input method to a camera
  6697. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6698. * @param input camera input method
  6699. */
  6700. add(input: ICameraInput<TCamera>): void;
  6701. /**
  6702. * Remove a specific input method from a camera
  6703. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6704. * @param inputToRemove camera input method
  6705. */
  6706. remove(inputToRemove: ICameraInput<TCamera>): void;
  6707. /**
  6708. * Remove a specific input type from a camera
  6709. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6710. * @param inputType the type of the input to remove
  6711. */
  6712. removeByType(inputType: string): void;
  6713. private _addCheckInputs;
  6714. /**
  6715. * Attach the input controls to the currently attached dom element to listen the events from.
  6716. * @param input Defines the input to attach
  6717. */
  6718. attachInput(input: ICameraInput<TCamera>): void;
  6719. /**
  6720. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6721. * @param element Defines the dom element to collect the events from
  6722. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6723. */
  6724. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6725. /**
  6726. * Detach the current manager inputs controls from a specific dom element.
  6727. * @param element Defines the dom element to collect the events from
  6728. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6729. */
  6730. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6731. /**
  6732. * Rebuild the dynamic inputCheck function from the current list of
  6733. * defined inputs in the manager.
  6734. */
  6735. rebuildInputCheck(): void;
  6736. /**
  6737. * Remove all attached input methods from a camera
  6738. */
  6739. clear(): void;
  6740. /**
  6741. * Serialize the current input manager attached to a camera.
  6742. * This ensures than once parsed,
  6743. * the input associated to the camera will be identical to the current ones
  6744. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6745. */
  6746. serialize(serializedCamera: any): void;
  6747. /**
  6748. * Parses an input manager serialized JSON to restore the previous list of inputs
  6749. * and states associated to a camera.
  6750. * @param parsedCamera Defines the JSON to parse
  6751. */
  6752. parse(parsedCamera: any): void;
  6753. }
  6754. }
  6755. declare module "babylonjs/Collisions/intersectionInfo" {
  6756. import { Nullable } from "babylonjs/types";
  6757. /**
  6758. * @hidden
  6759. */
  6760. export class IntersectionInfo {
  6761. bu: Nullable<number>;
  6762. bv: Nullable<number>;
  6763. distance: number;
  6764. faceId: number;
  6765. subMeshId: number;
  6766. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6767. }
  6768. }
  6769. declare module "babylonjs/Maths/math.plane" {
  6770. import { DeepImmutable } from "babylonjs/types";
  6771. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6772. /**
  6773. * Represens a plane by the equation ax + by + cz + d = 0
  6774. */
  6775. export class Plane {
  6776. private static _TmpMatrix;
  6777. /**
  6778. * Normal of the plane (a,b,c)
  6779. */
  6780. normal: Vector3;
  6781. /**
  6782. * d component of the plane
  6783. */
  6784. d: number;
  6785. /**
  6786. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6787. * @param a a component of the plane
  6788. * @param b b component of the plane
  6789. * @param c c component of the plane
  6790. * @param d d component of the plane
  6791. */
  6792. constructor(a: number, b: number, c: number, d: number);
  6793. /**
  6794. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6795. */
  6796. asArray(): number[];
  6797. /**
  6798. * @returns a new plane copied from the current Plane.
  6799. */
  6800. clone(): Plane;
  6801. /**
  6802. * @returns the string "Plane".
  6803. */
  6804. getClassName(): string;
  6805. /**
  6806. * @returns the Plane hash code.
  6807. */
  6808. getHashCode(): number;
  6809. /**
  6810. * Normalize the current Plane in place.
  6811. * @returns the updated Plane.
  6812. */
  6813. normalize(): Plane;
  6814. /**
  6815. * Applies a transformation the plane and returns the result
  6816. * @param transformation the transformation matrix to be applied to the plane
  6817. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6818. */
  6819. transform(transformation: DeepImmutable<Matrix>): Plane;
  6820. /**
  6821. * Calcualtte the dot product between the point and the plane normal
  6822. * @param point point to calculate the dot product with
  6823. * @returns the dot product (float) of the point coordinates and the plane normal.
  6824. */
  6825. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6826. /**
  6827. * Updates the current Plane from the plane defined by the three given points.
  6828. * @param point1 one of the points used to contruct the plane
  6829. * @param point2 one of the points used to contruct the plane
  6830. * @param point3 one of the points used to contruct the plane
  6831. * @returns the updated Plane.
  6832. */
  6833. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6834. /**
  6835. * Checks if the plane is facing a given direction
  6836. * @param direction the direction to check if the plane is facing
  6837. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6838. * @returns True is the vector "direction" is the same side than the plane normal.
  6839. */
  6840. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6841. /**
  6842. * Calculates the distance to a point
  6843. * @param point point to calculate distance to
  6844. * @returns the signed distance (float) from the given point to the Plane.
  6845. */
  6846. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6847. /**
  6848. * Creates a plane from an array
  6849. * @param array the array to create a plane from
  6850. * @returns a new Plane from the given array.
  6851. */
  6852. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6853. /**
  6854. * Creates a plane from three points
  6855. * @param point1 point used to create the plane
  6856. * @param point2 point used to create the plane
  6857. * @param point3 point used to create the plane
  6858. * @returns a new Plane defined by the three given points.
  6859. */
  6860. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6861. /**
  6862. * Creates a plane from an origin point and a normal
  6863. * @param origin origin of the plane to be constructed
  6864. * @param normal normal of the plane to be constructed
  6865. * @returns a new Plane the normal vector to this plane at the given origin point.
  6866. * Note : the vector "normal" is updated because normalized.
  6867. */
  6868. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6869. /**
  6870. * Calculates the distance from a plane and a point
  6871. * @param origin origin of the plane to be constructed
  6872. * @param normal normal of the plane to be constructed
  6873. * @param point point to calculate distance to
  6874. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6875. */
  6876. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6877. }
  6878. }
  6879. declare module "babylonjs/Culling/boundingSphere" {
  6880. import { DeepImmutable } from "babylonjs/types";
  6881. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6882. import { Plane } from "babylonjs/Maths/math.plane";
  6883. /**
  6884. * Class used to store bounding sphere information
  6885. */
  6886. export class BoundingSphere {
  6887. /**
  6888. * Gets the center of the bounding sphere in local space
  6889. */
  6890. readonly center: Vector3;
  6891. /**
  6892. * Radius of the bounding sphere in local space
  6893. */
  6894. radius: number;
  6895. /**
  6896. * Gets the center of the bounding sphere in world space
  6897. */
  6898. readonly centerWorld: Vector3;
  6899. /**
  6900. * Radius of the bounding sphere in world space
  6901. */
  6902. radiusWorld: number;
  6903. /**
  6904. * Gets the minimum vector in local space
  6905. */
  6906. readonly minimum: Vector3;
  6907. /**
  6908. * Gets the maximum vector in local space
  6909. */
  6910. readonly maximum: Vector3;
  6911. private _worldMatrix;
  6912. private static readonly TmpVector3;
  6913. /**
  6914. * Creates a new bounding sphere
  6915. * @param min defines the minimum vector (in local space)
  6916. * @param max defines the maximum vector (in local space)
  6917. * @param worldMatrix defines the new world matrix
  6918. */
  6919. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6920. /**
  6921. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6922. * @param min defines the new minimum vector (in local space)
  6923. * @param max defines the new maximum vector (in local space)
  6924. * @param worldMatrix defines the new world matrix
  6925. */
  6926. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6927. /**
  6928. * Scale the current bounding sphere by applying a scale factor
  6929. * @param factor defines the scale factor to apply
  6930. * @returns the current bounding box
  6931. */
  6932. scale(factor: number): BoundingSphere;
  6933. /**
  6934. * Gets the world matrix of the bounding box
  6935. * @returns a matrix
  6936. */
  6937. getWorldMatrix(): DeepImmutable<Matrix>;
  6938. /** @hidden */
  6939. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6940. /**
  6941. * Tests if the bounding sphere is intersecting the frustum planes
  6942. * @param frustumPlanes defines the frustum planes to test
  6943. * @returns true if there is an intersection
  6944. */
  6945. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6946. /**
  6947. * Tests if the bounding sphere center is in between the frustum planes.
  6948. * Used for optimistic fast inclusion.
  6949. * @param frustumPlanes defines the frustum planes to test
  6950. * @returns true if the sphere center is in between the frustum planes
  6951. */
  6952. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6953. /**
  6954. * Tests if a point is inside the bounding sphere
  6955. * @param point defines the point to test
  6956. * @returns true if the point is inside the bounding sphere
  6957. */
  6958. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6959. /**
  6960. * Checks if two sphere intersct
  6961. * @param sphere0 sphere 0
  6962. * @param sphere1 sphere 1
  6963. * @returns true if the speres intersect
  6964. */
  6965. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6966. }
  6967. }
  6968. declare module "babylonjs/Culling/boundingBox" {
  6969. import { DeepImmutable } from "babylonjs/types";
  6970. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6971. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6972. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6973. import { Plane } from "babylonjs/Maths/math.plane";
  6974. /**
  6975. * Class used to store bounding box information
  6976. */
  6977. export class BoundingBox implements ICullable {
  6978. /**
  6979. * Gets the 8 vectors representing the bounding box in local space
  6980. */
  6981. readonly vectors: Vector3[];
  6982. /**
  6983. * Gets the center of the bounding box in local space
  6984. */
  6985. readonly center: Vector3;
  6986. /**
  6987. * Gets the center of the bounding box in world space
  6988. */
  6989. readonly centerWorld: Vector3;
  6990. /**
  6991. * Gets the extend size in local space
  6992. */
  6993. readonly extendSize: Vector3;
  6994. /**
  6995. * Gets the extend size in world space
  6996. */
  6997. readonly extendSizeWorld: Vector3;
  6998. /**
  6999. * Gets the OBB (object bounding box) directions
  7000. */
  7001. readonly directions: Vector3[];
  7002. /**
  7003. * Gets the 8 vectors representing the bounding box in world space
  7004. */
  7005. readonly vectorsWorld: Vector3[];
  7006. /**
  7007. * Gets the minimum vector in world space
  7008. */
  7009. readonly minimumWorld: Vector3;
  7010. /**
  7011. * Gets the maximum vector in world space
  7012. */
  7013. readonly maximumWorld: Vector3;
  7014. /**
  7015. * Gets the minimum vector in local space
  7016. */
  7017. readonly minimum: Vector3;
  7018. /**
  7019. * Gets the maximum vector in local space
  7020. */
  7021. readonly maximum: Vector3;
  7022. private _worldMatrix;
  7023. private static readonly TmpVector3;
  7024. /**
  7025. * @hidden
  7026. */
  7027. _tag: number;
  7028. /**
  7029. * Creates a new bounding box
  7030. * @param min defines the minimum vector (in local space)
  7031. * @param max defines the maximum vector (in local space)
  7032. * @param worldMatrix defines the new world matrix
  7033. */
  7034. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7035. /**
  7036. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7037. * @param min defines the new minimum vector (in local space)
  7038. * @param max defines the new maximum vector (in local space)
  7039. * @param worldMatrix defines the new world matrix
  7040. */
  7041. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7042. /**
  7043. * Scale the current bounding box by applying a scale factor
  7044. * @param factor defines the scale factor to apply
  7045. * @returns the current bounding box
  7046. */
  7047. scale(factor: number): BoundingBox;
  7048. /**
  7049. * Gets the world matrix of the bounding box
  7050. * @returns a matrix
  7051. */
  7052. getWorldMatrix(): DeepImmutable<Matrix>;
  7053. /** @hidden */
  7054. _update(world: DeepImmutable<Matrix>): void;
  7055. /**
  7056. * Tests if the bounding box is intersecting the frustum planes
  7057. * @param frustumPlanes defines the frustum planes to test
  7058. * @returns true if there is an intersection
  7059. */
  7060. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7061. /**
  7062. * Tests if the bounding box is entirely inside the frustum planes
  7063. * @param frustumPlanes defines the frustum planes to test
  7064. * @returns true if there is an inclusion
  7065. */
  7066. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7067. /**
  7068. * Tests if a point is inside the bounding box
  7069. * @param point defines the point to test
  7070. * @returns true if the point is inside the bounding box
  7071. */
  7072. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7073. /**
  7074. * Tests if the bounding box intersects with a bounding sphere
  7075. * @param sphere defines the sphere to test
  7076. * @returns true if there is an intersection
  7077. */
  7078. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7079. /**
  7080. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7081. * @param min defines the min vector to use
  7082. * @param max defines the max vector to use
  7083. * @returns true if there is an intersection
  7084. */
  7085. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7086. /**
  7087. * Tests if two bounding boxes are intersections
  7088. * @param box0 defines the first box to test
  7089. * @param box1 defines the second box to test
  7090. * @returns true if there is an intersection
  7091. */
  7092. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7093. /**
  7094. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7095. * @param minPoint defines the minimum vector of the bounding box
  7096. * @param maxPoint defines the maximum vector of the bounding box
  7097. * @param sphereCenter defines the sphere center
  7098. * @param sphereRadius defines the sphere radius
  7099. * @returns true if there is an intersection
  7100. */
  7101. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7102. /**
  7103. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7104. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7105. * @param frustumPlanes defines the frustum planes to test
  7106. * @return true if there is an inclusion
  7107. */
  7108. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7109. /**
  7110. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7111. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7112. * @param frustumPlanes defines the frustum planes to test
  7113. * @return true if there is an intersection
  7114. */
  7115. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7116. }
  7117. }
  7118. declare module "babylonjs/Collisions/collider" {
  7119. import { Nullable, IndicesArray } from "babylonjs/types";
  7120. import { Vector3 } from "babylonjs/Maths/math.vector";
  7121. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7122. import { Plane } from "babylonjs/Maths/math.plane";
  7123. /** @hidden */
  7124. export class Collider {
  7125. /** Define if a collision was found */
  7126. collisionFound: boolean;
  7127. /**
  7128. * Define last intersection point in local space
  7129. */
  7130. intersectionPoint: Vector3;
  7131. /**
  7132. * Define last collided mesh
  7133. */
  7134. collidedMesh: Nullable<AbstractMesh>;
  7135. private _collisionPoint;
  7136. private _planeIntersectionPoint;
  7137. private _tempVector;
  7138. private _tempVector2;
  7139. private _tempVector3;
  7140. private _tempVector4;
  7141. private _edge;
  7142. private _baseToVertex;
  7143. private _destinationPoint;
  7144. private _slidePlaneNormal;
  7145. private _displacementVector;
  7146. /** @hidden */
  7147. _radius: Vector3;
  7148. /** @hidden */
  7149. _retry: number;
  7150. private _velocity;
  7151. private _basePoint;
  7152. private _epsilon;
  7153. /** @hidden */
  7154. _velocityWorldLength: number;
  7155. /** @hidden */
  7156. _basePointWorld: Vector3;
  7157. private _velocityWorld;
  7158. private _normalizedVelocity;
  7159. /** @hidden */
  7160. _initialVelocity: Vector3;
  7161. /** @hidden */
  7162. _initialPosition: Vector3;
  7163. private _nearestDistance;
  7164. private _collisionMask;
  7165. collisionMask: number;
  7166. /**
  7167. * Gets the plane normal used to compute the sliding response (in local space)
  7168. */
  7169. readonly slidePlaneNormal: Vector3;
  7170. /** @hidden */
  7171. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7172. /** @hidden */
  7173. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7174. /** @hidden */
  7175. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7176. /** @hidden */
  7177. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7178. /** @hidden */
  7179. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7180. /** @hidden */
  7181. _getResponse(pos: Vector3, vel: Vector3): void;
  7182. }
  7183. }
  7184. declare module "babylonjs/Culling/boundingInfo" {
  7185. import { DeepImmutable } from "babylonjs/types";
  7186. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7187. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7188. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7189. import { Plane } from "babylonjs/Maths/math.plane";
  7190. import { Collider } from "babylonjs/Collisions/collider";
  7191. /**
  7192. * Interface for cullable objects
  7193. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7194. */
  7195. export interface ICullable {
  7196. /**
  7197. * Checks if the object or part of the object is in the frustum
  7198. * @param frustumPlanes Camera near/planes
  7199. * @returns true if the object is in frustum otherwise false
  7200. */
  7201. isInFrustum(frustumPlanes: Plane[]): boolean;
  7202. /**
  7203. * Checks if a cullable object (mesh...) is in the camera frustum
  7204. * Unlike isInFrustum this cheks the full bounding box
  7205. * @param frustumPlanes Camera near/planes
  7206. * @returns true if the object is in frustum otherwise false
  7207. */
  7208. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7209. }
  7210. /**
  7211. * Info for a bounding data of a mesh
  7212. */
  7213. export class BoundingInfo implements ICullable {
  7214. /**
  7215. * Bounding box for the mesh
  7216. */
  7217. readonly boundingBox: BoundingBox;
  7218. /**
  7219. * Bounding sphere for the mesh
  7220. */
  7221. readonly boundingSphere: BoundingSphere;
  7222. private _isLocked;
  7223. private static readonly TmpVector3;
  7224. /**
  7225. * Constructs bounding info
  7226. * @param minimum min vector of the bounding box/sphere
  7227. * @param maximum max vector of the bounding box/sphere
  7228. * @param worldMatrix defines the new world matrix
  7229. */
  7230. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7231. /**
  7232. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7233. * @param min defines the new minimum vector (in local space)
  7234. * @param max defines the new maximum vector (in local space)
  7235. * @param worldMatrix defines the new world matrix
  7236. */
  7237. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7238. /**
  7239. * min vector of the bounding box/sphere
  7240. */
  7241. readonly minimum: Vector3;
  7242. /**
  7243. * max vector of the bounding box/sphere
  7244. */
  7245. readonly maximum: Vector3;
  7246. /**
  7247. * If the info is locked and won't be updated to avoid perf overhead
  7248. */
  7249. isLocked: boolean;
  7250. /**
  7251. * Updates the bounding sphere and box
  7252. * @param world world matrix to be used to update
  7253. */
  7254. update(world: DeepImmutable<Matrix>): void;
  7255. /**
  7256. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7257. * @param center New center of the bounding info
  7258. * @param extend New extend of the bounding info
  7259. * @returns the current bounding info
  7260. */
  7261. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7262. /**
  7263. * Scale the current bounding info by applying a scale factor
  7264. * @param factor defines the scale factor to apply
  7265. * @returns the current bounding info
  7266. */
  7267. scale(factor: number): BoundingInfo;
  7268. /**
  7269. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7270. * @param frustumPlanes defines the frustum to test
  7271. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7272. * @returns true if the bounding info is in the frustum planes
  7273. */
  7274. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7275. /**
  7276. * Gets the world distance between the min and max points of the bounding box
  7277. */
  7278. readonly diagonalLength: number;
  7279. /**
  7280. * Checks if a cullable object (mesh...) is in the camera frustum
  7281. * Unlike isInFrustum this cheks the full bounding box
  7282. * @param frustumPlanes Camera near/planes
  7283. * @returns true if the object is in frustum otherwise false
  7284. */
  7285. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7286. /** @hidden */
  7287. _checkCollision(collider: Collider): boolean;
  7288. /**
  7289. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7290. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7291. * @param point the point to check intersection with
  7292. * @returns if the point intersects
  7293. */
  7294. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7295. /**
  7296. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7297. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7298. * @param boundingInfo the bounding info to check intersection with
  7299. * @param precise if the intersection should be done using OBB
  7300. * @returns if the bounding info intersects
  7301. */
  7302. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7303. }
  7304. }
  7305. declare module "babylonjs/Maths/math.functions" {
  7306. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7307. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7308. /**
  7309. * Extracts minimum and maximum values from a list of indexed positions
  7310. * @param positions defines the positions to use
  7311. * @param indices defines the indices to the positions
  7312. * @param indexStart defines the start index
  7313. * @param indexCount defines the end index
  7314. * @param bias defines bias value to add to the result
  7315. * @return minimum and maximum values
  7316. */
  7317. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7318. minimum: Vector3;
  7319. maximum: Vector3;
  7320. };
  7321. /**
  7322. * Extracts minimum and maximum values from a list of positions
  7323. * @param positions defines the positions to use
  7324. * @param start defines the start index in the positions array
  7325. * @param count defines the number of positions to handle
  7326. * @param bias defines bias value to add to the result
  7327. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7328. * @return minimum and maximum values
  7329. */
  7330. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7331. minimum: Vector3;
  7332. maximum: Vector3;
  7333. };
  7334. }
  7335. declare module "babylonjs/Misc/iInspectable" {
  7336. /**
  7337. * Enum that determines the text-wrapping mode to use.
  7338. */
  7339. export enum InspectableType {
  7340. /**
  7341. * Checkbox for booleans
  7342. */
  7343. Checkbox = 0,
  7344. /**
  7345. * Sliders for numbers
  7346. */
  7347. Slider = 1,
  7348. /**
  7349. * Vector3
  7350. */
  7351. Vector3 = 2,
  7352. /**
  7353. * Quaternions
  7354. */
  7355. Quaternion = 3,
  7356. /**
  7357. * Color3
  7358. */
  7359. Color3 = 4,
  7360. /**
  7361. * String
  7362. */
  7363. String = 5
  7364. }
  7365. /**
  7366. * Interface used to define custom inspectable properties.
  7367. * This interface is used by the inspector to display custom property grids
  7368. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7369. */
  7370. export interface IInspectable {
  7371. /**
  7372. * Gets the label to display
  7373. */
  7374. label: string;
  7375. /**
  7376. * Gets the name of the property to edit
  7377. */
  7378. propertyName: string;
  7379. /**
  7380. * Gets the type of the editor to use
  7381. */
  7382. type: InspectableType;
  7383. /**
  7384. * Gets the minimum value of the property when using in "slider" mode
  7385. */
  7386. min?: number;
  7387. /**
  7388. * Gets the maximum value of the property when using in "slider" mode
  7389. */
  7390. max?: number;
  7391. /**
  7392. * Gets the setp to use when using in "slider" mode
  7393. */
  7394. step?: number;
  7395. }
  7396. }
  7397. declare module "babylonjs/Misc/timingTools" {
  7398. /**
  7399. * Class used to provide helper for timing
  7400. */
  7401. export class TimingTools {
  7402. /**
  7403. * Polyfill for setImmediate
  7404. * @param action defines the action to execute after the current execution block
  7405. */
  7406. static SetImmediate(action: () => void): void;
  7407. }
  7408. }
  7409. declare module "babylonjs/Misc/instantiationTools" {
  7410. /**
  7411. * Class used to enable instatition of objects by class name
  7412. */
  7413. export class InstantiationTools {
  7414. /**
  7415. * Use this object to register external classes like custom textures or material
  7416. * to allow the laoders to instantiate them
  7417. */
  7418. static RegisteredExternalClasses: {
  7419. [key: string]: Object;
  7420. };
  7421. /**
  7422. * Tries to instantiate a new object from a given class name
  7423. * @param className defines the class name to instantiate
  7424. * @returns the new object or null if the system was not able to do the instantiation
  7425. */
  7426. static Instantiate(className: string): any;
  7427. }
  7428. }
  7429. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  7430. import { Nullable } from "babylonjs/types";
  7431. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7432. /**
  7433. * This represents the required contract to create a new type of texture loader.
  7434. */
  7435. export interface IInternalTextureLoader {
  7436. /**
  7437. * Defines wether the loader supports cascade loading the different faces.
  7438. */
  7439. supportCascades: boolean;
  7440. /**
  7441. * This returns if the loader support the current file information.
  7442. * @param extension defines the file extension of the file being loaded
  7443. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7444. * @param fallback defines the fallback internal texture if any
  7445. * @param isBase64 defines whether the texture is encoded as a base64
  7446. * @param isBuffer defines whether the texture data are stored as a buffer
  7447. * @returns true if the loader can load the specified file
  7448. */
  7449. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  7450. /**
  7451. * Transform the url before loading if required.
  7452. * @param rootUrl the url of the texture
  7453. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7454. * @returns the transformed texture
  7455. */
  7456. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  7457. /**
  7458. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  7459. * @param rootUrl the url of the texture
  7460. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7461. * @returns the fallback texture
  7462. */
  7463. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  7464. /**
  7465. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  7466. * @param data contains the texture data
  7467. * @param texture defines the BabylonJS internal texture
  7468. * @param createPolynomials will be true if polynomials have been requested
  7469. * @param onLoad defines the callback to trigger once the texture is ready
  7470. * @param onError defines the callback to trigger in case of error
  7471. */
  7472. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  7473. /**
  7474. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  7475. * @param data contains the texture data
  7476. * @param texture defines the BabylonJS internal texture
  7477. * @param callback defines the method to call once ready to upload
  7478. */
  7479. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  7480. }
  7481. }
  7482. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7483. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7484. import { Nullable } from "babylonjs/types";
  7485. import { Scene } from "babylonjs/scene";
  7486. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7487. module "babylonjs/Engines/engine" {
  7488. interface Engine {
  7489. /**
  7490. * Creates a depth stencil cube texture.
  7491. * This is only available in WebGL 2.
  7492. * @param size The size of face edge in the cube texture.
  7493. * @param options The options defining the cube texture.
  7494. * @returns The cube texture
  7495. */
  7496. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7497. /**
  7498. * Creates a cube texture
  7499. * @param rootUrl defines the url where the files to load is located
  7500. * @param scene defines the current scene
  7501. * @param files defines the list of files to load (1 per face)
  7502. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7503. * @param onLoad defines an optional callback raised when the texture is loaded
  7504. * @param onError defines an optional callback raised if there is an issue to load the texture
  7505. * @param format defines the format of the data
  7506. * @param forcedExtension defines the extension to use to pick the right loader
  7507. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7508. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7509. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7510. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7511. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7512. * @returns the cube texture as an InternalTexture
  7513. */
  7514. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  7515. /**
  7516. * Creates a cube texture
  7517. * @param rootUrl defines the url where the files to load is located
  7518. * @param scene defines the current scene
  7519. * @param files defines the list of files to load (1 per face)
  7520. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7521. * @param onLoad defines an optional callback raised when the texture is loaded
  7522. * @param onError defines an optional callback raised if there is an issue to load the texture
  7523. * @param format defines the format of the data
  7524. * @param forcedExtension defines the extension to use to pick the right loader
  7525. * @returns the cube texture as an InternalTexture
  7526. */
  7527. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7528. /**
  7529. * Creates a cube texture
  7530. * @param rootUrl defines the url where the files to load is located
  7531. * @param scene defines the current scene
  7532. * @param files defines the list of files to load (1 per face)
  7533. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7534. * @param onLoad defines an optional callback raised when the texture is loaded
  7535. * @param onError defines an optional callback raised if there is an issue to load the texture
  7536. * @param format defines the format of the data
  7537. * @param forcedExtension defines the extension to use to pick the right loader
  7538. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7539. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7540. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7541. * @returns the cube texture as an InternalTexture
  7542. */
  7543. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7544. /** @hidden */
  7545. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7546. /** @hidden */
  7547. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7548. /** @hidden */
  7549. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7550. /** @hidden */
  7551. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7552. }
  7553. }
  7554. }
  7555. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7556. import { Nullable } from "babylonjs/types";
  7557. import { Scene } from "babylonjs/scene";
  7558. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7559. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7560. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7561. /**
  7562. * Class for creating a cube texture
  7563. */
  7564. export class CubeTexture extends BaseTexture {
  7565. private _delayedOnLoad;
  7566. /**
  7567. * The url of the texture
  7568. */
  7569. url: string;
  7570. /**
  7571. * Gets or sets the center of the bounding box associated with the cube texture.
  7572. * It must define where the camera used to render the texture was set
  7573. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7574. */
  7575. boundingBoxPosition: Vector3;
  7576. private _boundingBoxSize;
  7577. /**
  7578. * Gets or sets the size of the bounding box associated with the cube texture
  7579. * When defined, the cubemap will switch to local mode
  7580. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7581. * @example https://www.babylonjs-playground.com/#RNASML
  7582. */
  7583. /**
  7584. * Returns the bounding box size
  7585. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7586. */
  7587. boundingBoxSize: Vector3;
  7588. protected _rotationY: number;
  7589. /**
  7590. * Sets texture matrix rotation angle around Y axis in radians.
  7591. */
  7592. /**
  7593. * Gets texture matrix rotation angle around Y axis radians.
  7594. */
  7595. rotationY: number;
  7596. /**
  7597. * Are mip maps generated for this texture or not.
  7598. */
  7599. readonly noMipmap: boolean;
  7600. private _noMipmap;
  7601. private _files;
  7602. private _extensions;
  7603. private _textureMatrix;
  7604. private _format;
  7605. private _createPolynomials;
  7606. /** @hidden */
  7607. _prefiltered: boolean;
  7608. /**
  7609. * Creates a cube texture from an array of image urls
  7610. * @param files defines an array of image urls
  7611. * @param scene defines the hosting scene
  7612. * @param noMipmap specifies if mip maps are not used
  7613. * @returns a cube texture
  7614. */
  7615. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7616. /**
  7617. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7618. * @param url defines the url of the prefiltered texture
  7619. * @param scene defines the scene the texture is attached to
  7620. * @param forcedExtension defines the extension of the file if different from the url
  7621. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7622. * @return the prefiltered texture
  7623. */
  7624. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7625. /**
  7626. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7627. * as prefiltered data.
  7628. * @param rootUrl defines the url of the texture or the root name of the six images
  7629. * @param scene defines the scene the texture is attached to
  7630. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7631. * @param noMipmap defines if mipmaps should be created or not
  7632. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7633. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7634. * @param onError defines a callback triggered in case of error during load
  7635. * @param format defines the internal format to use for the texture once loaded
  7636. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7637. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7638. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7639. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7640. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7641. * @return the cube texture
  7642. */
  7643. constructor(rootUrl: string, scene: Scene, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  7644. /**
  7645. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7646. */
  7647. readonly isPrefiltered: boolean;
  7648. /**
  7649. * Get the current class name of the texture useful for serialization or dynamic coding.
  7650. * @returns "CubeTexture"
  7651. */
  7652. getClassName(): string;
  7653. /**
  7654. * Update the url (and optional buffer) of this texture if url was null during construction.
  7655. * @param url the url of the texture
  7656. * @param forcedExtension defines the extension to use
  7657. * @param onLoad callback called when the texture is loaded (defaults to null)
  7658. */
  7659. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7660. /**
  7661. * Delays loading of the cube texture
  7662. * @param forcedExtension defines the extension to use
  7663. */
  7664. delayLoad(forcedExtension?: string): void;
  7665. /**
  7666. * Returns the reflection texture matrix
  7667. * @returns the reflection texture matrix
  7668. */
  7669. getReflectionTextureMatrix(): Matrix;
  7670. /**
  7671. * Sets the reflection texture matrix
  7672. * @param value Reflection texture matrix
  7673. */
  7674. setReflectionTextureMatrix(value: Matrix): void;
  7675. /**
  7676. * Parses text to create a cube texture
  7677. * @param parsedTexture define the serialized text to read from
  7678. * @param scene defines the hosting scene
  7679. * @param rootUrl defines the root url of the cube texture
  7680. * @returns a cube texture
  7681. */
  7682. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7683. /**
  7684. * Makes a clone, or deep copy, of the cube texture
  7685. * @returns a new cube texture
  7686. */
  7687. clone(): CubeTexture;
  7688. }
  7689. }
  7690. declare module "babylonjs/Materials/materialDefines" {
  7691. /**
  7692. * Manages the defines for the Material
  7693. */
  7694. export class MaterialDefines {
  7695. /** @hidden */
  7696. protected _keys: string[];
  7697. private _isDirty;
  7698. /** @hidden */
  7699. _renderId: number;
  7700. /** @hidden */
  7701. _areLightsDirty: boolean;
  7702. /** @hidden */
  7703. _areLightsDisposed: boolean;
  7704. /** @hidden */
  7705. _areAttributesDirty: boolean;
  7706. /** @hidden */
  7707. _areTexturesDirty: boolean;
  7708. /** @hidden */
  7709. _areFresnelDirty: boolean;
  7710. /** @hidden */
  7711. _areMiscDirty: boolean;
  7712. /** @hidden */
  7713. _areImageProcessingDirty: boolean;
  7714. /** @hidden */
  7715. _normals: boolean;
  7716. /** @hidden */
  7717. _uvs: boolean;
  7718. /** @hidden */
  7719. _needNormals: boolean;
  7720. /** @hidden */
  7721. _needUVs: boolean;
  7722. [id: string]: any;
  7723. /**
  7724. * Specifies if the material needs to be re-calculated
  7725. */
  7726. readonly isDirty: boolean;
  7727. /**
  7728. * Marks the material to indicate that it has been re-calculated
  7729. */
  7730. markAsProcessed(): void;
  7731. /**
  7732. * Marks the material to indicate that it needs to be re-calculated
  7733. */
  7734. markAsUnprocessed(): void;
  7735. /**
  7736. * Marks the material to indicate all of its defines need to be re-calculated
  7737. */
  7738. markAllAsDirty(): void;
  7739. /**
  7740. * Marks the material to indicate that image processing needs to be re-calculated
  7741. */
  7742. markAsImageProcessingDirty(): void;
  7743. /**
  7744. * Marks the material to indicate the lights need to be re-calculated
  7745. * @param disposed Defines whether the light is dirty due to dispose or not
  7746. */
  7747. markAsLightDirty(disposed?: boolean): void;
  7748. /**
  7749. * Marks the attribute state as changed
  7750. */
  7751. markAsAttributesDirty(): void;
  7752. /**
  7753. * Marks the texture state as changed
  7754. */
  7755. markAsTexturesDirty(): void;
  7756. /**
  7757. * Marks the fresnel state as changed
  7758. */
  7759. markAsFresnelDirty(): void;
  7760. /**
  7761. * Marks the misc state as changed
  7762. */
  7763. markAsMiscDirty(): void;
  7764. /**
  7765. * Rebuilds the material defines
  7766. */
  7767. rebuild(): void;
  7768. /**
  7769. * Specifies if two material defines are equal
  7770. * @param other - A material define instance to compare to
  7771. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7772. */
  7773. isEqual(other: MaterialDefines): boolean;
  7774. /**
  7775. * Clones this instance's defines to another instance
  7776. * @param other - material defines to clone values to
  7777. */
  7778. cloneTo(other: MaterialDefines): void;
  7779. /**
  7780. * Resets the material define values
  7781. */
  7782. reset(): void;
  7783. /**
  7784. * Converts the material define values to a string
  7785. * @returns - String of material define information
  7786. */
  7787. toString(): string;
  7788. }
  7789. }
  7790. declare module "babylonjs/Materials/colorCurves" {
  7791. import { Effect } from "babylonjs/Materials/effect";
  7792. /**
  7793. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7794. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7795. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  7796. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7797. */
  7798. export class ColorCurves {
  7799. private _dirty;
  7800. private _tempColor;
  7801. private _globalCurve;
  7802. private _highlightsCurve;
  7803. private _midtonesCurve;
  7804. private _shadowsCurve;
  7805. private _positiveCurve;
  7806. private _negativeCurve;
  7807. private _globalHue;
  7808. private _globalDensity;
  7809. private _globalSaturation;
  7810. private _globalExposure;
  7811. /**
  7812. * Gets the global Hue value.
  7813. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7814. */
  7815. /**
  7816. * Sets the global Hue value.
  7817. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7818. */
  7819. globalHue: number;
  7820. /**
  7821. * Gets the global Density value.
  7822. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7823. * Values less than zero provide a filter of opposite hue.
  7824. */
  7825. /**
  7826. * Sets the global Density value.
  7827. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7828. * Values less than zero provide a filter of opposite hue.
  7829. */
  7830. globalDensity: number;
  7831. /**
  7832. * Gets the global Saturation value.
  7833. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7834. */
  7835. /**
  7836. * Sets the global Saturation value.
  7837. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7838. */
  7839. globalSaturation: number;
  7840. /**
  7841. * Gets the global Exposure value.
  7842. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7843. */
  7844. /**
  7845. * Sets the global Exposure value.
  7846. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7847. */
  7848. globalExposure: number;
  7849. private _highlightsHue;
  7850. private _highlightsDensity;
  7851. private _highlightsSaturation;
  7852. private _highlightsExposure;
  7853. /**
  7854. * Gets the highlights Hue value.
  7855. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7856. */
  7857. /**
  7858. * Sets the highlights Hue value.
  7859. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7860. */
  7861. highlightsHue: number;
  7862. /**
  7863. * Gets the highlights Density value.
  7864. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7865. * Values less than zero provide a filter of opposite hue.
  7866. */
  7867. /**
  7868. * Sets the highlights Density value.
  7869. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7870. * Values less than zero provide a filter of opposite hue.
  7871. */
  7872. highlightsDensity: number;
  7873. /**
  7874. * Gets the highlights Saturation value.
  7875. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7876. */
  7877. /**
  7878. * Sets the highlights Saturation value.
  7879. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7880. */
  7881. highlightsSaturation: number;
  7882. /**
  7883. * Gets the highlights Exposure value.
  7884. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7885. */
  7886. /**
  7887. * Sets the highlights Exposure value.
  7888. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7889. */
  7890. highlightsExposure: number;
  7891. private _midtonesHue;
  7892. private _midtonesDensity;
  7893. private _midtonesSaturation;
  7894. private _midtonesExposure;
  7895. /**
  7896. * Gets the midtones Hue value.
  7897. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7898. */
  7899. /**
  7900. * Sets the midtones Hue value.
  7901. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7902. */
  7903. midtonesHue: number;
  7904. /**
  7905. * Gets the midtones Density value.
  7906. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7907. * Values less than zero provide a filter of opposite hue.
  7908. */
  7909. /**
  7910. * Sets the midtones Density value.
  7911. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7912. * Values less than zero provide a filter of opposite hue.
  7913. */
  7914. midtonesDensity: number;
  7915. /**
  7916. * Gets the midtones Saturation value.
  7917. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7918. */
  7919. /**
  7920. * Sets the midtones Saturation value.
  7921. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7922. */
  7923. midtonesSaturation: number;
  7924. /**
  7925. * Gets the midtones Exposure value.
  7926. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7927. */
  7928. /**
  7929. * Sets the midtones Exposure value.
  7930. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7931. */
  7932. midtonesExposure: number;
  7933. private _shadowsHue;
  7934. private _shadowsDensity;
  7935. private _shadowsSaturation;
  7936. private _shadowsExposure;
  7937. /**
  7938. * Gets the shadows Hue value.
  7939. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7940. */
  7941. /**
  7942. * Sets the shadows Hue value.
  7943. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7944. */
  7945. shadowsHue: number;
  7946. /**
  7947. * Gets the shadows Density value.
  7948. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7949. * Values less than zero provide a filter of opposite hue.
  7950. */
  7951. /**
  7952. * Sets the shadows Density value.
  7953. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7954. * Values less than zero provide a filter of opposite hue.
  7955. */
  7956. shadowsDensity: number;
  7957. /**
  7958. * Gets the shadows Saturation value.
  7959. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7960. */
  7961. /**
  7962. * Sets the shadows Saturation value.
  7963. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7964. */
  7965. shadowsSaturation: number;
  7966. /**
  7967. * Gets the shadows Exposure value.
  7968. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7969. */
  7970. /**
  7971. * Sets the shadows Exposure value.
  7972. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7973. */
  7974. shadowsExposure: number;
  7975. /**
  7976. * Returns the class name
  7977. * @returns The class name
  7978. */
  7979. getClassName(): string;
  7980. /**
  7981. * Binds the color curves to the shader.
  7982. * @param colorCurves The color curve to bind
  7983. * @param effect The effect to bind to
  7984. * @param positiveUniform The positive uniform shader parameter
  7985. * @param neutralUniform The neutral uniform shader parameter
  7986. * @param negativeUniform The negative uniform shader parameter
  7987. */
  7988. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  7989. /**
  7990. * Prepare the list of uniforms associated with the ColorCurves effects.
  7991. * @param uniformsList The list of uniforms used in the effect
  7992. */
  7993. static PrepareUniforms(uniformsList: string[]): void;
  7994. /**
  7995. * Returns color grading data based on a hue, density, saturation and exposure value.
  7996. * @param filterHue The hue of the color filter.
  7997. * @param filterDensity The density of the color filter.
  7998. * @param saturation The saturation.
  7999. * @param exposure The exposure.
  8000. * @param result The result data container.
  8001. */
  8002. private getColorGradingDataToRef;
  8003. /**
  8004. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8005. * @param value The input slider value in range [-100,100].
  8006. * @returns Adjusted value.
  8007. */
  8008. private static applyColorGradingSliderNonlinear;
  8009. /**
  8010. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8011. * @param hue The hue (H) input.
  8012. * @param saturation The saturation (S) input.
  8013. * @param brightness The brightness (B) input.
  8014. * @result An RGBA color represented as Vector4.
  8015. */
  8016. private static fromHSBToRef;
  8017. /**
  8018. * Returns a value clamped between min and max
  8019. * @param value The value to clamp
  8020. * @param min The minimum of value
  8021. * @param max The maximum of value
  8022. * @returns The clamped value.
  8023. */
  8024. private static clamp;
  8025. /**
  8026. * Clones the current color curve instance.
  8027. * @return The cloned curves
  8028. */
  8029. clone(): ColorCurves;
  8030. /**
  8031. * Serializes the current color curve instance to a json representation.
  8032. * @return a JSON representation
  8033. */
  8034. serialize(): any;
  8035. /**
  8036. * Parses the color curve from a json representation.
  8037. * @param source the JSON source to parse
  8038. * @return The parsed curves
  8039. */
  8040. static Parse(source: any): ColorCurves;
  8041. }
  8042. }
  8043. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8044. import { Observable } from "babylonjs/Misc/observable";
  8045. import { Nullable } from "babylonjs/types";
  8046. import { Color4 } from "babylonjs/Maths/math.color";
  8047. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8048. import { Effect } from "babylonjs/Materials/effect";
  8049. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8050. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8051. /**
  8052. * Interface to follow in your material defines to integrate easily the
  8053. * Image proccessing functions.
  8054. * @hidden
  8055. */
  8056. export interface IImageProcessingConfigurationDefines {
  8057. IMAGEPROCESSING: boolean;
  8058. VIGNETTE: boolean;
  8059. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8060. VIGNETTEBLENDMODEOPAQUE: boolean;
  8061. TONEMAPPING: boolean;
  8062. TONEMAPPING_ACES: boolean;
  8063. CONTRAST: boolean;
  8064. EXPOSURE: boolean;
  8065. COLORCURVES: boolean;
  8066. COLORGRADING: boolean;
  8067. COLORGRADING3D: boolean;
  8068. SAMPLER3DGREENDEPTH: boolean;
  8069. SAMPLER3DBGRMAP: boolean;
  8070. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8071. }
  8072. /**
  8073. * @hidden
  8074. */
  8075. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8076. IMAGEPROCESSING: boolean;
  8077. VIGNETTE: boolean;
  8078. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8079. VIGNETTEBLENDMODEOPAQUE: boolean;
  8080. TONEMAPPING: boolean;
  8081. TONEMAPPING_ACES: boolean;
  8082. CONTRAST: boolean;
  8083. COLORCURVES: boolean;
  8084. COLORGRADING: boolean;
  8085. COLORGRADING3D: boolean;
  8086. SAMPLER3DGREENDEPTH: boolean;
  8087. SAMPLER3DBGRMAP: boolean;
  8088. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8089. EXPOSURE: boolean;
  8090. constructor();
  8091. }
  8092. /**
  8093. * This groups together the common properties used for image processing either in direct forward pass
  8094. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8095. * or not.
  8096. */
  8097. export class ImageProcessingConfiguration {
  8098. /**
  8099. * Default tone mapping applied in BabylonJS.
  8100. */
  8101. static readonly TONEMAPPING_STANDARD: number;
  8102. /**
  8103. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8104. * to other engines rendering to increase portability.
  8105. */
  8106. static readonly TONEMAPPING_ACES: number;
  8107. /**
  8108. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8109. */
  8110. colorCurves: Nullable<ColorCurves>;
  8111. private _colorCurvesEnabled;
  8112. /**
  8113. * Gets wether the color curves effect is enabled.
  8114. */
  8115. /**
  8116. * Sets wether the color curves effect is enabled.
  8117. */
  8118. colorCurvesEnabled: boolean;
  8119. private _colorGradingTexture;
  8120. /**
  8121. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8122. */
  8123. /**
  8124. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8125. */
  8126. colorGradingTexture: Nullable<BaseTexture>;
  8127. private _colorGradingEnabled;
  8128. /**
  8129. * Gets wether the color grading effect is enabled.
  8130. */
  8131. /**
  8132. * Sets wether the color grading effect is enabled.
  8133. */
  8134. colorGradingEnabled: boolean;
  8135. private _colorGradingWithGreenDepth;
  8136. /**
  8137. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8138. */
  8139. /**
  8140. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8141. */
  8142. colorGradingWithGreenDepth: boolean;
  8143. private _colorGradingBGR;
  8144. /**
  8145. * Gets wether the color grading texture contains BGR values.
  8146. */
  8147. /**
  8148. * Sets wether the color grading texture contains BGR values.
  8149. */
  8150. colorGradingBGR: boolean;
  8151. /** @hidden */
  8152. _exposure: number;
  8153. /**
  8154. * Gets the Exposure used in the effect.
  8155. */
  8156. /**
  8157. * Sets the Exposure used in the effect.
  8158. */
  8159. exposure: number;
  8160. private _toneMappingEnabled;
  8161. /**
  8162. * Gets wether the tone mapping effect is enabled.
  8163. */
  8164. /**
  8165. * Sets wether the tone mapping effect is enabled.
  8166. */
  8167. toneMappingEnabled: boolean;
  8168. private _toneMappingType;
  8169. /**
  8170. * Gets the type of tone mapping effect.
  8171. */
  8172. /**
  8173. * Sets the type of tone mapping effect used in BabylonJS.
  8174. */
  8175. toneMappingType: number;
  8176. protected _contrast: number;
  8177. /**
  8178. * Gets the contrast used in the effect.
  8179. */
  8180. /**
  8181. * Sets the contrast used in the effect.
  8182. */
  8183. contrast: number;
  8184. /**
  8185. * Vignette stretch size.
  8186. */
  8187. vignetteStretch: number;
  8188. /**
  8189. * Vignette centre X Offset.
  8190. */
  8191. vignetteCentreX: number;
  8192. /**
  8193. * Vignette centre Y Offset.
  8194. */
  8195. vignetteCentreY: number;
  8196. /**
  8197. * Vignette weight or intensity of the vignette effect.
  8198. */
  8199. vignetteWeight: number;
  8200. /**
  8201. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8202. * if vignetteEnabled is set to true.
  8203. */
  8204. vignetteColor: Color4;
  8205. /**
  8206. * Camera field of view used by the Vignette effect.
  8207. */
  8208. vignetteCameraFov: number;
  8209. private _vignetteBlendMode;
  8210. /**
  8211. * Gets the vignette blend mode allowing different kind of effect.
  8212. */
  8213. /**
  8214. * Sets the vignette blend mode allowing different kind of effect.
  8215. */
  8216. vignetteBlendMode: number;
  8217. private _vignetteEnabled;
  8218. /**
  8219. * Gets wether the vignette effect is enabled.
  8220. */
  8221. /**
  8222. * Sets wether the vignette effect is enabled.
  8223. */
  8224. vignetteEnabled: boolean;
  8225. private _applyByPostProcess;
  8226. /**
  8227. * Gets wether the image processing is applied through a post process or not.
  8228. */
  8229. /**
  8230. * Sets wether the image processing is applied through a post process or not.
  8231. */
  8232. applyByPostProcess: boolean;
  8233. private _isEnabled;
  8234. /**
  8235. * Gets wether the image processing is enabled or not.
  8236. */
  8237. /**
  8238. * Sets wether the image processing is enabled or not.
  8239. */
  8240. isEnabled: boolean;
  8241. /**
  8242. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8243. */
  8244. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8245. /**
  8246. * Method called each time the image processing information changes requires to recompile the effect.
  8247. */
  8248. protected _updateParameters(): void;
  8249. /**
  8250. * Gets the current class name.
  8251. * @return "ImageProcessingConfiguration"
  8252. */
  8253. getClassName(): string;
  8254. /**
  8255. * Prepare the list of uniforms associated with the Image Processing effects.
  8256. * @param uniforms The list of uniforms used in the effect
  8257. * @param defines the list of defines currently in use
  8258. */
  8259. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8260. /**
  8261. * Prepare the list of samplers associated with the Image Processing effects.
  8262. * @param samplersList The list of uniforms used in the effect
  8263. * @param defines the list of defines currently in use
  8264. */
  8265. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8266. /**
  8267. * Prepare the list of defines associated to the shader.
  8268. * @param defines the list of defines to complete
  8269. * @param forPostProcess Define if we are currently in post process mode or not
  8270. */
  8271. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8272. /**
  8273. * Returns true if all the image processing information are ready.
  8274. * @returns True if ready, otherwise, false
  8275. */
  8276. isReady(): boolean;
  8277. /**
  8278. * Binds the image processing to the shader.
  8279. * @param effect The effect to bind to
  8280. * @param aspectRatio Define the current aspect ratio of the effect
  8281. */
  8282. bind(effect: Effect, aspectRatio?: number): void;
  8283. /**
  8284. * Clones the current image processing instance.
  8285. * @return The cloned image processing
  8286. */
  8287. clone(): ImageProcessingConfiguration;
  8288. /**
  8289. * Serializes the current image processing instance to a json representation.
  8290. * @return a JSON representation
  8291. */
  8292. serialize(): any;
  8293. /**
  8294. * Parses the image processing from a json representation.
  8295. * @param source the JSON source to parse
  8296. * @return The parsed image processing
  8297. */
  8298. static Parse(source: any): ImageProcessingConfiguration;
  8299. private static _VIGNETTEMODE_MULTIPLY;
  8300. private static _VIGNETTEMODE_OPAQUE;
  8301. /**
  8302. * Used to apply the vignette as a mix with the pixel color.
  8303. */
  8304. static readonly VIGNETTEMODE_MULTIPLY: number;
  8305. /**
  8306. * Used to apply the vignette as a replacement of the pixel color.
  8307. */
  8308. static readonly VIGNETTEMODE_OPAQUE: number;
  8309. }
  8310. }
  8311. declare module "babylonjs/Shaders/postprocess.vertex" {
  8312. /** @hidden */
  8313. export var postprocessVertexShader: {
  8314. name: string;
  8315. shader: string;
  8316. };
  8317. }
  8318. declare module "babylonjs/Maths/math.axis" {
  8319. import { Vector3 } from "babylonjs/Maths/math.vector";
  8320. /** Defines supported spaces */
  8321. export enum Space {
  8322. /** Local (object) space */
  8323. LOCAL = 0,
  8324. /** World space */
  8325. WORLD = 1,
  8326. /** Bone space */
  8327. BONE = 2
  8328. }
  8329. /** Defines the 3 main axes */
  8330. export class Axis {
  8331. /** X axis */
  8332. static X: Vector3;
  8333. /** Y axis */
  8334. static Y: Vector3;
  8335. /** Z axis */
  8336. static Z: Vector3;
  8337. }
  8338. }
  8339. declare module "babylonjs/Cameras/targetCamera" {
  8340. import { Nullable } from "babylonjs/types";
  8341. import { Camera } from "babylonjs/Cameras/camera";
  8342. import { Scene } from "babylonjs/scene";
  8343. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8344. /**
  8345. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8346. * This is the base of the follow, arc rotate cameras and Free camera
  8347. * @see http://doc.babylonjs.com/features/cameras
  8348. */
  8349. export class TargetCamera extends Camera {
  8350. private static _RigCamTransformMatrix;
  8351. private static _TargetTransformMatrix;
  8352. private static _TargetFocalPoint;
  8353. /**
  8354. * Define the current direction the camera is moving to
  8355. */
  8356. cameraDirection: Vector3;
  8357. /**
  8358. * Define the current rotation the camera is rotating to
  8359. */
  8360. cameraRotation: Vector2;
  8361. /**
  8362. * When set, the up vector of the camera will be updated by the rotation of the camera
  8363. */
  8364. updateUpVectorFromRotation: boolean;
  8365. private _tmpQuaternion;
  8366. /**
  8367. * Define the current rotation of the camera
  8368. */
  8369. rotation: Vector3;
  8370. /**
  8371. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8372. */
  8373. rotationQuaternion: Quaternion;
  8374. /**
  8375. * Define the current speed of the camera
  8376. */
  8377. speed: number;
  8378. /**
  8379. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8380. * around all axis.
  8381. */
  8382. noRotationConstraint: boolean;
  8383. /**
  8384. * Define the current target of the camera as an object or a position.
  8385. */
  8386. lockedTarget: any;
  8387. /** @hidden */
  8388. _currentTarget: Vector3;
  8389. /** @hidden */
  8390. _initialFocalDistance: number;
  8391. /** @hidden */
  8392. _viewMatrix: Matrix;
  8393. /** @hidden */
  8394. _camMatrix: Matrix;
  8395. /** @hidden */
  8396. _cameraTransformMatrix: Matrix;
  8397. /** @hidden */
  8398. _cameraRotationMatrix: Matrix;
  8399. /** @hidden */
  8400. _referencePoint: Vector3;
  8401. /** @hidden */
  8402. _transformedReferencePoint: Vector3;
  8403. protected _globalCurrentTarget: Vector3;
  8404. protected _globalCurrentUpVector: Vector3;
  8405. /** @hidden */
  8406. _reset: () => void;
  8407. private _defaultUp;
  8408. /**
  8409. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8410. * This is the base of the follow, arc rotate cameras and Free camera
  8411. * @see http://doc.babylonjs.com/features/cameras
  8412. * @param name Defines the name of the camera in the scene
  8413. * @param position Defines the start position of the camera in the scene
  8414. * @param scene Defines the scene the camera belongs to
  8415. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8416. */
  8417. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8418. /**
  8419. * Gets the position in front of the camera at a given distance.
  8420. * @param distance The distance from the camera we want the position to be
  8421. * @returns the position
  8422. */
  8423. getFrontPosition(distance: number): Vector3;
  8424. /** @hidden */
  8425. _getLockedTargetPosition(): Nullable<Vector3>;
  8426. private _storedPosition;
  8427. private _storedRotation;
  8428. private _storedRotationQuaternion;
  8429. /**
  8430. * Store current camera state of the camera (fov, position, rotation, etc..)
  8431. * @returns the camera
  8432. */
  8433. storeState(): Camera;
  8434. /**
  8435. * Restored camera state. You must call storeState() first
  8436. * @returns whether it was successful or not
  8437. * @hidden
  8438. */
  8439. _restoreStateValues(): boolean;
  8440. /** @hidden */
  8441. _initCache(): void;
  8442. /** @hidden */
  8443. _updateCache(ignoreParentClass?: boolean): void;
  8444. /** @hidden */
  8445. _isSynchronizedViewMatrix(): boolean;
  8446. /** @hidden */
  8447. _computeLocalCameraSpeed(): number;
  8448. /**
  8449. * Defines the target the camera should look at.
  8450. * @param target Defines the new target as a Vector or a mesh
  8451. */
  8452. setTarget(target: Vector3): void;
  8453. /**
  8454. * Return the current target position of the camera. This value is expressed in local space.
  8455. * @returns the target position
  8456. */
  8457. getTarget(): Vector3;
  8458. /** @hidden */
  8459. _decideIfNeedsToMove(): boolean;
  8460. /** @hidden */
  8461. _updatePosition(): void;
  8462. /** @hidden */
  8463. _checkInputs(): void;
  8464. protected _updateCameraRotationMatrix(): void;
  8465. /**
  8466. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  8467. * @returns the current camera
  8468. */
  8469. private _rotateUpVectorWithCameraRotationMatrix;
  8470. private _cachedRotationZ;
  8471. private _cachedQuaternionRotationZ;
  8472. /** @hidden */
  8473. _getViewMatrix(): Matrix;
  8474. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8475. /**
  8476. * @hidden
  8477. */
  8478. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8479. /**
  8480. * @hidden
  8481. */
  8482. _updateRigCameras(): void;
  8483. private _getRigCamPositionAndTarget;
  8484. /**
  8485. * Gets the current object class name.
  8486. * @return the class name
  8487. */
  8488. getClassName(): string;
  8489. }
  8490. }
  8491. declare module "babylonjs/Events/keyboardEvents" {
  8492. /**
  8493. * Gather the list of keyboard event types as constants.
  8494. */
  8495. export class KeyboardEventTypes {
  8496. /**
  8497. * The keydown event is fired when a key becomes active (pressed).
  8498. */
  8499. static readonly KEYDOWN: number;
  8500. /**
  8501. * The keyup event is fired when a key has been released.
  8502. */
  8503. static readonly KEYUP: number;
  8504. }
  8505. /**
  8506. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8507. */
  8508. export class KeyboardInfo {
  8509. /**
  8510. * Defines the type of event (KeyboardEventTypes)
  8511. */
  8512. type: number;
  8513. /**
  8514. * Defines the related dom event
  8515. */
  8516. event: KeyboardEvent;
  8517. /**
  8518. * Instantiates a new keyboard info.
  8519. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8520. * @param type Defines the type of event (KeyboardEventTypes)
  8521. * @param event Defines the related dom event
  8522. */
  8523. constructor(
  8524. /**
  8525. * Defines the type of event (KeyboardEventTypes)
  8526. */
  8527. type: number,
  8528. /**
  8529. * Defines the related dom event
  8530. */
  8531. event: KeyboardEvent);
  8532. }
  8533. /**
  8534. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8535. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8536. */
  8537. export class KeyboardInfoPre extends KeyboardInfo {
  8538. /**
  8539. * Defines the type of event (KeyboardEventTypes)
  8540. */
  8541. type: number;
  8542. /**
  8543. * Defines the related dom event
  8544. */
  8545. event: KeyboardEvent;
  8546. /**
  8547. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8548. */
  8549. skipOnPointerObservable: boolean;
  8550. /**
  8551. * Instantiates a new keyboard pre info.
  8552. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8553. * @param type Defines the type of event (KeyboardEventTypes)
  8554. * @param event Defines the related dom event
  8555. */
  8556. constructor(
  8557. /**
  8558. * Defines the type of event (KeyboardEventTypes)
  8559. */
  8560. type: number,
  8561. /**
  8562. * Defines the related dom event
  8563. */
  8564. event: KeyboardEvent);
  8565. }
  8566. }
  8567. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8568. import { Nullable } from "babylonjs/types";
  8569. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8570. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8571. /**
  8572. * Manage the keyboard inputs to control the movement of a free camera.
  8573. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8574. */
  8575. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8576. /**
  8577. * Defines the camera the input is attached to.
  8578. */
  8579. camera: FreeCamera;
  8580. /**
  8581. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8582. */
  8583. keysUp: number[];
  8584. /**
  8585. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8586. */
  8587. keysDown: number[];
  8588. /**
  8589. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8590. */
  8591. keysLeft: number[];
  8592. /**
  8593. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8594. */
  8595. keysRight: number[];
  8596. private _keys;
  8597. private _onCanvasBlurObserver;
  8598. private _onKeyboardObserver;
  8599. private _engine;
  8600. private _scene;
  8601. /**
  8602. * Attach the input controls to a specific dom element to get the input from.
  8603. * @param element Defines the element the controls should be listened from
  8604. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8605. */
  8606. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8607. /**
  8608. * Detach the current controls from the specified dom element.
  8609. * @param element Defines the element to stop listening the inputs from
  8610. */
  8611. detachControl(element: Nullable<HTMLElement>): void;
  8612. /**
  8613. * Update the current camera state depending on the inputs that have been used this frame.
  8614. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8615. */
  8616. checkInputs(): void;
  8617. /**
  8618. * Gets the class name of the current intput.
  8619. * @returns the class name
  8620. */
  8621. getClassName(): string;
  8622. /** @hidden */
  8623. _onLostFocus(): void;
  8624. /**
  8625. * Get the friendly name associated with the input class.
  8626. * @returns the input friendly name
  8627. */
  8628. getSimpleName(): string;
  8629. }
  8630. }
  8631. declare module "babylonjs/Lights/shadowLight" {
  8632. import { Camera } from "babylonjs/Cameras/camera";
  8633. import { Scene } from "babylonjs/scene";
  8634. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8635. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8636. import { Light } from "babylonjs/Lights/light";
  8637. /**
  8638. * Interface describing all the common properties and methods a shadow light needs to implement.
  8639. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8640. * as well as binding the different shadow properties to the effects.
  8641. */
  8642. export interface IShadowLight extends Light {
  8643. /**
  8644. * The light id in the scene (used in scene.findLighById for instance)
  8645. */
  8646. id: string;
  8647. /**
  8648. * The position the shdow will be casted from.
  8649. */
  8650. position: Vector3;
  8651. /**
  8652. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8653. */
  8654. direction: Vector3;
  8655. /**
  8656. * The transformed position. Position of the light in world space taking parenting in account.
  8657. */
  8658. transformedPosition: Vector3;
  8659. /**
  8660. * The transformed direction. Direction of the light in world space taking parenting in account.
  8661. */
  8662. transformedDirection: Vector3;
  8663. /**
  8664. * The friendly name of the light in the scene.
  8665. */
  8666. name: string;
  8667. /**
  8668. * Defines the shadow projection clipping minimum z value.
  8669. */
  8670. shadowMinZ: number;
  8671. /**
  8672. * Defines the shadow projection clipping maximum z value.
  8673. */
  8674. shadowMaxZ: number;
  8675. /**
  8676. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8677. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8678. */
  8679. computeTransformedInformation(): boolean;
  8680. /**
  8681. * Gets the scene the light belongs to.
  8682. * @returns The scene
  8683. */
  8684. getScene(): Scene;
  8685. /**
  8686. * Callback defining a custom Projection Matrix Builder.
  8687. * This can be used to override the default projection matrix computation.
  8688. */
  8689. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8690. /**
  8691. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8692. * @param matrix The materix to updated with the projection information
  8693. * @param viewMatrix The transform matrix of the light
  8694. * @param renderList The list of mesh to render in the map
  8695. * @returns The current light
  8696. */
  8697. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8698. /**
  8699. * Gets the current depth scale used in ESM.
  8700. * @returns The scale
  8701. */
  8702. getDepthScale(): number;
  8703. /**
  8704. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8705. * @returns true if a cube texture needs to be use
  8706. */
  8707. needCube(): boolean;
  8708. /**
  8709. * Detects if the projection matrix requires to be recomputed this frame.
  8710. * @returns true if it requires to be recomputed otherwise, false.
  8711. */
  8712. needProjectionMatrixCompute(): boolean;
  8713. /**
  8714. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8715. */
  8716. forceProjectionMatrixCompute(): void;
  8717. /**
  8718. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8719. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8720. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8721. */
  8722. getShadowDirection(faceIndex?: number): Vector3;
  8723. /**
  8724. * Gets the minZ used for shadow according to both the scene and the light.
  8725. * @param activeCamera The camera we are returning the min for
  8726. * @returns the depth min z
  8727. */
  8728. getDepthMinZ(activeCamera: Camera): number;
  8729. /**
  8730. * Gets the maxZ used for shadow according to both the scene and the light.
  8731. * @param activeCamera The camera we are returning the max for
  8732. * @returns the depth max z
  8733. */
  8734. getDepthMaxZ(activeCamera: Camera): number;
  8735. }
  8736. /**
  8737. * Base implementation IShadowLight
  8738. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8739. */
  8740. export abstract class ShadowLight extends Light implements IShadowLight {
  8741. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8742. protected _position: Vector3;
  8743. protected _setPosition(value: Vector3): void;
  8744. /**
  8745. * Sets the position the shadow will be casted from. Also use as the light position for both
  8746. * point and spot lights.
  8747. */
  8748. /**
  8749. * Sets the position the shadow will be casted from. Also use as the light position for both
  8750. * point and spot lights.
  8751. */
  8752. position: Vector3;
  8753. protected _direction: Vector3;
  8754. protected _setDirection(value: Vector3): void;
  8755. /**
  8756. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8757. * Also use as the light direction on spot and directional lights.
  8758. */
  8759. /**
  8760. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8761. * Also use as the light direction on spot and directional lights.
  8762. */
  8763. direction: Vector3;
  8764. private _shadowMinZ;
  8765. /**
  8766. * Gets the shadow projection clipping minimum z value.
  8767. */
  8768. /**
  8769. * Sets the shadow projection clipping minimum z value.
  8770. */
  8771. shadowMinZ: number;
  8772. private _shadowMaxZ;
  8773. /**
  8774. * Sets the shadow projection clipping maximum z value.
  8775. */
  8776. /**
  8777. * Gets the shadow projection clipping maximum z value.
  8778. */
  8779. shadowMaxZ: number;
  8780. /**
  8781. * Callback defining a custom Projection Matrix Builder.
  8782. * This can be used to override the default projection matrix computation.
  8783. */
  8784. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8785. /**
  8786. * The transformed position. Position of the light in world space taking parenting in account.
  8787. */
  8788. transformedPosition: Vector3;
  8789. /**
  8790. * The transformed direction. Direction of the light in world space taking parenting in account.
  8791. */
  8792. transformedDirection: Vector3;
  8793. private _needProjectionMatrixCompute;
  8794. /**
  8795. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8796. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8797. */
  8798. computeTransformedInformation(): boolean;
  8799. /**
  8800. * Return the depth scale used for the shadow map.
  8801. * @returns the depth scale.
  8802. */
  8803. getDepthScale(): number;
  8804. /**
  8805. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8806. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8807. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8808. */
  8809. getShadowDirection(faceIndex?: number): Vector3;
  8810. /**
  8811. * Returns the ShadowLight absolute position in the World.
  8812. * @returns the position vector in world space
  8813. */
  8814. getAbsolutePosition(): Vector3;
  8815. /**
  8816. * Sets the ShadowLight direction toward the passed target.
  8817. * @param target The point to target in local space
  8818. * @returns the updated ShadowLight direction
  8819. */
  8820. setDirectionToTarget(target: Vector3): Vector3;
  8821. /**
  8822. * Returns the light rotation in euler definition.
  8823. * @returns the x y z rotation in local space.
  8824. */
  8825. getRotation(): Vector3;
  8826. /**
  8827. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8828. * @returns true if a cube texture needs to be use
  8829. */
  8830. needCube(): boolean;
  8831. /**
  8832. * Detects if the projection matrix requires to be recomputed this frame.
  8833. * @returns true if it requires to be recomputed otherwise, false.
  8834. */
  8835. needProjectionMatrixCompute(): boolean;
  8836. /**
  8837. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8838. */
  8839. forceProjectionMatrixCompute(): void;
  8840. /** @hidden */
  8841. _initCache(): void;
  8842. /** @hidden */
  8843. _isSynchronized(): boolean;
  8844. /**
  8845. * Computes the world matrix of the node
  8846. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8847. * @returns the world matrix
  8848. */
  8849. computeWorldMatrix(force?: boolean): Matrix;
  8850. /**
  8851. * Gets the minZ used for shadow according to both the scene and the light.
  8852. * @param activeCamera The camera we are returning the min for
  8853. * @returns the depth min z
  8854. */
  8855. getDepthMinZ(activeCamera: Camera): number;
  8856. /**
  8857. * Gets the maxZ used for shadow according to both the scene and the light.
  8858. * @param activeCamera The camera we are returning the max for
  8859. * @returns the depth max z
  8860. */
  8861. getDepthMaxZ(activeCamera: Camera): number;
  8862. /**
  8863. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8864. * @param matrix The materix to updated with the projection information
  8865. * @param viewMatrix The transform matrix of the light
  8866. * @param renderList The list of mesh to render in the map
  8867. * @returns The current light
  8868. */
  8869. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8870. }
  8871. }
  8872. declare module "babylonjs/Materials/materialHelper" {
  8873. import { Nullable } from "babylonjs/types";
  8874. import { Scene } from "babylonjs/scene";
  8875. import { Engine } from "babylonjs/Engines/engine";
  8876. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8877. import { Light } from "babylonjs/Lights/light";
  8878. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  8879. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  8880. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8881. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8882. /**
  8883. * "Static Class" containing the most commonly used helper while dealing with material for
  8884. * rendering purpose.
  8885. *
  8886. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8887. *
  8888. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8889. */
  8890. export class MaterialHelper {
  8891. /**
  8892. * Bind the current view position to an effect.
  8893. * @param effect The effect to be bound
  8894. * @param scene The scene the eyes position is used from
  8895. */
  8896. static BindEyePosition(effect: Effect, scene: Scene): void;
  8897. /**
  8898. * Helps preparing the defines values about the UVs in used in the effect.
  8899. * UVs are shared as much as we can accross channels in the shaders.
  8900. * @param texture The texture we are preparing the UVs for
  8901. * @param defines The defines to update
  8902. * @param key The channel key "diffuse", "specular"... used in the shader
  8903. */
  8904. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8905. /**
  8906. * Binds a texture matrix value to its corrsponding uniform
  8907. * @param texture The texture to bind the matrix for
  8908. * @param uniformBuffer The uniform buffer receivin the data
  8909. * @param key The channel key "diffuse", "specular"... used in the shader
  8910. */
  8911. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8912. /**
  8913. * Gets the current status of the fog (should it be enabled?)
  8914. * @param mesh defines the mesh to evaluate for fog support
  8915. * @param scene defines the hosting scene
  8916. * @returns true if fog must be enabled
  8917. */
  8918. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8919. /**
  8920. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8921. * @param mesh defines the current mesh
  8922. * @param scene defines the current scene
  8923. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8924. * @param pointsCloud defines if point cloud rendering has to be turned on
  8925. * @param fogEnabled defines if fog has to be turned on
  8926. * @param alphaTest defines if alpha testing has to be turned on
  8927. * @param defines defines the current list of defines
  8928. */
  8929. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8930. /**
  8931. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8932. * @param scene defines the current scene
  8933. * @param engine defines the current engine
  8934. * @param defines specifies the list of active defines
  8935. * @param useInstances defines if instances have to be turned on
  8936. * @param useClipPlane defines if clip plane have to be turned on
  8937. */
  8938. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8939. /**
  8940. * Prepares the defines for bones
  8941. * @param mesh The mesh containing the geometry data we will draw
  8942. * @param defines The defines to update
  8943. */
  8944. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  8945. /**
  8946. * Prepares the defines for morph targets
  8947. * @param mesh The mesh containing the geometry data we will draw
  8948. * @param defines The defines to update
  8949. */
  8950. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  8951. /**
  8952. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8953. * @param mesh The mesh containing the geometry data we will draw
  8954. * @param defines The defines to update
  8955. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8956. * @param useBones Precise whether bones should be used or not (override mesh info)
  8957. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8958. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8959. * @returns false if defines are considered not dirty and have not been checked
  8960. */
  8961. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8962. /**
  8963. * Prepares the defines related to multiview
  8964. * @param scene The scene we are intending to draw
  8965. * @param defines The defines to update
  8966. */
  8967. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  8968. /**
  8969. * Prepares the defines related to the light information passed in parameter
  8970. * @param scene The scene we are intending to draw
  8971. * @param mesh The mesh the effect is compiling for
  8972. * @param light The light the effect is compiling for
  8973. * @param lightIndex The index of the light
  8974. * @param defines The defines to update
  8975. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8976. * @param state Defines the current state regarding what is needed (normals, etc...)
  8977. */
  8978. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  8979. needNormals: boolean;
  8980. needRebuild: boolean;
  8981. shadowEnabled: boolean;
  8982. specularEnabled: boolean;
  8983. lightmapMode: boolean;
  8984. }): void;
  8985. /**
  8986. * Prepares the defines related to the light information passed in parameter
  8987. * @param scene The scene we are intending to draw
  8988. * @param mesh The mesh the effect is compiling for
  8989. * @param defines The defines to update
  8990. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8991. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  8992. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  8993. * @returns true if normals will be required for the rest of the effect
  8994. */
  8995. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  8996. /**
  8997. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  8998. * @param lightIndex defines the light index
  8999. * @param uniformsList The uniform list
  9000. * @param samplersList The sampler list
  9001. * @param projectedLightTexture defines if projected texture must be used
  9002. * @param uniformBuffersList defines an optional list of uniform buffers
  9003. */
  9004. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9005. /**
  9006. * Prepares the uniforms and samplers list to be used in the effect
  9007. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9008. * @param samplersList The sampler list
  9009. * @param defines The defines helping in the list generation
  9010. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9011. */
  9012. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9013. /**
  9014. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9015. * @param defines The defines to update while falling back
  9016. * @param fallbacks The authorized effect fallbacks
  9017. * @param maxSimultaneousLights The maximum number of lights allowed
  9018. * @param rank the current rank of the Effect
  9019. * @returns The newly affected rank
  9020. */
  9021. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9022. private static _TmpMorphInfluencers;
  9023. /**
  9024. * Prepares the list of attributes required for morph targets according to the effect defines.
  9025. * @param attribs The current list of supported attribs
  9026. * @param mesh The mesh to prepare the morph targets attributes for
  9027. * @param influencers The number of influencers
  9028. */
  9029. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9030. /**
  9031. * Prepares the list of attributes required for morph targets according to the effect defines.
  9032. * @param attribs The current list of supported attribs
  9033. * @param mesh The mesh to prepare the morph targets attributes for
  9034. * @param defines The current Defines of the effect
  9035. */
  9036. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9037. /**
  9038. * Prepares the list of attributes required for bones according to the effect defines.
  9039. * @param attribs The current list of supported attribs
  9040. * @param mesh The mesh to prepare the bones attributes for
  9041. * @param defines The current Defines of the effect
  9042. * @param fallbacks The current efffect fallback strategy
  9043. */
  9044. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9045. /**
  9046. * Check and prepare the list of attributes required for instances according to the effect defines.
  9047. * @param attribs The current list of supported attribs
  9048. * @param defines The current MaterialDefines of the effect
  9049. */
  9050. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9051. /**
  9052. * Add the list of attributes required for instances to the attribs array.
  9053. * @param attribs The current list of supported attribs
  9054. */
  9055. static PushAttributesForInstances(attribs: string[]): void;
  9056. /**
  9057. * Binds the light shadow information to the effect for the given mesh.
  9058. * @param light The light containing the generator
  9059. * @param scene The scene the lights belongs to
  9060. * @param mesh The mesh we are binding the information to render
  9061. * @param lightIndex The light index in the effect used to render the mesh
  9062. * @param effect The effect we are binding the data to
  9063. */
  9064. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9065. /**
  9066. * Binds the light information to the effect.
  9067. * @param light The light containing the generator
  9068. * @param effect The effect we are binding the data to
  9069. * @param lightIndex The light index in the effect used to render
  9070. */
  9071. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9072. /**
  9073. * Binds the lights information from the scene to the effect for the given mesh.
  9074. * @param light Light to bind
  9075. * @param lightIndex Light index
  9076. * @param scene The scene where the light belongs to
  9077. * @param mesh The mesh we are binding the information to render
  9078. * @param effect The effect we are binding the data to
  9079. * @param useSpecular Defines if specular is supported
  9080. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9081. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9082. */
  9083. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9084. /**
  9085. * Binds the lights information from the scene to the effect for the given mesh.
  9086. * @param scene The scene the lights belongs to
  9087. * @param mesh The mesh we are binding the information to render
  9088. * @param effect The effect we are binding the data to
  9089. * @param defines The generated defines for the effect
  9090. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9091. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9092. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9093. */
  9094. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9095. private static _tempFogColor;
  9096. /**
  9097. * Binds the fog information from the scene to the effect for the given mesh.
  9098. * @param scene The scene the lights belongs to
  9099. * @param mesh The mesh we are binding the information to render
  9100. * @param effect The effect we are binding the data to
  9101. * @param linearSpace Defines if the fog effect is applied in linear space
  9102. */
  9103. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9104. /**
  9105. * Binds the bones information from the mesh to the effect.
  9106. * @param mesh The mesh we are binding the information to render
  9107. * @param effect The effect we are binding the data to
  9108. */
  9109. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9110. /**
  9111. * Binds the morph targets information from the mesh to the effect.
  9112. * @param abstractMesh The mesh we are binding the information to render
  9113. * @param effect The effect we are binding the data to
  9114. */
  9115. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9116. /**
  9117. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9118. * @param defines The generated defines used in the effect
  9119. * @param effect The effect we are binding the data to
  9120. * @param scene The scene we are willing to render with logarithmic scale for
  9121. */
  9122. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9123. /**
  9124. * Binds the clip plane information from the scene to the effect.
  9125. * @param scene The scene the clip plane information are extracted from
  9126. * @param effect The effect we are binding the data to
  9127. */
  9128. static BindClipPlane(effect: Effect, scene: Scene): void;
  9129. }
  9130. }
  9131. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9132. /** @hidden */
  9133. export var packingFunctions: {
  9134. name: string;
  9135. shader: string;
  9136. };
  9137. }
  9138. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9139. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9140. /** @hidden */
  9141. export var shadowMapPixelShader: {
  9142. name: string;
  9143. shader: string;
  9144. };
  9145. }
  9146. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9147. /** @hidden */
  9148. export var bonesDeclaration: {
  9149. name: string;
  9150. shader: string;
  9151. };
  9152. }
  9153. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9154. /** @hidden */
  9155. export var morphTargetsVertexGlobalDeclaration: {
  9156. name: string;
  9157. shader: string;
  9158. };
  9159. }
  9160. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9161. /** @hidden */
  9162. export var morphTargetsVertexDeclaration: {
  9163. name: string;
  9164. shader: string;
  9165. };
  9166. }
  9167. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9168. /** @hidden */
  9169. export var instancesDeclaration: {
  9170. name: string;
  9171. shader: string;
  9172. };
  9173. }
  9174. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9175. /** @hidden */
  9176. export var helperFunctions: {
  9177. name: string;
  9178. shader: string;
  9179. };
  9180. }
  9181. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9182. /** @hidden */
  9183. export var morphTargetsVertex: {
  9184. name: string;
  9185. shader: string;
  9186. };
  9187. }
  9188. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9189. /** @hidden */
  9190. export var instancesVertex: {
  9191. name: string;
  9192. shader: string;
  9193. };
  9194. }
  9195. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9196. /** @hidden */
  9197. export var bonesVertex: {
  9198. name: string;
  9199. shader: string;
  9200. };
  9201. }
  9202. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9203. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9204. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9205. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9206. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9207. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9208. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9209. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9210. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9211. /** @hidden */
  9212. export var shadowMapVertexShader: {
  9213. name: string;
  9214. shader: string;
  9215. };
  9216. }
  9217. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9218. /** @hidden */
  9219. export var depthBoxBlurPixelShader: {
  9220. name: string;
  9221. shader: string;
  9222. };
  9223. }
  9224. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9225. import { Nullable } from "babylonjs/types";
  9226. import { Scene } from "babylonjs/scene";
  9227. import { Matrix } from "babylonjs/Maths/math.vector";
  9228. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9229. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9230. import { Mesh } from "babylonjs/Meshes/mesh";
  9231. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9232. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9233. import { Effect } from "babylonjs/Materials/effect";
  9234. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9235. import "babylonjs/Shaders/shadowMap.fragment";
  9236. import "babylonjs/Shaders/shadowMap.vertex";
  9237. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9238. import { Observable } from "babylonjs/Misc/observable";
  9239. /**
  9240. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9241. */
  9242. export interface ICustomShaderOptions {
  9243. /**
  9244. * Gets or sets the custom shader name to use
  9245. */
  9246. shaderName: string;
  9247. /**
  9248. * The list of attribute names used in the shader
  9249. */
  9250. attributes?: string[];
  9251. /**
  9252. * The list of unifrom names used in the shader
  9253. */
  9254. uniforms?: string[];
  9255. /**
  9256. * The list of sampler names used in the shader
  9257. */
  9258. samplers?: string[];
  9259. /**
  9260. * The list of defines used in the shader
  9261. */
  9262. defines?: string[];
  9263. }
  9264. /**
  9265. * Interface to implement to create a shadow generator compatible with BJS.
  9266. */
  9267. export interface IShadowGenerator {
  9268. /**
  9269. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9270. * @returns The render target texture if present otherwise, null
  9271. */
  9272. getShadowMap(): Nullable<RenderTargetTexture>;
  9273. /**
  9274. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9275. * @returns The render target texture if the shadow map is present otherwise, null
  9276. */
  9277. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9278. /**
  9279. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9280. * @param subMesh The submesh we want to render in the shadow map
  9281. * @param useInstances Defines wether will draw in the map using instances
  9282. * @returns true if ready otherwise, false
  9283. */
  9284. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9285. /**
  9286. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9287. * @param defines Defines of the material we want to update
  9288. * @param lightIndex Index of the light in the enabled light list of the material
  9289. */
  9290. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9291. /**
  9292. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9293. * defined in the generator but impacting the effect).
  9294. * It implies the unifroms available on the materials are the standard BJS ones.
  9295. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9296. * @param effect The effect we are binfing the information for
  9297. */
  9298. bindShadowLight(lightIndex: string, effect: Effect): void;
  9299. /**
  9300. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9301. * (eq to shadow prjection matrix * light transform matrix)
  9302. * @returns The transform matrix used to create the shadow map
  9303. */
  9304. getTransformMatrix(): Matrix;
  9305. /**
  9306. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9307. * Cube and 2D textures for instance.
  9308. */
  9309. recreateShadowMap(): void;
  9310. /**
  9311. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9312. * @param onCompiled Callback triggered at the and of the effects compilation
  9313. * @param options Sets of optional options forcing the compilation with different modes
  9314. */
  9315. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9316. useInstances: boolean;
  9317. }>): void;
  9318. /**
  9319. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9320. * @param options Sets of optional options forcing the compilation with different modes
  9321. * @returns A promise that resolves when the compilation completes
  9322. */
  9323. forceCompilationAsync(options?: Partial<{
  9324. useInstances: boolean;
  9325. }>): Promise<void>;
  9326. /**
  9327. * Serializes the shadow generator setup to a json object.
  9328. * @returns The serialized JSON object
  9329. */
  9330. serialize(): any;
  9331. /**
  9332. * Disposes the Shadow map and related Textures and effects.
  9333. */
  9334. dispose(): void;
  9335. }
  9336. /**
  9337. * Default implementation IShadowGenerator.
  9338. * This is the main object responsible of generating shadows in the framework.
  9339. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9340. */
  9341. export class ShadowGenerator implements IShadowGenerator {
  9342. /**
  9343. * Shadow generator mode None: no filtering applied.
  9344. */
  9345. static readonly FILTER_NONE: number;
  9346. /**
  9347. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9348. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9349. */
  9350. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9351. /**
  9352. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9353. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9354. */
  9355. static readonly FILTER_POISSONSAMPLING: number;
  9356. /**
  9357. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9358. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9359. */
  9360. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9361. /**
  9362. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9363. * edge artifacts on steep falloff.
  9364. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9365. */
  9366. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9367. /**
  9368. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9369. * edge artifacts on steep falloff.
  9370. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9371. */
  9372. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9373. /**
  9374. * Shadow generator mode PCF: Percentage Closer Filtering
  9375. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9376. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9377. */
  9378. static readonly FILTER_PCF: number;
  9379. /**
  9380. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9381. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9382. * Contact Hardening
  9383. */
  9384. static readonly FILTER_PCSS: number;
  9385. /**
  9386. * Reserved for PCF and PCSS
  9387. * Highest Quality.
  9388. *
  9389. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9390. *
  9391. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9392. */
  9393. static readonly QUALITY_HIGH: number;
  9394. /**
  9395. * Reserved for PCF and PCSS
  9396. * Good tradeoff for quality/perf cross devices
  9397. *
  9398. * Execute PCF on a 3*3 kernel.
  9399. *
  9400. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9401. */
  9402. static readonly QUALITY_MEDIUM: number;
  9403. /**
  9404. * Reserved for PCF and PCSS
  9405. * The lowest quality but the fastest.
  9406. *
  9407. * Execute PCF on a 1*1 kernel.
  9408. *
  9409. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9410. */
  9411. static readonly QUALITY_LOW: number;
  9412. /** Gets or sets the custom shader name to use */
  9413. customShaderOptions: ICustomShaderOptions;
  9414. /**
  9415. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9416. */
  9417. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9418. /**
  9419. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9420. */
  9421. onAfterShadowMapRenderObservable: Observable<Effect>;
  9422. /**
  9423. * Observable triggered before a mesh is rendered in the shadow map.
  9424. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9425. */
  9426. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9427. /**
  9428. * Observable triggered after a mesh is rendered in the shadow map.
  9429. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9430. */
  9431. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9432. private _bias;
  9433. /**
  9434. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9435. */
  9436. /**
  9437. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9438. */
  9439. bias: number;
  9440. private _normalBias;
  9441. /**
  9442. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9443. */
  9444. /**
  9445. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9446. */
  9447. normalBias: number;
  9448. private _blurBoxOffset;
  9449. /**
  9450. * Gets the blur box offset: offset applied during the blur pass.
  9451. * Only useful if useKernelBlur = false
  9452. */
  9453. /**
  9454. * Sets the blur box offset: offset applied during the blur pass.
  9455. * Only useful if useKernelBlur = false
  9456. */
  9457. blurBoxOffset: number;
  9458. private _blurScale;
  9459. /**
  9460. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9461. * 2 means half of the size.
  9462. */
  9463. /**
  9464. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9465. * 2 means half of the size.
  9466. */
  9467. blurScale: number;
  9468. private _blurKernel;
  9469. /**
  9470. * Gets the blur kernel: kernel size of the blur pass.
  9471. * Only useful if useKernelBlur = true
  9472. */
  9473. /**
  9474. * Sets the blur kernel: kernel size of the blur pass.
  9475. * Only useful if useKernelBlur = true
  9476. */
  9477. blurKernel: number;
  9478. private _useKernelBlur;
  9479. /**
  9480. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9481. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9482. */
  9483. /**
  9484. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9485. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9486. */
  9487. useKernelBlur: boolean;
  9488. private _depthScale;
  9489. /**
  9490. * Gets the depth scale used in ESM mode.
  9491. */
  9492. /**
  9493. * Sets the depth scale used in ESM mode.
  9494. * This can override the scale stored on the light.
  9495. */
  9496. depthScale: number;
  9497. private _filter;
  9498. /**
  9499. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9500. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9501. */
  9502. /**
  9503. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9504. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9505. */
  9506. filter: number;
  9507. /**
  9508. * Gets if the current filter is set to Poisson Sampling.
  9509. */
  9510. /**
  9511. * Sets the current filter to Poisson Sampling.
  9512. */
  9513. usePoissonSampling: boolean;
  9514. /**
  9515. * Gets if the current filter is set to ESM.
  9516. */
  9517. /**
  9518. * Sets the current filter is to ESM.
  9519. */
  9520. useExponentialShadowMap: boolean;
  9521. /**
  9522. * Gets if the current filter is set to filtered ESM.
  9523. */
  9524. /**
  9525. * Gets if the current filter is set to filtered ESM.
  9526. */
  9527. useBlurExponentialShadowMap: boolean;
  9528. /**
  9529. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9530. * exponential to prevent steep falloff artifacts).
  9531. */
  9532. /**
  9533. * Sets the current filter to "close ESM" (using the inverse of the
  9534. * exponential to prevent steep falloff artifacts).
  9535. */
  9536. useCloseExponentialShadowMap: boolean;
  9537. /**
  9538. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9539. * exponential to prevent steep falloff artifacts).
  9540. */
  9541. /**
  9542. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9543. * exponential to prevent steep falloff artifacts).
  9544. */
  9545. useBlurCloseExponentialShadowMap: boolean;
  9546. /**
  9547. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9548. */
  9549. /**
  9550. * Sets the current filter to "PCF" (percentage closer filtering).
  9551. */
  9552. usePercentageCloserFiltering: boolean;
  9553. private _filteringQuality;
  9554. /**
  9555. * Gets the PCF or PCSS Quality.
  9556. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9557. */
  9558. /**
  9559. * Sets the PCF or PCSS Quality.
  9560. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9561. */
  9562. filteringQuality: number;
  9563. /**
  9564. * Gets if the current filter is set to "PCSS" (contact hardening).
  9565. */
  9566. /**
  9567. * Sets the current filter to "PCSS" (contact hardening).
  9568. */
  9569. useContactHardeningShadow: boolean;
  9570. private _contactHardeningLightSizeUVRatio;
  9571. /**
  9572. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9573. * Using a ratio helps keeping shape stability independently of the map size.
  9574. *
  9575. * It does not account for the light projection as it was having too much
  9576. * instability during the light setup or during light position changes.
  9577. *
  9578. * Only valid if useContactHardeningShadow is true.
  9579. */
  9580. /**
  9581. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9582. * Using a ratio helps keeping shape stability independently of the map size.
  9583. *
  9584. * It does not account for the light projection as it was having too much
  9585. * instability during the light setup or during light position changes.
  9586. *
  9587. * Only valid if useContactHardeningShadow is true.
  9588. */
  9589. contactHardeningLightSizeUVRatio: number;
  9590. private _darkness;
  9591. /** Gets or sets the actual darkness of a shadow */
  9592. darkness: number;
  9593. /**
  9594. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9595. * 0 means strongest and 1 would means no shadow.
  9596. * @returns the darkness.
  9597. */
  9598. getDarkness(): number;
  9599. /**
  9600. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9601. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9602. * @returns the shadow generator allowing fluent coding.
  9603. */
  9604. setDarkness(darkness: number): ShadowGenerator;
  9605. private _transparencyShadow;
  9606. /** Gets or sets the ability to have transparent shadow */
  9607. transparencyShadow: boolean;
  9608. /**
  9609. * Sets the ability to have transparent shadow (boolean).
  9610. * @param transparent True if transparent else False
  9611. * @returns the shadow generator allowing fluent coding
  9612. */
  9613. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9614. private _shadowMap;
  9615. private _shadowMap2;
  9616. /**
  9617. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9618. * @returns The render target texture if present otherwise, null
  9619. */
  9620. getShadowMap(): Nullable<RenderTargetTexture>;
  9621. /**
  9622. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9623. * @returns The render target texture if the shadow map is present otherwise, null
  9624. */
  9625. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9626. /**
  9627. * Gets the class name of that object
  9628. * @returns "ShadowGenerator"
  9629. */
  9630. getClassName(): string;
  9631. /**
  9632. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9633. * @param mesh Mesh to add
  9634. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9635. * @returns the Shadow Generator itself
  9636. */
  9637. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9638. /**
  9639. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9640. * @param mesh Mesh to remove
  9641. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9642. * @returns the Shadow Generator itself
  9643. */
  9644. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9645. /**
  9646. * Controls the extent to which the shadows fade out at the edge of the frustum
  9647. * Used only by directionals and spots
  9648. */
  9649. frustumEdgeFalloff: number;
  9650. private _light;
  9651. /**
  9652. * Returns the associated light object.
  9653. * @returns the light generating the shadow
  9654. */
  9655. getLight(): IShadowLight;
  9656. /**
  9657. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9658. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9659. * It might on the other hand introduce peter panning.
  9660. */
  9661. forceBackFacesOnly: boolean;
  9662. private _scene;
  9663. private _lightDirection;
  9664. private _effect;
  9665. private _viewMatrix;
  9666. private _projectionMatrix;
  9667. private _transformMatrix;
  9668. private _cachedPosition;
  9669. private _cachedDirection;
  9670. private _cachedDefines;
  9671. private _currentRenderID;
  9672. private _boxBlurPostprocess;
  9673. private _kernelBlurXPostprocess;
  9674. private _kernelBlurYPostprocess;
  9675. private _blurPostProcesses;
  9676. private _mapSize;
  9677. private _currentFaceIndex;
  9678. private _currentFaceIndexCache;
  9679. private _textureType;
  9680. private _defaultTextureMatrix;
  9681. /** @hidden */
  9682. static _SceneComponentInitialization: (scene: Scene) => void;
  9683. /**
  9684. * Creates a ShadowGenerator object.
  9685. * A ShadowGenerator is the required tool to use the shadows.
  9686. * Each light casting shadows needs to use its own ShadowGenerator.
  9687. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9688. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9689. * @param light The light object generating the shadows.
  9690. * @param usefulFloatFirst By default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture.
  9691. */
  9692. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9693. private _initializeGenerator;
  9694. private _initializeShadowMap;
  9695. private _initializeBlurRTTAndPostProcesses;
  9696. private _renderForShadowMap;
  9697. private _renderSubMeshForShadowMap;
  9698. private _applyFilterValues;
  9699. /**
  9700. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9701. * @param onCompiled Callback triggered at the and of the effects compilation
  9702. * @param options Sets of optional options forcing the compilation with different modes
  9703. */
  9704. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9705. useInstances: boolean;
  9706. }>): void;
  9707. /**
  9708. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9709. * @param options Sets of optional options forcing the compilation with different modes
  9710. * @returns A promise that resolves when the compilation completes
  9711. */
  9712. forceCompilationAsync(options?: Partial<{
  9713. useInstances: boolean;
  9714. }>): Promise<void>;
  9715. /**
  9716. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9717. * @param subMesh The submesh we want to render in the shadow map
  9718. * @param useInstances Defines wether will draw in the map using instances
  9719. * @returns true if ready otherwise, false
  9720. */
  9721. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9722. /**
  9723. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9724. * @param defines Defines of the material we want to update
  9725. * @param lightIndex Index of the light in the enabled light list of the material
  9726. */
  9727. prepareDefines(defines: any, lightIndex: number): void;
  9728. /**
  9729. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9730. * defined in the generator but impacting the effect).
  9731. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9732. * @param effect The effect we are binfing the information for
  9733. */
  9734. bindShadowLight(lightIndex: string, effect: Effect): void;
  9735. /**
  9736. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9737. * (eq to shadow prjection matrix * light transform matrix)
  9738. * @returns The transform matrix used to create the shadow map
  9739. */
  9740. getTransformMatrix(): Matrix;
  9741. /**
  9742. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9743. * Cube and 2D textures for instance.
  9744. */
  9745. recreateShadowMap(): void;
  9746. private _disposeBlurPostProcesses;
  9747. private _disposeRTTandPostProcesses;
  9748. /**
  9749. * Disposes the ShadowGenerator.
  9750. * Returns nothing.
  9751. */
  9752. dispose(): void;
  9753. /**
  9754. * Serializes the shadow generator setup to a json object.
  9755. * @returns The serialized JSON object
  9756. */
  9757. serialize(): any;
  9758. /**
  9759. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9760. * @param parsedShadowGenerator The JSON object to parse
  9761. * @param scene The scene to create the shadow map for
  9762. * @returns The parsed shadow generator
  9763. */
  9764. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9765. }
  9766. }
  9767. declare module "babylonjs/Lights/light" {
  9768. import { Nullable } from "babylonjs/types";
  9769. import { Scene } from "babylonjs/scene";
  9770. import { Vector3 } from "babylonjs/Maths/math.vector";
  9771. import { Color3 } from "babylonjs/Maths/math.color";
  9772. import { Node } from "babylonjs/node";
  9773. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9774. import { Effect } from "babylonjs/Materials/effect";
  9775. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9776. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9777. /**
  9778. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9779. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9780. * All meshes allow light to pass through them unless shadow generation is activated. The default number of lights allowed is four but this can be increased.
  9781. */
  9782. export abstract class Light extends Node {
  9783. /**
  9784. * Falloff Default: light is falling off following the material specification:
  9785. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9786. */
  9787. static readonly FALLOFF_DEFAULT: number;
  9788. /**
  9789. * Falloff Physical: light is falling off following the inverse squared distance law.
  9790. */
  9791. static readonly FALLOFF_PHYSICAL: number;
  9792. /**
  9793. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9794. * to enhance interoperability with other engines.
  9795. */
  9796. static readonly FALLOFF_GLTF: number;
  9797. /**
  9798. * Falloff Standard: light is falling off like in the standard material
  9799. * to enhance interoperability with other materials.
  9800. */
  9801. static readonly FALLOFF_STANDARD: number;
  9802. /**
  9803. * If every light affecting the material is in this lightmapMode,
  9804. * material.lightmapTexture adds or multiplies
  9805. * (depends on material.useLightmapAsShadowmap)
  9806. * after every other light calculations.
  9807. */
  9808. static readonly LIGHTMAP_DEFAULT: number;
  9809. /**
  9810. * material.lightmapTexture as only diffuse lighting from this light
  9811. * adds only specular lighting from this light
  9812. * adds dynamic shadows
  9813. */
  9814. static readonly LIGHTMAP_SPECULAR: number;
  9815. /**
  9816. * material.lightmapTexture as only lighting
  9817. * no light calculation from this light
  9818. * only adds dynamic shadows from this light
  9819. */
  9820. static readonly LIGHTMAP_SHADOWSONLY: number;
  9821. /**
  9822. * Each light type uses the default quantity according to its type:
  9823. * point/spot lights use luminous intensity
  9824. * directional lights use illuminance
  9825. */
  9826. static readonly INTENSITYMODE_AUTOMATIC: number;
  9827. /**
  9828. * lumen (lm)
  9829. */
  9830. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9831. /**
  9832. * candela (lm/sr)
  9833. */
  9834. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9835. /**
  9836. * lux (lm/m^2)
  9837. */
  9838. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9839. /**
  9840. * nit (cd/m^2)
  9841. */
  9842. static readonly INTENSITYMODE_LUMINANCE: number;
  9843. /**
  9844. * Light type const id of the point light.
  9845. */
  9846. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9847. /**
  9848. * Light type const id of the directional light.
  9849. */
  9850. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9851. /**
  9852. * Light type const id of the spot light.
  9853. */
  9854. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9855. /**
  9856. * Light type const id of the hemispheric light.
  9857. */
  9858. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9859. /**
  9860. * Diffuse gives the basic color to an object.
  9861. */
  9862. diffuse: Color3;
  9863. /**
  9864. * Specular produces a highlight color on an object.
  9865. * Note: This is note affecting PBR materials.
  9866. */
  9867. specular: Color3;
  9868. /**
  9869. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9870. * falling off base on range or angle.
  9871. * This can be set to any values in Light.FALLOFF_x.
  9872. *
  9873. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9874. * other types of materials.
  9875. */
  9876. falloffType: number;
  9877. /**
  9878. * Strength of the light.
  9879. * Note: By default it is define in the framework own unit.
  9880. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9881. */
  9882. intensity: number;
  9883. private _range;
  9884. protected _inverseSquaredRange: number;
  9885. /**
  9886. * Defines how far from the source the light is impacting in scene units.
  9887. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9888. */
  9889. /**
  9890. * Defines how far from the source the light is impacting in scene units.
  9891. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9892. */
  9893. range: number;
  9894. /**
  9895. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9896. * of light.
  9897. */
  9898. private _photometricScale;
  9899. private _intensityMode;
  9900. /**
  9901. * Gets the photometric scale used to interpret the intensity.
  9902. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9903. */
  9904. /**
  9905. * Sets the photometric scale used to interpret the intensity.
  9906. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9907. */
  9908. intensityMode: number;
  9909. private _radius;
  9910. /**
  9911. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9912. */
  9913. /**
  9914. * sets the light radius used by PBR Materials to simulate soft area lights.
  9915. */
  9916. radius: number;
  9917. private _renderPriority;
  9918. /**
  9919. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9920. * exceeding the number allowed of the materials.
  9921. */
  9922. renderPriority: number;
  9923. private _shadowEnabled;
  9924. /**
  9925. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9926. * the current shadow generator.
  9927. */
  9928. /**
  9929. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9930. * the current shadow generator.
  9931. */
  9932. shadowEnabled: boolean;
  9933. private _includedOnlyMeshes;
  9934. /**
  9935. * Gets the only meshes impacted by this light.
  9936. */
  9937. /**
  9938. * Sets the only meshes impacted by this light.
  9939. */
  9940. includedOnlyMeshes: AbstractMesh[];
  9941. private _excludedMeshes;
  9942. /**
  9943. * Gets the meshes not impacted by this light.
  9944. */
  9945. /**
  9946. * Sets the meshes not impacted by this light.
  9947. */
  9948. excludedMeshes: AbstractMesh[];
  9949. private _excludeWithLayerMask;
  9950. /**
  9951. * Gets the layer id use to find what meshes are not impacted by the light.
  9952. * Inactive if 0
  9953. */
  9954. /**
  9955. * Sets the layer id use to find what meshes are not impacted by the light.
  9956. * Inactive if 0
  9957. */
  9958. excludeWithLayerMask: number;
  9959. private _includeOnlyWithLayerMask;
  9960. /**
  9961. * Gets the layer id use to find what meshes are impacted by the light.
  9962. * Inactive if 0
  9963. */
  9964. /**
  9965. * Sets the layer id use to find what meshes are impacted by the light.
  9966. * Inactive if 0
  9967. */
  9968. includeOnlyWithLayerMask: number;
  9969. private _lightmapMode;
  9970. /**
  9971. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9972. */
  9973. /**
  9974. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9975. */
  9976. lightmapMode: number;
  9977. /**
  9978. * Shadow generator associted to the light.
  9979. * @hidden Internal use only.
  9980. */
  9981. _shadowGenerator: Nullable<IShadowGenerator>;
  9982. /**
  9983. * @hidden Internal use only.
  9984. */
  9985. _excludedMeshesIds: string[];
  9986. /**
  9987. * @hidden Internal use only.
  9988. */
  9989. _includedOnlyMeshesIds: string[];
  9990. /**
  9991. * The current light unifom buffer.
  9992. * @hidden Internal use only.
  9993. */
  9994. _uniformBuffer: UniformBuffer;
  9995. /**
  9996. * Creates a Light object in the scene.
  9997. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9998. * @param name The firendly name of the light
  9999. * @param scene The scene the light belongs too
  10000. */
  10001. constructor(name: string, scene: Scene);
  10002. protected abstract _buildUniformLayout(): void;
  10003. /**
  10004. * Sets the passed Effect "effect" with the Light information.
  10005. * @param effect The effect to update
  10006. * @param lightIndex The index of the light in the effect to update
  10007. * @returns The light
  10008. */
  10009. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10010. /**
  10011. * Sets the passed Effect "effect" with the Light information.
  10012. * @param effect The effect to update
  10013. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10014. * @returns The light
  10015. */
  10016. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10017. /**
  10018. * Returns the string "Light".
  10019. * @returns the class name
  10020. */
  10021. getClassName(): string;
  10022. /** @hidden */
  10023. readonly _isLight: boolean;
  10024. /**
  10025. * Converts the light information to a readable string for debug purpose.
  10026. * @param fullDetails Supports for multiple levels of logging within scene loading
  10027. * @returns the human readable light info
  10028. */
  10029. toString(fullDetails?: boolean): string;
  10030. /** @hidden */
  10031. protected _syncParentEnabledState(): void;
  10032. /**
  10033. * Set the enabled state of this node.
  10034. * @param value - the new enabled state
  10035. */
  10036. setEnabled(value: boolean): void;
  10037. /**
  10038. * Returns the Light associated shadow generator if any.
  10039. * @return the associated shadow generator.
  10040. */
  10041. getShadowGenerator(): Nullable<IShadowGenerator>;
  10042. /**
  10043. * Returns a Vector3, the absolute light position in the World.
  10044. * @returns the world space position of the light
  10045. */
  10046. getAbsolutePosition(): Vector3;
  10047. /**
  10048. * Specifies if the light will affect the passed mesh.
  10049. * @param mesh The mesh to test against the light
  10050. * @return true the mesh is affected otherwise, false.
  10051. */
  10052. canAffectMesh(mesh: AbstractMesh): boolean;
  10053. /**
  10054. * Sort function to order lights for rendering.
  10055. * @param a First Light object to compare to second.
  10056. * @param b Second Light object to compare first.
  10057. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10058. */
  10059. static CompareLightsPriority(a: Light, b: Light): number;
  10060. /**
  10061. * Releases resources associated with this node.
  10062. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10063. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10064. */
  10065. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10066. /**
  10067. * Returns the light type ID (integer).
  10068. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10069. */
  10070. getTypeID(): number;
  10071. /**
  10072. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10073. * @returns the scaled intensity in intensity mode unit
  10074. */
  10075. getScaledIntensity(): number;
  10076. /**
  10077. * Returns a new Light object, named "name", from the current one.
  10078. * @param name The name of the cloned light
  10079. * @returns the new created light
  10080. */
  10081. clone(name: string): Nullable<Light>;
  10082. /**
  10083. * Serializes the current light into a Serialization object.
  10084. * @returns the serialized object.
  10085. */
  10086. serialize(): any;
  10087. /**
  10088. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10089. * This new light is named "name" and added to the passed scene.
  10090. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10091. * @param name The friendly name of the light
  10092. * @param scene The scene the new light will belong to
  10093. * @returns the constructor function
  10094. */
  10095. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10096. /**
  10097. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10098. * @param parsedLight The JSON representation of the light
  10099. * @param scene The scene to create the parsed light in
  10100. * @returns the created light after parsing
  10101. */
  10102. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10103. private _hookArrayForExcluded;
  10104. private _hookArrayForIncludedOnly;
  10105. private _resyncMeshes;
  10106. /**
  10107. * Forces the meshes to update their light related information in their rendering used effects
  10108. * @hidden Internal Use Only
  10109. */
  10110. _markMeshesAsLightDirty(): void;
  10111. /**
  10112. * Recomputes the cached photometric scale if needed.
  10113. */
  10114. private _computePhotometricScale;
  10115. /**
  10116. * Returns the Photometric Scale according to the light type and intensity mode.
  10117. */
  10118. private _getPhotometricScale;
  10119. /**
  10120. * Reorder the light in the scene according to their defined priority.
  10121. * @hidden Internal Use Only
  10122. */
  10123. _reorderLightsInScene(): void;
  10124. /**
  10125. * Prepares the list of defines specific to the light type.
  10126. * @param defines the list of defines
  10127. * @param lightIndex defines the index of the light for the effect
  10128. */
  10129. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10130. }
  10131. }
  10132. declare module "babylonjs/Actions/action" {
  10133. import { Observable } from "babylonjs/Misc/observable";
  10134. import { Condition } from "babylonjs/Actions/condition";
  10135. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10136. import { ActionManager } from "babylonjs/Actions/actionManager";
  10137. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10138. /**
  10139. * Interface used to define Action
  10140. */
  10141. export interface IAction {
  10142. /**
  10143. * Trigger for the action
  10144. */
  10145. trigger: number;
  10146. /** Options of the trigger */
  10147. triggerOptions: any;
  10148. /**
  10149. * Gets the trigger parameters
  10150. * @returns the trigger parameters
  10151. */
  10152. getTriggerParameter(): any;
  10153. /**
  10154. * Internal only - executes current action event
  10155. * @hidden
  10156. */
  10157. _executeCurrent(evt?: ActionEvent): void;
  10158. /**
  10159. * Serialize placeholder for child classes
  10160. * @param parent of child
  10161. * @returns the serialized object
  10162. */
  10163. serialize(parent: any): any;
  10164. /**
  10165. * Internal only
  10166. * @hidden
  10167. */
  10168. _prepare(): void;
  10169. /**
  10170. * Internal only - manager for action
  10171. * @hidden
  10172. */
  10173. _actionManager: AbstractActionManager;
  10174. /**
  10175. * Adds action to chain of actions, may be a DoNothingAction
  10176. * @param action defines the next action to execute
  10177. * @returns The action passed in
  10178. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10179. */
  10180. then(action: IAction): IAction;
  10181. }
  10182. /**
  10183. * The action to be carried out following a trigger
  10184. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10185. */
  10186. export class Action implements IAction {
  10187. /** the trigger, with or without parameters, for the action */
  10188. triggerOptions: any;
  10189. /**
  10190. * Trigger for the action
  10191. */
  10192. trigger: number;
  10193. /**
  10194. * Internal only - manager for action
  10195. * @hidden
  10196. */
  10197. _actionManager: ActionManager;
  10198. private _nextActiveAction;
  10199. private _child;
  10200. private _condition?;
  10201. private _triggerParameter;
  10202. /**
  10203. * An event triggered prior to action being executed.
  10204. */
  10205. onBeforeExecuteObservable: Observable<Action>;
  10206. /**
  10207. * Creates a new Action
  10208. * @param triggerOptions the trigger, with or without parameters, for the action
  10209. * @param condition an optional determinant of action
  10210. */
  10211. constructor(
  10212. /** the trigger, with or without parameters, for the action */
  10213. triggerOptions: any, condition?: Condition);
  10214. /**
  10215. * Internal only
  10216. * @hidden
  10217. */
  10218. _prepare(): void;
  10219. /**
  10220. * Gets the trigger parameters
  10221. * @returns the trigger parameters
  10222. */
  10223. getTriggerParameter(): any;
  10224. /**
  10225. * Internal only - executes current action event
  10226. * @hidden
  10227. */
  10228. _executeCurrent(evt?: ActionEvent): void;
  10229. /**
  10230. * Execute placeholder for child classes
  10231. * @param evt optional action event
  10232. */
  10233. execute(evt?: ActionEvent): void;
  10234. /**
  10235. * Skips to next active action
  10236. */
  10237. skipToNextActiveAction(): void;
  10238. /**
  10239. * Adds action to chain of actions, may be a DoNothingAction
  10240. * @param action defines the next action to execute
  10241. * @returns The action passed in
  10242. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10243. */
  10244. then(action: Action): Action;
  10245. /**
  10246. * Internal only
  10247. * @hidden
  10248. */
  10249. _getProperty(propertyPath: string): string;
  10250. /**
  10251. * Internal only
  10252. * @hidden
  10253. */
  10254. _getEffectiveTarget(target: any, propertyPath: string): any;
  10255. /**
  10256. * Serialize placeholder for child classes
  10257. * @param parent of child
  10258. * @returns the serialized object
  10259. */
  10260. serialize(parent: any): any;
  10261. /**
  10262. * Internal only called by serialize
  10263. * @hidden
  10264. */
  10265. protected _serialize(serializedAction: any, parent?: any): any;
  10266. /**
  10267. * Internal only
  10268. * @hidden
  10269. */
  10270. static _SerializeValueAsString: (value: any) => string;
  10271. /**
  10272. * Internal only
  10273. * @hidden
  10274. */
  10275. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10276. name: string;
  10277. targetType: string;
  10278. value: string;
  10279. };
  10280. }
  10281. }
  10282. declare module "babylonjs/Actions/condition" {
  10283. import { ActionManager } from "babylonjs/Actions/actionManager";
  10284. /**
  10285. * A Condition applied to an Action
  10286. */
  10287. export class Condition {
  10288. /**
  10289. * Internal only - manager for action
  10290. * @hidden
  10291. */
  10292. _actionManager: ActionManager;
  10293. /**
  10294. * Internal only
  10295. * @hidden
  10296. */
  10297. _evaluationId: number;
  10298. /**
  10299. * Internal only
  10300. * @hidden
  10301. */
  10302. _currentResult: boolean;
  10303. /**
  10304. * Creates a new Condition
  10305. * @param actionManager the manager of the action the condition is applied to
  10306. */
  10307. constructor(actionManager: ActionManager);
  10308. /**
  10309. * Check if the current condition is valid
  10310. * @returns a boolean
  10311. */
  10312. isValid(): boolean;
  10313. /**
  10314. * Internal only
  10315. * @hidden
  10316. */
  10317. _getProperty(propertyPath: string): string;
  10318. /**
  10319. * Internal only
  10320. * @hidden
  10321. */
  10322. _getEffectiveTarget(target: any, propertyPath: string): any;
  10323. /**
  10324. * Serialize placeholder for child classes
  10325. * @returns the serialized object
  10326. */
  10327. serialize(): any;
  10328. /**
  10329. * Internal only
  10330. * @hidden
  10331. */
  10332. protected _serialize(serializedCondition: any): any;
  10333. }
  10334. /**
  10335. * Defines specific conditional operators as extensions of Condition
  10336. */
  10337. export class ValueCondition extends Condition {
  10338. /** path to specify the property of the target the conditional operator uses */
  10339. propertyPath: string;
  10340. /** the value compared by the conditional operator against the current value of the property */
  10341. value: any;
  10342. /** the conditional operator, default ValueCondition.IsEqual */
  10343. operator: number;
  10344. /**
  10345. * Internal only
  10346. * @hidden
  10347. */
  10348. private static _IsEqual;
  10349. /**
  10350. * Internal only
  10351. * @hidden
  10352. */
  10353. private static _IsDifferent;
  10354. /**
  10355. * Internal only
  10356. * @hidden
  10357. */
  10358. private static _IsGreater;
  10359. /**
  10360. * Internal only
  10361. * @hidden
  10362. */
  10363. private static _IsLesser;
  10364. /**
  10365. * returns the number for IsEqual
  10366. */
  10367. static readonly IsEqual: number;
  10368. /**
  10369. * Returns the number for IsDifferent
  10370. */
  10371. static readonly IsDifferent: number;
  10372. /**
  10373. * Returns the number for IsGreater
  10374. */
  10375. static readonly IsGreater: number;
  10376. /**
  10377. * Returns the number for IsLesser
  10378. */
  10379. static readonly IsLesser: number;
  10380. /**
  10381. * Internal only The action manager for the condition
  10382. * @hidden
  10383. */
  10384. _actionManager: ActionManager;
  10385. /**
  10386. * Internal only
  10387. * @hidden
  10388. */
  10389. private _target;
  10390. /**
  10391. * Internal only
  10392. * @hidden
  10393. */
  10394. private _effectiveTarget;
  10395. /**
  10396. * Internal only
  10397. * @hidden
  10398. */
  10399. private _property;
  10400. /**
  10401. * Creates a new ValueCondition
  10402. * @param actionManager manager for the action the condition applies to
  10403. * @param target for the action
  10404. * @param propertyPath path to specify the property of the target the conditional operator uses
  10405. * @param value the value compared by the conditional operator against the current value of the property
  10406. * @param operator the conditional operator, default ValueCondition.IsEqual
  10407. */
  10408. constructor(actionManager: ActionManager, target: any,
  10409. /** path to specify the property of the target the conditional operator uses */
  10410. propertyPath: string,
  10411. /** the value compared by the conditional operator against the current value of the property */
  10412. value: any,
  10413. /** the conditional operator, default ValueCondition.IsEqual */
  10414. operator?: number);
  10415. /**
  10416. * Compares the given value with the property value for the specified conditional operator
  10417. * @returns the result of the comparison
  10418. */
  10419. isValid(): boolean;
  10420. /**
  10421. * Serialize the ValueCondition into a JSON compatible object
  10422. * @returns serialization object
  10423. */
  10424. serialize(): any;
  10425. /**
  10426. * Gets the name of the conditional operator for the ValueCondition
  10427. * @param operator the conditional operator
  10428. * @returns the name
  10429. */
  10430. static GetOperatorName(operator: number): string;
  10431. }
  10432. /**
  10433. * Defines a predicate condition as an extension of Condition
  10434. */
  10435. export class PredicateCondition extends Condition {
  10436. /** defines the predicate function used to validate the condition */
  10437. predicate: () => boolean;
  10438. /**
  10439. * Internal only - manager for action
  10440. * @hidden
  10441. */
  10442. _actionManager: ActionManager;
  10443. /**
  10444. * Creates a new PredicateCondition
  10445. * @param actionManager manager for the action the condition applies to
  10446. * @param predicate defines the predicate function used to validate the condition
  10447. */
  10448. constructor(actionManager: ActionManager,
  10449. /** defines the predicate function used to validate the condition */
  10450. predicate: () => boolean);
  10451. /**
  10452. * @returns the validity of the predicate condition
  10453. */
  10454. isValid(): boolean;
  10455. }
  10456. /**
  10457. * Defines a state condition as an extension of Condition
  10458. */
  10459. export class StateCondition extends Condition {
  10460. /** Value to compare with target state */
  10461. value: string;
  10462. /**
  10463. * Internal only - manager for action
  10464. * @hidden
  10465. */
  10466. _actionManager: ActionManager;
  10467. /**
  10468. * Internal only
  10469. * @hidden
  10470. */
  10471. private _target;
  10472. /**
  10473. * Creates a new StateCondition
  10474. * @param actionManager manager for the action the condition applies to
  10475. * @param target of the condition
  10476. * @param value to compare with target state
  10477. */
  10478. constructor(actionManager: ActionManager, target: any,
  10479. /** Value to compare with target state */
  10480. value: string);
  10481. /**
  10482. * Gets a boolean indicating if the current condition is met
  10483. * @returns the validity of the state
  10484. */
  10485. isValid(): boolean;
  10486. /**
  10487. * Serialize the StateCondition into a JSON compatible object
  10488. * @returns serialization object
  10489. */
  10490. serialize(): any;
  10491. }
  10492. }
  10493. declare module "babylonjs/Actions/directActions" {
  10494. import { Action } from "babylonjs/Actions/action";
  10495. import { Condition } from "babylonjs/Actions/condition";
  10496. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10497. /**
  10498. * This defines an action responsible to toggle a boolean once triggered.
  10499. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10500. */
  10501. export class SwitchBooleanAction extends Action {
  10502. /**
  10503. * The path to the boolean property in the target object
  10504. */
  10505. propertyPath: string;
  10506. private _target;
  10507. private _effectiveTarget;
  10508. private _property;
  10509. /**
  10510. * Instantiate the action
  10511. * @param triggerOptions defines the trigger options
  10512. * @param target defines the object containing the boolean
  10513. * @param propertyPath defines the path to the boolean property in the target object
  10514. * @param condition defines the trigger related conditions
  10515. */
  10516. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10517. /** @hidden */
  10518. _prepare(): void;
  10519. /**
  10520. * Execute the action toggle the boolean value.
  10521. */
  10522. execute(): void;
  10523. /**
  10524. * Serializes the actions and its related information.
  10525. * @param parent defines the object to serialize in
  10526. * @returns the serialized object
  10527. */
  10528. serialize(parent: any): any;
  10529. }
  10530. /**
  10531. * This defines an action responsible to set a the state field of the target
  10532. * to a desired value once triggered.
  10533. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10534. */
  10535. export class SetStateAction extends Action {
  10536. /**
  10537. * The value to store in the state field.
  10538. */
  10539. value: string;
  10540. private _target;
  10541. /**
  10542. * Instantiate the action
  10543. * @param triggerOptions defines the trigger options
  10544. * @param target defines the object containing the state property
  10545. * @param value defines the value to store in the state field
  10546. * @param condition defines the trigger related conditions
  10547. */
  10548. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10549. /**
  10550. * Execute the action and store the value on the target state property.
  10551. */
  10552. execute(): void;
  10553. /**
  10554. * Serializes the actions and its related information.
  10555. * @param parent defines the object to serialize in
  10556. * @returns the serialized object
  10557. */
  10558. serialize(parent: any): any;
  10559. }
  10560. /**
  10561. * This defines an action responsible to set a property of the target
  10562. * to a desired value once triggered.
  10563. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10564. */
  10565. export class SetValueAction extends Action {
  10566. /**
  10567. * The path of the property to set in the target.
  10568. */
  10569. propertyPath: string;
  10570. /**
  10571. * The value to set in the property
  10572. */
  10573. value: any;
  10574. private _target;
  10575. private _effectiveTarget;
  10576. private _property;
  10577. /**
  10578. * Instantiate the action
  10579. * @param triggerOptions defines the trigger options
  10580. * @param target defines the object containing the property
  10581. * @param propertyPath defines the path of the property to set in the target
  10582. * @param value defines the value to set in the property
  10583. * @param condition defines the trigger related conditions
  10584. */
  10585. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10586. /** @hidden */
  10587. _prepare(): void;
  10588. /**
  10589. * Execute the action and set the targetted property to the desired value.
  10590. */
  10591. execute(): void;
  10592. /**
  10593. * Serializes the actions and its related information.
  10594. * @param parent defines the object to serialize in
  10595. * @returns the serialized object
  10596. */
  10597. serialize(parent: any): any;
  10598. }
  10599. /**
  10600. * This defines an action responsible to increment the target value
  10601. * to a desired value once triggered.
  10602. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10603. */
  10604. export class IncrementValueAction extends Action {
  10605. /**
  10606. * The path of the property to increment in the target.
  10607. */
  10608. propertyPath: string;
  10609. /**
  10610. * The value we should increment the property by.
  10611. */
  10612. value: any;
  10613. private _target;
  10614. private _effectiveTarget;
  10615. private _property;
  10616. /**
  10617. * Instantiate the action
  10618. * @param triggerOptions defines the trigger options
  10619. * @param target defines the object containing the property
  10620. * @param propertyPath defines the path of the property to increment in the target
  10621. * @param value defines the value value we should increment the property by
  10622. * @param condition defines the trigger related conditions
  10623. */
  10624. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10625. /** @hidden */
  10626. _prepare(): void;
  10627. /**
  10628. * Execute the action and increment the target of the value amount.
  10629. */
  10630. execute(): void;
  10631. /**
  10632. * Serializes the actions and its related information.
  10633. * @param parent defines the object to serialize in
  10634. * @returns the serialized object
  10635. */
  10636. serialize(parent: any): any;
  10637. }
  10638. /**
  10639. * This defines an action responsible to start an animation once triggered.
  10640. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10641. */
  10642. export class PlayAnimationAction extends Action {
  10643. /**
  10644. * Where the animation should start (animation frame)
  10645. */
  10646. from: number;
  10647. /**
  10648. * Where the animation should stop (animation frame)
  10649. */
  10650. to: number;
  10651. /**
  10652. * Define if the animation should loop or stop after the first play.
  10653. */
  10654. loop?: boolean;
  10655. private _target;
  10656. /**
  10657. * Instantiate the action
  10658. * @param triggerOptions defines the trigger options
  10659. * @param target defines the target animation or animation name
  10660. * @param from defines from where the animation should start (animation frame)
  10661. * @param end defines where the animation should stop (animation frame)
  10662. * @param loop defines if the animation should loop or stop after the first play
  10663. * @param condition defines the trigger related conditions
  10664. */
  10665. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10666. /** @hidden */
  10667. _prepare(): void;
  10668. /**
  10669. * Execute the action and play the animation.
  10670. */
  10671. execute(): void;
  10672. /**
  10673. * Serializes the actions and its related information.
  10674. * @param parent defines the object to serialize in
  10675. * @returns the serialized object
  10676. */
  10677. serialize(parent: any): any;
  10678. }
  10679. /**
  10680. * This defines an action responsible to stop an animation once triggered.
  10681. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10682. */
  10683. export class StopAnimationAction extends Action {
  10684. private _target;
  10685. /**
  10686. * Instantiate the action
  10687. * @param triggerOptions defines the trigger options
  10688. * @param target defines the target animation or animation name
  10689. * @param condition defines the trigger related conditions
  10690. */
  10691. constructor(triggerOptions: any, target: any, condition?: Condition);
  10692. /** @hidden */
  10693. _prepare(): void;
  10694. /**
  10695. * Execute the action and stop the animation.
  10696. */
  10697. execute(): void;
  10698. /**
  10699. * Serializes the actions and its related information.
  10700. * @param parent defines the object to serialize in
  10701. * @returns the serialized object
  10702. */
  10703. serialize(parent: any): any;
  10704. }
  10705. /**
  10706. * This defines an action responsible that does nothing once triggered.
  10707. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10708. */
  10709. export class DoNothingAction extends Action {
  10710. /**
  10711. * Instantiate the action
  10712. * @param triggerOptions defines the trigger options
  10713. * @param condition defines the trigger related conditions
  10714. */
  10715. constructor(triggerOptions?: any, condition?: Condition);
  10716. /**
  10717. * Execute the action and do nothing.
  10718. */
  10719. execute(): void;
  10720. /**
  10721. * Serializes the actions and its related information.
  10722. * @param parent defines the object to serialize in
  10723. * @returns the serialized object
  10724. */
  10725. serialize(parent: any): any;
  10726. }
  10727. /**
  10728. * This defines an action responsible to trigger several actions once triggered.
  10729. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10730. */
  10731. export class CombineAction extends Action {
  10732. /**
  10733. * The list of aggregated animations to run.
  10734. */
  10735. children: Action[];
  10736. /**
  10737. * Instantiate the action
  10738. * @param triggerOptions defines the trigger options
  10739. * @param children defines the list of aggregated animations to run
  10740. * @param condition defines the trigger related conditions
  10741. */
  10742. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10743. /** @hidden */
  10744. _prepare(): void;
  10745. /**
  10746. * Execute the action and executes all the aggregated actions.
  10747. */
  10748. execute(evt: ActionEvent): void;
  10749. /**
  10750. * Serializes the actions and its related information.
  10751. * @param parent defines the object to serialize in
  10752. * @returns the serialized object
  10753. */
  10754. serialize(parent: any): any;
  10755. }
  10756. /**
  10757. * This defines an action responsible to run code (external event) once triggered.
  10758. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10759. */
  10760. export class ExecuteCodeAction extends Action {
  10761. /**
  10762. * The callback function to run.
  10763. */
  10764. func: (evt: ActionEvent) => void;
  10765. /**
  10766. * Instantiate the action
  10767. * @param triggerOptions defines the trigger options
  10768. * @param func defines the callback function to run
  10769. * @param condition defines the trigger related conditions
  10770. */
  10771. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10772. /**
  10773. * Execute the action and run the attached code.
  10774. */
  10775. execute(evt: ActionEvent): void;
  10776. }
  10777. /**
  10778. * This defines an action responsible to set the parent property of the target once triggered.
  10779. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10780. */
  10781. export class SetParentAction extends Action {
  10782. private _parent;
  10783. private _target;
  10784. /**
  10785. * Instantiate the action
  10786. * @param triggerOptions defines the trigger options
  10787. * @param target defines the target containing the parent property
  10788. * @param parent defines from where the animation should start (animation frame)
  10789. * @param condition defines the trigger related conditions
  10790. */
  10791. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10792. /** @hidden */
  10793. _prepare(): void;
  10794. /**
  10795. * Execute the action and set the parent property.
  10796. */
  10797. execute(): void;
  10798. /**
  10799. * Serializes the actions and its related information.
  10800. * @param parent defines the object to serialize in
  10801. * @returns the serialized object
  10802. */
  10803. serialize(parent: any): any;
  10804. }
  10805. }
  10806. declare module "babylonjs/Actions/actionManager" {
  10807. import { Nullable } from "babylonjs/types";
  10808. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10809. import { Scene } from "babylonjs/scene";
  10810. import { IAction } from "babylonjs/Actions/action";
  10811. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10812. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10813. /**
  10814. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10815. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10816. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10817. */
  10818. export class ActionManager extends AbstractActionManager {
  10819. /**
  10820. * Nothing
  10821. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10822. */
  10823. static readonly NothingTrigger: number;
  10824. /**
  10825. * On pick
  10826. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10827. */
  10828. static readonly OnPickTrigger: number;
  10829. /**
  10830. * On left pick
  10831. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10832. */
  10833. static readonly OnLeftPickTrigger: number;
  10834. /**
  10835. * On right pick
  10836. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10837. */
  10838. static readonly OnRightPickTrigger: number;
  10839. /**
  10840. * On center pick
  10841. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10842. */
  10843. static readonly OnCenterPickTrigger: number;
  10844. /**
  10845. * On pick down
  10846. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10847. */
  10848. static readonly OnPickDownTrigger: number;
  10849. /**
  10850. * On double pick
  10851. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10852. */
  10853. static readonly OnDoublePickTrigger: number;
  10854. /**
  10855. * On pick up
  10856. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10857. */
  10858. static readonly OnPickUpTrigger: number;
  10859. /**
  10860. * On pick out.
  10861. * This trigger will only be raised if you also declared a OnPickDown
  10862. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10863. */
  10864. static readonly OnPickOutTrigger: number;
  10865. /**
  10866. * On long press
  10867. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10868. */
  10869. static readonly OnLongPressTrigger: number;
  10870. /**
  10871. * On pointer over
  10872. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10873. */
  10874. static readonly OnPointerOverTrigger: number;
  10875. /**
  10876. * On pointer out
  10877. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10878. */
  10879. static readonly OnPointerOutTrigger: number;
  10880. /**
  10881. * On every frame
  10882. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10883. */
  10884. static readonly OnEveryFrameTrigger: number;
  10885. /**
  10886. * On intersection enter
  10887. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10888. */
  10889. static readonly OnIntersectionEnterTrigger: number;
  10890. /**
  10891. * On intersection exit
  10892. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10893. */
  10894. static readonly OnIntersectionExitTrigger: number;
  10895. /**
  10896. * On key down
  10897. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10898. */
  10899. static readonly OnKeyDownTrigger: number;
  10900. /**
  10901. * On key up
  10902. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10903. */
  10904. static readonly OnKeyUpTrigger: number;
  10905. private _scene;
  10906. /**
  10907. * Creates a new action manager
  10908. * @param scene defines the hosting scene
  10909. */
  10910. constructor(scene: Scene);
  10911. /**
  10912. * Releases all associated resources
  10913. */
  10914. dispose(): void;
  10915. /**
  10916. * Gets hosting scene
  10917. * @returns the hosting scene
  10918. */
  10919. getScene(): Scene;
  10920. /**
  10921. * Does this action manager handles actions of any of the given triggers
  10922. * @param triggers defines the triggers to be tested
  10923. * @return a boolean indicating whether one (or more) of the triggers is handled
  10924. */
  10925. hasSpecificTriggers(triggers: number[]): boolean;
  10926. /**
  10927. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10928. * speed.
  10929. * @param triggerA defines the trigger to be tested
  10930. * @param triggerB defines the trigger to be tested
  10931. * @return a boolean indicating whether one (or more) of the triggers is handled
  10932. */
  10933. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10934. /**
  10935. * Does this action manager handles actions of a given trigger
  10936. * @param trigger defines the trigger to be tested
  10937. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10938. * @return whether the trigger is handled
  10939. */
  10940. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10941. /**
  10942. * Does this action manager has pointer triggers
  10943. */
  10944. readonly hasPointerTriggers: boolean;
  10945. /**
  10946. * Does this action manager has pick triggers
  10947. */
  10948. readonly hasPickTriggers: boolean;
  10949. /**
  10950. * Registers an action to this action manager
  10951. * @param action defines the action to be registered
  10952. * @return the action amended (prepared) after registration
  10953. */
  10954. registerAction(action: IAction): Nullable<IAction>;
  10955. /**
  10956. * Unregisters an action to this action manager
  10957. * @param action defines the action to be unregistered
  10958. * @return a boolean indicating whether the action has been unregistered
  10959. */
  10960. unregisterAction(action: IAction): Boolean;
  10961. /**
  10962. * Process a specific trigger
  10963. * @param trigger defines the trigger to process
  10964. * @param evt defines the event details to be processed
  10965. */
  10966. processTrigger(trigger: number, evt?: IActionEvent): void;
  10967. /** @hidden */
  10968. _getEffectiveTarget(target: any, propertyPath: string): any;
  10969. /** @hidden */
  10970. _getProperty(propertyPath: string): string;
  10971. /**
  10972. * Serialize this manager to a JSON object
  10973. * @param name defines the property name to store this manager
  10974. * @returns a JSON representation of this manager
  10975. */
  10976. serialize(name: string): any;
  10977. /**
  10978. * Creates a new ActionManager from a JSON data
  10979. * @param parsedActions defines the JSON data to read from
  10980. * @param object defines the hosting mesh
  10981. * @param scene defines the hosting scene
  10982. */
  10983. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10984. /**
  10985. * Get a trigger name by index
  10986. * @param trigger defines the trigger index
  10987. * @returns a trigger name
  10988. */
  10989. static GetTriggerName(trigger: number): string;
  10990. }
  10991. }
  10992. declare module "babylonjs/Culling/ray" {
  10993. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10994. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10995. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10996. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10997. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10998. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10999. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11000. import { Plane } from "babylonjs/Maths/math.plane";
  11001. /**
  11002. * Class representing a ray with position and direction
  11003. */
  11004. export class Ray {
  11005. /** origin point */
  11006. origin: Vector3;
  11007. /** direction */
  11008. direction: Vector3;
  11009. /** length of the ray */
  11010. length: number;
  11011. private static readonly TmpVector3;
  11012. private _tmpRay;
  11013. /**
  11014. * Creates a new ray
  11015. * @param origin origin point
  11016. * @param direction direction
  11017. * @param length length of the ray
  11018. */
  11019. constructor(
  11020. /** origin point */
  11021. origin: Vector3,
  11022. /** direction */
  11023. direction: Vector3,
  11024. /** length of the ray */
  11025. length?: number);
  11026. /**
  11027. * Checks if the ray intersects a box
  11028. * @param minimum bound of the box
  11029. * @param maximum bound of the box
  11030. * @param intersectionTreshold extra extend to be added to the box in all direction
  11031. * @returns if the box was hit
  11032. */
  11033. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11034. /**
  11035. * Checks if the ray intersects a box
  11036. * @param box the bounding box to check
  11037. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11038. * @returns if the box was hit
  11039. */
  11040. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11041. /**
  11042. * If the ray hits a sphere
  11043. * @param sphere the bounding sphere to check
  11044. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11045. * @returns true if it hits the sphere
  11046. */
  11047. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11048. /**
  11049. * If the ray hits a triange
  11050. * @param vertex0 triangle vertex
  11051. * @param vertex1 triangle vertex
  11052. * @param vertex2 triangle vertex
  11053. * @returns intersection information if hit
  11054. */
  11055. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11056. /**
  11057. * Checks if ray intersects a plane
  11058. * @param plane the plane to check
  11059. * @returns the distance away it was hit
  11060. */
  11061. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11062. /**
  11063. * Calculate the intercept of a ray on a given axis
  11064. * @param axis to check 'x' | 'y' | 'z'
  11065. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11066. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11067. */
  11068. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11069. /**
  11070. * Checks if ray intersects a mesh
  11071. * @param mesh the mesh to check
  11072. * @param fastCheck if only the bounding box should checked
  11073. * @returns picking info of the intersecton
  11074. */
  11075. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11076. /**
  11077. * Checks if ray intersects a mesh
  11078. * @param meshes the meshes to check
  11079. * @param fastCheck if only the bounding box should checked
  11080. * @param results array to store result in
  11081. * @returns Array of picking infos
  11082. */
  11083. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11084. private _comparePickingInfo;
  11085. private static smallnum;
  11086. private static rayl;
  11087. /**
  11088. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11089. * @param sega the first point of the segment to test the intersection against
  11090. * @param segb the second point of the segment to test the intersection against
  11091. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11092. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11093. */
  11094. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11095. /**
  11096. * Update the ray from viewport position
  11097. * @param x position
  11098. * @param y y position
  11099. * @param viewportWidth viewport width
  11100. * @param viewportHeight viewport height
  11101. * @param world world matrix
  11102. * @param view view matrix
  11103. * @param projection projection matrix
  11104. * @returns this ray updated
  11105. */
  11106. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11107. /**
  11108. * Creates a ray with origin and direction of 0,0,0
  11109. * @returns the new ray
  11110. */
  11111. static Zero(): Ray;
  11112. /**
  11113. * Creates a new ray from screen space and viewport
  11114. * @param x position
  11115. * @param y y position
  11116. * @param viewportWidth viewport width
  11117. * @param viewportHeight viewport height
  11118. * @param world world matrix
  11119. * @param view view matrix
  11120. * @param projection projection matrix
  11121. * @returns new ray
  11122. */
  11123. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11124. /**
  11125. * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
  11126. * transformed to the given world matrix.
  11127. * @param origin The origin point
  11128. * @param end The end point
  11129. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11130. * @returns the new ray
  11131. */
  11132. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11133. /**
  11134. * Transforms a ray by a matrix
  11135. * @param ray ray to transform
  11136. * @param matrix matrix to apply
  11137. * @returns the resulting new ray
  11138. */
  11139. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11140. /**
  11141. * Transforms a ray by a matrix
  11142. * @param ray ray to transform
  11143. * @param matrix matrix to apply
  11144. * @param result ray to store result in
  11145. */
  11146. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11147. /**
  11148. * Unproject a ray from screen space to object space
  11149. * @param sourceX defines the screen space x coordinate to use
  11150. * @param sourceY defines the screen space y coordinate to use
  11151. * @param viewportWidth defines the current width of the viewport
  11152. * @param viewportHeight defines the current height of the viewport
  11153. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11154. * @param view defines the view matrix to use
  11155. * @param projection defines the projection matrix to use
  11156. */
  11157. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11158. }
  11159. /**
  11160. * Type used to define predicate used to select faces when a mesh intersection is detected
  11161. */
  11162. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11163. module "babylonjs/scene" {
  11164. interface Scene {
  11165. /** @hidden */
  11166. _tempPickingRay: Nullable<Ray>;
  11167. /** @hidden */
  11168. _cachedRayForTransform: Ray;
  11169. /** @hidden */
  11170. _pickWithRayInverseMatrix: Matrix;
  11171. /** @hidden */
  11172. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11173. /** @hidden */
  11174. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11175. }
  11176. }
  11177. }
  11178. declare module "babylonjs/sceneComponent" {
  11179. import { Scene } from "babylonjs/scene";
  11180. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11181. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11182. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11183. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11184. import { Nullable } from "babylonjs/types";
  11185. import { Camera } from "babylonjs/Cameras/camera";
  11186. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11187. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11188. import { AbstractScene } from "babylonjs/abstractScene";
  11189. /**
  11190. * Groups all the scene component constants in one place to ease maintenance.
  11191. * @hidden
  11192. */
  11193. export class SceneComponentConstants {
  11194. static readonly NAME_EFFECTLAYER: string;
  11195. static readonly NAME_LAYER: string;
  11196. static readonly NAME_LENSFLARESYSTEM: string;
  11197. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11198. static readonly NAME_PARTICLESYSTEM: string;
  11199. static readonly NAME_GAMEPAD: string;
  11200. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11201. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11202. static readonly NAME_DEPTHRENDERER: string;
  11203. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11204. static readonly NAME_SPRITE: string;
  11205. static readonly NAME_OUTLINERENDERER: string;
  11206. static readonly NAME_PROCEDURALTEXTURE: string;
  11207. static readonly NAME_SHADOWGENERATOR: string;
  11208. static readonly NAME_OCTREE: string;
  11209. static readonly NAME_PHYSICSENGINE: string;
  11210. static readonly NAME_AUDIO: string;
  11211. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11212. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11213. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11214. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11215. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11216. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11217. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11218. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11219. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11220. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11221. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11222. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11223. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11224. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11225. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11226. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11227. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11228. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11229. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11230. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11231. static readonly STEP_AFTERRENDER_AUDIO: number;
  11232. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11233. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11234. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11235. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11236. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11237. static readonly STEP_POINTERMOVE_SPRITE: number;
  11238. static readonly STEP_POINTERDOWN_SPRITE: number;
  11239. static readonly STEP_POINTERUP_SPRITE: number;
  11240. }
  11241. /**
  11242. * This represents a scene component.
  11243. *
  11244. * This is used to decouple the dependency the scene is having on the different workloads like
  11245. * layers, post processes...
  11246. */
  11247. export interface ISceneComponent {
  11248. /**
  11249. * The name of the component. Each component must have a unique name.
  11250. */
  11251. name: string;
  11252. /**
  11253. * The scene the component belongs to.
  11254. */
  11255. scene: Scene;
  11256. /**
  11257. * Register the component to one instance of a scene.
  11258. */
  11259. register(): void;
  11260. /**
  11261. * Rebuilds the elements related to this component in case of
  11262. * context lost for instance.
  11263. */
  11264. rebuild(): void;
  11265. /**
  11266. * Disposes the component and the associated ressources.
  11267. */
  11268. dispose(): void;
  11269. }
  11270. /**
  11271. * This represents a SERIALIZABLE scene component.
  11272. *
  11273. * This extends Scene Component to add Serialization methods on top.
  11274. */
  11275. export interface ISceneSerializableComponent extends ISceneComponent {
  11276. /**
  11277. * Adds all the elements from the container to the scene
  11278. * @param container the container holding the elements
  11279. */
  11280. addFromContainer(container: AbstractScene): void;
  11281. /**
  11282. * Removes all the elements in the container from the scene
  11283. * @param container contains the elements to remove
  11284. * @param dispose if the removed element should be disposed (default: false)
  11285. */
  11286. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11287. /**
  11288. * Serializes the component data to the specified json object
  11289. * @param serializationObject The object to serialize to
  11290. */
  11291. serialize(serializationObject: any): void;
  11292. }
  11293. /**
  11294. * Strong typing of a Mesh related stage step action
  11295. */
  11296. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11297. /**
  11298. * Strong typing of a Evaluate Sub Mesh related stage step action
  11299. */
  11300. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11301. /**
  11302. * Strong typing of a Active Mesh related stage step action
  11303. */
  11304. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11305. /**
  11306. * Strong typing of a Camera related stage step action
  11307. */
  11308. export type CameraStageAction = (camera: Camera) => void;
  11309. /**
  11310. * Strong typing of a Camera Frame buffer related stage step action
  11311. */
  11312. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11313. /**
  11314. * Strong typing of a Render Target related stage step action
  11315. */
  11316. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11317. /**
  11318. * Strong typing of a RenderingGroup related stage step action
  11319. */
  11320. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11321. /**
  11322. * Strong typing of a Mesh Render related stage step action
  11323. */
  11324. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11325. /**
  11326. * Strong typing of a simple stage step action
  11327. */
  11328. export type SimpleStageAction = () => void;
  11329. /**
  11330. * Strong typing of a render target action.
  11331. */
  11332. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11333. /**
  11334. * Strong typing of a pointer move action.
  11335. */
  11336. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11337. /**
  11338. * Strong typing of a pointer up/down action.
  11339. */
  11340. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11341. /**
  11342. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11343. * @hidden
  11344. */
  11345. export class Stage<T extends Function> extends Array<{
  11346. index: number;
  11347. component: ISceneComponent;
  11348. action: T;
  11349. }> {
  11350. /**
  11351. * Hide ctor from the rest of the world.
  11352. * @param items The items to add.
  11353. */
  11354. private constructor();
  11355. /**
  11356. * Creates a new Stage.
  11357. * @returns A new instance of a Stage
  11358. */
  11359. static Create<T extends Function>(): Stage<T>;
  11360. /**
  11361. * Registers a step in an ordered way in the targeted stage.
  11362. * @param index Defines the position to register the step in
  11363. * @param component Defines the component attached to the step
  11364. * @param action Defines the action to launch during the step
  11365. */
  11366. registerStep(index: number, component: ISceneComponent, action: T): void;
  11367. /**
  11368. * Clears all the steps from the stage.
  11369. */
  11370. clear(): void;
  11371. }
  11372. }
  11373. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11374. import { Nullable } from "babylonjs/types";
  11375. import { Observable } from "babylonjs/Misc/observable";
  11376. import { Scene } from "babylonjs/scene";
  11377. import { Sprite } from "babylonjs/Sprites/sprite";
  11378. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11379. import { Ray } from "babylonjs/Culling/ray";
  11380. import { Camera } from "babylonjs/Cameras/camera";
  11381. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11382. import { ISceneComponent } from "babylonjs/sceneComponent";
  11383. module "babylonjs/scene" {
  11384. interface Scene {
  11385. /** @hidden */
  11386. _pointerOverSprite: Nullable<Sprite>;
  11387. /** @hidden */
  11388. _pickedDownSprite: Nullable<Sprite>;
  11389. /** @hidden */
  11390. _tempSpritePickingRay: Nullable<Ray>;
  11391. /**
  11392. * All of the sprite managers added to this scene
  11393. * @see http://doc.babylonjs.com/babylon101/sprites
  11394. */
  11395. spriteManagers: Array<ISpriteManager>;
  11396. /**
  11397. * An event triggered when sprites rendering is about to start
  11398. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11399. */
  11400. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11401. /**
  11402. * An event triggered when sprites rendering is done
  11403. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11404. */
  11405. onAfterSpritesRenderingObservable: Observable<Scene>;
  11406. /** @hidden */
  11407. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11408. /** Launch a ray to try to pick a sprite in the scene
  11409. * @param x position on screen
  11410. * @param y position on screen
  11411. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11412. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11413. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11414. * @returns a PickingInfo
  11415. */
  11416. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11417. /** Use the given ray to pick a sprite in the scene
  11418. * @param ray The ray (in world space) to use to pick meshes
  11419. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11420. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11421. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11422. * @returns a PickingInfo
  11423. */
  11424. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11425. /** @hidden */
  11426. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11427. /** Launch a ray to try to pick sprites in the scene
  11428. * @param x position on screen
  11429. * @param y position on screen
  11430. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11431. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11432. * @returns a PickingInfo array
  11433. */
  11434. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11435. /** Use the given ray to pick sprites in the scene
  11436. * @param ray The ray (in world space) to use to pick meshes
  11437. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11438. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11439. * @returns a PickingInfo array
  11440. */
  11441. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11442. /**
  11443. * Force the sprite under the pointer
  11444. * @param sprite defines the sprite to use
  11445. */
  11446. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11447. /**
  11448. * Gets the sprite under the pointer
  11449. * @returns a Sprite or null if no sprite is under the pointer
  11450. */
  11451. getPointerOverSprite(): Nullable<Sprite>;
  11452. }
  11453. }
  11454. /**
  11455. * Defines the sprite scene component responsible to manage sprites
  11456. * in a given scene.
  11457. */
  11458. export class SpriteSceneComponent implements ISceneComponent {
  11459. /**
  11460. * The component name helpfull to identify the component in the list of scene components.
  11461. */
  11462. readonly name: string;
  11463. /**
  11464. * The scene the component belongs to.
  11465. */
  11466. scene: Scene;
  11467. /** @hidden */
  11468. private _spritePredicate;
  11469. /**
  11470. * Creates a new instance of the component for the given scene
  11471. * @param scene Defines the scene to register the component in
  11472. */
  11473. constructor(scene: Scene);
  11474. /**
  11475. * Registers the component in a given scene
  11476. */
  11477. register(): void;
  11478. /**
  11479. * Rebuilds the elements related to this component in case of
  11480. * context lost for instance.
  11481. */
  11482. rebuild(): void;
  11483. /**
  11484. * Disposes the component and the associated ressources.
  11485. */
  11486. dispose(): void;
  11487. private _pickSpriteButKeepRay;
  11488. private _pointerMove;
  11489. private _pointerDown;
  11490. private _pointerUp;
  11491. }
  11492. }
  11493. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11494. /** @hidden */
  11495. export var fogFragmentDeclaration: {
  11496. name: string;
  11497. shader: string;
  11498. };
  11499. }
  11500. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11501. /** @hidden */
  11502. export var fogFragment: {
  11503. name: string;
  11504. shader: string;
  11505. };
  11506. }
  11507. declare module "babylonjs/Shaders/sprites.fragment" {
  11508. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11509. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11510. /** @hidden */
  11511. export var spritesPixelShader: {
  11512. name: string;
  11513. shader: string;
  11514. };
  11515. }
  11516. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11517. /** @hidden */
  11518. export var fogVertexDeclaration: {
  11519. name: string;
  11520. shader: string;
  11521. };
  11522. }
  11523. declare module "babylonjs/Shaders/sprites.vertex" {
  11524. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11525. /** @hidden */
  11526. export var spritesVertexShader: {
  11527. name: string;
  11528. shader: string;
  11529. };
  11530. }
  11531. declare module "babylonjs/Sprites/spriteManager" {
  11532. import { IDisposable, Scene } from "babylonjs/scene";
  11533. import { Nullable } from "babylonjs/types";
  11534. import { Observable } from "babylonjs/Misc/observable";
  11535. import { Sprite } from "babylonjs/Sprites/sprite";
  11536. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11537. import { Camera } from "babylonjs/Cameras/camera";
  11538. import { Texture } from "babylonjs/Materials/Textures/texture";
  11539. import "babylonjs/Shaders/sprites.fragment";
  11540. import "babylonjs/Shaders/sprites.vertex";
  11541. import { Ray } from "babylonjs/Culling/ray";
  11542. /**
  11543. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11544. */
  11545. export interface ISpriteManager extends IDisposable {
  11546. /**
  11547. * Restricts the camera to viewing objects with the same layerMask.
  11548. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11549. */
  11550. layerMask: number;
  11551. /**
  11552. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11553. */
  11554. isPickable: boolean;
  11555. /**
  11556. * Specifies the rendering group id for this mesh (0 by default)
  11557. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11558. */
  11559. renderingGroupId: number;
  11560. /**
  11561. * Defines the list of sprites managed by the manager.
  11562. */
  11563. sprites: Array<Sprite>;
  11564. /**
  11565. * Tests the intersection of a sprite with a specific ray.
  11566. * @param ray The ray we are sending to test the collision
  11567. * @param camera The camera space we are sending rays in
  11568. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11569. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11570. * @returns picking info or null.
  11571. */
  11572. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11573. /**
  11574. * Intersects the sprites with a ray
  11575. * @param ray defines the ray to intersect with
  11576. * @param camera defines the current active camera
  11577. * @param predicate defines a predicate used to select candidate sprites
  11578. * @returns null if no hit or a PickingInfo array
  11579. */
  11580. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11581. /**
  11582. * Renders the list of sprites on screen.
  11583. */
  11584. render(): void;
  11585. }
  11586. /**
  11587. * Class used to manage multiple sprites on the same spritesheet
  11588. * @see http://doc.babylonjs.com/babylon101/sprites
  11589. */
  11590. export class SpriteManager implements ISpriteManager {
  11591. /** defines the manager's name */
  11592. name: string;
  11593. /** Gets the list of sprites */
  11594. sprites: Sprite[];
  11595. /** Gets or sets the rendering group id (0 by default) */
  11596. renderingGroupId: number;
  11597. /** Gets or sets camera layer mask */
  11598. layerMask: number;
  11599. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11600. fogEnabled: boolean;
  11601. /** Gets or sets a boolean indicating if the sprites are pickable */
  11602. isPickable: boolean;
  11603. /** Defines the default width of a cell in the spritesheet */
  11604. cellWidth: number;
  11605. /** Defines the default height of a cell in the spritesheet */
  11606. cellHeight: number;
  11607. /** Associative array from JSON sprite data file */
  11608. private _cellData;
  11609. /** Array of sprite names from JSON sprite data file */
  11610. private _spriteMap;
  11611. /** True when packed cell data from JSON file is ready*/
  11612. private _packedAndReady;
  11613. /**
  11614. * An event triggered when the manager is disposed.
  11615. */
  11616. onDisposeObservable: Observable<SpriteManager>;
  11617. private _onDisposeObserver;
  11618. /**
  11619. * Callback called when the manager is disposed
  11620. */
  11621. onDispose: () => void;
  11622. private _capacity;
  11623. private _fromPacked;
  11624. private _spriteTexture;
  11625. private _epsilon;
  11626. private _scene;
  11627. private _vertexData;
  11628. private _buffer;
  11629. private _vertexBuffers;
  11630. private _indexBuffer;
  11631. private _effectBase;
  11632. private _effectFog;
  11633. /**
  11634. * Gets or sets the spritesheet texture
  11635. */
  11636. texture: Texture;
  11637. /**
  11638. * Creates a new sprite manager
  11639. * @param name defines the manager's name
  11640. * @param imgUrl defines the sprite sheet url
  11641. * @param capacity defines the maximum allowed number of sprites
  11642. * @param cellSize defines the size of a sprite cell
  11643. * @param scene defines the hosting scene
  11644. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11645. * @param samplingMode defines the smapling mode to use with spritesheet
  11646. * @param fromPacked set to false; do not alter
  11647. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11648. */
  11649. constructor(
  11650. /** defines the manager's name */
  11651. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11652. private _makePacked;
  11653. private _appendSpriteVertex;
  11654. /**
  11655. * Intersects the sprites with a ray
  11656. * @param ray defines the ray to intersect with
  11657. * @param camera defines the current active camera
  11658. * @param predicate defines a predicate used to select candidate sprites
  11659. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11660. * @returns null if no hit or a PickingInfo
  11661. */
  11662. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11663. /**
  11664. * Intersects the sprites with a ray
  11665. * @param ray defines the ray to intersect with
  11666. * @param camera defines the current active camera
  11667. * @param predicate defines a predicate used to select candidate sprites
  11668. * @returns null if no hit or a PickingInfo array
  11669. */
  11670. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11671. /**
  11672. * Render all child sprites
  11673. */
  11674. render(): void;
  11675. /**
  11676. * Release associated resources
  11677. */
  11678. dispose(): void;
  11679. }
  11680. }
  11681. declare module "babylonjs/Sprites/sprite" {
  11682. import { Vector3 } from "babylonjs/Maths/math.vector";
  11683. import { Nullable } from "babylonjs/types";
  11684. import { ActionManager } from "babylonjs/Actions/actionManager";
  11685. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11686. import { Color4 } from "babylonjs/Maths/math.color";
  11687. /**
  11688. * Class used to represent a sprite
  11689. * @see http://doc.babylonjs.com/babylon101/sprites
  11690. */
  11691. export class Sprite {
  11692. /** defines the name */
  11693. name: string;
  11694. /** Gets or sets the current world position */
  11695. position: Vector3;
  11696. /** Gets or sets the main color */
  11697. color: Color4;
  11698. /** Gets or sets the width */
  11699. width: number;
  11700. /** Gets or sets the height */
  11701. height: number;
  11702. /** Gets or sets rotation angle */
  11703. angle: number;
  11704. /** Gets or sets the cell index in the sprite sheet */
  11705. cellIndex: number;
  11706. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11707. cellRef: string;
  11708. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11709. invertU: number;
  11710. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11711. invertV: number;
  11712. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11713. disposeWhenFinishedAnimating: boolean;
  11714. /** Gets the list of attached animations */
  11715. animations: Animation[];
  11716. /** Gets or sets a boolean indicating if the sprite can be picked */
  11717. isPickable: boolean;
  11718. /**
  11719. * Gets or sets the associated action manager
  11720. */
  11721. actionManager: Nullable<ActionManager>;
  11722. private _animationStarted;
  11723. private _loopAnimation;
  11724. private _fromIndex;
  11725. private _toIndex;
  11726. private _delay;
  11727. private _direction;
  11728. private _manager;
  11729. private _time;
  11730. private _onAnimationEnd;
  11731. /**
  11732. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11733. */
  11734. isVisible: boolean;
  11735. /**
  11736. * Gets or sets the sprite size
  11737. */
  11738. size: number;
  11739. /**
  11740. * Creates a new Sprite
  11741. * @param name defines the name
  11742. * @param manager defines the manager
  11743. */
  11744. constructor(
  11745. /** defines the name */
  11746. name: string, manager: ISpriteManager);
  11747. /**
  11748. * Starts an animation
  11749. * @param from defines the initial key
  11750. * @param to defines the end key
  11751. * @param loop defines if the animation must loop
  11752. * @param delay defines the start delay (in ms)
  11753. * @param onAnimationEnd defines a callback to call when animation ends
  11754. */
  11755. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11756. /** Stops current animation (if any) */
  11757. stopAnimation(): void;
  11758. /** @hidden */
  11759. _animate(deltaTime: number): void;
  11760. /** Release associated resources */
  11761. dispose(): void;
  11762. }
  11763. }
  11764. declare module "babylonjs/Collisions/pickingInfo" {
  11765. import { Nullable } from "babylonjs/types";
  11766. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11767. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11768. import { Sprite } from "babylonjs/Sprites/sprite";
  11769. import { Ray } from "babylonjs/Culling/ray";
  11770. /**
  11771. * Information about the result of picking within a scene
  11772. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11773. */
  11774. export class PickingInfo {
  11775. /** @hidden */
  11776. _pickingUnavailable: boolean;
  11777. /**
  11778. * If the pick collided with an object
  11779. */
  11780. hit: boolean;
  11781. /**
  11782. * Distance away where the pick collided
  11783. */
  11784. distance: number;
  11785. /**
  11786. * The location of pick collision
  11787. */
  11788. pickedPoint: Nullable<Vector3>;
  11789. /**
  11790. * The mesh corresponding the the pick collision
  11791. */
  11792. pickedMesh: Nullable<AbstractMesh>;
  11793. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11794. bu: number;
  11795. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11796. bv: number;
  11797. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11798. faceId: number;
  11799. /** Id of the the submesh that was picked */
  11800. subMeshId: number;
  11801. /** If a sprite was picked, this will be the sprite the pick collided with */
  11802. pickedSprite: Nullable<Sprite>;
  11803. /**
  11804. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11805. */
  11806. originMesh: Nullable<AbstractMesh>;
  11807. /**
  11808. * The ray that was used to perform the picking.
  11809. */
  11810. ray: Nullable<Ray>;
  11811. /**
  11812. * Gets the normal correspodning to the face the pick collided with
  11813. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11814. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11815. * @returns The normal correspodning to the face the pick collided with
  11816. */
  11817. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11818. /**
  11819. * Gets the texture coordinates of where the pick occured
  11820. * @returns the vector containing the coordnates of the texture
  11821. */
  11822. getTextureCoordinates(): Nullable<Vector2>;
  11823. }
  11824. }
  11825. declare module "babylonjs/Events/pointerEvents" {
  11826. import { Nullable } from "babylonjs/types";
  11827. import { Vector2 } from "babylonjs/Maths/math.vector";
  11828. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11829. import { Ray } from "babylonjs/Culling/ray";
  11830. /**
  11831. * Gather the list of pointer event types as constants.
  11832. */
  11833. export class PointerEventTypes {
  11834. /**
  11835. * The pointerdown event is fired when a pointer becomes active. For mouse, it is fired when the device transitions from no buttons depressed to at least one button depressed. For touch, it is fired when physical contact is made with the digitizer. For pen, it is fired when the stylus makes physical contact with the digitizer.
  11836. */
  11837. static readonly POINTERDOWN: number;
  11838. /**
  11839. * The pointerup event is fired when a pointer is no longer active.
  11840. */
  11841. static readonly POINTERUP: number;
  11842. /**
  11843. * The pointermove event is fired when a pointer changes coordinates.
  11844. */
  11845. static readonly POINTERMOVE: number;
  11846. /**
  11847. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11848. */
  11849. static readonly POINTERWHEEL: number;
  11850. /**
  11851. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11852. */
  11853. static readonly POINTERPICK: number;
  11854. /**
  11855. * The pointertap event is fired when a the object has been touched and released without drag.
  11856. */
  11857. static readonly POINTERTAP: number;
  11858. /**
  11859. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11860. */
  11861. static readonly POINTERDOUBLETAP: number;
  11862. }
  11863. /**
  11864. * Base class of pointer info types.
  11865. */
  11866. export class PointerInfoBase {
  11867. /**
  11868. * Defines the type of event (PointerEventTypes)
  11869. */
  11870. type: number;
  11871. /**
  11872. * Defines the related dom event
  11873. */
  11874. event: PointerEvent | MouseWheelEvent;
  11875. /**
  11876. * Instantiates the base class of pointers info.
  11877. * @param type Defines the type of event (PointerEventTypes)
  11878. * @param event Defines the related dom event
  11879. */
  11880. constructor(
  11881. /**
  11882. * Defines the type of event (PointerEventTypes)
  11883. */
  11884. type: number,
  11885. /**
  11886. * Defines the related dom event
  11887. */
  11888. event: PointerEvent | MouseWheelEvent);
  11889. }
  11890. /**
  11891. * This class is used to store pointer related info for the onPrePointerObservable event.
  11892. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11893. */
  11894. export class PointerInfoPre extends PointerInfoBase {
  11895. /**
  11896. * Ray from a pointer if availible (eg. 6dof controller)
  11897. */
  11898. ray: Nullable<Ray>;
  11899. /**
  11900. * Defines the local position of the pointer on the canvas.
  11901. */
  11902. localPosition: Vector2;
  11903. /**
  11904. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11905. */
  11906. skipOnPointerObservable: boolean;
  11907. /**
  11908. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11909. * @param type Defines the type of event (PointerEventTypes)
  11910. * @param event Defines the related dom event
  11911. * @param localX Defines the local x coordinates of the pointer when the event occured
  11912. * @param localY Defines the local y coordinates of the pointer when the event occured
  11913. */
  11914. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11915. }
  11916. /**
  11917. * This type contains all the data related to a pointer event in Babylon.js.
  11918. * The event member is an instance of PointerEvent for all types except PointerWheel and is of type MouseWheelEvent when type equals PointerWheel. The different event types can be found in the PointerEventTypes class.
  11919. */
  11920. export class PointerInfo extends PointerInfoBase {
  11921. /**
  11922. * Defines the picking info associated to the info (if any)\
  11923. */
  11924. pickInfo: Nullable<PickingInfo>;
  11925. /**
  11926. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11927. * @param type Defines the type of event (PointerEventTypes)
  11928. * @param event Defines the related dom event
  11929. * @param pickInfo Defines the picking info associated to the info (if any)\
  11930. */
  11931. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11932. /**
  11933. * Defines the picking info associated to the info (if any)\
  11934. */
  11935. pickInfo: Nullable<PickingInfo>);
  11936. }
  11937. /**
  11938. * Data relating to a touch event on the screen.
  11939. */
  11940. export interface PointerTouch {
  11941. /**
  11942. * X coordinate of touch.
  11943. */
  11944. x: number;
  11945. /**
  11946. * Y coordinate of touch.
  11947. */
  11948. y: number;
  11949. /**
  11950. * Id of touch. Unique for each finger.
  11951. */
  11952. pointerId: number;
  11953. /**
  11954. * Event type passed from DOM.
  11955. */
  11956. type: any;
  11957. }
  11958. }
  11959. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  11960. import { Observable } from "babylonjs/Misc/observable";
  11961. import { Nullable } from "babylonjs/types";
  11962. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  11963. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  11964. /**
  11965. * Manage the mouse inputs to control the movement of a free camera.
  11966. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11967. */
  11968. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11969. /**
  11970. * Define if touch is enabled in the mouse input
  11971. */
  11972. touchEnabled: boolean;
  11973. /**
  11974. * Defines the camera the input is attached to.
  11975. */
  11976. camera: FreeCamera;
  11977. /**
  11978. * Defines the buttons associated with the input to handle camera move.
  11979. */
  11980. buttons: number[];
  11981. /**
  11982. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11983. */
  11984. angularSensibility: number;
  11985. private _pointerInput;
  11986. private _onMouseMove;
  11987. private _observer;
  11988. private previousPosition;
  11989. /**
  11990. * Observable for when a pointer move event occurs containing the move offset
  11991. */
  11992. onPointerMovedObservable: Observable<{
  11993. offsetX: number;
  11994. offsetY: number;
  11995. }>;
  11996. /**
  11997. * @hidden
  11998. * If the camera should be rotated automatically based on pointer movement
  11999. */
  12000. _allowCameraRotation: boolean;
  12001. /**
  12002. * Manage the mouse inputs to control the movement of a free camera.
  12003. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12004. * @param touchEnabled Defines if touch is enabled or not
  12005. */
  12006. constructor(
  12007. /**
  12008. * Define if touch is enabled in the mouse input
  12009. */
  12010. touchEnabled?: boolean);
  12011. /**
  12012. * Attach the input controls to a specific dom element to get the input from.
  12013. * @param element Defines the element the controls should be listened from
  12014. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12015. */
  12016. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12017. /**
  12018. * Called on JS contextmenu event.
  12019. * Override this method to provide functionality.
  12020. */
  12021. protected onContextMenu(evt: PointerEvent): void;
  12022. /**
  12023. * Detach the current controls from the specified dom element.
  12024. * @param element Defines the element to stop listening the inputs from
  12025. */
  12026. detachControl(element: Nullable<HTMLElement>): void;
  12027. /**
  12028. * Gets the class name of the current intput.
  12029. * @returns the class name
  12030. */
  12031. getClassName(): string;
  12032. /**
  12033. * Get the friendly name associated with the input class.
  12034. * @returns the input friendly name
  12035. */
  12036. getSimpleName(): string;
  12037. }
  12038. }
  12039. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12040. import { Nullable } from "babylonjs/types";
  12041. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12042. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12043. /**
  12044. * Manage the touch inputs to control the movement of a free camera.
  12045. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12046. */
  12047. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12048. /**
  12049. * Defines the camera the input is attached to.
  12050. */
  12051. camera: FreeCamera;
  12052. /**
  12053. * Defines the touch sensibility for rotation.
  12054. * The higher the faster.
  12055. */
  12056. touchAngularSensibility: number;
  12057. /**
  12058. * Defines the touch sensibility for move.
  12059. * The higher the faster.
  12060. */
  12061. touchMoveSensibility: number;
  12062. private _offsetX;
  12063. private _offsetY;
  12064. private _pointerPressed;
  12065. private _pointerInput;
  12066. private _observer;
  12067. private _onLostFocus;
  12068. /**
  12069. * Attach the input controls to a specific dom element to get the input from.
  12070. * @param element Defines the element the controls should be listened from
  12071. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12072. */
  12073. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12074. /**
  12075. * Detach the current controls from the specified dom element.
  12076. * @param element Defines the element to stop listening the inputs from
  12077. */
  12078. detachControl(element: Nullable<HTMLElement>): void;
  12079. /**
  12080. * Update the current camera state depending on the inputs that have been used this frame.
  12081. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12082. */
  12083. checkInputs(): void;
  12084. /**
  12085. * Gets the class name of the current intput.
  12086. * @returns the class name
  12087. */
  12088. getClassName(): string;
  12089. /**
  12090. * Get the friendly name associated with the input class.
  12091. * @returns the input friendly name
  12092. */
  12093. getSimpleName(): string;
  12094. }
  12095. }
  12096. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12097. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12098. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12099. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12100. import { Nullable } from "babylonjs/types";
  12101. /**
  12102. * Default Inputs manager for the FreeCamera.
  12103. * It groups all the default supported inputs for ease of use.
  12104. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12105. */
  12106. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12107. /**
  12108. * @hidden
  12109. */
  12110. _mouseInput: Nullable<FreeCameraMouseInput>;
  12111. /**
  12112. * Instantiates a new FreeCameraInputsManager.
  12113. * @param camera Defines the camera the inputs belong to
  12114. */
  12115. constructor(camera: FreeCamera);
  12116. /**
  12117. * Add keyboard input support to the input manager.
  12118. * @returns the current input manager
  12119. */
  12120. addKeyboard(): FreeCameraInputsManager;
  12121. /**
  12122. * Add mouse input support to the input manager.
  12123. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12124. * @returns the current input manager
  12125. */
  12126. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12127. /**
  12128. * Removes the mouse input support from the manager
  12129. * @returns the current input manager
  12130. */
  12131. removeMouse(): FreeCameraInputsManager;
  12132. /**
  12133. * Add touch input support to the input manager.
  12134. * @returns the current input manager
  12135. */
  12136. addTouch(): FreeCameraInputsManager;
  12137. /**
  12138. * Remove all attached input methods from a camera
  12139. */
  12140. clear(): void;
  12141. }
  12142. }
  12143. declare module "babylonjs/Cameras/freeCamera" {
  12144. import { Vector3 } from "babylonjs/Maths/math.vector";
  12145. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12146. import { Scene } from "babylonjs/scene";
  12147. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12148. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12149. /**
  12150. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12151. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12152. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12153. */
  12154. export class FreeCamera extends TargetCamera {
  12155. /**
  12156. * Define the collision ellipsoid of the camera.
  12157. * This is helpful to simulate a camera body like the player body around the camera
  12158. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12159. */
  12160. ellipsoid: Vector3;
  12161. /**
  12162. * Define an offset for the position of the ellipsoid around the camera.
  12163. * This can be helpful to determine the center of the body near the gravity center of the body
  12164. * instead of its head.
  12165. */
  12166. ellipsoidOffset: Vector3;
  12167. /**
  12168. * Enable or disable collisions of the camera with the rest of the scene objects.
  12169. */
  12170. checkCollisions: boolean;
  12171. /**
  12172. * Enable or disable gravity on the camera.
  12173. */
  12174. applyGravity: boolean;
  12175. /**
  12176. * Define the input manager associated to the camera.
  12177. */
  12178. inputs: FreeCameraInputsManager;
  12179. /**
  12180. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12181. * Higher values reduce sensitivity.
  12182. */
  12183. /**
  12184. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12185. * Higher values reduce sensitivity.
  12186. */
  12187. angularSensibility: number;
  12188. /**
  12189. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12190. */
  12191. keysUp: number[];
  12192. /**
  12193. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12194. */
  12195. keysDown: number[];
  12196. /**
  12197. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12198. */
  12199. keysLeft: number[];
  12200. /**
  12201. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12202. */
  12203. keysRight: number[];
  12204. /**
  12205. * Event raised when the camera collide with a mesh in the scene.
  12206. */
  12207. onCollide: (collidedMesh: AbstractMesh) => void;
  12208. private _collider;
  12209. private _needMoveForGravity;
  12210. private _oldPosition;
  12211. private _diffPosition;
  12212. private _newPosition;
  12213. /** @hidden */
  12214. _localDirection: Vector3;
  12215. /** @hidden */
  12216. _transformedDirection: Vector3;
  12217. /**
  12218. * Instantiates a Free Camera.
  12219. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12220. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12221. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12222. * @param name Define the name of the camera in the scene
  12223. * @param position Define the start position of the camera in the scene
  12224. * @param scene Define the scene the camera belongs to
  12225. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12226. */
  12227. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12228. /**
  12229. * Attached controls to the current camera.
  12230. * @param element Defines the element the controls should be listened from
  12231. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12232. */
  12233. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12234. /**
  12235. * Detach the current controls from the camera.
  12236. * The camera will stop reacting to inputs.
  12237. * @param element Defines the element to stop listening the inputs from
  12238. */
  12239. detachControl(element: HTMLElement): void;
  12240. private _collisionMask;
  12241. /**
  12242. * Define a collision mask to limit the list of object the camera can collide with
  12243. */
  12244. collisionMask: number;
  12245. /** @hidden */
  12246. _collideWithWorld(displacement: Vector3): void;
  12247. private _onCollisionPositionChange;
  12248. /** @hidden */
  12249. _checkInputs(): void;
  12250. /** @hidden */
  12251. _decideIfNeedsToMove(): boolean;
  12252. /** @hidden */
  12253. _updatePosition(): void;
  12254. /**
  12255. * Destroy the camera and release the current resources hold by it.
  12256. */
  12257. dispose(): void;
  12258. /**
  12259. * Gets the current object class name.
  12260. * @return the class name
  12261. */
  12262. getClassName(): string;
  12263. }
  12264. }
  12265. declare module "babylonjs/Gamepads/gamepad" {
  12266. import { Observable } from "babylonjs/Misc/observable";
  12267. /**
  12268. * Represents a gamepad control stick position
  12269. */
  12270. export class StickValues {
  12271. /**
  12272. * The x component of the control stick
  12273. */
  12274. x: number;
  12275. /**
  12276. * The y component of the control stick
  12277. */
  12278. y: number;
  12279. /**
  12280. * Initializes the gamepad x and y control stick values
  12281. * @param x The x component of the gamepad control stick value
  12282. * @param y The y component of the gamepad control stick value
  12283. */
  12284. constructor(
  12285. /**
  12286. * The x component of the control stick
  12287. */
  12288. x: number,
  12289. /**
  12290. * The y component of the control stick
  12291. */
  12292. y: number);
  12293. }
  12294. /**
  12295. * An interface which manages callbacks for gamepad button changes
  12296. */
  12297. export interface GamepadButtonChanges {
  12298. /**
  12299. * Called when a gamepad has been changed
  12300. */
  12301. changed: boolean;
  12302. /**
  12303. * Called when a gamepad press event has been triggered
  12304. */
  12305. pressChanged: boolean;
  12306. /**
  12307. * Called when a touch event has been triggered
  12308. */
  12309. touchChanged: boolean;
  12310. /**
  12311. * Called when a value has changed
  12312. */
  12313. valueChanged: boolean;
  12314. }
  12315. /**
  12316. * Represents a gamepad
  12317. */
  12318. export class Gamepad {
  12319. /**
  12320. * The id of the gamepad
  12321. */
  12322. id: string;
  12323. /**
  12324. * The index of the gamepad
  12325. */
  12326. index: number;
  12327. /**
  12328. * The browser gamepad
  12329. */
  12330. browserGamepad: any;
  12331. /**
  12332. * Specifies what type of gamepad this represents
  12333. */
  12334. type: number;
  12335. private _leftStick;
  12336. private _rightStick;
  12337. /** @hidden */
  12338. _isConnected: boolean;
  12339. private _leftStickAxisX;
  12340. private _leftStickAxisY;
  12341. private _rightStickAxisX;
  12342. private _rightStickAxisY;
  12343. /**
  12344. * Triggered when the left control stick has been changed
  12345. */
  12346. private _onleftstickchanged;
  12347. /**
  12348. * Triggered when the right control stick has been changed
  12349. */
  12350. private _onrightstickchanged;
  12351. /**
  12352. * Represents a gamepad controller
  12353. */
  12354. static GAMEPAD: number;
  12355. /**
  12356. * Represents a generic controller
  12357. */
  12358. static GENERIC: number;
  12359. /**
  12360. * Represents an XBox controller
  12361. */
  12362. static XBOX: number;
  12363. /**
  12364. * Represents a pose-enabled controller
  12365. */
  12366. static POSE_ENABLED: number;
  12367. /**
  12368. * Represents an Dual Shock controller
  12369. */
  12370. static DUALSHOCK: number;
  12371. /**
  12372. * Specifies whether the left control stick should be Y-inverted
  12373. */
  12374. protected _invertLeftStickY: boolean;
  12375. /**
  12376. * Specifies if the gamepad has been connected
  12377. */
  12378. readonly isConnected: boolean;
  12379. /**
  12380. * Initializes the gamepad
  12381. * @param id The id of the gamepad
  12382. * @param index The index of the gamepad
  12383. * @param browserGamepad The browser gamepad
  12384. * @param leftStickX The x component of the left joystick
  12385. * @param leftStickY The y component of the left joystick
  12386. * @param rightStickX The x component of the right joystick
  12387. * @param rightStickY The y component of the right joystick
  12388. */
  12389. constructor(
  12390. /**
  12391. * The id of the gamepad
  12392. */
  12393. id: string,
  12394. /**
  12395. * The index of the gamepad
  12396. */
  12397. index: number,
  12398. /**
  12399. * The browser gamepad
  12400. */
  12401. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12402. /**
  12403. * Callback triggered when the left joystick has changed
  12404. * @param callback
  12405. */
  12406. onleftstickchanged(callback: (values: StickValues) => void): void;
  12407. /**
  12408. * Callback triggered when the right joystick has changed
  12409. * @param callback
  12410. */
  12411. onrightstickchanged(callback: (values: StickValues) => void): void;
  12412. /**
  12413. * Gets the left joystick
  12414. */
  12415. /**
  12416. * Sets the left joystick values
  12417. */
  12418. leftStick: StickValues;
  12419. /**
  12420. * Gets the right joystick
  12421. */
  12422. /**
  12423. * Sets the right joystick value
  12424. */
  12425. rightStick: StickValues;
  12426. /**
  12427. * Updates the gamepad joystick positions
  12428. */
  12429. update(): void;
  12430. /**
  12431. * Disposes the gamepad
  12432. */
  12433. dispose(): void;
  12434. }
  12435. /**
  12436. * Represents a generic gamepad
  12437. */
  12438. export class GenericPad extends Gamepad {
  12439. private _buttons;
  12440. private _onbuttondown;
  12441. private _onbuttonup;
  12442. /**
  12443. * Observable triggered when a button has been pressed
  12444. */
  12445. onButtonDownObservable: Observable<number>;
  12446. /**
  12447. * Observable triggered when a button has been released
  12448. */
  12449. onButtonUpObservable: Observable<number>;
  12450. /**
  12451. * Callback triggered when a button has been pressed
  12452. * @param callback Called when a button has been pressed
  12453. */
  12454. onbuttondown(callback: (buttonPressed: number) => void): void;
  12455. /**
  12456. * Callback triggered when a button has been released
  12457. * @param callback Called when a button has been released
  12458. */
  12459. onbuttonup(callback: (buttonReleased: number) => void): void;
  12460. /**
  12461. * Initializes the generic gamepad
  12462. * @param id The id of the generic gamepad
  12463. * @param index The index of the generic gamepad
  12464. * @param browserGamepad The browser gamepad
  12465. */
  12466. constructor(id: string, index: number, browserGamepad: any);
  12467. private _setButtonValue;
  12468. /**
  12469. * Updates the generic gamepad
  12470. */
  12471. update(): void;
  12472. /**
  12473. * Disposes the generic gamepad
  12474. */
  12475. dispose(): void;
  12476. }
  12477. }
  12478. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12479. import { Nullable } from "babylonjs/types";
  12480. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12481. import { Scene } from "babylonjs/scene";
  12482. module "babylonjs/Engines/engine" {
  12483. interface Engine {
  12484. /**
  12485. * Creates a raw texture
  12486. * @param data defines the data to store in the texture
  12487. * @param width defines the width of the texture
  12488. * @param height defines the height of the texture
  12489. * @param format defines the format of the data
  12490. * @param generateMipMaps defines if the engine should generate the mip levels
  12491. * @param invertY defines if data must be stored with Y axis inverted
  12492. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12493. * @param compression defines the compression used (null by default)
  12494. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12495. * @returns the raw texture inside an InternalTexture
  12496. */
  12497. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12498. /**
  12499. * Update a raw texture
  12500. * @param texture defines the texture to update
  12501. * @param data defines the data to store in the texture
  12502. * @param format defines the format of the data
  12503. * @param invertY defines if data must be stored with Y axis inverted
  12504. */
  12505. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12506. /**
  12507. * Update a raw texture
  12508. * @param texture defines the texture to update
  12509. * @param data defines the data to store in the texture
  12510. * @param format defines the format of the data
  12511. * @param invertY defines if data must be stored with Y axis inverted
  12512. * @param compression defines the compression used (null by default)
  12513. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12514. */
  12515. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12516. /**
  12517. * Creates a new raw cube texture
  12518. * @param data defines the array of data to use to create each face
  12519. * @param size defines the size of the textures
  12520. * @param format defines the format of the data
  12521. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12522. * @param generateMipMaps defines if the engine should generate the mip levels
  12523. * @param invertY defines if data must be stored with Y axis inverted
  12524. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12525. * @param compression defines the compression used (null by default)
  12526. * @returns the cube texture as an InternalTexture
  12527. */
  12528. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12529. /**
  12530. * Update a raw cube texture
  12531. * @param texture defines the texture to udpdate
  12532. * @param data defines the data to store
  12533. * @param format defines the data format
  12534. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12535. * @param invertY defines if data must be stored with Y axis inverted
  12536. */
  12537. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12538. /**
  12539. * Update a raw cube texture
  12540. * @param texture defines the texture to udpdate
  12541. * @param data defines the data to store
  12542. * @param format defines the data format
  12543. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12544. * @param invertY defines if data must be stored with Y axis inverted
  12545. * @param compression defines the compression used (null by default)
  12546. */
  12547. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12548. /**
  12549. * Update a raw cube texture
  12550. * @param texture defines the texture to udpdate
  12551. * @param data defines the data to store
  12552. * @param format defines the data format
  12553. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12554. * @param invertY defines if data must be stored with Y axis inverted
  12555. * @param compression defines the compression used (null by default)
  12556. * @param level defines which level of the texture to update
  12557. */
  12558. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12559. /**
  12560. * Creates a new raw cube texture from a specified url
  12561. * @param url defines the url where the data is located
  12562. * @param scene defines the current scene
  12563. * @param size defines the size of the textures
  12564. * @param format defines the format of the data
  12565. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12566. * @param noMipmap defines if the engine should avoid generating the mip levels
  12567. * @param callback defines a callback used to extract texture data from loaded data
  12568. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12569. * @param onLoad defines a callback called when texture is loaded
  12570. * @param onError defines a callback called if there is an error
  12571. * @returns the cube texture as an InternalTexture
  12572. */
  12573. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  12574. /**
  12575. * Creates a new raw cube texture from a specified url
  12576. * @param url defines the url where the data is located
  12577. * @param scene defines the current scene
  12578. * @param size defines the size of the textures
  12579. * @param format defines the format of the data
  12580. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12581. * @param noMipmap defines if the engine should avoid generating the mip levels
  12582. * @param callback defines a callback used to extract texture data from loaded data
  12583. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12584. * @param onLoad defines a callback called when texture is loaded
  12585. * @param onError defines a callback called if there is an error
  12586. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12587. * @param invertY defines if data must be stored with Y axis inverted
  12588. * @returns the cube texture as an InternalTexture
  12589. */
  12590. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>, samplingMode: number, invertY: boolean): InternalTexture;
  12591. /**
  12592. * Creates a new raw 3D texture
  12593. * @param data defines the data used to create the texture
  12594. * @param width defines the width of the texture
  12595. * @param height defines the height of the texture
  12596. * @param depth defines the depth of the texture
  12597. * @param format defines the format of the texture
  12598. * @param generateMipMaps defines if the engine must generate mip levels
  12599. * @param invertY defines if data must be stored with Y axis inverted
  12600. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12601. * @param compression defines the compressed used (can be null)
  12602. * @param textureType defines the compressed used (can be null)
  12603. * @returns a new raw 3D texture (stored in an InternalTexture)
  12604. */
  12605. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12606. /**
  12607. * Update a raw 3D texture
  12608. * @param texture defines the texture to update
  12609. * @param data defines the data to store
  12610. * @param format defines the data format
  12611. * @param invertY defines if data must be stored with Y axis inverted
  12612. */
  12613. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12614. /**
  12615. * Update a raw 3D texture
  12616. * @param texture defines the texture to update
  12617. * @param data defines the data to store
  12618. * @param format defines the data format
  12619. * @param invertY defines if data must be stored with Y axis inverted
  12620. * @param compression defines the used compression (can be null)
  12621. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12622. */
  12623. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12624. }
  12625. }
  12626. }
  12627. declare module "babylonjs/Materials/Textures/rawTexture" {
  12628. import { Scene } from "babylonjs/scene";
  12629. import { Texture } from "babylonjs/Materials/Textures/texture";
  12630. import "babylonjs/Engines/Extensions/engine.rawTexture";
  12631. /**
  12632. * Raw texture can help creating a texture directly from an array of data.
  12633. * This can be super useful if you either get the data from an uncompressed source or
  12634. * if you wish to create your texture pixel by pixel.
  12635. */
  12636. export class RawTexture extends Texture {
  12637. /**
  12638. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12639. */
  12640. format: number;
  12641. private _engine;
  12642. /**
  12643. * Instantiates a new RawTexture.
  12644. * Raw texture can help creating a texture directly from an array of data.
  12645. * This can be super useful if you either get the data from an uncompressed source or
  12646. * if you wish to create your texture pixel by pixel.
  12647. * @param data define the array of data to use to create the texture
  12648. * @param width define the width of the texture
  12649. * @param height define the height of the texture
  12650. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12651. * @param scene define the scene the texture belongs to
  12652. * @param generateMipMaps define whether mip maps should be generated or not
  12653. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12654. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12655. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12656. */
  12657. constructor(data: ArrayBufferView, width: number, height: number,
  12658. /**
  12659. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12660. */
  12661. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12662. /**
  12663. * Updates the texture underlying data.
  12664. * @param data Define the new data of the texture
  12665. */
  12666. update(data: ArrayBufferView): void;
  12667. /**
  12668. * Creates a luminance texture from some data.
  12669. * @param data Define the texture data
  12670. * @param width Define the width of the texture
  12671. * @param height Define the height of the texture
  12672. * @param scene Define the scene the texture belongs to
  12673. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12674. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12675. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12676. * @returns the luminance texture
  12677. */
  12678. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12679. /**
  12680. * Creates a luminance alpha texture from some data.
  12681. * @param data Define the texture data
  12682. * @param width Define the width of the texture
  12683. * @param height Define the height of the texture
  12684. * @param scene Define the scene the texture belongs to
  12685. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12686. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12687. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12688. * @returns the luminance alpha texture
  12689. */
  12690. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12691. /**
  12692. * Creates an alpha texture from some data.
  12693. * @param data Define the texture data
  12694. * @param width Define the width of the texture
  12695. * @param height Define the height of the texture
  12696. * @param scene Define the scene the texture belongs to
  12697. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12698. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12699. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12700. * @returns the alpha texture
  12701. */
  12702. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12703. /**
  12704. * Creates a RGB texture from some data.
  12705. * @param data Define the texture data
  12706. * @param width Define the width of the texture
  12707. * @param height Define the height of the texture
  12708. * @param scene Define the scene the texture belongs to
  12709. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12710. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12711. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12712. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12713. * @returns the RGB alpha texture
  12714. */
  12715. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12716. /**
  12717. * Creates a RGBA texture from some data.
  12718. * @param data Define the texture data
  12719. * @param width Define the width of the texture
  12720. * @param height Define the height of the texture
  12721. * @param scene Define the scene the texture belongs to
  12722. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12723. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12724. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12725. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12726. * @returns the RGBA texture
  12727. */
  12728. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12729. /**
  12730. * Creates a R texture from some data.
  12731. * @param data Define the texture data
  12732. * @param width Define the width of the texture
  12733. * @param height Define the height of the texture
  12734. * @param scene Define the scene the texture belongs to
  12735. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12736. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12737. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12738. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12739. * @returns the R texture
  12740. */
  12741. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12742. }
  12743. }
  12744. declare module "babylonjs/Maths/math.size" {
  12745. /**
  12746. * Interface for the size containing width and height
  12747. */
  12748. export interface ISize {
  12749. /**
  12750. * Width
  12751. */
  12752. width: number;
  12753. /**
  12754. * Heighht
  12755. */
  12756. height: number;
  12757. }
  12758. /**
  12759. * Size containing widht and height
  12760. */
  12761. export class Size implements ISize {
  12762. /**
  12763. * Width
  12764. */
  12765. width: number;
  12766. /**
  12767. * Height
  12768. */
  12769. height: number;
  12770. /**
  12771. * Creates a Size object from the given width and height (floats).
  12772. * @param width width of the new size
  12773. * @param height height of the new size
  12774. */
  12775. constructor(width: number, height: number);
  12776. /**
  12777. * Returns a string with the Size width and height
  12778. * @returns a string with the Size width and height
  12779. */
  12780. toString(): string;
  12781. /**
  12782. * "Size"
  12783. * @returns the string "Size"
  12784. */
  12785. getClassName(): string;
  12786. /**
  12787. * Returns the Size hash code.
  12788. * @returns a hash code for a unique width and height
  12789. */
  12790. getHashCode(): number;
  12791. /**
  12792. * Updates the current size from the given one.
  12793. * @param src the given size
  12794. */
  12795. copyFrom(src: Size): void;
  12796. /**
  12797. * Updates in place the current Size from the given floats.
  12798. * @param width width of the new size
  12799. * @param height height of the new size
  12800. * @returns the updated Size.
  12801. */
  12802. copyFromFloats(width: number, height: number): Size;
  12803. /**
  12804. * Updates in place the current Size from the given floats.
  12805. * @param width width to set
  12806. * @param height height to set
  12807. * @returns the updated Size.
  12808. */
  12809. set(width: number, height: number): Size;
  12810. /**
  12811. * Multiplies the width and height by numbers
  12812. * @param w factor to multiple the width by
  12813. * @param h factor to multiple the height by
  12814. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12815. */
  12816. multiplyByFloats(w: number, h: number): Size;
  12817. /**
  12818. * Clones the size
  12819. * @returns a new Size copied from the given one.
  12820. */
  12821. clone(): Size;
  12822. /**
  12823. * True if the current Size and the given one width and height are strictly equal.
  12824. * @param other the other size to compare against
  12825. * @returns True if the current Size and the given one width and height are strictly equal.
  12826. */
  12827. equals(other: Size): boolean;
  12828. /**
  12829. * The surface of the Size : width * height (float).
  12830. */
  12831. readonly surface: number;
  12832. /**
  12833. * Create a new size of zero
  12834. * @returns a new Size set to (0.0, 0.0)
  12835. */
  12836. static Zero(): Size;
  12837. /**
  12838. * Sums the width and height of two sizes
  12839. * @param otherSize size to add to this size
  12840. * @returns a new Size set as the addition result of the current Size and the given one.
  12841. */
  12842. add(otherSize: Size): Size;
  12843. /**
  12844. * Subtracts the width and height of two
  12845. * @param otherSize size to subtract to this size
  12846. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12847. */
  12848. subtract(otherSize: Size): Size;
  12849. /**
  12850. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12851. * @param start starting size to lerp between
  12852. * @param end end size to lerp between
  12853. * @param amount amount to lerp between the start and end values
  12854. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12855. */
  12856. static Lerp(start: Size, end: Size, amount: number): Size;
  12857. }
  12858. }
  12859. declare module "babylonjs/Animations/runtimeAnimation" {
  12860. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  12861. import { Animatable } from "babylonjs/Animations/animatable";
  12862. import { Scene } from "babylonjs/scene";
  12863. /**
  12864. * Defines a runtime animation
  12865. */
  12866. export class RuntimeAnimation {
  12867. private _events;
  12868. /**
  12869. * The current frame of the runtime animation
  12870. */
  12871. private _currentFrame;
  12872. /**
  12873. * The animation used by the runtime animation
  12874. */
  12875. private _animation;
  12876. /**
  12877. * The target of the runtime animation
  12878. */
  12879. private _target;
  12880. /**
  12881. * The initiating animatable
  12882. */
  12883. private _host;
  12884. /**
  12885. * The original value of the runtime animation
  12886. */
  12887. private _originalValue;
  12888. /**
  12889. * The original blend value of the runtime animation
  12890. */
  12891. private _originalBlendValue;
  12892. /**
  12893. * The offsets cache of the runtime animation
  12894. */
  12895. private _offsetsCache;
  12896. /**
  12897. * The high limits cache of the runtime animation
  12898. */
  12899. private _highLimitsCache;
  12900. /**
  12901. * Specifies if the runtime animation has been stopped
  12902. */
  12903. private _stopped;
  12904. /**
  12905. * The blending factor of the runtime animation
  12906. */
  12907. private _blendingFactor;
  12908. /**
  12909. * The BabylonJS scene
  12910. */
  12911. private _scene;
  12912. /**
  12913. * The current value of the runtime animation
  12914. */
  12915. private _currentValue;
  12916. /** @hidden */
  12917. _animationState: _IAnimationState;
  12918. /**
  12919. * The active target of the runtime animation
  12920. */
  12921. private _activeTargets;
  12922. private _currentActiveTarget;
  12923. private _directTarget;
  12924. /**
  12925. * The target path of the runtime animation
  12926. */
  12927. private _targetPath;
  12928. /**
  12929. * The weight of the runtime animation
  12930. */
  12931. private _weight;
  12932. /**
  12933. * The ratio offset of the runtime animation
  12934. */
  12935. private _ratioOffset;
  12936. /**
  12937. * The previous delay of the runtime animation
  12938. */
  12939. private _previousDelay;
  12940. /**
  12941. * The previous ratio of the runtime animation
  12942. */
  12943. private _previousRatio;
  12944. private _enableBlending;
  12945. private _keys;
  12946. private _minFrame;
  12947. private _maxFrame;
  12948. private _minValue;
  12949. private _maxValue;
  12950. private _targetIsArray;
  12951. /**
  12952. * Gets the current frame of the runtime animation
  12953. */
  12954. readonly currentFrame: number;
  12955. /**
  12956. * Gets the weight of the runtime animation
  12957. */
  12958. readonly weight: number;
  12959. /**
  12960. * Gets the current value of the runtime animation
  12961. */
  12962. readonly currentValue: any;
  12963. /**
  12964. * Gets the target path of the runtime animation
  12965. */
  12966. readonly targetPath: string;
  12967. /**
  12968. * Gets the actual target of the runtime animation
  12969. */
  12970. readonly target: any;
  12971. /** @hidden */
  12972. _onLoop: () => void;
  12973. /**
  12974. * Create a new RuntimeAnimation object
  12975. * @param target defines the target of the animation
  12976. * @param animation defines the source animation object
  12977. * @param scene defines the hosting scene
  12978. * @param host defines the initiating Animatable
  12979. */
  12980. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  12981. private _preparePath;
  12982. /**
  12983. * Gets the animation from the runtime animation
  12984. */
  12985. readonly animation: Animation;
  12986. /**
  12987. * Resets the runtime animation to the beginning
  12988. * @param restoreOriginal defines whether to restore the target property to the original value
  12989. */
  12990. reset(restoreOriginal?: boolean): void;
  12991. /**
  12992. * Specifies if the runtime animation is stopped
  12993. * @returns Boolean specifying if the runtime animation is stopped
  12994. */
  12995. isStopped(): boolean;
  12996. /**
  12997. * Disposes of the runtime animation
  12998. */
  12999. dispose(): void;
  13000. /**
  13001. * Apply the interpolated value to the target
  13002. * @param currentValue defines the value computed by the animation
  13003. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13004. */
  13005. setValue(currentValue: any, weight: number): void;
  13006. private _getOriginalValues;
  13007. private _setValue;
  13008. /**
  13009. * Gets the loop pmode of the runtime animation
  13010. * @returns Loop Mode
  13011. */
  13012. private _getCorrectLoopMode;
  13013. /**
  13014. * Move the current animation to a given frame
  13015. * @param frame defines the frame to move to
  13016. */
  13017. goToFrame(frame: number): void;
  13018. /**
  13019. * @hidden Internal use only
  13020. */
  13021. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13022. /**
  13023. * Execute the current animation
  13024. * @param delay defines the delay to add to the current frame
  13025. * @param from defines the lower bound of the animation range
  13026. * @param to defines the upper bound of the animation range
  13027. * @param loop defines if the current animation must loop
  13028. * @param speedRatio defines the current speed ratio
  13029. * @param weight defines the weight of the animation (default is -1 so no weight)
  13030. * @param onLoop optional callback called when animation loops
  13031. * @returns a boolean indicating if the animation is running
  13032. */
  13033. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13034. }
  13035. }
  13036. declare module "babylonjs/Animations/animatable" {
  13037. import { Animation } from "babylonjs/Animations/animation";
  13038. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  13039. import { Nullable } from "babylonjs/types";
  13040. import { Observable } from "babylonjs/Misc/observable";
  13041. import { Scene } from "babylonjs/scene";
  13042. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  13043. import { Node } from "babylonjs/node";
  13044. /**
  13045. * Class used to store an actual running animation
  13046. */
  13047. export class Animatable {
  13048. /** defines the target object */
  13049. target: any;
  13050. /** defines the starting frame number (default is 0) */
  13051. fromFrame: number;
  13052. /** defines the ending frame number (default is 100) */
  13053. toFrame: number;
  13054. /** defines if the animation must loop (default is false) */
  13055. loopAnimation: boolean;
  13056. /** defines a callback to call when animation ends if it is not looping */
  13057. onAnimationEnd?: (() => void) | null | undefined;
  13058. /** defines a callback to call when animation loops */
  13059. onAnimationLoop?: (() => void) | null | undefined;
  13060. private _localDelayOffset;
  13061. private _pausedDelay;
  13062. private _runtimeAnimations;
  13063. private _paused;
  13064. private _scene;
  13065. private _speedRatio;
  13066. private _weight;
  13067. private _syncRoot;
  13068. /**
  13069. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13070. * This will only apply for non looping animation (default is true)
  13071. */
  13072. disposeOnEnd: boolean;
  13073. /**
  13074. * Gets a boolean indicating if the animation has started
  13075. */
  13076. animationStarted: boolean;
  13077. /**
  13078. * Observer raised when the animation ends
  13079. */
  13080. onAnimationEndObservable: Observable<Animatable>;
  13081. /**
  13082. * Observer raised when the animation loops
  13083. */
  13084. onAnimationLoopObservable: Observable<Animatable>;
  13085. /**
  13086. * Gets the root Animatable used to synchronize and normalize animations
  13087. */
  13088. readonly syncRoot: Nullable<Animatable>;
  13089. /**
  13090. * Gets the current frame of the first RuntimeAnimation
  13091. * Used to synchronize Animatables
  13092. */
  13093. readonly masterFrame: number;
  13094. /**
  13095. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13096. */
  13097. weight: number;
  13098. /**
  13099. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13100. */
  13101. speedRatio: number;
  13102. /**
  13103. * Creates a new Animatable
  13104. * @param scene defines the hosting scene
  13105. * @param target defines the target object
  13106. * @param fromFrame defines the starting frame number (default is 0)
  13107. * @param toFrame defines the ending frame number (default is 100)
  13108. * @param loopAnimation defines if the animation must loop (default is false)
  13109. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13110. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13111. * @param animations defines a group of animation to add to the new Animatable
  13112. * @param onAnimationLoop defines a callback to call when animation loops
  13113. */
  13114. constructor(scene: Scene,
  13115. /** defines the target object */
  13116. target: any,
  13117. /** defines the starting frame number (default is 0) */
  13118. fromFrame?: number,
  13119. /** defines the ending frame number (default is 100) */
  13120. toFrame?: number,
  13121. /** defines if the animation must loop (default is false) */
  13122. loopAnimation?: boolean, speedRatio?: number,
  13123. /** defines a callback to call when animation ends if it is not looping */
  13124. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13125. /** defines a callback to call when animation loops */
  13126. onAnimationLoop?: (() => void) | null | undefined);
  13127. /**
  13128. * Synchronize and normalize current Animatable with a source Animatable
  13129. * This is useful when using animation weights and when animations are not of the same length
  13130. * @param root defines the root Animatable to synchronize with
  13131. * @returns the current Animatable
  13132. */
  13133. syncWith(root: Animatable): Animatable;
  13134. /**
  13135. * Gets the list of runtime animations
  13136. * @returns an array of RuntimeAnimation
  13137. */
  13138. getAnimations(): RuntimeAnimation[];
  13139. /**
  13140. * Adds more animations to the current animatable
  13141. * @param target defines the target of the animations
  13142. * @param animations defines the new animations to add
  13143. */
  13144. appendAnimations(target: any, animations: Animation[]): void;
  13145. /**
  13146. * Gets the source animation for a specific property
  13147. * @param property defines the propertyu to look for
  13148. * @returns null or the source animation for the given property
  13149. */
  13150. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13151. /**
  13152. * Gets the runtime animation for a specific property
  13153. * @param property defines the propertyu to look for
  13154. * @returns null or the runtime animation for the given property
  13155. */
  13156. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13157. /**
  13158. * Resets the animatable to its original state
  13159. */
  13160. reset(): void;
  13161. /**
  13162. * Allows the animatable to blend with current running animations
  13163. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13164. * @param blendingSpeed defines the blending speed to use
  13165. */
  13166. enableBlending(blendingSpeed: number): void;
  13167. /**
  13168. * Disable animation blending
  13169. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13170. */
  13171. disableBlending(): void;
  13172. /**
  13173. * Jump directly to a given frame
  13174. * @param frame defines the frame to jump to
  13175. */
  13176. goToFrame(frame: number): void;
  13177. /**
  13178. * Pause the animation
  13179. */
  13180. pause(): void;
  13181. /**
  13182. * Restart the animation
  13183. */
  13184. restart(): void;
  13185. private _raiseOnAnimationEnd;
  13186. /**
  13187. * Stop and delete the current animation
  13188. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13189. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  13190. */
  13191. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13192. /**
  13193. * Wait asynchronously for the animation to end
  13194. * @returns a promise which will be fullfilled when the animation ends
  13195. */
  13196. waitAsync(): Promise<Animatable>;
  13197. /** @hidden */
  13198. _animate(delay: number): boolean;
  13199. }
  13200. module "babylonjs/scene" {
  13201. interface Scene {
  13202. /** @hidden */
  13203. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13204. /** @hidden */
  13205. _processLateAnimationBindingsForMatrices(holder: {
  13206. totalWeight: number;
  13207. animations: RuntimeAnimation[];
  13208. originalValue: Matrix;
  13209. }): any;
  13210. /** @hidden */
  13211. _processLateAnimationBindingsForQuaternions(holder: {
  13212. totalWeight: number;
  13213. animations: RuntimeAnimation[];
  13214. originalValue: Quaternion;
  13215. }, refQuaternion: Quaternion): Quaternion;
  13216. /** @hidden */
  13217. _processLateAnimationBindings(): void;
  13218. /**
  13219. * Will start the animation sequence of a given target
  13220. * @param target defines the target
  13221. * @param from defines from which frame should animation start
  13222. * @param to defines until which frame should animation run.
  13223. * @param weight defines the weight to apply to the animation (1.0 by default)
  13224. * @param loop defines if the animation loops
  13225. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13226. * @param onAnimationEnd defines the function to be executed when the animation ends
  13227. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13228. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13229. * @param onAnimationLoop defines the callback to call when an animation loops
  13230. * @returns the animatable object created for this animation
  13231. */
  13232. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13233. /**
  13234. * Will start the animation sequence of a given target
  13235. * @param target defines the target
  13236. * @param from defines from which frame should animation start
  13237. * @param to defines until which frame should animation run.
  13238. * @param loop defines if the animation loops
  13239. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13240. * @param onAnimationEnd defines the function to be executed when the animation ends
  13241. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13242. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13243. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13244. * @param onAnimationLoop defines the callback to call when an animation loops
  13245. * @returns the animatable object created for this animation
  13246. */
  13247. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13248. /**
  13249. * Will start the animation sequence of a given target and its hierarchy
  13250. * @param target defines the target
  13251. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  13252. * @param from defines from which frame should animation start
  13253. * @param to defines until which frame should animation run.
  13254. * @param loop defines if the animation loops
  13255. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13256. * @param onAnimationEnd defines the function to be executed when the animation ends
  13257. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13258. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13259. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13260. * @param onAnimationLoop defines the callback to call when an animation loops
  13261. * @returns the list of created animatables
  13262. */
  13263. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable[];
  13264. /**
  13265. * Begin a new animation on a given node
  13266. * @param target defines the target where the animation will take place
  13267. * @param animations defines the list of animations to start
  13268. * @param from defines the initial value
  13269. * @param to defines the final value
  13270. * @param loop defines if you want animation to loop (off by default)
  13271. * @param speedRatio defines the speed ratio to apply to all animations
  13272. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13273. * @param onAnimationLoop defines the callback to call when an animation loops
  13274. * @returns the list of created animatables
  13275. */
  13276. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13277. /**
  13278. * Begin a new animation on a given node and its hierarchy
  13279. * @param target defines the root node where the animation will take place
  13280. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  13281. * @param animations defines the list of animations to start
  13282. * @param from defines the initial value
  13283. * @param to defines the final value
  13284. * @param loop defines if you want animation to loop (off by default)
  13285. * @param speedRatio defines the speed ratio to apply to all animations
  13286. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13287. * @param onAnimationLoop defines the callback to call when an animation loops
  13288. * @returns the list of animatables created for all nodes
  13289. */
  13290. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13291. /**
  13292. * Gets the animatable associated with a specific target
  13293. * @param target defines the target of the animatable
  13294. * @returns the required animatable if found
  13295. */
  13296. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13297. /**
  13298. * Gets all animatables associated with a given target
  13299. * @param target defines the target to look animatables for
  13300. * @returns an array of Animatables
  13301. */
  13302. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13303. /**
  13304. * Stops and removes all animations that have been applied to the scene
  13305. */
  13306. stopAllAnimations(): void;
  13307. }
  13308. }
  13309. module "babylonjs/Bones/bone" {
  13310. interface Bone {
  13311. /**
  13312. * Copy an animation range from another bone
  13313. * @param source defines the source bone
  13314. * @param rangeName defines the range name to copy
  13315. * @param frameOffset defines the frame offset
  13316. * @param rescaleAsRequired defines if rescaling must be applied if required
  13317. * @param skelDimensionsRatio defines the scaling ratio
  13318. * @returns true if operation was successful
  13319. */
  13320. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13321. }
  13322. }
  13323. }
  13324. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13325. /**
  13326. * Class used to override all child animations of a given target
  13327. */
  13328. export class AnimationPropertiesOverride {
  13329. /**
  13330. * Gets or sets a value indicating if animation blending must be used
  13331. */
  13332. enableBlending: boolean;
  13333. /**
  13334. * Gets or sets the blending speed to use when enableBlending is true
  13335. */
  13336. blendingSpeed: number;
  13337. /**
  13338. * Gets or sets the default loop mode to use
  13339. */
  13340. loopMode: number;
  13341. }
  13342. }
  13343. declare module "babylonjs/Bones/skeleton" {
  13344. import { Bone } from "babylonjs/Bones/bone";
  13345. import { Observable } from "babylonjs/Misc/observable";
  13346. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13347. import { Scene } from "babylonjs/scene";
  13348. import { Nullable } from "babylonjs/types";
  13349. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13350. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13351. import { Animatable } from "babylonjs/Animations/animatable";
  13352. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13353. import { Animation } from "babylonjs/Animations/animation";
  13354. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13355. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13356. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13357. /**
  13358. * Class used to handle skinning animations
  13359. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13360. */
  13361. export class Skeleton implements IAnimatable {
  13362. /** defines the skeleton name */
  13363. name: string;
  13364. /** defines the skeleton Id */
  13365. id: string;
  13366. /**
  13367. * Defines the list of child bones
  13368. */
  13369. bones: Bone[];
  13370. /**
  13371. * Defines an estimate of the dimension of the skeleton at rest
  13372. */
  13373. dimensionsAtRest: Vector3;
  13374. /**
  13375. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13376. */
  13377. needInitialSkinMatrix: boolean;
  13378. /**
  13379. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13380. */
  13381. overrideMesh: Nullable<AbstractMesh>;
  13382. /**
  13383. * Gets the list of animations attached to this skeleton
  13384. */
  13385. animations: Array<Animation>;
  13386. private _scene;
  13387. private _isDirty;
  13388. private _transformMatrices;
  13389. private _transformMatrixTexture;
  13390. private _meshesWithPoseMatrix;
  13391. private _animatables;
  13392. private _identity;
  13393. private _synchronizedWithMesh;
  13394. private _ranges;
  13395. private _lastAbsoluteTransformsUpdateId;
  13396. private _canUseTextureForBones;
  13397. private _uniqueId;
  13398. /** @hidden */
  13399. _numBonesWithLinkedTransformNode: number;
  13400. /** @hidden */
  13401. _hasWaitingData: Nullable<boolean>;
  13402. /**
  13403. * Specifies if the skeleton should be serialized
  13404. */
  13405. doNotSerialize: boolean;
  13406. private _useTextureToStoreBoneMatrices;
  13407. /**
  13408. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13409. * Please note that this option is not available if the hardware does not support it
  13410. */
  13411. useTextureToStoreBoneMatrices: boolean;
  13412. private _animationPropertiesOverride;
  13413. /**
  13414. * Gets or sets the animation properties override
  13415. */
  13416. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13417. /**
  13418. * List of inspectable custom properties (used by the Inspector)
  13419. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13420. */
  13421. inspectableCustomProperties: IInspectable[];
  13422. /**
  13423. * An observable triggered before computing the skeleton's matrices
  13424. */
  13425. onBeforeComputeObservable: Observable<Skeleton>;
  13426. /**
  13427. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13428. */
  13429. readonly isUsingTextureForMatrices: boolean;
  13430. /**
  13431. * Gets the unique ID of this skeleton
  13432. */
  13433. readonly uniqueId: number;
  13434. /**
  13435. * Creates a new skeleton
  13436. * @param name defines the skeleton name
  13437. * @param id defines the skeleton Id
  13438. * @param scene defines the hosting scene
  13439. */
  13440. constructor(
  13441. /** defines the skeleton name */
  13442. name: string,
  13443. /** defines the skeleton Id */
  13444. id: string, scene: Scene);
  13445. /**
  13446. * Gets the current object class name.
  13447. * @return the class name
  13448. */
  13449. getClassName(): string;
  13450. /**
  13451. * Returns an array containing the root bones
  13452. * @returns an array containing the root bones
  13453. */
  13454. getChildren(): Array<Bone>;
  13455. /**
  13456. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13457. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13458. * @returns a Float32Array containing matrices data
  13459. */
  13460. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13461. /**
  13462. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13463. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13464. * @returns a raw texture containing the data
  13465. */
  13466. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13467. /**
  13468. * Gets the current hosting scene
  13469. * @returns a scene object
  13470. */
  13471. getScene(): Scene;
  13472. /**
  13473. * Gets a string representing the current skeleton data
  13474. * @param fullDetails defines a boolean indicating if we want a verbose version
  13475. * @returns a string representing the current skeleton data
  13476. */
  13477. toString(fullDetails?: boolean): string;
  13478. /**
  13479. * Get bone's index searching by name
  13480. * @param name defines bone's name to search for
  13481. * @return the indice of the bone. Returns -1 if not found
  13482. */
  13483. getBoneIndexByName(name: string): number;
  13484. /**
  13485. * Creater a new animation range
  13486. * @param name defines the name of the range
  13487. * @param from defines the start key
  13488. * @param to defines the end key
  13489. */
  13490. createAnimationRange(name: string, from: number, to: number): void;
  13491. /**
  13492. * Delete a specific animation range
  13493. * @param name defines the name of the range
  13494. * @param deleteFrames defines if frames must be removed as well
  13495. */
  13496. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13497. /**
  13498. * Gets a specific animation range
  13499. * @param name defines the name of the range to look for
  13500. * @returns the requested animation range or null if not found
  13501. */
  13502. getAnimationRange(name: string): Nullable<AnimationRange>;
  13503. /**
  13504. * Gets the list of all animation ranges defined on this skeleton
  13505. * @returns an array
  13506. */
  13507. getAnimationRanges(): Nullable<AnimationRange>[];
  13508. /**
  13509. * Copy animation range from a source skeleton.
  13510. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13511. * @param source defines the source skeleton
  13512. * @param name defines the name of the range to copy
  13513. * @param rescaleAsRequired defines if rescaling must be applied if required
  13514. * @returns true if operation was successful
  13515. */
  13516. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13517. /**
  13518. * Forces the skeleton to go to rest pose
  13519. */
  13520. returnToRest(): void;
  13521. private _getHighestAnimationFrame;
  13522. /**
  13523. * Begin a specific animation range
  13524. * @param name defines the name of the range to start
  13525. * @param loop defines if looping must be turned on (false by default)
  13526. * @param speedRatio defines the speed ratio to apply (1 by default)
  13527. * @param onAnimationEnd defines a callback which will be called when animation will end
  13528. * @returns a new animatable
  13529. */
  13530. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13531. /** @hidden */
  13532. _markAsDirty(): void;
  13533. /** @hidden */
  13534. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13535. /** @hidden */
  13536. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13537. private _computeTransformMatrices;
  13538. /**
  13539. * Build all resources required to render a skeleton
  13540. */
  13541. prepare(): void;
  13542. /**
  13543. * Gets the list of animatables currently running for this skeleton
  13544. * @returns an array of animatables
  13545. */
  13546. getAnimatables(): IAnimatable[];
  13547. /**
  13548. * Clone the current skeleton
  13549. * @param name defines the name of the new skeleton
  13550. * @param id defines the id of the new skeleton
  13551. * @returns the new skeleton
  13552. */
  13553. clone(name: string, id: string): Skeleton;
  13554. /**
  13555. * Enable animation blending for this skeleton
  13556. * @param blendingSpeed defines the blending speed to apply
  13557. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13558. */
  13559. enableBlending(blendingSpeed?: number): void;
  13560. /**
  13561. * Releases all resources associated with the current skeleton
  13562. */
  13563. dispose(): void;
  13564. /**
  13565. * Serialize the skeleton in a JSON object
  13566. * @returns a JSON object
  13567. */
  13568. serialize(): any;
  13569. /**
  13570. * Creates a new skeleton from serialized data
  13571. * @param parsedSkeleton defines the serialized data
  13572. * @param scene defines the hosting scene
  13573. * @returns a new skeleton
  13574. */
  13575. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13576. /**
  13577. * Compute all node absolute transforms
  13578. * @param forceUpdate defines if computation must be done even if cache is up to date
  13579. */
  13580. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13581. /**
  13582. * Gets the root pose matrix
  13583. * @returns a matrix
  13584. */
  13585. getPoseMatrix(): Nullable<Matrix>;
  13586. /**
  13587. * Sorts bones per internal index
  13588. */
  13589. sortBones(): void;
  13590. private _sortBones;
  13591. }
  13592. }
  13593. declare module "babylonjs/Bones/bone" {
  13594. import { Skeleton } from "babylonjs/Bones/skeleton";
  13595. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13596. import { Nullable } from "babylonjs/types";
  13597. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13598. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13599. import { Node } from "babylonjs/node";
  13600. import { Space } from "babylonjs/Maths/math.axis";
  13601. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13602. /**
  13603. * Class used to store bone information
  13604. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13605. */
  13606. export class Bone extends Node {
  13607. /**
  13608. * defines the bone name
  13609. */
  13610. name: string;
  13611. private static _tmpVecs;
  13612. private static _tmpQuat;
  13613. private static _tmpMats;
  13614. /**
  13615. * Gets the list of child bones
  13616. */
  13617. children: Bone[];
  13618. /** Gets the animations associated with this bone */
  13619. animations: import("babylonjs/Animations/animation").Animation[];
  13620. /**
  13621. * Gets or sets bone length
  13622. */
  13623. length: number;
  13624. /**
  13625. * @hidden Internal only
  13626. * Set this value to map this bone to a different index in the transform matrices
  13627. * Set this value to -1 to exclude the bone from the transform matrices
  13628. */
  13629. _index: Nullable<number>;
  13630. private _skeleton;
  13631. private _localMatrix;
  13632. private _restPose;
  13633. private _baseMatrix;
  13634. private _absoluteTransform;
  13635. private _invertedAbsoluteTransform;
  13636. private _parent;
  13637. private _scalingDeterminant;
  13638. private _worldTransform;
  13639. private _localScaling;
  13640. private _localRotation;
  13641. private _localPosition;
  13642. private _needToDecompose;
  13643. private _needToCompose;
  13644. /** @hidden */
  13645. _linkedTransformNode: Nullable<TransformNode>;
  13646. /** @hidden */
  13647. _waitingTransformNodeId: Nullable<string>;
  13648. /** @hidden */
  13649. /** @hidden */
  13650. _matrix: Matrix;
  13651. /**
  13652. * Create a new bone
  13653. * @param name defines the bone name
  13654. * @param skeleton defines the parent skeleton
  13655. * @param parentBone defines the parent (can be null if the bone is the root)
  13656. * @param localMatrix defines the local matrix
  13657. * @param restPose defines the rest pose matrix
  13658. * @param baseMatrix defines the base matrix
  13659. * @param index defines index of the bone in the hiearchy
  13660. */
  13661. constructor(
  13662. /**
  13663. * defines the bone name
  13664. */
  13665. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13666. /**
  13667. * Gets the current object class name.
  13668. * @return the class name
  13669. */
  13670. getClassName(): string;
  13671. /**
  13672. * Gets the parent skeleton
  13673. * @returns a skeleton
  13674. */
  13675. getSkeleton(): Skeleton;
  13676. /**
  13677. * Gets parent bone
  13678. * @returns a bone or null if the bone is the root of the bone hierarchy
  13679. */
  13680. getParent(): Nullable<Bone>;
  13681. /**
  13682. * Returns an array containing the root bones
  13683. * @returns an array containing the root bones
  13684. */
  13685. getChildren(): Array<Bone>;
  13686. /**
  13687. * Sets the parent bone
  13688. * @param parent defines the parent (can be null if the bone is the root)
  13689. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13690. */
  13691. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13692. /**
  13693. * Gets the local matrix
  13694. * @returns a matrix
  13695. */
  13696. getLocalMatrix(): Matrix;
  13697. /**
  13698. * Gets the base matrix (initial matrix which remains unchanged)
  13699. * @returns a matrix
  13700. */
  13701. getBaseMatrix(): Matrix;
  13702. /**
  13703. * Gets the rest pose matrix
  13704. * @returns a matrix
  13705. */
  13706. getRestPose(): Matrix;
  13707. /**
  13708. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13709. */
  13710. getWorldMatrix(): Matrix;
  13711. /**
  13712. * Sets the local matrix to rest pose matrix
  13713. */
  13714. returnToRest(): void;
  13715. /**
  13716. * Gets the inverse of the absolute transform matrix.
  13717. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13718. * @returns a matrix
  13719. */
  13720. getInvertedAbsoluteTransform(): Matrix;
  13721. /**
  13722. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13723. * @returns a matrix
  13724. */
  13725. getAbsoluteTransform(): Matrix;
  13726. /**
  13727. * Links with the given transform node.
  13728. * The local matrix of this bone is copied from the transform node every frame.
  13729. * @param transformNode defines the transform node to link to
  13730. */
  13731. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13732. /**
  13733. * Gets the node used to drive the bone's transformation
  13734. * @returns a transform node or null
  13735. */
  13736. getTransformNode(): Nullable<TransformNode>;
  13737. /** Gets or sets current position (in local space) */
  13738. position: Vector3;
  13739. /** Gets or sets current rotation (in local space) */
  13740. rotation: Vector3;
  13741. /** Gets or sets current rotation quaternion (in local space) */
  13742. rotationQuaternion: Quaternion;
  13743. /** Gets or sets current scaling (in local space) */
  13744. scaling: Vector3;
  13745. /**
  13746. * Gets the animation properties override
  13747. */
  13748. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13749. private _decompose;
  13750. private _compose;
  13751. /**
  13752. * Update the base and local matrices
  13753. * @param matrix defines the new base or local matrix
  13754. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13755. * @param updateLocalMatrix defines if the local matrix should be updated
  13756. */
  13757. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13758. /** @hidden */
  13759. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13760. /**
  13761. * Flag the bone as dirty (Forcing it to update everything)
  13762. */
  13763. markAsDirty(): void;
  13764. /** @hidden */
  13765. _markAsDirtyAndCompose(): void;
  13766. private _markAsDirtyAndDecompose;
  13767. /**
  13768. * Translate the bone in local or world space
  13769. * @param vec The amount to translate the bone
  13770. * @param space The space that the translation is in
  13771. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13772. */
  13773. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13774. /**
  13775. * Set the postion of the bone in local or world space
  13776. * @param position The position to set the bone
  13777. * @param space The space that the position is in
  13778. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13779. */
  13780. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13781. /**
  13782. * Set the absolute position of the bone (world space)
  13783. * @param position The position to set the bone
  13784. * @param mesh The mesh that this bone is attached to
  13785. */
  13786. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13787. /**
  13788. * Scale the bone on the x, y and z axes (in local space)
  13789. * @param x The amount to scale the bone on the x axis
  13790. * @param y The amount to scale the bone on the y axis
  13791. * @param z The amount to scale the bone on the z axis
  13792. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13793. */
  13794. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13795. /**
  13796. * Set the bone scaling in local space
  13797. * @param scale defines the scaling vector
  13798. */
  13799. setScale(scale: Vector3): void;
  13800. /**
  13801. * Gets the current scaling in local space
  13802. * @returns the current scaling vector
  13803. */
  13804. getScale(): Vector3;
  13805. /**
  13806. * Gets the current scaling in local space and stores it in a target vector
  13807. * @param result defines the target vector
  13808. */
  13809. getScaleToRef(result: Vector3): void;
  13810. /**
  13811. * Set the yaw, pitch, and roll of the bone in local or world space
  13812. * @param yaw The rotation of the bone on the y axis
  13813. * @param pitch The rotation of the bone on the x axis
  13814. * @param roll The rotation of the bone on the z axis
  13815. * @param space The space that the axes of rotation are in
  13816. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13817. */
  13818. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13819. /**
  13820. * Add a rotation to the bone on an axis in local or world space
  13821. * @param axis The axis to rotate the bone on
  13822. * @param amount The amount to rotate the bone
  13823. * @param space The space that the axis is in
  13824. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13825. */
  13826. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13827. /**
  13828. * Set the rotation of the bone to a particular axis angle in local or world space
  13829. * @param axis The axis to rotate the bone on
  13830. * @param angle The angle that the bone should be rotated to
  13831. * @param space The space that the axis is in
  13832. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13833. */
  13834. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13835. /**
  13836. * Set the euler rotation of the bone in local of world space
  13837. * @param rotation The euler rotation that the bone should be set to
  13838. * @param space The space that the rotation is in
  13839. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13840. */
  13841. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13842. /**
  13843. * Set the quaternion rotation of the bone in local of world space
  13844. * @param quat The quaternion rotation that the bone should be set to
  13845. * @param space The space that the rotation is in
  13846. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13847. */
  13848. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13849. /**
  13850. * Set the rotation matrix of the bone in local of world space
  13851. * @param rotMat The rotation matrix that the bone should be set to
  13852. * @param space The space that the rotation is in
  13853. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13854. */
  13855. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13856. private _rotateWithMatrix;
  13857. private _getNegativeRotationToRef;
  13858. /**
  13859. * Get the position of the bone in local or world space
  13860. * @param space The space that the returned position is in
  13861. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13862. * @returns The position of the bone
  13863. */
  13864. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13865. /**
  13866. * Copy the position of the bone to a vector3 in local or world space
  13867. * @param space The space that the returned position is in
  13868. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13869. * @param result The vector3 to copy the position to
  13870. */
  13871. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13872. /**
  13873. * Get the absolute position of the bone (world space)
  13874. * @param mesh The mesh that this bone is attached to
  13875. * @returns The absolute position of the bone
  13876. */
  13877. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13878. /**
  13879. * Copy the absolute position of the bone (world space) to the result param
  13880. * @param mesh The mesh that this bone is attached to
  13881. * @param result The vector3 to copy the absolute position to
  13882. */
  13883. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13884. /**
  13885. * Compute the absolute transforms of this bone and its children
  13886. */
  13887. computeAbsoluteTransforms(): void;
  13888. /**
  13889. * Get the world direction from an axis that is in the local space of the bone
  13890. * @param localAxis The local direction that is used to compute the world direction
  13891. * @param mesh The mesh that this bone is attached to
  13892. * @returns The world direction
  13893. */
  13894. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13895. /**
  13896. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13897. * @param localAxis The local direction that is used to compute the world direction
  13898. * @param mesh The mesh that this bone is attached to
  13899. * @param result The vector3 that the world direction will be copied to
  13900. */
  13901. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13902. /**
  13903. * Get the euler rotation of the bone in local or world space
  13904. * @param space The space that the rotation should be in
  13905. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13906. * @returns The euler rotation
  13907. */
  13908. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13909. /**
  13910. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13911. * @param space The space that the rotation should be in
  13912. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13913. * @param result The vector3 that the rotation should be copied to
  13914. */
  13915. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13916. /**
  13917. * Get the quaternion rotation of the bone in either local or world space
  13918. * @param space The space that the rotation should be in
  13919. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13920. * @returns The quaternion rotation
  13921. */
  13922. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13923. /**
  13924. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13925. * @param space The space that the rotation should be in
  13926. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13927. * @param result The quaternion that the rotation should be copied to
  13928. */
  13929. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13930. /**
  13931. * Get the rotation matrix of the bone in local or world space
  13932. * @param space The space that the rotation should be in
  13933. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13934. * @returns The rotation matrix
  13935. */
  13936. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13937. /**
  13938. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13939. * @param space The space that the rotation should be in
  13940. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13941. * @param result The quaternion that the rotation should be copied to
  13942. */
  13943. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13944. /**
  13945. * Get the world position of a point that is in the local space of the bone
  13946. * @param position The local position
  13947. * @param mesh The mesh that this bone is attached to
  13948. * @returns The world position
  13949. */
  13950. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13951. /**
  13952. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13953. * @param position The local position
  13954. * @param mesh The mesh that this bone is attached to
  13955. * @param result The vector3 that the world position should be copied to
  13956. */
  13957. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13958. /**
  13959. * Get the local position of a point that is in world space
  13960. * @param position The world position
  13961. * @param mesh The mesh that this bone is attached to
  13962. * @returns The local position
  13963. */
  13964. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13965. /**
  13966. * Get the local position of a point that is in world space and copy it to the result param
  13967. * @param position The world position
  13968. * @param mesh The mesh that this bone is attached to
  13969. * @param result The vector3 that the local position should be copied to
  13970. */
  13971. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13972. }
  13973. }
  13974. declare module "babylonjs/Meshes/transformNode" {
  13975. import { DeepImmutable } from "babylonjs/types";
  13976. import { Observable } from "babylonjs/Misc/observable";
  13977. import { Nullable } from "babylonjs/types";
  13978. import { Camera } from "babylonjs/Cameras/camera";
  13979. import { Scene } from "babylonjs/scene";
  13980. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  13981. import { Node } from "babylonjs/node";
  13982. import { Bone } from "babylonjs/Bones/bone";
  13983. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13984. import { Space } from "babylonjs/Maths/math.axis";
  13985. /**
  13986. * A TransformNode is an object that is not rendered but can be used as a center of transformation. This can decrease memory usage and increase rendering speed compared to using an empty mesh as a parent and is less complicated than using a pivot matrix.
  13987. * @see https://doc.babylonjs.com/how_to/transformnode
  13988. */
  13989. export class TransformNode extends Node {
  13990. /**
  13991. * Object will not rotate to face the camera
  13992. */
  13993. static BILLBOARDMODE_NONE: number;
  13994. /**
  13995. * Object will rotate to face the camera but only on the x axis
  13996. */
  13997. static BILLBOARDMODE_X: number;
  13998. /**
  13999. * Object will rotate to face the camera but only on the y axis
  14000. */
  14001. static BILLBOARDMODE_Y: number;
  14002. /**
  14003. * Object will rotate to face the camera but only on the z axis
  14004. */
  14005. static BILLBOARDMODE_Z: number;
  14006. /**
  14007. * Object will rotate to face the camera
  14008. */
  14009. static BILLBOARDMODE_ALL: number;
  14010. /**
  14011. * Object will rotate to face the camera's position instead of orientation
  14012. */
  14013. static BILLBOARDMODE_USE_POSITION: number;
  14014. private _forward;
  14015. private _forwardInverted;
  14016. private _up;
  14017. private _right;
  14018. private _rightInverted;
  14019. private _position;
  14020. private _rotation;
  14021. private _rotationQuaternion;
  14022. protected _scaling: Vector3;
  14023. protected _isDirty: boolean;
  14024. private _transformToBoneReferal;
  14025. private _isAbsoluteSynced;
  14026. private _billboardMode;
  14027. /**
  14028. * Gets or sets the billboard mode. Default is 0.
  14029. *
  14030. * | Value | Type | Description |
  14031. * | --- | --- | --- |
  14032. * | 0 | BILLBOARDMODE_NONE | |
  14033. * | 1 | BILLBOARDMODE_X | |
  14034. * | 2 | BILLBOARDMODE_Y | |
  14035. * | 4 | BILLBOARDMODE_Z | |
  14036. * | 7 | BILLBOARDMODE_ALL | |
  14037. *
  14038. */
  14039. billboardMode: number;
  14040. private _preserveParentRotationForBillboard;
  14041. /**
  14042. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14043. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14044. */
  14045. preserveParentRotationForBillboard: boolean;
  14046. /**
  14047. * Multiplication factor on scale x/y/z when computing the world matrix. Eg. for a 1x1x1 cube setting this to 2 will make it a 2x2x2 cube
  14048. */
  14049. scalingDeterminant: number;
  14050. private _infiniteDistance;
  14051. /**
  14052. * Gets or sets the distance of the object to max, often used by skybox
  14053. */
  14054. infiniteDistance: boolean;
  14055. /**
  14056. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14057. * By default the system will update normals to compensate
  14058. */
  14059. ignoreNonUniformScaling: boolean;
  14060. /**
  14061. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  14062. */
  14063. reIntegrateRotationIntoRotationQuaternion: boolean;
  14064. /** @hidden */
  14065. _poseMatrix: Nullable<Matrix>;
  14066. /** @hidden */
  14067. _localMatrix: Matrix;
  14068. private _usePivotMatrix;
  14069. private _absolutePosition;
  14070. private _absoluteScaling;
  14071. private _absoluteRotationQuaternion;
  14072. private _pivotMatrix;
  14073. private _pivotMatrixInverse;
  14074. protected _postMultiplyPivotMatrix: boolean;
  14075. protected _isWorldMatrixFrozen: boolean;
  14076. /** @hidden */
  14077. _indexInSceneTransformNodesArray: number;
  14078. /**
  14079. * An event triggered after the world matrix is updated
  14080. */
  14081. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14082. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14083. /**
  14084. * Gets a string identifying the name of the class
  14085. * @returns "TransformNode" string
  14086. */
  14087. getClassName(): string;
  14088. /**
  14089. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14090. */
  14091. position: Vector3;
  14092. /**
  14093. * Gets or sets the rotation property : a Vector3 defining the rotation value in radians around each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  14094. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14095. */
  14096. rotation: Vector3;
  14097. /**
  14098. * Gets or sets the scaling property : a Vector3 defining the node scaling along each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  14099. */
  14100. scaling: Vector3;
  14101. /**
  14102. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (undefined by default, but can be null).
  14103. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14104. */
  14105. rotationQuaternion: Nullable<Quaternion>;
  14106. /**
  14107. * The forward direction of that transform in world space.
  14108. */
  14109. readonly forward: Vector3;
  14110. /**
  14111. * The up direction of that transform in world space.
  14112. */
  14113. readonly up: Vector3;
  14114. /**
  14115. * The right direction of that transform in world space.
  14116. */
  14117. readonly right: Vector3;
  14118. /**
  14119. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14120. * @param matrix the matrix to copy the pose from
  14121. * @returns this TransformNode.
  14122. */
  14123. updatePoseMatrix(matrix: Matrix): TransformNode;
  14124. /**
  14125. * Returns the mesh Pose matrix.
  14126. * @returns the pose matrix
  14127. */
  14128. getPoseMatrix(): Matrix;
  14129. /** @hidden */
  14130. _isSynchronized(): boolean;
  14131. /** @hidden */
  14132. _initCache(): void;
  14133. /**
  14134. * Flag the transform node as dirty (Forcing it to update everything)
  14135. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14136. * @returns this transform node
  14137. */
  14138. markAsDirty(property: string): TransformNode;
  14139. /**
  14140. * Returns the current mesh absolute position.
  14141. * Returns a Vector3.
  14142. */
  14143. readonly absolutePosition: Vector3;
  14144. /**
  14145. * Returns the current mesh absolute scaling.
  14146. * Returns a Vector3.
  14147. */
  14148. readonly absoluteScaling: Vector3;
  14149. /**
  14150. * Returns the current mesh absolute rotation.
  14151. * Returns a Quaternion.
  14152. */
  14153. readonly absoluteRotationQuaternion: Quaternion;
  14154. /**
  14155. * Sets a new matrix to apply before all other transformation
  14156. * @param matrix defines the transform matrix
  14157. * @returns the current TransformNode
  14158. */
  14159. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14160. /**
  14161. * Sets a new pivot matrix to the current node
  14162. * @param matrix defines the new pivot matrix to use
  14163. * @param postMultiplyPivotMatrix defines if the pivot matrix must be cancelled in the world matrix. When this parameter is set to true (default), the inverse of the pivot matrix is also applied at the end to cancel the transformation effect
  14164. * @returns the current TransformNode
  14165. */
  14166. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14167. /**
  14168. * Returns the mesh pivot matrix.
  14169. * Default : Identity.
  14170. * @returns the matrix
  14171. */
  14172. getPivotMatrix(): Matrix;
  14173. /**
  14174. * Instantiate (when possible) or clone that node with its hierarchy
  14175. * @param newParent defines the new parent to use for the instance (or clone)
  14176. * @returns an instance (or a clone) of the current node with its hiearchy
  14177. */
  14178. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  14179. /**
  14180. * Prevents the World matrix to be computed any longer
  14181. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14182. * @returns the TransformNode.
  14183. */
  14184. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14185. /**
  14186. * Allows back the World matrix computation.
  14187. * @returns the TransformNode.
  14188. */
  14189. unfreezeWorldMatrix(): this;
  14190. /**
  14191. * True if the World matrix has been frozen.
  14192. */
  14193. readonly isWorldMatrixFrozen: boolean;
  14194. /**
  14195. * Retuns the mesh absolute position in the World.
  14196. * @returns a Vector3.
  14197. */
  14198. getAbsolutePosition(): Vector3;
  14199. /**
  14200. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14201. * @param absolutePosition the absolute position to set
  14202. * @returns the TransformNode.
  14203. */
  14204. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14205. /**
  14206. * Sets the mesh position in its local space.
  14207. * @param vector3 the position to set in localspace
  14208. * @returns the TransformNode.
  14209. */
  14210. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14211. /**
  14212. * Returns the mesh position in the local space from the current World matrix values.
  14213. * @returns a new Vector3.
  14214. */
  14215. getPositionExpressedInLocalSpace(): Vector3;
  14216. /**
  14217. * Translates the mesh along the passed Vector3 in its local space.
  14218. * @param vector3 the distance to translate in localspace
  14219. * @returns the TransformNode.
  14220. */
  14221. locallyTranslate(vector3: Vector3): TransformNode;
  14222. private static _lookAtVectorCache;
  14223. /**
  14224. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14225. * @param targetPoint the position (must be in same space as current mesh) to look at
  14226. * @param yawCor optional yaw (y-axis) correction in radians
  14227. * @param pitchCor optional pitch (x-axis) correction in radians
  14228. * @param rollCor optional roll (z-axis) correction in radians
  14229. * @param space the choosen space of the target
  14230. * @returns the TransformNode.
  14231. */
  14232. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14233. /**
  14234. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14235. * This Vector3 is expressed in the World space.
  14236. * @param localAxis axis to rotate
  14237. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14238. */
  14239. getDirection(localAxis: Vector3): Vector3;
  14240. /**
  14241. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14242. * localAxis is expressed in the mesh local space.
  14243. * result is computed in the Wordl space from the mesh World matrix.
  14244. * @param localAxis axis to rotate
  14245. * @param result the resulting transformnode
  14246. * @returns this TransformNode.
  14247. */
  14248. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14249. /**
  14250. * Sets this transform node rotation to the given local axis.
  14251. * @param localAxis the axis in local space
  14252. * @param yawCor optional yaw (y-axis) correction in radians
  14253. * @param pitchCor optional pitch (x-axis) correction in radians
  14254. * @param rollCor optional roll (z-axis) correction in radians
  14255. * @returns this TransformNode
  14256. */
  14257. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14258. /**
  14259. * Sets a new pivot point to the current node
  14260. * @param point defines the new pivot point to use
  14261. * @param space defines if the point is in world or local space (local by default)
  14262. * @returns the current TransformNode
  14263. */
  14264. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14265. /**
  14266. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14267. * @returns the pivot point
  14268. */
  14269. getPivotPoint(): Vector3;
  14270. /**
  14271. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14272. * @param result the vector3 to store the result
  14273. * @returns this TransformNode.
  14274. */
  14275. getPivotPointToRef(result: Vector3): TransformNode;
  14276. /**
  14277. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14278. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14279. */
  14280. getAbsolutePivotPoint(): Vector3;
  14281. /**
  14282. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14283. * @param result vector3 to store the result
  14284. * @returns this TransformNode.
  14285. */
  14286. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14287. /**
  14288. * Defines the passed node as the parent of the current node.
  14289. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14290. * @see https://doc.babylonjs.com/how_to/parenting
  14291. * @param node the node ot set as the parent
  14292. * @returns this TransformNode.
  14293. */
  14294. setParent(node: Nullable<Node>): TransformNode;
  14295. private _nonUniformScaling;
  14296. /**
  14297. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14298. */
  14299. readonly nonUniformScaling: boolean;
  14300. /** @hidden */
  14301. _updateNonUniformScalingState(value: boolean): boolean;
  14302. /**
  14303. * Attach the current TransformNode to another TransformNode associated with a bone
  14304. * @param bone Bone affecting the TransformNode
  14305. * @param affectedTransformNode TransformNode associated with the bone
  14306. * @returns this object
  14307. */
  14308. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14309. /**
  14310. * Detach the transform node if its associated with a bone
  14311. * @returns this object
  14312. */
  14313. detachFromBone(): TransformNode;
  14314. private static _rotationAxisCache;
  14315. /**
  14316. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14317. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14318. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14319. * The passed axis is also normalized.
  14320. * @param axis the axis to rotate around
  14321. * @param amount the amount to rotate in radians
  14322. * @param space Space to rotate in (Default: local)
  14323. * @returns the TransformNode.
  14324. */
  14325. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14326. /**
  14327. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14328. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14329. * The passed axis is also normalized. .
  14330. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14331. * @param point the point to rotate around
  14332. * @param axis the axis to rotate around
  14333. * @param amount the amount to rotate in radians
  14334. * @returns the TransformNode
  14335. */
  14336. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14337. /**
  14338. * Translates the mesh along the axis vector for the passed distance in the given space.
  14339. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14340. * @param axis the axis to translate in
  14341. * @param distance the distance to translate
  14342. * @param space Space to rotate in (Default: local)
  14343. * @returns the TransformNode.
  14344. */
  14345. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14346. /**
  14347. * Adds a rotation step to the mesh current rotation.
  14348. * x, y, z are Euler angles expressed in radians.
  14349. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14350. * This means this rotation is made in the mesh local space only.
  14351. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14352. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14353. * ```javascript
  14354. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14355. * ```
  14356. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14357. * Under the hood, only quaternions are used. So it's a little faster is you use .rotationQuaternion because it doesn't need to translate them back to Euler angles.
  14358. * @param x Rotation to add
  14359. * @param y Rotation to add
  14360. * @param z Rotation to add
  14361. * @returns the TransformNode.
  14362. */
  14363. addRotation(x: number, y: number, z: number): TransformNode;
  14364. /**
  14365. * @hidden
  14366. */
  14367. protected _getEffectiveParent(): Nullable<Node>;
  14368. /**
  14369. * Computes the world matrix of the node
  14370. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14371. * @returns the world matrix
  14372. */
  14373. computeWorldMatrix(force?: boolean): Matrix;
  14374. protected _afterComputeWorldMatrix(): void;
  14375. /**
  14376. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14377. * @param func callback function to add
  14378. *
  14379. * @returns the TransformNode.
  14380. */
  14381. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14382. /**
  14383. * Removes a registered callback function.
  14384. * @param func callback function to remove
  14385. * @returns the TransformNode.
  14386. */
  14387. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14388. /**
  14389. * Gets the position of the current mesh in camera space
  14390. * @param camera defines the camera to use
  14391. * @returns a position
  14392. */
  14393. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14394. /**
  14395. * Returns the distance from the mesh to the active camera
  14396. * @param camera defines the camera to use
  14397. * @returns the distance
  14398. */
  14399. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14400. /**
  14401. * Clone the current transform node
  14402. * @param name Name of the new clone
  14403. * @param newParent New parent for the clone
  14404. * @param doNotCloneChildren Do not clone children hierarchy
  14405. * @returns the new transform node
  14406. */
  14407. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14408. /**
  14409. * Serializes the objects information.
  14410. * @param currentSerializationObject defines the object to serialize in
  14411. * @returns the serialized object
  14412. */
  14413. serialize(currentSerializationObject?: any): any;
  14414. /**
  14415. * Returns a new TransformNode object parsed from the source provided.
  14416. * @param parsedTransformNode is the source.
  14417. * @param scene the scne the object belongs to
  14418. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14419. * @returns a new TransformNode object parsed from the source provided.
  14420. */
  14421. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14422. /**
  14423. * Get all child-transformNodes of this node
  14424. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  14425. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  14426. * @returns an array of TransformNode
  14427. */
  14428. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14429. /**
  14430. * Releases resources associated with this transform node.
  14431. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14432. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14433. */
  14434. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14435. /**
  14436. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14437. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14438. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14439. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14440. * @returns the current mesh
  14441. */
  14442. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14443. private _syncAbsoluteScalingAndRotation;
  14444. }
  14445. }
  14446. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14447. import { Observable } from "babylonjs/Misc/observable";
  14448. import { Nullable } from "babylonjs/types";
  14449. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14450. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14451. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14452. import { Ray } from "babylonjs/Culling/ray";
  14453. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14454. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14455. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14456. /**
  14457. * Defines the types of pose enabled controllers that are supported
  14458. */
  14459. export enum PoseEnabledControllerType {
  14460. /**
  14461. * HTC Vive
  14462. */
  14463. VIVE = 0,
  14464. /**
  14465. * Oculus Rift
  14466. */
  14467. OCULUS = 1,
  14468. /**
  14469. * Windows mixed reality
  14470. */
  14471. WINDOWS = 2,
  14472. /**
  14473. * Samsung gear VR
  14474. */
  14475. GEAR_VR = 3,
  14476. /**
  14477. * Google Daydream
  14478. */
  14479. DAYDREAM = 4,
  14480. /**
  14481. * Generic
  14482. */
  14483. GENERIC = 5
  14484. }
  14485. /**
  14486. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14487. */
  14488. export interface MutableGamepadButton {
  14489. /**
  14490. * Value of the button/trigger
  14491. */
  14492. value: number;
  14493. /**
  14494. * If the button/trigger is currently touched
  14495. */
  14496. touched: boolean;
  14497. /**
  14498. * If the button/trigger is currently pressed
  14499. */
  14500. pressed: boolean;
  14501. }
  14502. /**
  14503. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14504. * @hidden
  14505. */
  14506. export interface ExtendedGamepadButton extends GamepadButton {
  14507. /**
  14508. * If the button/trigger is currently pressed
  14509. */
  14510. readonly pressed: boolean;
  14511. /**
  14512. * If the button/trigger is currently touched
  14513. */
  14514. readonly touched: boolean;
  14515. /**
  14516. * Value of the button/trigger
  14517. */
  14518. readonly value: number;
  14519. }
  14520. /** @hidden */
  14521. export interface _GamePadFactory {
  14522. /**
  14523. * Returns wether or not the current gamepad can be created for this type of controller.
  14524. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14525. * @returns true if it can be created, otherwise false
  14526. */
  14527. canCreate(gamepadInfo: any): boolean;
  14528. /**
  14529. * Creates a new instance of the Gamepad.
  14530. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14531. * @returns the new gamepad instance
  14532. */
  14533. create(gamepadInfo: any): Gamepad;
  14534. }
  14535. /**
  14536. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14537. */
  14538. export class PoseEnabledControllerHelper {
  14539. /** @hidden */
  14540. static _ControllerFactories: _GamePadFactory[];
  14541. /** @hidden */
  14542. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14543. /**
  14544. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14545. * @param vrGamepad the gamepad to initialized
  14546. * @returns a vr controller of the type the gamepad identified as
  14547. */
  14548. static InitiateController(vrGamepad: any): Gamepad;
  14549. }
  14550. /**
  14551. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14552. */
  14553. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14554. /**
  14555. * If the controller is used in a webXR session
  14556. */
  14557. isXR: boolean;
  14558. private _deviceRoomPosition;
  14559. private _deviceRoomRotationQuaternion;
  14560. /**
  14561. * The device position in babylon space
  14562. */
  14563. devicePosition: Vector3;
  14564. /**
  14565. * The device rotation in babylon space
  14566. */
  14567. deviceRotationQuaternion: Quaternion;
  14568. /**
  14569. * The scale factor of the device in babylon space
  14570. */
  14571. deviceScaleFactor: number;
  14572. /**
  14573. * (Likely devicePosition should be used instead) The device position in its room space
  14574. */
  14575. position: Vector3;
  14576. /**
  14577. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14578. */
  14579. rotationQuaternion: Quaternion;
  14580. /**
  14581. * The type of controller (Eg. Windows mixed reality)
  14582. */
  14583. controllerType: PoseEnabledControllerType;
  14584. protected _calculatedPosition: Vector3;
  14585. private _calculatedRotation;
  14586. /**
  14587. * The raw pose from the device
  14588. */
  14589. rawPose: DevicePose;
  14590. private _trackPosition;
  14591. private _maxRotationDistFromHeadset;
  14592. private _draggedRoomRotation;
  14593. /**
  14594. * @hidden
  14595. */
  14596. _disableTrackPosition(fixedPosition: Vector3): void;
  14597. /**
  14598. * Internal, the mesh attached to the controller
  14599. * @hidden
  14600. */
  14601. _mesh: Nullable<AbstractMesh>;
  14602. private _poseControlledCamera;
  14603. private _leftHandSystemQuaternion;
  14604. /**
  14605. * Internal, matrix used to convert room space to babylon space
  14606. * @hidden
  14607. */
  14608. _deviceToWorld: Matrix;
  14609. /**
  14610. * Node to be used when casting a ray from the controller
  14611. * @hidden
  14612. */
  14613. _pointingPoseNode: Nullable<TransformNode>;
  14614. /**
  14615. * Name of the child mesh that can be used to cast a ray from the controller
  14616. */
  14617. static readonly POINTING_POSE: string;
  14618. /**
  14619. * Creates a new PoseEnabledController from a gamepad
  14620. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14621. */
  14622. constructor(browserGamepad: any);
  14623. private _workingMatrix;
  14624. /**
  14625. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14626. */
  14627. update(): void;
  14628. /**
  14629. * Updates only the pose device and mesh without doing any button event checking
  14630. */
  14631. protected _updatePoseAndMesh(): void;
  14632. /**
  14633. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14634. * @param poseData raw pose fromthe device
  14635. */
  14636. updateFromDevice(poseData: DevicePose): void;
  14637. /**
  14638. * @hidden
  14639. */
  14640. _meshAttachedObservable: Observable<AbstractMesh>;
  14641. /**
  14642. * Attaches a mesh to the controller
  14643. * @param mesh the mesh to be attached
  14644. */
  14645. attachToMesh(mesh: AbstractMesh): void;
  14646. /**
  14647. * Attaches the controllers mesh to a camera
  14648. * @param camera the camera the mesh should be attached to
  14649. */
  14650. attachToPoseControlledCamera(camera: TargetCamera): void;
  14651. /**
  14652. * Disposes of the controller
  14653. */
  14654. dispose(): void;
  14655. /**
  14656. * The mesh that is attached to the controller
  14657. */
  14658. readonly mesh: Nullable<AbstractMesh>;
  14659. /**
  14660. * Gets the ray of the controller in the direction the controller is pointing
  14661. * @param length the length the resulting ray should be
  14662. * @returns a ray in the direction the controller is pointing
  14663. */
  14664. getForwardRay(length?: number): Ray;
  14665. }
  14666. }
  14667. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  14668. import { Observable } from "babylonjs/Misc/observable";
  14669. import { Scene } from "babylonjs/scene";
  14670. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14671. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  14672. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  14673. /**
  14674. * Defines the WebVRController object that represents controllers tracked in 3D space
  14675. */
  14676. export abstract class WebVRController extends PoseEnabledController {
  14677. /**
  14678. * Internal, the default controller model for the controller
  14679. */
  14680. protected _defaultModel: AbstractMesh;
  14681. /**
  14682. * Fired when the trigger state has changed
  14683. */
  14684. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14685. /**
  14686. * Fired when the main button state has changed
  14687. */
  14688. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14689. /**
  14690. * Fired when the secondary button state has changed
  14691. */
  14692. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14693. /**
  14694. * Fired when the pad state has changed
  14695. */
  14696. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14697. /**
  14698. * Fired when controllers stick values have changed
  14699. */
  14700. onPadValuesChangedObservable: Observable<StickValues>;
  14701. /**
  14702. * Array of button availible on the controller
  14703. */
  14704. protected _buttons: Array<MutableGamepadButton>;
  14705. private _onButtonStateChange;
  14706. /**
  14707. * Fired when a controller button's state has changed
  14708. * @param callback the callback containing the button that was modified
  14709. */
  14710. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14711. /**
  14712. * X and Y axis corresponding to the controllers joystick
  14713. */
  14714. pad: StickValues;
  14715. /**
  14716. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14717. */
  14718. hand: string;
  14719. /**
  14720. * The default controller model for the controller
  14721. */
  14722. readonly defaultModel: AbstractMesh;
  14723. /**
  14724. * Creates a new WebVRController from a gamepad
  14725. * @param vrGamepad the gamepad that the WebVRController should be created from
  14726. */
  14727. constructor(vrGamepad: any);
  14728. /**
  14729. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14730. */
  14731. update(): void;
  14732. /**
  14733. * Function to be called when a button is modified
  14734. */
  14735. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14736. /**
  14737. * Loads a mesh and attaches it to the controller
  14738. * @param scene the scene the mesh should be added to
  14739. * @param meshLoaded callback for when the mesh has been loaded
  14740. */
  14741. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14742. private _setButtonValue;
  14743. private _changes;
  14744. private _checkChanges;
  14745. /**
  14746. * Disposes of th webVRCOntroller
  14747. */
  14748. dispose(): void;
  14749. }
  14750. }
  14751. declare module "babylonjs/Lights/hemisphericLight" {
  14752. import { Nullable } from "babylonjs/types";
  14753. import { Scene } from "babylonjs/scene";
  14754. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14755. import { Color3 } from "babylonjs/Maths/math.color";
  14756. import { Effect } from "babylonjs/Materials/effect";
  14757. import { Light } from "babylonjs/Lights/light";
  14758. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  14759. /**
  14760. * The HemisphericLight simulates the ambient environment light,
  14761. * so the passed direction is the light reflection direction, not the incoming direction.
  14762. */
  14763. export class HemisphericLight extends Light {
  14764. /**
  14765. * The groundColor is the light in the opposite direction to the one specified during creation.
  14766. * You can think of the diffuse and specular light as coming from the centre of the object in the given direction and the groundColor light in the opposite direction.
  14767. */
  14768. groundColor: Color3;
  14769. /**
  14770. * The light reflection direction, not the incoming direction.
  14771. */
  14772. direction: Vector3;
  14773. /**
  14774. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14775. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14776. * The HemisphericLight can't cast shadows.
  14777. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14778. * @param name The friendly name of the light
  14779. * @param direction The direction of the light reflection
  14780. * @param scene The scene the light belongs to
  14781. */
  14782. constructor(name: string, direction: Vector3, scene: Scene);
  14783. protected _buildUniformLayout(): void;
  14784. /**
  14785. * Returns the string "HemisphericLight".
  14786. * @return The class name
  14787. */
  14788. getClassName(): string;
  14789. /**
  14790. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14791. * Returns the updated direction.
  14792. * @param target The target the direction should point to
  14793. * @return The computed direction
  14794. */
  14795. setDirectionToTarget(target: Vector3): Vector3;
  14796. /**
  14797. * Returns the shadow generator associated to the light.
  14798. * @returns Always null for hemispheric lights because it does not support shadows.
  14799. */
  14800. getShadowGenerator(): Nullable<IShadowGenerator>;
  14801. /**
  14802. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14803. * @param effect The effect to update
  14804. * @param lightIndex The index of the light in the effect to update
  14805. * @returns The hemispheric light
  14806. */
  14807. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14808. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14809. /**
  14810. * Computes the world matrix of the node
  14811. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14812. * @param useWasUpdatedFlag defines a reserved property
  14813. * @returns the world matrix
  14814. */
  14815. computeWorldMatrix(): Matrix;
  14816. /**
  14817. * Returns the integer 3.
  14818. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14819. */
  14820. getTypeID(): number;
  14821. /**
  14822. * Prepares the list of defines specific to the light type.
  14823. * @param defines the list of defines
  14824. * @param lightIndex defines the index of the light for the effect
  14825. */
  14826. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14827. }
  14828. }
  14829. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  14830. /** @hidden */
  14831. export var vrMultiviewToSingleviewPixelShader: {
  14832. name: string;
  14833. shader: string;
  14834. };
  14835. }
  14836. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  14837. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14838. import { Scene } from "babylonjs/scene";
  14839. /**
  14840. * Renders to multiple views with a single draw call
  14841. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14842. */
  14843. export class MultiviewRenderTarget extends RenderTargetTexture {
  14844. /**
  14845. * Creates a multiview render target
  14846. * @param scene scene used with the render target
  14847. * @param size the size of the render target (used for each view)
  14848. */
  14849. constructor(scene: Scene, size?: number | {
  14850. width: number;
  14851. height: number;
  14852. } | {
  14853. ratio: number;
  14854. });
  14855. /**
  14856. * @hidden
  14857. * @param faceIndex the face index, if its a cube texture
  14858. */
  14859. _bindFrameBuffer(faceIndex?: number): void;
  14860. /**
  14861. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14862. * @returns the view count
  14863. */
  14864. getViewCount(): number;
  14865. }
  14866. }
  14867. declare module "babylonjs/Maths/math.frustum" {
  14868. import { Matrix } from "babylonjs/Maths/math.vector";
  14869. import { DeepImmutable } from "babylonjs/types";
  14870. import { Plane } from "babylonjs/Maths/math.plane";
  14871. /**
  14872. * Represents a camera frustum
  14873. */
  14874. export class Frustum {
  14875. /**
  14876. * Gets the planes representing the frustum
  14877. * @param transform matrix to be applied to the returned planes
  14878. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14879. */
  14880. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14881. /**
  14882. * Gets the near frustum plane transformed by the transform matrix
  14883. * @param transform transformation matrix to be applied to the resulting frustum plane
  14884. * @param frustumPlane the resuling frustum plane
  14885. */
  14886. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14887. /**
  14888. * Gets the far frustum plane transformed by the transform matrix
  14889. * @param transform transformation matrix to be applied to the resulting frustum plane
  14890. * @param frustumPlane the resuling frustum plane
  14891. */
  14892. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14893. /**
  14894. * Gets the left frustum plane transformed by the transform matrix
  14895. * @param transform transformation matrix to be applied to the resulting frustum plane
  14896. * @param frustumPlane the resuling frustum plane
  14897. */
  14898. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14899. /**
  14900. * Gets the right frustum plane transformed by the transform matrix
  14901. * @param transform transformation matrix to be applied to the resulting frustum plane
  14902. * @param frustumPlane the resuling frustum plane
  14903. */
  14904. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14905. /**
  14906. * Gets the top frustum plane transformed by the transform matrix
  14907. * @param transform transformation matrix to be applied to the resulting frustum plane
  14908. * @param frustumPlane the resuling frustum plane
  14909. */
  14910. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14911. /**
  14912. * Gets the bottom frustum plane transformed by the transform matrix
  14913. * @param transform transformation matrix to be applied to the resulting frustum plane
  14914. * @param frustumPlane the resuling frustum plane
  14915. */
  14916. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14917. /**
  14918. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14919. * @param transform transformation matrix to be applied to the resulting frustum planes
  14920. * @param frustumPlanes the resuling frustum planes
  14921. */
  14922. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14923. }
  14924. }
  14925. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  14926. import { Camera } from "babylonjs/Cameras/camera";
  14927. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14928. import { Nullable } from "babylonjs/types";
  14929. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14930. import { Matrix } from "babylonjs/Maths/math.vector";
  14931. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  14932. module "babylonjs/Engines/engine" {
  14933. interface Engine {
  14934. /**
  14935. * Creates a new multiview render target
  14936. * @param width defines the width of the texture
  14937. * @param height defines the height of the texture
  14938. * @returns the created multiview texture
  14939. */
  14940. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14941. /**
  14942. * Binds a multiview framebuffer to be drawn to
  14943. * @param multiviewTexture texture to bind
  14944. */
  14945. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14946. }
  14947. }
  14948. module "babylonjs/Cameras/camera" {
  14949. interface Camera {
  14950. /**
  14951. * @hidden
  14952. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  14953. */
  14954. _useMultiviewToSingleView: boolean;
  14955. /**
  14956. * @hidden
  14957. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  14958. */
  14959. _multiviewTexture: Nullable<RenderTargetTexture>;
  14960. /**
  14961. * @hidden
  14962. * ensures the multiview texture of the camera exists and has the specified width/height
  14963. * @param width height to set on the multiview texture
  14964. * @param height width to set on the multiview texture
  14965. */
  14966. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14967. }
  14968. }
  14969. module "babylonjs/scene" {
  14970. interface Scene {
  14971. /** @hidden */
  14972. _transformMatrixR: Matrix;
  14973. /** @hidden */
  14974. _multiviewSceneUbo: Nullable<UniformBuffer>;
  14975. /** @hidden */
  14976. _createMultiviewUbo(): void;
  14977. /** @hidden */
  14978. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14979. /** @hidden */
  14980. _renderMultiviewToSingleView(camera: Camera): void;
  14981. }
  14982. }
  14983. }
  14984. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  14985. import { Camera } from "babylonjs/Cameras/camera";
  14986. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  14987. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  14988. import "babylonjs/Engines/Extensions/engine.multiview";
  14989. /**
  14990. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14991. * This will not be used for webXR as it supports displaying texture arrays directly
  14992. */
  14993. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14994. /**
  14995. * Initializes a VRMultiviewToSingleview
  14996. * @param name name of the post process
  14997. * @param camera camera to be applied to
  14998. * @param scaleFactor scaling factor to the size of the output texture
  14999. */
  15000. constructor(name: string, camera: Camera, scaleFactor: number);
  15001. }
  15002. }
  15003. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  15004. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  15005. import { Nullable } from "babylonjs/types";
  15006. import { Size } from "babylonjs/Maths/math.size";
  15007. import { Observable } from "babylonjs/Misc/observable";
  15008. module "babylonjs/Engines/engine" {
  15009. interface Engine {
  15010. /** @hidden */
  15011. _vrDisplay: any;
  15012. /** @hidden */
  15013. _vrSupported: boolean;
  15014. /** @hidden */
  15015. _oldSize: Size;
  15016. /** @hidden */
  15017. _oldHardwareScaleFactor: number;
  15018. /** @hidden */
  15019. _vrExclusivePointerMode: boolean;
  15020. /** @hidden */
  15021. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15022. /** @hidden */
  15023. _onVRDisplayPointerRestricted: () => void;
  15024. /** @hidden */
  15025. _onVRDisplayPointerUnrestricted: () => void;
  15026. /** @hidden */
  15027. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15028. /** @hidden */
  15029. _onVrDisplayDisconnect: Nullable<() => void>;
  15030. /** @hidden */
  15031. _onVrDisplayPresentChange: Nullable<() => void>;
  15032. /**
  15033. * Observable signaled when VR display mode changes
  15034. */
  15035. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15036. /**
  15037. * Observable signaled when VR request present is complete
  15038. */
  15039. onVRRequestPresentComplete: Observable<boolean>;
  15040. /**
  15041. * Observable signaled when VR request present starts
  15042. */
  15043. onVRRequestPresentStart: Observable<Engine>;
  15044. /**
  15045. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15046. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15047. */
  15048. isInVRExclusivePointerMode: boolean;
  15049. /**
  15050. * Gets a boolean indicating if a webVR device was detected
  15051. * @returns true if a webVR device was detected
  15052. */
  15053. isVRDevicePresent(): boolean;
  15054. /**
  15055. * Gets the current webVR device
  15056. * @returns the current webVR device (or null)
  15057. */
  15058. getVRDevice(): any;
  15059. /**
  15060. * Initializes a webVR display and starts listening to display change events
  15061. * The onVRDisplayChangedObservable will be notified upon these changes
  15062. * @returns A promise containing a VRDisplay and if vr is supported
  15063. */
  15064. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15065. /** @hidden */
  15066. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15067. /**
  15068. * Call this function to switch to webVR mode
  15069. * Will do nothing if webVR is not supported or if there is no webVR device
  15070. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15071. */
  15072. enableVR(): void;
  15073. /** @hidden */
  15074. _onVRFullScreenTriggered(): void;
  15075. }
  15076. }
  15077. }
  15078. declare module "babylonjs/Cameras/VR/webVRCamera" {
  15079. import { Nullable } from "babylonjs/types";
  15080. import { Observable } from "babylonjs/Misc/observable";
  15081. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  15082. import { Scene } from "babylonjs/scene";
  15083. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15084. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15085. import { Node } from "babylonjs/node";
  15086. import { Ray } from "babylonjs/Culling/ray";
  15087. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15088. import "babylonjs/Engines/Extensions/engine.webVR";
  15089. /**
  15090. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15091. * IMPORTANT!! The data is right-hand data.
  15092. * @export
  15093. * @interface DevicePose
  15094. */
  15095. export interface DevicePose {
  15096. /**
  15097. * The position of the device, values in array are [x,y,z].
  15098. */
  15099. readonly position: Nullable<Float32Array>;
  15100. /**
  15101. * The linearVelocity of the device, values in array are [x,y,z].
  15102. */
  15103. readonly linearVelocity: Nullable<Float32Array>;
  15104. /**
  15105. * The linearAcceleration of the device, values in array are [x,y,z].
  15106. */
  15107. readonly linearAcceleration: Nullable<Float32Array>;
  15108. /**
  15109. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15110. */
  15111. readonly orientation: Nullable<Float32Array>;
  15112. /**
  15113. * The angularVelocity of the device, values in array are [x,y,z].
  15114. */
  15115. readonly angularVelocity: Nullable<Float32Array>;
  15116. /**
  15117. * The angularAcceleration of the device, values in array are [x,y,z].
  15118. */
  15119. readonly angularAcceleration: Nullable<Float32Array>;
  15120. }
  15121. /**
  15122. * Interface representing a pose controlled object in Babylon.
  15123. * A pose controlled object has both regular pose values as well as pose values
  15124. * from an external device such as a VR head mounted display
  15125. */
  15126. export interface PoseControlled {
  15127. /**
  15128. * The position of the object in babylon space.
  15129. */
  15130. position: Vector3;
  15131. /**
  15132. * The rotation quaternion of the object in babylon space.
  15133. */
  15134. rotationQuaternion: Quaternion;
  15135. /**
  15136. * The position of the device in babylon space.
  15137. */
  15138. devicePosition?: Vector3;
  15139. /**
  15140. * The rotation quaternion of the device in babylon space.
  15141. */
  15142. deviceRotationQuaternion: Quaternion;
  15143. /**
  15144. * The raw pose coming from the device.
  15145. */
  15146. rawPose: Nullable<DevicePose>;
  15147. /**
  15148. * The scale of the device to be used when translating from device space to babylon space.
  15149. */
  15150. deviceScaleFactor: number;
  15151. /**
  15152. * Updates the poseControlled values based on the input device pose.
  15153. * @param poseData the pose data to update the object with
  15154. */
  15155. updateFromDevice(poseData: DevicePose): void;
  15156. }
  15157. /**
  15158. * Set of options to customize the webVRCamera
  15159. */
  15160. export interface WebVROptions {
  15161. /**
  15162. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15163. */
  15164. trackPosition?: boolean;
  15165. /**
  15166. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15167. */
  15168. positionScale?: number;
  15169. /**
  15170. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15171. */
  15172. displayName?: string;
  15173. /**
  15174. * Should the native controller meshes be initialized. (default: true)
  15175. */
  15176. controllerMeshes?: boolean;
  15177. /**
  15178. * Creating a default HemiLight only on controllers. (default: true)
  15179. */
  15180. defaultLightingOnControllers?: boolean;
  15181. /**
  15182. * If you don't want to use the default VR button of the helper. (default: false)
  15183. */
  15184. useCustomVRButton?: boolean;
  15185. /**
  15186. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15187. */
  15188. customVRButton?: HTMLButtonElement;
  15189. /**
  15190. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15191. */
  15192. rayLength?: number;
  15193. /**
  15194. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15195. */
  15196. defaultHeight?: number;
  15197. /**
  15198. * If multiview should be used if availible (default: false)
  15199. */
  15200. useMultiview?: boolean;
  15201. }
  15202. /**
  15203. * This represents a WebVR camera.
  15204. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15205. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15206. */
  15207. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15208. private webVROptions;
  15209. /**
  15210. * @hidden
  15211. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15212. */
  15213. _vrDevice: any;
  15214. /**
  15215. * The rawPose of the vrDevice.
  15216. */
  15217. rawPose: Nullable<DevicePose>;
  15218. private _onVREnabled;
  15219. private _specsVersion;
  15220. private _attached;
  15221. private _frameData;
  15222. protected _descendants: Array<Node>;
  15223. private _deviceRoomPosition;
  15224. /** @hidden */
  15225. _deviceRoomRotationQuaternion: Quaternion;
  15226. private _standingMatrix;
  15227. /**
  15228. * Represents device position in babylon space.
  15229. */
  15230. devicePosition: Vector3;
  15231. /**
  15232. * Represents device rotation in babylon space.
  15233. */
  15234. deviceRotationQuaternion: Quaternion;
  15235. /**
  15236. * The scale of the device to be used when translating from device space to babylon space.
  15237. */
  15238. deviceScaleFactor: number;
  15239. private _deviceToWorld;
  15240. private _worldToDevice;
  15241. /**
  15242. * References to the webVR controllers for the vrDevice.
  15243. */
  15244. controllers: Array<WebVRController>;
  15245. /**
  15246. * Emits an event when a controller is attached.
  15247. */
  15248. onControllersAttachedObservable: Observable<WebVRController[]>;
  15249. /**
  15250. * Emits an event when a controller's mesh has been loaded;
  15251. */
  15252. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15253. /**
  15254. * Emits an event when the HMD's pose has been updated.
  15255. */
  15256. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15257. private _poseSet;
  15258. /**
  15259. * If the rig cameras be used as parent instead of this camera.
  15260. */
  15261. rigParenting: boolean;
  15262. private _lightOnControllers;
  15263. private _defaultHeight?;
  15264. /**
  15265. * Instantiates a WebVRFreeCamera.
  15266. * @param name The name of the WebVRFreeCamera
  15267. * @param position The starting anchor position for the camera
  15268. * @param scene The scene the camera belongs to
  15269. * @param webVROptions a set of customizable options for the webVRCamera
  15270. */
  15271. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15272. /**
  15273. * Gets the device distance from the ground in meters.
  15274. * @returns the distance in meters from the vrDevice to ground in device space. If standing matrix is not supported for the vrDevice 0 is returned.
  15275. */
  15276. deviceDistanceToRoomGround(): number;
  15277. /**
  15278. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15279. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15280. */
  15281. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15282. /**
  15283. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15284. * @returns A promise with a boolean set to if the standing matrix is supported.
  15285. */
  15286. useStandingMatrixAsync(): Promise<boolean>;
  15287. /**
  15288. * Disposes the camera
  15289. */
  15290. dispose(): void;
  15291. /**
  15292. * Gets a vrController by name.
  15293. * @param name The name of the controller to retreive
  15294. * @returns the controller matching the name specified or null if not found
  15295. */
  15296. getControllerByName(name: string): Nullable<WebVRController>;
  15297. private _leftController;
  15298. /**
  15299. * The controller corresponding to the users left hand.
  15300. */
  15301. readonly leftController: Nullable<WebVRController>;
  15302. private _rightController;
  15303. /**
  15304. * The controller corresponding to the users right hand.
  15305. */
  15306. readonly rightController: Nullable<WebVRController>;
  15307. /**
  15308. * Casts a ray forward from the vrCamera's gaze.
  15309. * @param length Length of the ray (default: 100)
  15310. * @returns the ray corresponding to the gaze
  15311. */
  15312. getForwardRay(length?: number): Ray;
  15313. /**
  15314. * @hidden
  15315. * Updates the camera based on device's frame data
  15316. */
  15317. _checkInputs(): void;
  15318. /**
  15319. * Updates the poseControlled values based on the input device pose.
  15320. * @param poseData Pose coming from the device
  15321. */
  15322. updateFromDevice(poseData: DevicePose): void;
  15323. private _htmlElementAttached;
  15324. private _detachIfAttached;
  15325. /**
  15326. * WebVR's attach control will start broadcasting frames to the device.
  15327. * Note that in certain browsers (chrome for example) this function must be called
  15328. * within a user-interaction callback. Example:
  15329. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15330. *
  15331. * @param element html element to attach the vrDevice to
  15332. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15333. */
  15334. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15335. /**
  15336. * Detaches the camera from the html element and disables VR
  15337. *
  15338. * @param element html element to detach from
  15339. */
  15340. detachControl(element: HTMLElement): void;
  15341. /**
  15342. * @returns the name of this class
  15343. */
  15344. getClassName(): string;
  15345. /**
  15346. * Calls resetPose on the vrDisplay
  15347. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15348. */
  15349. resetToCurrentRotation(): void;
  15350. /**
  15351. * @hidden
  15352. * Updates the rig cameras (left and right eye)
  15353. */
  15354. _updateRigCameras(): void;
  15355. private _workingVector;
  15356. private _oneVector;
  15357. private _workingMatrix;
  15358. private updateCacheCalled;
  15359. private _correctPositionIfNotTrackPosition;
  15360. /**
  15361. * @hidden
  15362. * Updates the cached values of the camera
  15363. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15364. */
  15365. _updateCache(ignoreParentClass?: boolean): void;
  15366. /**
  15367. * @hidden
  15368. * Get current device position in babylon world
  15369. */
  15370. _computeDevicePosition(): void;
  15371. /**
  15372. * Updates the current device position and rotation in the babylon world
  15373. */
  15374. update(): void;
  15375. /**
  15376. * @hidden
  15377. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15378. * @returns an identity matrix
  15379. */
  15380. _getViewMatrix(): Matrix;
  15381. private _tmpMatrix;
  15382. /**
  15383. * This function is called by the two RIG cameras.
  15384. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15385. * @hidden
  15386. */
  15387. _getWebVRViewMatrix(): Matrix;
  15388. /** @hidden */
  15389. _getWebVRProjectionMatrix(): Matrix;
  15390. private _onGamepadConnectedObserver;
  15391. private _onGamepadDisconnectedObserver;
  15392. private _updateCacheWhenTrackingDisabledObserver;
  15393. /**
  15394. * Initializes the controllers and their meshes
  15395. */
  15396. initControllers(): void;
  15397. }
  15398. }
  15399. declare module "babylonjs/PostProcesses/postProcess" {
  15400. import { Nullable } from "babylonjs/types";
  15401. import { SmartArray } from "babylonjs/Misc/smartArray";
  15402. import { Observable } from "babylonjs/Misc/observable";
  15403. import { Vector2 } from "babylonjs/Maths/math.vector";
  15404. import { Camera } from "babylonjs/Cameras/camera";
  15405. import { Effect } from "babylonjs/Materials/effect";
  15406. import "babylonjs/Shaders/postprocess.vertex";
  15407. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15408. import { Engine } from "babylonjs/Engines/engine";
  15409. import { Color4 } from "babylonjs/Maths/math.color";
  15410. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15411. /**
  15412. * Size options for a post process
  15413. */
  15414. export type PostProcessOptions = {
  15415. width: number;
  15416. height: number;
  15417. };
  15418. /**
  15419. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15420. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15421. */
  15422. export class PostProcess {
  15423. /** Name of the PostProcess. */
  15424. name: string;
  15425. /**
  15426. * Gets or sets the unique id of the post process
  15427. */
  15428. uniqueId: number;
  15429. /**
  15430. * Width of the texture to apply the post process on
  15431. */
  15432. width: number;
  15433. /**
  15434. * Height of the texture to apply the post process on
  15435. */
  15436. height: number;
  15437. /**
  15438. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15439. * @hidden
  15440. */
  15441. _outputTexture: Nullable<InternalTexture>;
  15442. /**
  15443. * Sampling mode used by the shader
  15444. * See https://doc.babylonjs.com/classes/3.1/texture
  15445. */
  15446. renderTargetSamplingMode: number;
  15447. /**
  15448. * Clear color to use when screen clearing
  15449. */
  15450. clearColor: Color4;
  15451. /**
  15452. * If the buffer needs to be cleared before applying the post process. (default: true)
  15453. * Should be set to false if shader will overwrite all previous pixels.
  15454. */
  15455. autoClear: boolean;
  15456. /**
  15457. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15458. */
  15459. alphaMode: number;
  15460. /**
  15461. * Sets the setAlphaBlendConstants of the babylon engine
  15462. */
  15463. alphaConstants: Color4;
  15464. /**
  15465. * Animations to be used for the post processing
  15466. */
  15467. animations: import("babylonjs/Animations/animation").Animation[];
  15468. /**
  15469. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15470. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15471. */
  15472. enablePixelPerfectMode: boolean;
  15473. /**
  15474. * Force the postprocess to be applied without taking in account viewport
  15475. */
  15476. forceFullscreenViewport: boolean;
  15477. /**
  15478. * List of inspectable custom properties (used by the Inspector)
  15479. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15480. */
  15481. inspectableCustomProperties: IInspectable[];
  15482. /**
  15483. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15484. *
  15485. * | Value | Type | Description |
  15486. * | ----- | ----------------------------------- | ----------- |
  15487. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15488. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15489. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15490. *
  15491. */
  15492. scaleMode: number;
  15493. /**
  15494. * Force textures to be a power of two (default: false)
  15495. */
  15496. alwaysForcePOT: boolean;
  15497. private _samples;
  15498. /**
  15499. * Number of sample textures (default: 1)
  15500. */
  15501. samples: number;
  15502. /**
  15503. * Modify the scale of the post process to be the same as the viewport (default: false)
  15504. */
  15505. adaptScaleToCurrentViewport: boolean;
  15506. private _camera;
  15507. private _scene;
  15508. private _engine;
  15509. private _options;
  15510. private _reusable;
  15511. private _textureType;
  15512. /**
  15513. * Smart array of input and output textures for the post process.
  15514. * @hidden
  15515. */
  15516. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15517. /**
  15518. * The index in _textures that corresponds to the output texture.
  15519. * @hidden
  15520. */
  15521. _currentRenderTextureInd: number;
  15522. private _effect;
  15523. private _samplers;
  15524. private _fragmentUrl;
  15525. private _vertexUrl;
  15526. private _parameters;
  15527. private _scaleRatio;
  15528. protected _indexParameters: any;
  15529. private _shareOutputWithPostProcess;
  15530. private _texelSize;
  15531. private _forcedOutputTexture;
  15532. /**
  15533. * Returns the fragment url or shader name used in the post process.
  15534. * @returns the fragment url or name in the shader store.
  15535. */
  15536. getEffectName(): string;
  15537. /**
  15538. * An event triggered when the postprocess is activated.
  15539. */
  15540. onActivateObservable: Observable<Camera>;
  15541. private _onActivateObserver;
  15542. /**
  15543. * A function that is added to the onActivateObservable
  15544. */
  15545. onActivate: Nullable<(camera: Camera) => void>;
  15546. /**
  15547. * An event triggered when the postprocess changes its size.
  15548. */
  15549. onSizeChangedObservable: Observable<PostProcess>;
  15550. private _onSizeChangedObserver;
  15551. /**
  15552. * A function that is added to the onSizeChangedObservable
  15553. */
  15554. onSizeChanged: (postProcess: PostProcess) => void;
  15555. /**
  15556. * An event triggered when the postprocess applies its effect.
  15557. */
  15558. onApplyObservable: Observable<Effect>;
  15559. private _onApplyObserver;
  15560. /**
  15561. * A function that is added to the onApplyObservable
  15562. */
  15563. onApply: (effect: Effect) => void;
  15564. /**
  15565. * An event triggered before rendering the postprocess
  15566. */
  15567. onBeforeRenderObservable: Observable<Effect>;
  15568. private _onBeforeRenderObserver;
  15569. /**
  15570. * A function that is added to the onBeforeRenderObservable
  15571. */
  15572. onBeforeRender: (effect: Effect) => void;
  15573. /**
  15574. * An event triggered after rendering the postprocess
  15575. */
  15576. onAfterRenderObservable: Observable<Effect>;
  15577. private _onAfterRenderObserver;
  15578. /**
  15579. * A function that is added to the onAfterRenderObservable
  15580. */
  15581. onAfterRender: (efect: Effect) => void;
  15582. /**
  15583. * The input texture for this post process and the output texture of the previous post process. When added to a pipeline the previous post process will
  15584. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15585. */
  15586. inputTexture: InternalTexture;
  15587. /**
  15588. * Gets the camera which post process is applied to.
  15589. * @returns The camera the post process is applied to.
  15590. */
  15591. getCamera(): Camera;
  15592. /**
  15593. * Gets the texel size of the postprocess.
  15594. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15595. */
  15596. readonly texelSize: Vector2;
  15597. /**
  15598. * Creates a new instance PostProcess
  15599. * @param name The name of the PostProcess.
  15600. * @param fragmentUrl The url of the fragment shader to be used.
  15601. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15602. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15603. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15604. * @param camera The camera to apply the render pass to.
  15605. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15606. * @param engine The engine which the post process will be applied. (default: current engine)
  15607. * @param reusable If the post process can be reused on the same frame. (default: false)
  15608. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15609. * @param textureType Type of textures used when performing the post process. (default: 0)
  15610. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15611. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  15612. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15613. */
  15614. constructor(
  15615. /** Name of the PostProcess. */
  15616. name: string, fragmentUrl: string, parameters: Nullable<string[]>, samplers: Nullable<string[]>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, defines?: Nullable<string>, textureType?: number, vertexUrl?: string, indexParameters?: any, blockCompilation?: boolean);
  15617. /**
  15618. * Gets a string idenfifying the name of the class
  15619. * @returns "PostProcess" string
  15620. */
  15621. getClassName(): string;
  15622. /**
  15623. * Gets the engine which this post process belongs to.
  15624. * @returns The engine the post process was enabled with.
  15625. */
  15626. getEngine(): Engine;
  15627. /**
  15628. * The effect that is created when initializing the post process.
  15629. * @returns The created effect corresponding the the postprocess.
  15630. */
  15631. getEffect(): Effect;
  15632. /**
  15633. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15634. * @param postProcess The post process to share the output with.
  15635. * @returns This post process.
  15636. */
  15637. shareOutputWith(postProcess: PostProcess): PostProcess;
  15638. /**
  15639. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15640. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15641. */
  15642. useOwnOutput(): void;
  15643. /**
  15644. * Updates the effect with the current post process compile time values and recompiles the shader.
  15645. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15646. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15647. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15648. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  15649. * @param onCompiled Called when the shader has been compiled.
  15650. * @param onError Called if there is an error when compiling a shader.
  15651. */
  15652. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15653. /**
  15654. * The post process is reusable if it can be used multiple times within one frame.
  15655. * @returns If the post process is reusable
  15656. */
  15657. isReusable(): boolean;
  15658. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15659. markTextureDirty(): void;
  15660. /**
  15661. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15662. * When this post process is used in a pipeline, this is call will bind the input texture of this post process to the output of the previous.
  15663. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15664. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15665. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15666. * @returns The target texture that was bound to be written to.
  15667. */
  15668. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15669. /**
  15670. * If the post process is supported.
  15671. */
  15672. readonly isSupported: boolean;
  15673. /**
  15674. * The aspect ratio of the output texture.
  15675. */
  15676. readonly aspectRatio: number;
  15677. /**
  15678. * Get a value indicating if the post-process is ready to be used
  15679. * @returns true if the post-process is ready (shader is compiled)
  15680. */
  15681. isReady(): boolean;
  15682. /**
  15683. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15684. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15685. */
  15686. apply(): Nullable<Effect>;
  15687. private _disposeTextures;
  15688. /**
  15689. * Disposes the post process.
  15690. * @param camera The camera to dispose the post process on.
  15691. */
  15692. dispose(camera?: Camera): void;
  15693. }
  15694. }
  15695. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  15696. /** @hidden */
  15697. export var kernelBlurVaryingDeclaration: {
  15698. name: string;
  15699. shader: string;
  15700. };
  15701. }
  15702. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  15703. /** @hidden */
  15704. export var kernelBlurFragment: {
  15705. name: string;
  15706. shader: string;
  15707. };
  15708. }
  15709. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  15710. /** @hidden */
  15711. export var kernelBlurFragment2: {
  15712. name: string;
  15713. shader: string;
  15714. };
  15715. }
  15716. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  15717. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15718. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  15719. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  15720. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  15721. /** @hidden */
  15722. export var kernelBlurPixelShader: {
  15723. name: string;
  15724. shader: string;
  15725. };
  15726. }
  15727. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  15728. /** @hidden */
  15729. export var kernelBlurVertex: {
  15730. name: string;
  15731. shader: string;
  15732. };
  15733. }
  15734. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  15735. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15736. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  15737. /** @hidden */
  15738. export var kernelBlurVertexShader: {
  15739. name: string;
  15740. shader: string;
  15741. };
  15742. }
  15743. declare module "babylonjs/PostProcesses/blurPostProcess" {
  15744. import { Vector2 } from "babylonjs/Maths/math.vector";
  15745. import { Nullable } from "babylonjs/types";
  15746. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  15747. import { Camera } from "babylonjs/Cameras/camera";
  15748. import { Effect } from "babylonjs/Materials/effect";
  15749. import { Engine } from "babylonjs/Engines/engine";
  15750. import "babylonjs/Shaders/kernelBlur.fragment";
  15751. import "babylonjs/Shaders/kernelBlur.vertex";
  15752. /**
  15753. * The Blur Post Process which blurs an image based on a kernel and direction.
  15754. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15755. */
  15756. export class BlurPostProcess extends PostProcess {
  15757. /** The direction in which to blur the image. */
  15758. direction: Vector2;
  15759. private blockCompilation;
  15760. protected _kernel: number;
  15761. protected _idealKernel: number;
  15762. protected _packedFloat: boolean;
  15763. private _staticDefines;
  15764. /**
  15765. * Sets the length in pixels of the blur sample region
  15766. */
  15767. /**
  15768. * Gets the length in pixels of the blur sample region
  15769. */
  15770. kernel: number;
  15771. /**
  15772. * Sets wether or not the blur needs to unpack/repack floats
  15773. */
  15774. /**
  15775. * Gets wether or not the blur is unpacking/repacking floats
  15776. */
  15777. packedFloat: boolean;
  15778. /**
  15779. * Creates a new instance BlurPostProcess
  15780. * @param name The name of the effect.
  15781. * @param direction The direction in which to blur the image.
  15782. * @param kernel The size of the kernel to be used when computing the blur. eg. Size of 3 will blur the center pixel by 2 pixels surrounding it.
  15783. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15784. * @param camera The camera to apply the render pass to.
  15785. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15786. * @param engine The engine which the post process will be applied. (default: current engine)
  15787. * @param reusable If the post process can be reused on the same frame. (default: false)
  15788. * @param textureType Type of textures used when performing the post process. (default: 0)
  15789. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  15790. */
  15791. constructor(name: string,
  15792. /** The direction in which to blur the image. */
  15793. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15794. /**
  15795. * Updates the effect with the current post process compile time values and recompiles the shader.
  15796. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15797. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15798. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15799. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  15800. * @param onCompiled Called when the shader has been compiled.
  15801. * @param onError Called if there is an error when compiling a shader.
  15802. */
  15803. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15804. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15805. /**
  15806. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15807. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15808. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15809. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15810. * The gaps between physical kernels are compensated for in the weighting of the samples
  15811. * @param idealKernel Ideal blur kernel.
  15812. * @return Nearest best kernel.
  15813. */
  15814. protected _nearestBestKernel(idealKernel: number): number;
  15815. /**
  15816. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15817. * @param x The point on the Gaussian distribution to sample.
  15818. * @return the value of the Gaussian function at x.
  15819. */
  15820. protected _gaussianWeight(x: number): number;
  15821. /**
  15822. * Generates a string that can be used as a floating point number in GLSL.
  15823. * @param x Value to print.
  15824. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15825. * @return GLSL float string.
  15826. */
  15827. protected _glslFloat(x: number, decimalFigures?: number): string;
  15828. }
  15829. }
  15830. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  15831. import { Scene } from "babylonjs/scene";
  15832. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15833. import { Plane } from "babylonjs/Maths/math.plane";
  15834. /**
  15835. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15836. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15837. * You can then easily use it as a reflectionTexture on a flat surface.
  15838. * In case the surface is not a plane, please consider relying on reflection probes.
  15839. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15840. */
  15841. export class MirrorTexture extends RenderTargetTexture {
  15842. private scene;
  15843. /**
  15844. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15845. * It is possible to directly set the mirrorPlane by directly using a Plane(a, b, c, d) where a, b and c give the plane normal vector (a, b, c) and d is a scalar displacement from the mirrorPlane to the origin. However in all but the very simplest of situations it is more straight forward to set it to the reflector as stated in the doc.
  15846. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15847. */
  15848. mirrorPlane: Plane;
  15849. /**
  15850. * Define the blur ratio used to blur the reflection if needed.
  15851. */
  15852. blurRatio: number;
  15853. /**
  15854. * Define the adaptive blur kernel used to blur the reflection if needed.
  15855. * This will autocompute the closest best match for the `blurKernel`
  15856. */
  15857. adaptiveBlurKernel: number;
  15858. /**
  15859. * Define the blur kernel used to blur the reflection if needed.
  15860. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15861. */
  15862. blurKernel: number;
  15863. /**
  15864. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15865. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15866. */
  15867. blurKernelX: number;
  15868. /**
  15869. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15870. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15871. */
  15872. blurKernelY: number;
  15873. private _autoComputeBlurKernel;
  15874. protected _onRatioRescale(): void;
  15875. private _updateGammaSpace;
  15876. private _imageProcessingConfigChangeObserver;
  15877. private _transformMatrix;
  15878. private _mirrorMatrix;
  15879. private _savedViewMatrix;
  15880. private _blurX;
  15881. private _blurY;
  15882. private _adaptiveBlurKernel;
  15883. private _blurKernelX;
  15884. private _blurKernelY;
  15885. private _blurRatio;
  15886. /**
  15887. * Instantiates a Mirror Texture.
  15888. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15889. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15890. * You can then easily use it as a reflectionTexture on a flat surface.
  15891. * In case the surface is not a plane, please consider relying on reflection probes.
  15892. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15893. * @param name
  15894. * @param size
  15895. * @param scene
  15896. * @param generateMipMaps
  15897. * @param type
  15898. * @param samplingMode
  15899. * @param generateDepthBuffer
  15900. */
  15901. constructor(name: string, size: number | {
  15902. width: number;
  15903. height: number;
  15904. } | {
  15905. ratio: number;
  15906. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15907. private _preparePostProcesses;
  15908. /**
  15909. * Clone the mirror texture.
  15910. * @returns the cloned texture
  15911. */
  15912. clone(): MirrorTexture;
  15913. /**
  15914. * Serialize the texture to a JSON representation you could use in Parse later on
  15915. * @returns the serialized JSON representation
  15916. */
  15917. serialize(): any;
  15918. /**
  15919. * Dispose the texture and release its associated resources.
  15920. */
  15921. dispose(): void;
  15922. }
  15923. }
  15924. declare module "babylonjs/Materials/Textures/texture" {
  15925. import { Observable } from "babylonjs/Misc/observable";
  15926. import { Nullable } from "babylonjs/types";
  15927. import { Scene } from "babylonjs/scene";
  15928. import { Matrix } from "babylonjs/Maths/math.vector";
  15929. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15930. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15931. import { Engine } from "babylonjs/Engines/engine";
  15932. /**
  15933. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15934. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15935. */
  15936. export class Texture extends BaseTexture {
  15937. /**
  15938. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  15939. */
  15940. static SerializeBuffers: boolean;
  15941. /** @hidden */
  15942. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  15943. /** @hidden */
  15944. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  15945. /** @hidden */
  15946. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  15947. /** nearest is mag = nearest and min = nearest and mip = linear */
  15948. static readonly NEAREST_SAMPLINGMODE: number;
  15949. /** nearest is mag = nearest and min = nearest and mip = linear */
  15950. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15951. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15952. static readonly BILINEAR_SAMPLINGMODE: number;
  15953. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15954. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15955. /** Trilinear is mag = linear and min = linear and mip = linear */
  15956. static readonly TRILINEAR_SAMPLINGMODE: number;
  15957. /** Trilinear is mag = linear and min = linear and mip = linear */
  15958. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15959. /** mag = nearest and min = nearest and mip = nearest */
  15960. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15961. /** mag = nearest and min = linear and mip = nearest */
  15962. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15963. /** mag = nearest and min = linear and mip = linear */
  15964. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15965. /** mag = nearest and min = linear and mip = none */
  15966. static readonly NEAREST_LINEAR: number;
  15967. /** mag = nearest and min = nearest and mip = none */
  15968. static readonly NEAREST_NEAREST: number;
  15969. /** mag = linear and min = nearest and mip = nearest */
  15970. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15971. /** mag = linear and min = nearest and mip = linear */
  15972. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15973. /** mag = linear and min = linear and mip = none */
  15974. static readonly LINEAR_LINEAR: number;
  15975. /** mag = linear and min = nearest and mip = none */
  15976. static readonly LINEAR_NEAREST: number;
  15977. /** Explicit coordinates mode */
  15978. static readonly EXPLICIT_MODE: number;
  15979. /** Spherical coordinates mode */
  15980. static readonly SPHERICAL_MODE: number;
  15981. /** Planar coordinates mode */
  15982. static readonly PLANAR_MODE: number;
  15983. /** Cubic coordinates mode */
  15984. static readonly CUBIC_MODE: number;
  15985. /** Projection coordinates mode */
  15986. static readonly PROJECTION_MODE: number;
  15987. /** Inverse Cubic coordinates mode */
  15988. static readonly SKYBOX_MODE: number;
  15989. /** Inverse Cubic coordinates mode */
  15990. static readonly INVCUBIC_MODE: number;
  15991. /** Equirectangular coordinates mode */
  15992. static readonly EQUIRECTANGULAR_MODE: number;
  15993. /** Equirectangular Fixed coordinates mode */
  15994. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15995. /** Equirectangular Fixed Mirrored coordinates mode */
  15996. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15997. /** Texture is not repeating outside of 0..1 UVs */
  15998. static readonly CLAMP_ADDRESSMODE: number;
  15999. /** Texture is repeating outside of 0..1 UVs */
  16000. static readonly WRAP_ADDRESSMODE: number;
  16001. /** Texture is repeating and mirrored */
  16002. static readonly MIRROR_ADDRESSMODE: number;
  16003. /**
  16004. * Gets or sets a boolean which defines if the texture url must be build from the serialized URL instead of just using the name and loading them side by side with the scene file
  16005. */
  16006. static UseSerializedUrlIfAny: boolean;
  16007. /**
  16008. * Define the url of the texture.
  16009. */
  16010. url: Nullable<string>;
  16011. /**
  16012. * Define an offset on the texture to offset the u coordinates of the UVs
  16013. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16014. */
  16015. uOffset: number;
  16016. /**
  16017. * Define an offset on the texture to offset the v coordinates of the UVs
  16018. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16019. */
  16020. vOffset: number;
  16021. /**
  16022. * Define an offset on the texture to scale the u coordinates of the UVs
  16023. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16024. */
  16025. uScale: number;
  16026. /**
  16027. * Define an offset on the texture to scale the v coordinates of the UVs
  16028. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16029. */
  16030. vScale: number;
  16031. /**
  16032. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16033. * @see http://doc.babylonjs.com/how_to/more_materials
  16034. */
  16035. uAng: number;
  16036. /**
  16037. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16038. * @see http://doc.babylonjs.com/how_to/more_materials
  16039. */
  16040. vAng: number;
  16041. /**
  16042. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16043. * @see http://doc.babylonjs.com/how_to/more_materials
  16044. */
  16045. wAng: number;
  16046. /**
  16047. * Defines the center of rotation (U)
  16048. */
  16049. uRotationCenter: number;
  16050. /**
  16051. * Defines the center of rotation (V)
  16052. */
  16053. vRotationCenter: number;
  16054. /**
  16055. * Defines the center of rotation (W)
  16056. */
  16057. wRotationCenter: number;
  16058. /**
  16059. * Are mip maps generated for this texture or not.
  16060. */
  16061. readonly noMipmap: boolean;
  16062. /**
  16063. * List of inspectable custom properties (used by the Inspector)
  16064. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16065. */
  16066. inspectableCustomProperties: Nullable<IInspectable[]>;
  16067. private _noMipmap;
  16068. /** @hidden */
  16069. _invertY: boolean;
  16070. private _rowGenerationMatrix;
  16071. private _cachedTextureMatrix;
  16072. private _projectionModeMatrix;
  16073. private _t0;
  16074. private _t1;
  16075. private _t2;
  16076. private _cachedUOffset;
  16077. private _cachedVOffset;
  16078. private _cachedUScale;
  16079. private _cachedVScale;
  16080. private _cachedUAng;
  16081. private _cachedVAng;
  16082. private _cachedWAng;
  16083. private _cachedProjectionMatrixId;
  16084. private _cachedCoordinatesMode;
  16085. /** @hidden */
  16086. protected _initialSamplingMode: number;
  16087. /** @hidden */
  16088. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  16089. private _deleteBuffer;
  16090. protected _format: Nullable<number>;
  16091. private _delayedOnLoad;
  16092. private _delayedOnError;
  16093. /**
  16094. * Observable triggered once the texture has been loaded.
  16095. */
  16096. onLoadObservable: Observable<Texture>;
  16097. protected _isBlocking: boolean;
  16098. /**
  16099. * Is the texture preventing material to render while loading.
  16100. * If false, a default texture will be used instead of the loading one during the preparation step.
  16101. */
  16102. isBlocking: boolean;
  16103. /**
  16104. * Get the current sampling mode associated with the texture.
  16105. */
  16106. readonly samplingMode: number;
  16107. /**
  16108. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16109. */
  16110. readonly invertY: boolean;
  16111. /**
  16112. * Instantiates a new texture.
  16113. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16114. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16115. * @param url define the url of the picture to load as a texture
  16116. * @param scene define the scene or engine the texture will belong to
  16117. * @param noMipmap define if the texture will require mip maps or not
  16118. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16119. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16120. * @param onLoad define a callback triggered when the texture has been loaded
  16121. * @param onError define a callback triggered when an error occurred during the loading session
  16122. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16123. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16124. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16125. */
  16126. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  16127. /**
  16128. * Update the url (and optional buffer) of this texture if url was null during construction.
  16129. * @param url the url of the texture
  16130. * @param buffer the buffer of the texture (defaults to null)
  16131. * @param onLoad callback called when the texture is loaded (defaults to null)
  16132. */
  16133. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16134. /**
  16135. * Finish the loading sequence of a texture flagged as delayed load.
  16136. * @hidden
  16137. */
  16138. delayLoad(): void;
  16139. private _prepareRowForTextureGeneration;
  16140. /**
  16141. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16142. * @returns the transform matrix of the texture.
  16143. */
  16144. getTextureMatrix(): Matrix;
  16145. /**
  16146. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16147. * @returns The reflection texture transform
  16148. */
  16149. getReflectionTextureMatrix(): Matrix;
  16150. /**
  16151. * Clones the texture.
  16152. * @returns the cloned texture
  16153. */
  16154. clone(): Texture;
  16155. /**
  16156. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16157. * @returns The JSON representation of the texture
  16158. */
  16159. serialize(): any;
  16160. /**
  16161. * Get the current class name of the texture useful for serialization or dynamic coding.
  16162. * @returns "Texture"
  16163. */
  16164. getClassName(): string;
  16165. /**
  16166. * Dispose the texture and release its associated resources.
  16167. */
  16168. dispose(): void;
  16169. /**
  16170. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16171. * @param parsedTexture Define the JSON representation of the texture
  16172. * @param scene Define the scene the parsed texture should be instantiated in
  16173. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16174. * @returns The parsed texture if successful
  16175. */
  16176. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16177. /**
  16178. * Creates a texture from its base 64 representation.
  16179. * @param data Define the base64 payload without the data: prefix
  16180. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16181. * @param scene Define the scene the texture should belong to
  16182. * @param noMipmap Forces the texture to not create mip map information if true
  16183. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16184. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16185. * @param onLoad define a callback triggered when the texture has been loaded
  16186. * @param onError define a callback triggered when an error occurred during the loading session
  16187. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16188. * @returns the created texture
  16189. */
  16190. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16191. /**
  16192. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16193. * @param data Define the base64 payload without the data: prefix
  16194. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16195. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16196. * @param scene Define the scene the texture should belong to
  16197. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16198. * @param noMipmap Forces the texture to not create mip map information if true
  16199. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16200. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16201. * @param onLoad define a callback triggered when the texture has been loaded
  16202. * @param onError define a callback triggered when an error occurred during the loading session
  16203. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16204. * @returns the created texture
  16205. */
  16206. static LoadFromDataString(name: string, buffer: any, scene: Scene, deleteBuffer?: boolean, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number): Texture;
  16207. }
  16208. }
  16209. declare module "babylonjs/PostProcesses/postProcessManager" {
  16210. import { Nullable } from "babylonjs/types";
  16211. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16212. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16213. import { Scene } from "babylonjs/scene";
  16214. /**
  16215. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16216. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16217. */
  16218. export class PostProcessManager {
  16219. private _scene;
  16220. private _indexBuffer;
  16221. private _vertexBuffers;
  16222. /**
  16223. * Creates a new instance PostProcess
  16224. * @param scene The scene that the post process is associated with.
  16225. */
  16226. constructor(scene: Scene);
  16227. private _prepareBuffers;
  16228. private _buildIndexBuffer;
  16229. /**
  16230. * Rebuilds the vertex buffers of the manager.
  16231. * @hidden
  16232. */
  16233. _rebuild(): void;
  16234. /**
  16235. * Prepares a frame to be run through a post process.
  16236. * @param sourceTexture The input texture to the post procesess. (default: null)
  16237. * @param postProcesses An array of post processes to be run. (default: null)
  16238. * @returns True if the post processes were able to be run.
  16239. * @hidden
  16240. */
  16241. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16242. /**
  16243. * Manually render a set of post processes to a texture.
  16244. * @param postProcesses An array of post processes to be run.
  16245. * @param targetTexture The target texture to render to.
  16246. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16247. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16248. * @param lodLevel defines which lod of the texture to render to
  16249. */
  16250. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16251. /**
  16252. * Finalize the result of the output of the postprocesses.
  16253. * @param doNotPresent If true the result will not be displayed to the screen.
  16254. * @param targetTexture The target texture to render to.
  16255. * @param faceIndex The index of the face to bind the target texture to.
  16256. * @param postProcesses The array of post processes to render.
  16257. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16258. * @hidden
  16259. */
  16260. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16261. /**
  16262. * Disposes of the post process manager.
  16263. */
  16264. dispose(): void;
  16265. }
  16266. }
  16267. declare module "babylonjs/Misc/gradients" {
  16268. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16269. /** Interface used by value gradients (color, factor, ...) */
  16270. export interface IValueGradient {
  16271. /**
  16272. * Gets or sets the gradient value (between 0 and 1)
  16273. */
  16274. gradient: number;
  16275. }
  16276. /** Class used to store color4 gradient */
  16277. export class ColorGradient implements IValueGradient {
  16278. /**
  16279. * Gets or sets the gradient value (between 0 and 1)
  16280. */
  16281. gradient: number;
  16282. /**
  16283. * Gets or sets first associated color
  16284. */
  16285. color1: Color4;
  16286. /**
  16287. * Gets or sets second associated color
  16288. */
  16289. color2?: Color4;
  16290. /**
  16291. * Will get a color picked randomly between color1 and color2.
  16292. * If color2 is undefined then color1 will be used
  16293. * @param result defines the target Color4 to store the result in
  16294. */
  16295. getColorToRef(result: Color4): void;
  16296. }
  16297. /** Class used to store color 3 gradient */
  16298. export class Color3Gradient implements IValueGradient {
  16299. /**
  16300. * Gets or sets the gradient value (between 0 and 1)
  16301. */
  16302. gradient: number;
  16303. /**
  16304. * Gets or sets the associated color
  16305. */
  16306. color: Color3;
  16307. }
  16308. /** Class used to store factor gradient */
  16309. export class FactorGradient implements IValueGradient {
  16310. /**
  16311. * Gets or sets the gradient value (between 0 and 1)
  16312. */
  16313. gradient: number;
  16314. /**
  16315. * Gets or sets first associated factor
  16316. */
  16317. factor1: number;
  16318. /**
  16319. * Gets or sets second associated factor
  16320. */
  16321. factor2?: number;
  16322. /**
  16323. * Will get a number picked randomly between factor1 and factor2.
  16324. * If factor2 is undefined then factor1 will be used
  16325. * @returns the picked number
  16326. */
  16327. getFactor(): number;
  16328. }
  16329. /**
  16330. * Helper used to simplify some generic gradient tasks
  16331. */
  16332. export class GradientHelper {
  16333. /**
  16334. * Gets the current gradient from an array of IValueGradient
  16335. * @param ratio defines the current ratio to get
  16336. * @param gradients defines the array of IValueGradient
  16337. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16338. */
  16339. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16340. }
  16341. }
  16342. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  16343. import { Scene } from "babylonjs/scene";
  16344. import { Texture } from "babylonjs/Materials/Textures/texture";
  16345. /**
  16346. * A class extending Texture allowing drawing on a texture
  16347. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16348. */
  16349. export class DynamicTexture extends Texture {
  16350. private _generateMipMaps;
  16351. private _canvas;
  16352. private _context;
  16353. private _engine;
  16354. /**
  16355. * Creates a DynamicTexture
  16356. * @param name defines the name of the texture
  16357. * @param options provides 3 alternatives for width and height of texture, a canvas, object with width and height properties, number for both width and height
  16358. * @param scene defines the scene where you want the texture
  16359. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16360. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16361. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16362. */
  16363. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16364. /**
  16365. * Get the current class name of the texture useful for serialization or dynamic coding.
  16366. * @returns "DynamicTexture"
  16367. */
  16368. getClassName(): string;
  16369. /**
  16370. * Gets the current state of canRescale
  16371. */
  16372. readonly canRescale: boolean;
  16373. private _recreate;
  16374. /**
  16375. * Scales the texture
  16376. * @param ratio the scale factor to apply to both width and height
  16377. */
  16378. scale(ratio: number): void;
  16379. /**
  16380. * Resizes the texture
  16381. * @param width the new width
  16382. * @param height the new height
  16383. */
  16384. scaleTo(width: number, height: number): void;
  16385. /**
  16386. * Gets the context of the canvas used by the texture
  16387. * @returns the canvas context of the dynamic texture
  16388. */
  16389. getContext(): CanvasRenderingContext2D;
  16390. /**
  16391. * Clears the texture
  16392. */
  16393. clear(): void;
  16394. /**
  16395. * Updates the texture
  16396. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16397. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16398. */
  16399. update(invertY?: boolean, premulAlpha?: boolean): void;
  16400. /**
  16401. * Draws text onto the texture
  16402. * @param text defines the text to be drawn
  16403. * @param x defines the placement of the text from the left
  16404. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16405. * @param font defines the font to be used with font-style, font-size, font-name
  16406. * @param color defines the color used for the text
  16407. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16408. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16409. * @param update defines whether texture is immediately update (default is true)
  16410. */
  16411. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16412. /**
  16413. * Clones the texture
  16414. * @returns the clone of the texture.
  16415. */
  16416. clone(): DynamicTexture;
  16417. /**
  16418. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16419. * @returns a serialized dynamic texture object
  16420. */
  16421. serialize(): any;
  16422. /** @hidden */
  16423. _rebuild(): void;
  16424. }
  16425. }
  16426. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16427. import { Scene } from "babylonjs/scene";
  16428. import { ISceneComponent } from "babylonjs/sceneComponent";
  16429. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16430. module "babylonjs/abstractScene" {
  16431. interface AbstractScene {
  16432. /**
  16433. * The list of procedural textures added to the scene
  16434. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16435. */
  16436. proceduralTextures: Array<ProceduralTexture>;
  16437. }
  16438. }
  16439. /**
  16440. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16441. * in a given scene.
  16442. */
  16443. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16444. /**
  16445. * The component name helpfull to identify the component in the list of scene components.
  16446. */
  16447. readonly name: string;
  16448. /**
  16449. * The scene the component belongs to.
  16450. */
  16451. scene: Scene;
  16452. /**
  16453. * Creates a new instance of the component for the given scene
  16454. * @param scene Defines the scene to register the component in
  16455. */
  16456. constructor(scene: Scene);
  16457. /**
  16458. * Registers the component in a given scene
  16459. */
  16460. register(): void;
  16461. /**
  16462. * Rebuilds the elements related to this component in case of
  16463. * context lost for instance.
  16464. */
  16465. rebuild(): void;
  16466. /**
  16467. * Disposes the component and the associated ressources.
  16468. */
  16469. dispose(): void;
  16470. private _beforeClear;
  16471. }
  16472. }
  16473. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  16474. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16475. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16476. module "babylonjs/Engines/engine" {
  16477. interface Engine {
  16478. /**
  16479. * Creates a new render target cube texture
  16480. * @param size defines the size of the texture
  16481. * @param options defines the options used to create the texture
  16482. * @returns a new render target cube texture stored in an InternalTexture
  16483. */
  16484. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16485. }
  16486. }
  16487. }
  16488. declare module "babylonjs/Shaders/procedural.vertex" {
  16489. /** @hidden */
  16490. export var proceduralVertexShader: {
  16491. name: string;
  16492. shader: string;
  16493. };
  16494. }
  16495. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16496. import { Observable } from "babylonjs/Misc/observable";
  16497. import { Nullable } from "babylonjs/types";
  16498. import { Scene } from "babylonjs/scene";
  16499. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16500. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16501. import { Effect } from "babylonjs/Materials/effect";
  16502. import { Texture } from "babylonjs/Materials/Textures/texture";
  16503. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16504. import "babylonjs/Shaders/procedural.vertex";
  16505. /**
  16506. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes calmpler' images.
  16507. * This is the base class of any Procedural texture and contains most of the shareable code.
  16508. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16509. */
  16510. export class ProceduralTexture extends Texture {
  16511. isCube: boolean;
  16512. /**
  16513. * Define if the texture is enabled or not (disabled texture will not render)
  16514. */
  16515. isEnabled: boolean;
  16516. /**
  16517. * Define if the texture must be cleared before rendering (default is true)
  16518. */
  16519. autoClear: boolean;
  16520. /**
  16521. * Callback called when the texture is generated
  16522. */
  16523. onGenerated: () => void;
  16524. /**
  16525. * Event raised when the texture is generated
  16526. */
  16527. onGeneratedObservable: Observable<ProceduralTexture>;
  16528. /** @hidden */
  16529. _generateMipMaps: boolean;
  16530. /** @hidden **/
  16531. _effect: Effect;
  16532. /** @hidden */
  16533. _textures: {
  16534. [key: string]: Texture;
  16535. };
  16536. private _size;
  16537. private _currentRefreshId;
  16538. private _refreshRate;
  16539. private _vertexBuffers;
  16540. private _indexBuffer;
  16541. private _uniforms;
  16542. private _samplers;
  16543. private _fragment;
  16544. private _floats;
  16545. private _ints;
  16546. private _floatsArrays;
  16547. private _colors3;
  16548. private _colors4;
  16549. private _vectors2;
  16550. private _vectors3;
  16551. private _matrices;
  16552. private _fallbackTexture;
  16553. private _fallbackTextureUsed;
  16554. private _engine;
  16555. private _cachedDefines;
  16556. private _contentUpdateId;
  16557. private _contentData;
  16558. /**
  16559. * Instantiates a new procedural texture.
  16560. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  16561. * This is the base class of any Procedural texture and contains most of the shareable code.
  16562. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16563. * @param name Define the name of the texture
  16564. * @param size Define the size of the texture to create
  16565. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16566. * @param scene Define the scene the texture belongs to
  16567. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16568. * @param generateMipMaps Define if the texture should creates mip maps or not
  16569. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16570. */
  16571. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16572. /**
  16573. * The effect that is created when initializing the post process.
  16574. * @returns The created effect corresponding the the postprocess.
  16575. */
  16576. getEffect(): Effect;
  16577. /**
  16578. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16579. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16580. */
  16581. getContent(): Nullable<ArrayBufferView>;
  16582. private _createIndexBuffer;
  16583. /** @hidden */
  16584. _rebuild(): void;
  16585. /**
  16586. * Resets the texture in order to recreate its associated resources.
  16587. * This can be called in case of context loss
  16588. */
  16589. reset(): void;
  16590. protected _getDefines(): string;
  16591. /**
  16592. * Is the texture ready to be used ? (rendered at least once)
  16593. * @returns true if ready, otherwise, false.
  16594. */
  16595. isReady(): boolean;
  16596. /**
  16597. * Resets the refresh counter of the texture and start bak from scratch.
  16598. * Could be useful to regenerate the texture if it is setup to render only once.
  16599. */
  16600. resetRefreshCounter(): void;
  16601. /**
  16602. * Set the fragment shader to use in order to render the texture.
  16603. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16604. */
  16605. setFragment(fragment: any): void;
  16606. /**
  16607. * Define the refresh rate of the texture or the rendering frequency.
  16608. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16609. */
  16610. refreshRate: number;
  16611. /** @hidden */
  16612. _shouldRender(): boolean;
  16613. /**
  16614. * Get the size the texture is rendering at.
  16615. * @returns the size (texture is always squared)
  16616. */
  16617. getRenderSize(): number;
  16618. /**
  16619. * Resize the texture to new value.
  16620. * @param size Define the new size the texture should have
  16621. * @param generateMipMaps Define whether the new texture should create mip maps
  16622. */
  16623. resize(size: number, generateMipMaps: boolean): void;
  16624. private _checkUniform;
  16625. /**
  16626. * Set a texture in the shader program used to render.
  16627. * @param name Define the name of the uniform samplers as defined in the shader
  16628. * @param texture Define the texture to bind to this sampler
  16629. * @return the texture itself allowing "fluent" like uniform updates
  16630. */
  16631. setTexture(name: string, texture: Texture): ProceduralTexture;
  16632. /**
  16633. * Set a float in the shader.
  16634. * @param name Define the name of the uniform as defined in the shader
  16635. * @param value Define the value to give to the uniform
  16636. * @return the texture itself allowing "fluent" like uniform updates
  16637. */
  16638. setFloat(name: string, value: number): ProceduralTexture;
  16639. /**
  16640. * Set a int in the shader.
  16641. * @param name Define the name of the uniform as defined in the shader
  16642. * @param value Define the value to give to the uniform
  16643. * @return the texture itself allowing "fluent" like uniform updates
  16644. */
  16645. setInt(name: string, value: number): ProceduralTexture;
  16646. /**
  16647. * Set an array of floats in the shader.
  16648. * @param name Define the name of the uniform as defined in the shader
  16649. * @param value Define the value to give to the uniform
  16650. * @return the texture itself allowing "fluent" like uniform updates
  16651. */
  16652. setFloats(name: string, value: number[]): ProceduralTexture;
  16653. /**
  16654. * Set a vec3 in the shader from a Color3.
  16655. * @param name Define the name of the uniform as defined in the shader
  16656. * @param value Define the value to give to the uniform
  16657. * @return the texture itself allowing "fluent" like uniform updates
  16658. */
  16659. setColor3(name: string, value: Color3): ProceduralTexture;
  16660. /**
  16661. * Set a vec4 in the shader from a Color4.
  16662. * @param name Define the name of the uniform as defined in the shader
  16663. * @param value Define the value to give to the uniform
  16664. * @return the texture itself allowing "fluent" like uniform updates
  16665. */
  16666. setColor4(name: string, value: Color4): ProceduralTexture;
  16667. /**
  16668. * Set a vec2 in the shader from a Vector2.
  16669. * @param name Define the name of the uniform as defined in the shader
  16670. * @param value Define the value to give to the uniform
  16671. * @return the texture itself allowing "fluent" like uniform updates
  16672. */
  16673. setVector2(name: string, value: Vector2): ProceduralTexture;
  16674. /**
  16675. * Set a vec3 in the shader from a Vector3.
  16676. * @param name Define the name of the uniform as defined in the shader
  16677. * @param value Define the value to give to the uniform
  16678. * @return the texture itself allowing "fluent" like uniform updates
  16679. */
  16680. setVector3(name: string, value: Vector3): ProceduralTexture;
  16681. /**
  16682. * Set a mat4 in the shader from a MAtrix.
  16683. * @param name Define the name of the uniform as defined in the shader
  16684. * @param value Define the value to give to the uniform
  16685. * @return the texture itself allowing "fluent" like uniform updates
  16686. */
  16687. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16688. /**
  16689. * Render the texture to its associated render target.
  16690. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16691. */
  16692. render(useCameraPostProcess?: boolean): void;
  16693. /**
  16694. * Clone the texture.
  16695. * @returns the cloned texture
  16696. */
  16697. clone(): ProceduralTexture;
  16698. /**
  16699. * Dispose the texture and release its asoociated resources.
  16700. */
  16701. dispose(): void;
  16702. }
  16703. }
  16704. declare module "babylonjs/Particles/baseParticleSystem" {
  16705. import { Nullable } from "babylonjs/types";
  16706. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  16707. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16708. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  16709. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16710. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16711. import { Scene } from "babylonjs/scene";
  16712. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  16713. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16714. import { Texture } from "babylonjs/Materials/Textures/texture";
  16715. import { Color4 } from "babylonjs/Maths/math.color";
  16716. import { Animation } from "babylonjs/Animations/animation";
  16717. /**
  16718. * This represents the base class for particle system in Babylon.
  16719. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  16720. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16721. * @example https://doc.babylonjs.com/babylon101/particles
  16722. */
  16723. export class BaseParticleSystem {
  16724. /**
  16725. * Source color is added to the destination color without alpha affecting the result
  16726. */
  16727. static BLENDMODE_ONEONE: number;
  16728. /**
  16729. * Blend current color and particle color using particle’s alpha
  16730. */
  16731. static BLENDMODE_STANDARD: number;
  16732. /**
  16733. * Add current color and particle color multiplied by particle’s alpha
  16734. */
  16735. static BLENDMODE_ADD: number;
  16736. /**
  16737. * Multiply current color with particle color
  16738. */
  16739. static BLENDMODE_MULTIPLY: number;
  16740. /**
  16741. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16742. */
  16743. static BLENDMODE_MULTIPLYADD: number;
  16744. /**
  16745. * List of animations used by the particle system.
  16746. */
  16747. animations: Animation[];
  16748. /**
  16749. * The id of the Particle system.
  16750. */
  16751. id: string;
  16752. /**
  16753. * The friendly name of the Particle system.
  16754. */
  16755. name: string;
  16756. /**
  16757. * The rendering group used by the Particle system to chose when to render.
  16758. */
  16759. renderingGroupId: number;
  16760. /**
  16761. * The emitter represents the Mesh or position we are attaching the particle system to.
  16762. */
  16763. emitter: Nullable<AbstractMesh | Vector3>;
  16764. /**
  16765. * The maximum number of particles to emit per frame
  16766. */
  16767. emitRate: number;
  16768. /**
  16769. * If you want to launch only a few particles at once, that can be done, as well.
  16770. */
  16771. manualEmitCount: number;
  16772. /**
  16773. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16774. */
  16775. updateSpeed: number;
  16776. /**
  16777. * The amount of time the particle system is running (depends of the overall update speed).
  16778. */
  16779. targetStopDuration: number;
  16780. /**
  16781. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16782. */
  16783. disposeOnStop: boolean;
  16784. /**
  16785. * Minimum power of emitting particles.
  16786. */
  16787. minEmitPower: number;
  16788. /**
  16789. * Maximum power of emitting particles.
  16790. */
  16791. maxEmitPower: number;
  16792. /**
  16793. * Minimum life time of emitting particles.
  16794. */
  16795. minLifeTime: number;
  16796. /**
  16797. * Maximum life time of emitting particles.
  16798. */
  16799. maxLifeTime: number;
  16800. /**
  16801. * Minimum Size of emitting particles.
  16802. */
  16803. minSize: number;
  16804. /**
  16805. * Maximum Size of emitting particles.
  16806. */
  16807. maxSize: number;
  16808. /**
  16809. * Minimum scale of emitting particles on X axis.
  16810. */
  16811. minScaleX: number;
  16812. /**
  16813. * Maximum scale of emitting particles on X axis.
  16814. */
  16815. maxScaleX: number;
  16816. /**
  16817. * Minimum scale of emitting particles on Y axis.
  16818. */
  16819. minScaleY: number;
  16820. /**
  16821. * Maximum scale of emitting particles on Y axis.
  16822. */
  16823. maxScaleY: number;
  16824. /**
  16825. * Gets or sets the minimal initial rotation in radians.
  16826. */
  16827. minInitialRotation: number;
  16828. /**
  16829. * Gets or sets the maximal initial rotation in radians.
  16830. */
  16831. maxInitialRotation: number;
  16832. /**
  16833. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16834. */
  16835. minAngularSpeed: number;
  16836. /**
  16837. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16838. */
  16839. maxAngularSpeed: number;
  16840. /**
  16841. * The texture used to render each particle. (this can be a spritesheet)
  16842. */
  16843. particleTexture: Nullable<Texture>;
  16844. /**
  16845. * The layer mask we are rendering the particles through.
  16846. */
  16847. layerMask: number;
  16848. /**
  16849. * This can help using your own shader to render the particle system.
  16850. * The according effect will be created
  16851. */
  16852. customShader: any;
  16853. /**
  16854. * By default particle system starts as soon as they are created. This prevents the
  16855. * automatic start to happen and let you decide when to start emitting particles.
  16856. */
  16857. preventAutoStart: boolean;
  16858. private _noiseTexture;
  16859. /**
  16860. * Gets or sets a texture used to add random noise to particle positions
  16861. */
  16862. noiseTexture: Nullable<ProceduralTexture>;
  16863. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16864. noiseStrength: Vector3;
  16865. /**
  16866. * Callback triggered when the particle animation is ending.
  16867. */
  16868. onAnimationEnd: Nullable<() => void>;
  16869. /**
  16870. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16871. */
  16872. blendMode: number;
  16873. /**
  16874. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16875. * to override the particles.
  16876. */
  16877. forceDepthWrite: boolean;
  16878. /** Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0 */
  16879. preWarmCycles: number;
  16880. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16881. preWarmStepOffset: number;
  16882. /**
  16883. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  16884. */
  16885. spriteCellChangeSpeed: number;
  16886. /**
  16887. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16888. */
  16889. startSpriteCellID: number;
  16890. /**
  16891. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16892. */
  16893. endSpriteCellID: number;
  16894. /**
  16895. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16896. */
  16897. spriteCellWidth: number;
  16898. /**
  16899. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16900. */
  16901. spriteCellHeight: number;
  16902. /**
  16903. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16904. */
  16905. spriteRandomStartCell: boolean;
  16906. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16907. translationPivot: Vector2;
  16908. /** @hidden */
  16909. protected _isAnimationSheetEnabled: boolean;
  16910. /**
  16911. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16912. */
  16913. beginAnimationOnStart: boolean;
  16914. /**
  16915. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16916. */
  16917. beginAnimationFrom: number;
  16918. /**
  16919. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16920. */
  16921. beginAnimationTo: number;
  16922. /**
  16923. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16924. */
  16925. beginAnimationLoop: boolean;
  16926. /**
  16927. * Gets or sets a world offset applied to all particles
  16928. */
  16929. worldOffset: Vector3;
  16930. /**
  16931. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16932. */
  16933. isAnimationSheetEnabled: boolean;
  16934. /**
  16935. * Get hosting scene
  16936. * @returns the scene
  16937. */
  16938. getScene(): Scene;
  16939. /**
  16940. * You can use gravity if you want to give an orientation to your particles.
  16941. */
  16942. gravity: Vector3;
  16943. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16944. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16945. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16946. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16947. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16948. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16949. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16950. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16951. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16952. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16953. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16954. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16955. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16956. /**
  16957. * Defines the delay in milliseconds before starting the system (0 by default)
  16958. */
  16959. startDelay: number;
  16960. /**
  16961. * Gets the current list of drag gradients.
  16962. * You must use addDragGradient and removeDragGradient to udpate this list
  16963. * @returns the list of drag gradients
  16964. */
  16965. getDragGradients(): Nullable<Array<FactorGradient>>;
  16966. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16967. limitVelocityDamping: number;
  16968. /**
  16969. * Gets the current list of limit velocity gradients.
  16970. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16971. * @returns the list of limit velocity gradients
  16972. */
  16973. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16974. /**
  16975. * Gets the current list of color gradients.
  16976. * You must use addColorGradient and removeColorGradient to udpate this list
  16977. * @returns the list of color gradients
  16978. */
  16979. getColorGradients(): Nullable<Array<ColorGradient>>;
  16980. /**
  16981. * Gets the current list of size gradients.
  16982. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16983. * @returns the list of size gradients
  16984. */
  16985. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16986. /**
  16987. * Gets the current list of color remap gradients.
  16988. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16989. * @returns the list of color remap gradients
  16990. */
  16991. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16992. /**
  16993. * Gets the current list of alpha remap gradients.
  16994. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16995. * @returns the list of alpha remap gradients
  16996. */
  16997. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16998. /**
  16999. * Gets the current list of life time gradients.
  17000. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17001. * @returns the list of life time gradients
  17002. */
  17003. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17004. /**
  17005. * Gets the current list of angular speed gradients.
  17006. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17007. * @returns the list of angular speed gradients
  17008. */
  17009. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17010. /**
  17011. * Gets the current list of velocity gradients.
  17012. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17013. * @returns the list of velocity gradients
  17014. */
  17015. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17016. /**
  17017. * Gets the current list of start size gradients.
  17018. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17019. * @returns the list of start size gradients
  17020. */
  17021. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17022. /**
  17023. * Gets the current list of emit rate gradients.
  17024. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17025. * @returns the list of emit rate gradients
  17026. */
  17027. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17028. /**
  17029. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17030. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17031. */
  17032. direction1: Vector3;
  17033. /**
  17034. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17035. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17036. */
  17037. direction2: Vector3;
  17038. /**
  17039. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  17040. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17041. */
  17042. minEmitBox: Vector3;
  17043. /**
  17044. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  17045. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17046. */
  17047. maxEmitBox: Vector3;
  17048. /**
  17049. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17050. */
  17051. color1: Color4;
  17052. /**
  17053. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17054. */
  17055. color2: Color4;
  17056. /**
  17057. * Color the particle will have at the end of its lifetime
  17058. */
  17059. colorDead: Color4;
  17060. /**
  17061. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  17062. */
  17063. textureMask: Color4;
  17064. /**
  17065. * The particle emitter type defines the emitter used by the particle system.
  17066. * It can be for example box, sphere, or cone...
  17067. */
  17068. particleEmitterType: IParticleEmitterType;
  17069. /** @hidden */
  17070. _isSubEmitter: boolean;
  17071. /**
  17072. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17073. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17074. */
  17075. billboardMode: number;
  17076. protected _isBillboardBased: boolean;
  17077. /**
  17078. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17079. */
  17080. isBillboardBased: boolean;
  17081. /**
  17082. * The scene the particle system belongs to.
  17083. */
  17084. protected _scene: Scene;
  17085. /**
  17086. * Local cache of defines for image processing.
  17087. */
  17088. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  17089. /**
  17090. * Default configuration related to image processing available in the standard Material.
  17091. */
  17092. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17093. /**
  17094. * Gets the image processing configuration used either in this material.
  17095. */
  17096. /**
  17097. * Sets the Default image processing configuration used either in the this material.
  17098. *
  17099. * If sets to null, the scene one is in use.
  17100. */
  17101. imageProcessingConfiguration: ImageProcessingConfiguration;
  17102. /**
  17103. * Attaches a new image processing configuration to the Standard Material.
  17104. * @param configuration
  17105. */
  17106. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17107. /** @hidden */
  17108. protected _reset(): void;
  17109. /** @hidden */
  17110. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17111. /**
  17112. * Instantiates a particle system.
  17113. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  17114. * @param name The name of the particle system
  17115. */
  17116. constructor(name: string);
  17117. /**
  17118. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17119. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17120. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17121. * @returns the emitter
  17122. */
  17123. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17124. /**
  17125. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17126. * @param radius The radius of the hemisphere to emit from
  17127. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17128. * @returns the emitter
  17129. */
  17130. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17131. /**
  17132. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17133. * @param radius The radius of the sphere to emit from
  17134. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17135. * @returns the emitter
  17136. */
  17137. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17138. /**
  17139. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17140. * @param radius The radius of the sphere to emit from
  17141. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17142. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17143. * @returns the emitter
  17144. */
  17145. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17146. /**
  17147. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17148. * @param radius The radius of the emission cylinder
  17149. * @param height The height of the emission cylinder
  17150. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17151. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17152. * @returns the emitter
  17153. */
  17154. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17155. /**
  17156. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17157. * @param radius The radius of the cylinder to emit from
  17158. * @param height The height of the emission cylinder
  17159. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17160. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17161. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17162. * @returns the emitter
  17163. */
  17164. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17165. /**
  17166. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17167. * @param radius The radius of the cone to emit from
  17168. * @param angle The base angle of the cone
  17169. * @returns the emitter
  17170. */
  17171. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17172. /**
  17173. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17174. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17175. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17176. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17177. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17178. * @returns the emitter
  17179. */
  17180. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17181. }
  17182. }
  17183. declare module "babylonjs/Particles/subEmitter" {
  17184. import { Scene } from "babylonjs/scene";
  17185. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17186. /**
  17187. * Type of sub emitter
  17188. */
  17189. export enum SubEmitterType {
  17190. /**
  17191. * Attached to the particle over it's lifetime
  17192. */
  17193. ATTACHED = 0,
  17194. /**
  17195. * Created when the particle dies
  17196. */
  17197. END = 1
  17198. }
  17199. /**
  17200. * Sub emitter class used to emit particles from an existing particle
  17201. */
  17202. export class SubEmitter {
  17203. /**
  17204. * the particle system to be used by the sub emitter
  17205. */
  17206. particleSystem: ParticleSystem;
  17207. /**
  17208. * Type of the submitter (Default: END)
  17209. */
  17210. type: SubEmitterType;
  17211. /**
  17212. * If the particle should inherit the direction from the particle it's attached to. (+Y will face the direction the particle is moving) (Default: false)
  17213. * Note: This only is supported when using an emitter of type Mesh
  17214. */
  17215. inheritDirection: boolean;
  17216. /**
  17217. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17218. */
  17219. inheritedVelocityAmount: number;
  17220. /**
  17221. * Creates a sub emitter
  17222. * @param particleSystem the particle system to be used by the sub emitter
  17223. */
  17224. constructor(
  17225. /**
  17226. * the particle system to be used by the sub emitter
  17227. */
  17228. particleSystem: ParticleSystem);
  17229. /**
  17230. * Clones the sub emitter
  17231. * @returns the cloned sub emitter
  17232. */
  17233. clone(): SubEmitter;
  17234. /**
  17235. * Serialize current object to a JSON object
  17236. * @returns the serialized object
  17237. */
  17238. serialize(): any;
  17239. /** @hidden */
  17240. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17241. /**
  17242. * Creates a new SubEmitter from a serialized JSON version
  17243. * @param serializationObject defines the JSON object to read from
  17244. * @param scene defines the hosting scene
  17245. * @param rootUrl defines the rootUrl for data loading
  17246. * @returns a new SubEmitter
  17247. */
  17248. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17249. /** Release associated resources */
  17250. dispose(): void;
  17251. }
  17252. }
  17253. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17254. /** @hidden */
  17255. export var clipPlaneFragmentDeclaration: {
  17256. name: string;
  17257. shader: string;
  17258. };
  17259. }
  17260. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17261. /** @hidden */
  17262. export var imageProcessingDeclaration: {
  17263. name: string;
  17264. shader: string;
  17265. };
  17266. }
  17267. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17268. /** @hidden */
  17269. export var imageProcessingFunctions: {
  17270. name: string;
  17271. shader: string;
  17272. };
  17273. }
  17274. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17275. /** @hidden */
  17276. export var clipPlaneFragment: {
  17277. name: string;
  17278. shader: string;
  17279. };
  17280. }
  17281. declare module "babylonjs/Shaders/particles.fragment" {
  17282. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17283. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17284. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17285. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17286. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17287. /** @hidden */
  17288. export var particlesPixelShader: {
  17289. name: string;
  17290. shader: string;
  17291. };
  17292. }
  17293. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17294. /** @hidden */
  17295. export var clipPlaneVertexDeclaration: {
  17296. name: string;
  17297. shader: string;
  17298. };
  17299. }
  17300. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17301. /** @hidden */
  17302. export var clipPlaneVertex: {
  17303. name: string;
  17304. shader: string;
  17305. };
  17306. }
  17307. declare module "babylonjs/Shaders/particles.vertex" {
  17308. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17309. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17310. /** @hidden */
  17311. export var particlesVertexShader: {
  17312. name: string;
  17313. shader: string;
  17314. };
  17315. }
  17316. declare module "babylonjs/Particles/particleSystem" {
  17317. import { Nullable } from "babylonjs/types";
  17318. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17319. import { Observable } from "babylonjs/Misc/observable";
  17320. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17321. import { Effect } from "babylonjs/Materials/effect";
  17322. import { Scene, IDisposable } from "babylonjs/scene";
  17323. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17324. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17325. import { Particle } from "babylonjs/Particles/particle";
  17326. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17327. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17328. import "babylonjs/Shaders/particles.fragment";
  17329. import "babylonjs/Shaders/particles.vertex";
  17330. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17331. /**
  17332. * This represents a particle system in Babylon.
  17333. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  17334. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17335. * @example https://doc.babylonjs.com/babylon101/particles
  17336. */
  17337. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17338. /**
  17339. * Billboard mode will only apply to Y axis
  17340. */
  17341. static readonly BILLBOARDMODE_Y: number;
  17342. /**
  17343. * Billboard mode will apply to all axes
  17344. */
  17345. static readonly BILLBOARDMODE_ALL: number;
  17346. /**
  17347. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17348. */
  17349. static readonly BILLBOARDMODE_STRETCHED: number;
  17350. /**
  17351. * This function can be defined to provide custom update for active particles.
  17352. * This function will be called instead of regular update (age, position, color, etc.).
  17353. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17354. */
  17355. updateFunction: (particles: Particle[]) => void;
  17356. private _emitterWorldMatrix;
  17357. /**
  17358. * This function can be defined to specify initial direction for every new particle.
  17359. * It by default use the emitterType defined function
  17360. */
  17361. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17362. /**
  17363. * This function can be defined to specify initial position for every new particle.
  17364. * It by default use the emitterType defined function
  17365. */
  17366. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17367. /**
  17368. * @hidden
  17369. */
  17370. _inheritedVelocityOffset: Vector3;
  17371. /**
  17372. * An event triggered when the system is disposed
  17373. */
  17374. onDisposeObservable: Observable<ParticleSystem>;
  17375. private _onDisposeObserver;
  17376. /**
  17377. * Sets a callback that will be triggered when the system is disposed
  17378. */
  17379. onDispose: () => void;
  17380. private _particles;
  17381. private _epsilon;
  17382. private _capacity;
  17383. private _stockParticles;
  17384. private _newPartsExcess;
  17385. private _vertexData;
  17386. private _vertexBuffer;
  17387. private _vertexBuffers;
  17388. private _spriteBuffer;
  17389. private _indexBuffer;
  17390. private _effect;
  17391. private _customEffect;
  17392. private _cachedDefines;
  17393. private _scaledColorStep;
  17394. private _colorDiff;
  17395. private _scaledDirection;
  17396. private _scaledGravity;
  17397. private _currentRenderId;
  17398. private _alive;
  17399. private _useInstancing;
  17400. private _started;
  17401. private _stopped;
  17402. private _actualFrame;
  17403. private _scaledUpdateSpeed;
  17404. private _vertexBufferSize;
  17405. /** @hidden */
  17406. _currentEmitRateGradient: Nullable<FactorGradient>;
  17407. /** @hidden */
  17408. _currentEmitRate1: number;
  17409. /** @hidden */
  17410. _currentEmitRate2: number;
  17411. /** @hidden */
  17412. _currentStartSizeGradient: Nullable<FactorGradient>;
  17413. /** @hidden */
  17414. _currentStartSize1: number;
  17415. /** @hidden */
  17416. _currentStartSize2: number;
  17417. private readonly _rawTextureWidth;
  17418. private _rampGradientsTexture;
  17419. private _useRampGradients;
  17420. /** Gets or sets a boolean indicating that ramp gradients must be used
  17421. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17422. */
  17423. useRampGradients: boolean;
  17424. /**
  17425. * The Sub-emitters templates that will be used to generate the sub particle system to be associated with the system, this property is used by the root particle system only.
  17426. * When a particle is spawned, an array will be chosen at random and all the emitters in that array will be attached to the particle. (Default: [])
  17427. */
  17428. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17429. private _subEmitters;
  17430. /**
  17431. * @hidden
  17432. * If the particle systems emitter should be disposed when the particle system is disposed
  17433. */
  17434. _disposeEmitterOnDispose: boolean;
  17435. /**
  17436. * The current active Sub-systems, this property is used by the root particle system only.
  17437. */
  17438. activeSubSystems: Array<ParticleSystem>;
  17439. private _rootParticleSystem;
  17440. /**
  17441. * Gets the current list of active particles
  17442. */
  17443. readonly particles: Particle[];
  17444. /**
  17445. * Returns the string "ParticleSystem"
  17446. * @returns a string containing the class name
  17447. */
  17448. getClassName(): string;
  17449. /**
  17450. * Instantiates a particle system.
  17451. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  17452. * @param name The name of the particle system
  17453. * @param capacity The max number of particles alive at the same time
  17454. * @param scene The scene the particle system belongs to
  17455. * @param customEffect a custom effect used to change the way particles are rendered by default
  17456. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17457. * @param epsilon Offset used to render the particles
  17458. */
  17459. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17460. private _addFactorGradient;
  17461. private _removeFactorGradient;
  17462. /**
  17463. * Adds a new life time gradient
  17464. * @param gradient defines the gradient to use (between 0 and 1)
  17465. * @param factor defines the life time factor to affect to the specified gradient
  17466. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17467. * @returns the current particle system
  17468. */
  17469. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17470. /**
  17471. * Remove a specific life time gradient
  17472. * @param gradient defines the gradient to remove
  17473. * @returns the current particle system
  17474. */
  17475. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17476. /**
  17477. * Adds a new size gradient
  17478. * @param gradient defines the gradient to use (between 0 and 1)
  17479. * @param factor defines the size factor to affect to the specified gradient
  17480. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17481. * @returns the current particle system
  17482. */
  17483. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17484. /**
  17485. * Remove a specific size gradient
  17486. * @param gradient defines the gradient to remove
  17487. * @returns the current particle system
  17488. */
  17489. removeSizeGradient(gradient: number): IParticleSystem;
  17490. /**
  17491. * Adds a new color remap gradient
  17492. * @param gradient defines the gradient to use (between 0 and 1)
  17493. * @param min defines the color remap minimal range
  17494. * @param max defines the color remap maximal range
  17495. * @returns the current particle system
  17496. */
  17497. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17498. /**
  17499. * Remove a specific color remap gradient
  17500. * @param gradient defines the gradient to remove
  17501. * @returns the current particle system
  17502. */
  17503. removeColorRemapGradient(gradient: number): IParticleSystem;
  17504. /**
  17505. * Adds a new alpha remap gradient
  17506. * @param gradient defines the gradient to use (between 0 and 1)
  17507. * @param min defines the alpha remap minimal range
  17508. * @param max defines the alpha remap maximal range
  17509. * @returns the current particle system
  17510. */
  17511. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17512. /**
  17513. * Remove a specific alpha remap gradient
  17514. * @param gradient defines the gradient to remove
  17515. * @returns the current particle system
  17516. */
  17517. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17518. /**
  17519. * Adds a new angular speed gradient
  17520. * @param gradient defines the gradient to use (between 0 and 1)
  17521. * @param factor defines the angular speed to affect to the specified gradient
  17522. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17523. * @returns the current particle system
  17524. */
  17525. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17526. /**
  17527. * Remove a specific angular speed gradient
  17528. * @param gradient defines the gradient to remove
  17529. * @returns the current particle system
  17530. */
  17531. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17532. /**
  17533. * Adds a new velocity gradient
  17534. * @param gradient defines the gradient to use (between 0 and 1)
  17535. * @param factor defines the velocity to affect to the specified gradient
  17536. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17537. * @returns the current particle system
  17538. */
  17539. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17540. /**
  17541. * Remove a specific velocity gradient
  17542. * @param gradient defines the gradient to remove
  17543. * @returns the current particle system
  17544. */
  17545. removeVelocityGradient(gradient: number): IParticleSystem;
  17546. /**
  17547. * Adds a new limit velocity gradient
  17548. * @param gradient defines the gradient to use (between 0 and 1)
  17549. * @param factor defines the limit velocity value to affect to the specified gradient
  17550. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17551. * @returns the current particle system
  17552. */
  17553. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17554. /**
  17555. * Remove a specific limit velocity gradient
  17556. * @param gradient defines the gradient to remove
  17557. * @returns the current particle system
  17558. */
  17559. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17560. /**
  17561. * Adds a new drag gradient
  17562. * @param gradient defines the gradient to use (between 0 and 1)
  17563. * @param factor defines the drag value to affect to the specified gradient
  17564. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17565. * @returns the current particle system
  17566. */
  17567. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17568. /**
  17569. * Remove a specific drag gradient
  17570. * @param gradient defines the gradient to remove
  17571. * @returns the current particle system
  17572. */
  17573. removeDragGradient(gradient: number): IParticleSystem;
  17574. /**
  17575. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17576. * @param gradient defines the gradient to use (between 0 and 1)
  17577. * @param factor defines the emit rate value to affect to the specified gradient
  17578. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17579. * @returns the current particle system
  17580. */
  17581. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17582. /**
  17583. * Remove a specific emit rate gradient
  17584. * @param gradient defines the gradient to remove
  17585. * @returns the current particle system
  17586. */
  17587. removeEmitRateGradient(gradient: number): IParticleSystem;
  17588. /**
  17589. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17590. * @param gradient defines the gradient to use (between 0 and 1)
  17591. * @param factor defines the start size value to affect to the specified gradient
  17592. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17593. * @returns the current particle system
  17594. */
  17595. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17596. /**
  17597. * Remove a specific start size gradient
  17598. * @param gradient defines the gradient to remove
  17599. * @returns the current particle system
  17600. */
  17601. removeStartSizeGradient(gradient: number): IParticleSystem;
  17602. private _createRampGradientTexture;
  17603. /**
  17604. * Gets the current list of ramp gradients.
  17605. * You must use addRampGradient and removeRampGradient to udpate this list
  17606. * @returns the list of ramp gradients
  17607. */
  17608. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17609. /**
  17610. * Adds a new ramp gradient used to remap particle colors
  17611. * @param gradient defines the gradient to use (between 0 and 1)
  17612. * @param color defines the color to affect to the specified gradient
  17613. * @returns the current particle system
  17614. */
  17615. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17616. /**
  17617. * Remove a specific ramp gradient
  17618. * @param gradient defines the gradient to remove
  17619. * @returns the current particle system
  17620. */
  17621. removeRampGradient(gradient: number): ParticleSystem;
  17622. /**
  17623. * Adds a new color gradient
  17624. * @param gradient defines the gradient to use (between 0 and 1)
  17625. * @param color1 defines the color to affect to the specified gradient
  17626. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17627. * @returns this particle system
  17628. */
  17629. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17630. /**
  17631. * Remove a specific color gradient
  17632. * @param gradient defines the gradient to remove
  17633. * @returns this particle system
  17634. */
  17635. removeColorGradient(gradient: number): IParticleSystem;
  17636. private _fetchR;
  17637. protected _reset(): void;
  17638. private _resetEffect;
  17639. private _createVertexBuffers;
  17640. private _createIndexBuffer;
  17641. /**
  17642. * Gets the maximum number of particles active at the same time.
  17643. * @returns The max number of active particles.
  17644. */
  17645. getCapacity(): number;
  17646. /**
  17647. * Gets whether there are still active particles in the system.
  17648. * @returns True if it is alive, otherwise false.
  17649. */
  17650. isAlive(): boolean;
  17651. /**
  17652. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17653. * @returns True if it has been started, otherwise false.
  17654. */
  17655. isStarted(): boolean;
  17656. private _prepareSubEmitterInternalArray;
  17657. /**
  17658. * Starts the particle system and begins to emit
  17659. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17660. */
  17661. start(delay?: number): void;
  17662. /**
  17663. * Stops the particle system.
  17664. * @param stopSubEmitters if true it will stop the current system and all created sub-Systems if false it will stop the current root system only, this param is used by the root particle system only. the default value is true.
  17665. */
  17666. stop(stopSubEmitters?: boolean): void;
  17667. /**
  17668. * Remove all active particles
  17669. */
  17670. reset(): void;
  17671. /**
  17672. * @hidden (for internal use only)
  17673. */
  17674. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17675. /**
  17676. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17677. * Its lifetime will start back at 0.
  17678. */
  17679. recycleParticle: (particle: Particle) => void;
  17680. private _stopSubEmitters;
  17681. private _createParticle;
  17682. private _removeFromRoot;
  17683. private _emitFromParticle;
  17684. private _update;
  17685. /** @hidden */
  17686. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17687. /** @hidden */
  17688. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17689. /** @hidden */
  17690. private _getEffect;
  17691. /**
  17692. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17693. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17694. */
  17695. animate(preWarmOnly?: boolean): void;
  17696. private _appendParticleVertices;
  17697. /**
  17698. * Rebuilds the particle system.
  17699. */
  17700. rebuild(): void;
  17701. /**
  17702. * Is this system ready to be used/rendered
  17703. * @return true if the system is ready
  17704. */
  17705. isReady(): boolean;
  17706. private _render;
  17707. /**
  17708. * Renders the particle system in its current state.
  17709. * @returns the current number of particles
  17710. */
  17711. render(): number;
  17712. /**
  17713. * Disposes the particle system and free the associated resources
  17714. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17715. */
  17716. dispose(disposeTexture?: boolean): void;
  17717. /**
  17718. * Clones the particle system.
  17719. * @param name The name of the cloned object
  17720. * @param newEmitter The new emitter to use
  17721. * @returns the cloned particle system
  17722. */
  17723. clone(name: string, newEmitter: any): ParticleSystem;
  17724. /**
  17725. * Serializes the particle system to a JSON object.
  17726. * @returns the JSON object
  17727. */
  17728. serialize(): any;
  17729. /** @hidden */
  17730. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17731. /** @hidden */
  17732. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17733. /**
  17734. * Parses a JSON object to create a particle system.
  17735. * @param parsedParticleSystem The JSON object to parse
  17736. * @param scene The scene to create the particle system in
  17737. * @param rootUrl The root url to use to load external dependencies like texture
  17738. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17739. * @returns the Parsed particle system
  17740. */
  17741. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17742. }
  17743. }
  17744. declare module "babylonjs/Particles/particle" {
  17745. import { Nullable } from "babylonjs/types";
  17746. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  17747. import { Color4 } from "babylonjs/Maths/math.color";
  17748. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17749. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17750. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  17751. /**
  17752. * A particle represents one of the element emitted by a particle system.
  17753. * This is mainly define by its coordinates, direction, velocity and age.
  17754. */
  17755. export class Particle {
  17756. /**
  17757. * The particle system the particle belongs to.
  17758. */
  17759. particleSystem: ParticleSystem;
  17760. private static _Count;
  17761. /**
  17762. * Unique ID of the particle
  17763. */
  17764. id: number;
  17765. /**
  17766. * The world position of the particle in the scene.
  17767. */
  17768. position: Vector3;
  17769. /**
  17770. * The world direction of the particle in the scene.
  17771. */
  17772. direction: Vector3;
  17773. /**
  17774. * The color of the particle.
  17775. */
  17776. color: Color4;
  17777. /**
  17778. * The color change of the particle per step.
  17779. */
  17780. colorStep: Color4;
  17781. /**
  17782. * Defines how long will the life of the particle be.
  17783. */
  17784. lifeTime: number;
  17785. /**
  17786. * The current age of the particle.
  17787. */
  17788. age: number;
  17789. /**
  17790. * The current size of the particle.
  17791. */
  17792. size: number;
  17793. /**
  17794. * The current scale of the particle.
  17795. */
  17796. scale: Vector2;
  17797. /**
  17798. * The current angle of the particle.
  17799. */
  17800. angle: number;
  17801. /**
  17802. * Defines how fast is the angle changing.
  17803. */
  17804. angularSpeed: number;
  17805. /**
  17806. * Defines the cell index used by the particle to be rendered from a sprite.
  17807. */
  17808. cellIndex: number;
  17809. /**
  17810. * The information required to support color remapping
  17811. */
  17812. remapData: Vector4;
  17813. /** @hidden */
  17814. _randomCellOffset?: number;
  17815. /** @hidden */
  17816. _initialDirection: Nullable<Vector3>;
  17817. /** @hidden */
  17818. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17819. /** @hidden */
  17820. _initialStartSpriteCellID: number;
  17821. /** @hidden */
  17822. _initialEndSpriteCellID: number;
  17823. /** @hidden */
  17824. _currentColorGradient: Nullable<ColorGradient>;
  17825. /** @hidden */
  17826. _currentColor1: Color4;
  17827. /** @hidden */
  17828. _currentColor2: Color4;
  17829. /** @hidden */
  17830. _currentSizeGradient: Nullable<FactorGradient>;
  17831. /** @hidden */
  17832. _currentSize1: number;
  17833. /** @hidden */
  17834. _currentSize2: number;
  17835. /** @hidden */
  17836. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17837. /** @hidden */
  17838. _currentAngularSpeed1: number;
  17839. /** @hidden */
  17840. _currentAngularSpeed2: number;
  17841. /** @hidden */
  17842. _currentVelocityGradient: Nullable<FactorGradient>;
  17843. /** @hidden */
  17844. _currentVelocity1: number;
  17845. /** @hidden */
  17846. _currentVelocity2: number;
  17847. /** @hidden */
  17848. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17849. /** @hidden */
  17850. _currentLimitVelocity1: number;
  17851. /** @hidden */
  17852. _currentLimitVelocity2: number;
  17853. /** @hidden */
  17854. _currentDragGradient: Nullable<FactorGradient>;
  17855. /** @hidden */
  17856. _currentDrag1: number;
  17857. /** @hidden */
  17858. _currentDrag2: number;
  17859. /** @hidden */
  17860. _randomNoiseCoordinates1: Vector3;
  17861. /** @hidden */
  17862. _randomNoiseCoordinates2: Vector3;
  17863. /**
  17864. * Creates a new instance Particle
  17865. * @param particleSystem the particle system the particle belongs to
  17866. */
  17867. constructor(
  17868. /**
  17869. * The particle system the particle belongs to.
  17870. */
  17871. particleSystem: ParticleSystem);
  17872. private updateCellInfoFromSystem;
  17873. /**
  17874. * Defines how the sprite cell index is updated for the particle
  17875. */
  17876. updateCellIndex(): void;
  17877. /** @hidden */
  17878. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17879. /** @hidden */
  17880. _inheritParticleInfoToSubEmitters(): void;
  17881. /** @hidden */
  17882. _reset(): void;
  17883. /**
  17884. * Copy the properties of particle to another one.
  17885. * @param other the particle to copy the information to.
  17886. */
  17887. copyTo(other: Particle): void;
  17888. }
  17889. }
  17890. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  17891. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17892. import { Effect } from "babylonjs/Materials/effect";
  17893. import { Particle } from "babylonjs/Particles/particle";
  17894. /**
  17895. * Particle emitter represents a volume emitting particles.
  17896. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17897. */
  17898. export interface IParticleEmitterType {
  17899. /**
  17900. * Called by the particle System when the direction is computed for the created particle.
  17901. * @param worldMatrix is the world matrix of the particle system
  17902. * @param directionToUpdate is the direction vector to update with the result
  17903. * @param particle is the particle we are computed the direction for
  17904. */
  17905. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17906. /**
  17907. * Called by the particle System when the position is computed for the created particle.
  17908. * @param worldMatrix is the world matrix of the particle system
  17909. * @param positionToUpdate is the position vector to update with the result
  17910. * @param particle is the particle we are computed the position for
  17911. */
  17912. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17913. /**
  17914. * Clones the current emitter and returns a copy of it
  17915. * @returns the new emitter
  17916. */
  17917. clone(): IParticleEmitterType;
  17918. /**
  17919. * Called by the GPUParticleSystem to setup the update shader
  17920. * @param effect defines the update shader
  17921. */
  17922. applyToShader(effect: Effect): void;
  17923. /**
  17924. * Returns a string to use to update the GPU particles update shader
  17925. * @returns the effect defines string
  17926. */
  17927. getEffectDefines(): string;
  17928. /**
  17929. * Returns a string representing the class name
  17930. * @returns a string containing the class name
  17931. */
  17932. getClassName(): string;
  17933. /**
  17934. * Serializes the particle system to a JSON object.
  17935. * @returns the JSON object
  17936. */
  17937. serialize(): any;
  17938. /**
  17939. * Parse properties from a JSON object
  17940. * @param serializationObject defines the JSON object
  17941. */
  17942. parse(serializationObject: any): void;
  17943. }
  17944. }
  17945. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  17946. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17947. import { Effect } from "babylonjs/Materials/effect";
  17948. import { Particle } from "babylonjs/Particles/particle";
  17949. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17950. /**
  17951. * Particle emitter emitting particles from the inside of a box.
  17952. * It emits the particles randomly between 2 given directions.
  17953. */
  17954. export class BoxParticleEmitter implements IParticleEmitterType {
  17955. /**
  17956. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17957. */
  17958. direction1: Vector3;
  17959. /**
  17960. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17961. */
  17962. direction2: Vector3;
  17963. /**
  17964. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  17965. */
  17966. minEmitBox: Vector3;
  17967. /**
  17968. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  17969. */
  17970. maxEmitBox: Vector3;
  17971. /**
  17972. * Creates a new instance BoxParticleEmitter
  17973. */
  17974. constructor();
  17975. /**
  17976. * Called by the particle System when the direction is computed for the created particle.
  17977. * @param worldMatrix is the world matrix of the particle system
  17978. * @param directionToUpdate is the direction vector to update with the result
  17979. * @param particle is the particle we are computed the direction for
  17980. */
  17981. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17982. /**
  17983. * Called by the particle System when the position is computed for the created particle.
  17984. * @param worldMatrix is the world matrix of the particle system
  17985. * @param positionToUpdate is the position vector to update with the result
  17986. * @param particle is the particle we are computed the position for
  17987. */
  17988. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17989. /**
  17990. * Clones the current emitter and returns a copy of it
  17991. * @returns the new emitter
  17992. */
  17993. clone(): BoxParticleEmitter;
  17994. /**
  17995. * Called by the GPUParticleSystem to setup the update shader
  17996. * @param effect defines the update shader
  17997. */
  17998. applyToShader(effect: Effect): void;
  17999. /**
  18000. * Returns a string to use to update the GPU particles update shader
  18001. * @returns a string containng the defines string
  18002. */
  18003. getEffectDefines(): string;
  18004. /**
  18005. * Returns the string "BoxParticleEmitter"
  18006. * @returns a string containing the class name
  18007. */
  18008. getClassName(): string;
  18009. /**
  18010. * Serializes the particle system to a JSON object.
  18011. * @returns the JSON object
  18012. */
  18013. serialize(): any;
  18014. /**
  18015. * Parse properties from a JSON object
  18016. * @param serializationObject defines the JSON object
  18017. */
  18018. parse(serializationObject: any): void;
  18019. }
  18020. }
  18021. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  18022. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18023. import { Effect } from "babylonjs/Materials/effect";
  18024. import { Particle } from "babylonjs/Particles/particle";
  18025. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18026. /**
  18027. * Particle emitter emitting particles from the inside of a cone.
  18028. * It emits the particles alongside the cone volume from the base to the particle.
  18029. * The emission direction might be randomized.
  18030. */
  18031. export class ConeParticleEmitter implements IParticleEmitterType {
  18032. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18033. directionRandomizer: number;
  18034. private _radius;
  18035. private _angle;
  18036. private _height;
  18037. /**
  18038. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  18039. */
  18040. radiusRange: number;
  18041. /**
  18042. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  18043. */
  18044. heightRange: number;
  18045. /**
  18046. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  18047. */
  18048. emitFromSpawnPointOnly: boolean;
  18049. /**
  18050. * Gets or sets the radius of the emission cone
  18051. */
  18052. radius: number;
  18053. /**
  18054. * Gets or sets the angle of the emission cone
  18055. */
  18056. angle: number;
  18057. private _buildHeight;
  18058. /**
  18059. * Creates a new instance ConeParticleEmitter
  18060. * @param radius the radius of the emission cone (1 by default)
  18061. * @param angle the cone base angle (PI by default)
  18062. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  18063. */
  18064. constructor(radius?: number, angle?: number,
  18065. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18066. directionRandomizer?: number);
  18067. /**
  18068. * Called by the particle System when the direction is computed for the created particle.
  18069. * @param worldMatrix is the world matrix of the particle system
  18070. * @param directionToUpdate is the direction vector to update with the result
  18071. * @param particle is the particle we are computed the direction for
  18072. */
  18073. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18074. /**
  18075. * Called by the particle System when the position is computed for the created particle.
  18076. * @param worldMatrix is the world matrix of the particle system
  18077. * @param positionToUpdate is the position vector to update with the result
  18078. * @param particle is the particle we are computed the position for
  18079. */
  18080. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18081. /**
  18082. * Clones the current emitter and returns a copy of it
  18083. * @returns the new emitter
  18084. */
  18085. clone(): ConeParticleEmitter;
  18086. /**
  18087. * Called by the GPUParticleSystem to setup the update shader
  18088. * @param effect defines the update shader
  18089. */
  18090. applyToShader(effect: Effect): void;
  18091. /**
  18092. * Returns a string to use to update the GPU particles update shader
  18093. * @returns a string containng the defines string
  18094. */
  18095. getEffectDefines(): string;
  18096. /**
  18097. * Returns the string "ConeParticleEmitter"
  18098. * @returns a string containing the class name
  18099. */
  18100. getClassName(): string;
  18101. /**
  18102. * Serializes the particle system to a JSON object.
  18103. * @returns the JSON object
  18104. */
  18105. serialize(): any;
  18106. /**
  18107. * Parse properties from a JSON object
  18108. * @param serializationObject defines the JSON object
  18109. */
  18110. parse(serializationObject: any): void;
  18111. }
  18112. }
  18113. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  18114. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18115. import { Effect } from "babylonjs/Materials/effect";
  18116. import { Particle } from "babylonjs/Particles/particle";
  18117. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18118. /**
  18119. * Particle emitter emitting particles from the inside of a cylinder.
  18120. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18121. */
  18122. export class CylinderParticleEmitter implements IParticleEmitterType {
  18123. /**
  18124. * The radius of the emission cylinder.
  18125. */
  18126. radius: number;
  18127. /**
  18128. * The height of the emission cylinder.
  18129. */
  18130. height: number;
  18131. /**
  18132. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18133. */
  18134. radiusRange: number;
  18135. /**
  18136. * How much to randomize the particle direction [0-1].
  18137. */
  18138. directionRandomizer: number;
  18139. /**
  18140. * Creates a new instance CylinderParticleEmitter
  18141. * @param radius the radius of the emission cylinder (1 by default)
  18142. * @param height the height of the emission cylinder (1 by default)
  18143. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18144. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18145. */
  18146. constructor(
  18147. /**
  18148. * The radius of the emission cylinder.
  18149. */
  18150. radius?: number,
  18151. /**
  18152. * The height of the emission cylinder.
  18153. */
  18154. height?: number,
  18155. /**
  18156. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18157. */
  18158. radiusRange?: number,
  18159. /**
  18160. * How much to randomize the particle direction [0-1].
  18161. */
  18162. directionRandomizer?: number);
  18163. /**
  18164. * Called by the particle System when the direction is computed for the created particle.
  18165. * @param worldMatrix is the world matrix of the particle system
  18166. * @param directionToUpdate is the direction vector to update with the result
  18167. * @param particle is the particle we are computed the direction for
  18168. */
  18169. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18170. /**
  18171. * Called by the particle System when the position is computed for the created particle.
  18172. * @param worldMatrix is the world matrix of the particle system
  18173. * @param positionToUpdate is the position vector to update with the result
  18174. * @param particle is the particle we are computed the position for
  18175. */
  18176. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18177. /**
  18178. * Clones the current emitter and returns a copy of it
  18179. * @returns the new emitter
  18180. */
  18181. clone(): CylinderParticleEmitter;
  18182. /**
  18183. * Called by the GPUParticleSystem to setup the update shader
  18184. * @param effect defines the update shader
  18185. */
  18186. applyToShader(effect: Effect): void;
  18187. /**
  18188. * Returns a string to use to update the GPU particles update shader
  18189. * @returns a string containng the defines string
  18190. */
  18191. getEffectDefines(): string;
  18192. /**
  18193. * Returns the string "CylinderParticleEmitter"
  18194. * @returns a string containing the class name
  18195. */
  18196. getClassName(): string;
  18197. /**
  18198. * Serializes the particle system to a JSON object.
  18199. * @returns the JSON object
  18200. */
  18201. serialize(): any;
  18202. /**
  18203. * Parse properties from a JSON object
  18204. * @param serializationObject defines the JSON object
  18205. */
  18206. parse(serializationObject: any): void;
  18207. }
  18208. /**
  18209. * Particle emitter emitting particles from the inside of a cylinder.
  18210. * It emits the particles randomly between two vectors.
  18211. */
  18212. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18213. /**
  18214. * The min limit of the emission direction.
  18215. */
  18216. direction1: Vector3;
  18217. /**
  18218. * The max limit of the emission direction.
  18219. */
  18220. direction2: Vector3;
  18221. /**
  18222. * Creates a new instance CylinderDirectedParticleEmitter
  18223. * @param radius the radius of the emission cylinder (1 by default)
  18224. * @param height the height of the emission cylinder (1 by default)
  18225. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18226. * @param direction1 the min limit of the emission direction (up vector by default)
  18227. * @param direction2 the max limit of the emission direction (up vector by default)
  18228. */
  18229. constructor(radius?: number, height?: number, radiusRange?: number,
  18230. /**
  18231. * The min limit of the emission direction.
  18232. */
  18233. direction1?: Vector3,
  18234. /**
  18235. * The max limit of the emission direction.
  18236. */
  18237. direction2?: Vector3);
  18238. /**
  18239. * Called by the particle System when the direction is computed for the created particle.
  18240. * @param worldMatrix is the world matrix of the particle system
  18241. * @param directionToUpdate is the direction vector to update with the result
  18242. * @param particle is the particle we are computed the direction for
  18243. */
  18244. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18245. /**
  18246. * Clones the current emitter and returns a copy of it
  18247. * @returns the new emitter
  18248. */
  18249. clone(): CylinderDirectedParticleEmitter;
  18250. /**
  18251. * Called by the GPUParticleSystem to setup the update shader
  18252. * @param effect defines the update shader
  18253. */
  18254. applyToShader(effect: Effect): void;
  18255. /**
  18256. * Returns a string to use to update the GPU particles update shader
  18257. * @returns a string containng the defines string
  18258. */
  18259. getEffectDefines(): string;
  18260. /**
  18261. * Returns the string "CylinderDirectedParticleEmitter"
  18262. * @returns a string containing the class name
  18263. */
  18264. getClassName(): string;
  18265. /**
  18266. * Serializes the particle system to a JSON object.
  18267. * @returns the JSON object
  18268. */
  18269. serialize(): any;
  18270. /**
  18271. * Parse properties from a JSON object
  18272. * @param serializationObject defines the JSON object
  18273. */
  18274. parse(serializationObject: any): void;
  18275. }
  18276. }
  18277. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18278. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18279. import { Effect } from "babylonjs/Materials/effect";
  18280. import { Particle } from "babylonjs/Particles/particle";
  18281. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18282. /**
  18283. * Particle emitter emitting particles from the inside of a hemisphere.
  18284. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18285. */
  18286. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18287. /**
  18288. * The radius of the emission hemisphere.
  18289. */
  18290. radius: number;
  18291. /**
  18292. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18293. */
  18294. radiusRange: number;
  18295. /**
  18296. * How much to randomize the particle direction [0-1].
  18297. */
  18298. directionRandomizer: number;
  18299. /**
  18300. * Creates a new instance HemisphericParticleEmitter
  18301. * @param radius the radius of the emission hemisphere (1 by default)
  18302. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18303. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18304. */
  18305. constructor(
  18306. /**
  18307. * The radius of the emission hemisphere.
  18308. */
  18309. radius?: number,
  18310. /**
  18311. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18312. */
  18313. radiusRange?: number,
  18314. /**
  18315. * How much to randomize the particle direction [0-1].
  18316. */
  18317. directionRandomizer?: number);
  18318. /**
  18319. * Called by the particle System when the direction is computed for the created particle.
  18320. * @param worldMatrix is the world matrix of the particle system
  18321. * @param directionToUpdate is the direction vector to update with the result
  18322. * @param particle is the particle we are computed the direction for
  18323. */
  18324. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18325. /**
  18326. * Called by the particle System when the position is computed for the created particle.
  18327. * @param worldMatrix is the world matrix of the particle system
  18328. * @param positionToUpdate is the position vector to update with the result
  18329. * @param particle is the particle we are computed the position for
  18330. */
  18331. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18332. /**
  18333. * Clones the current emitter and returns a copy of it
  18334. * @returns the new emitter
  18335. */
  18336. clone(): HemisphericParticleEmitter;
  18337. /**
  18338. * Called by the GPUParticleSystem to setup the update shader
  18339. * @param effect defines the update shader
  18340. */
  18341. applyToShader(effect: Effect): void;
  18342. /**
  18343. * Returns a string to use to update the GPU particles update shader
  18344. * @returns a string containng the defines string
  18345. */
  18346. getEffectDefines(): string;
  18347. /**
  18348. * Returns the string "HemisphericParticleEmitter"
  18349. * @returns a string containing the class name
  18350. */
  18351. getClassName(): string;
  18352. /**
  18353. * Serializes the particle system to a JSON object.
  18354. * @returns the JSON object
  18355. */
  18356. serialize(): any;
  18357. /**
  18358. * Parse properties from a JSON object
  18359. * @param serializationObject defines the JSON object
  18360. */
  18361. parse(serializationObject: any): void;
  18362. }
  18363. }
  18364. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18365. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18366. import { Effect } from "babylonjs/Materials/effect";
  18367. import { Particle } from "babylonjs/Particles/particle";
  18368. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18369. /**
  18370. * Particle emitter emitting particles from a point.
  18371. * It emits the particles randomly between 2 given directions.
  18372. */
  18373. export class PointParticleEmitter implements IParticleEmitterType {
  18374. /**
  18375. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18376. */
  18377. direction1: Vector3;
  18378. /**
  18379. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18380. */
  18381. direction2: Vector3;
  18382. /**
  18383. * Creates a new instance PointParticleEmitter
  18384. */
  18385. constructor();
  18386. /**
  18387. * Called by the particle System when the direction is computed for the created particle.
  18388. * @param worldMatrix is the world matrix of the particle system
  18389. * @param directionToUpdate is the direction vector to update with the result
  18390. * @param particle is the particle we are computed the direction for
  18391. */
  18392. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18393. /**
  18394. * Called by the particle System when the position is computed for the created particle.
  18395. * @param worldMatrix is the world matrix of the particle system
  18396. * @param positionToUpdate is the position vector to update with the result
  18397. * @param particle is the particle we are computed the position for
  18398. */
  18399. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18400. /**
  18401. * Clones the current emitter and returns a copy of it
  18402. * @returns the new emitter
  18403. */
  18404. clone(): PointParticleEmitter;
  18405. /**
  18406. * Called by the GPUParticleSystem to setup the update shader
  18407. * @param effect defines the update shader
  18408. */
  18409. applyToShader(effect: Effect): void;
  18410. /**
  18411. * Returns a string to use to update the GPU particles update shader
  18412. * @returns a string containng the defines string
  18413. */
  18414. getEffectDefines(): string;
  18415. /**
  18416. * Returns the string "PointParticleEmitter"
  18417. * @returns a string containing the class name
  18418. */
  18419. getClassName(): string;
  18420. /**
  18421. * Serializes the particle system to a JSON object.
  18422. * @returns the JSON object
  18423. */
  18424. serialize(): any;
  18425. /**
  18426. * Parse properties from a JSON object
  18427. * @param serializationObject defines the JSON object
  18428. */
  18429. parse(serializationObject: any): void;
  18430. }
  18431. }
  18432. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18433. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18434. import { Effect } from "babylonjs/Materials/effect";
  18435. import { Particle } from "babylonjs/Particles/particle";
  18436. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18437. /**
  18438. * Particle emitter emitting particles from the inside of a sphere.
  18439. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18440. */
  18441. export class SphereParticleEmitter implements IParticleEmitterType {
  18442. /**
  18443. * The radius of the emission sphere.
  18444. */
  18445. radius: number;
  18446. /**
  18447. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18448. */
  18449. radiusRange: number;
  18450. /**
  18451. * How much to randomize the particle direction [0-1].
  18452. */
  18453. directionRandomizer: number;
  18454. /**
  18455. * Creates a new instance SphereParticleEmitter
  18456. * @param radius the radius of the emission sphere (1 by default)
  18457. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18458. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18459. */
  18460. constructor(
  18461. /**
  18462. * The radius of the emission sphere.
  18463. */
  18464. radius?: number,
  18465. /**
  18466. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18467. */
  18468. radiusRange?: number,
  18469. /**
  18470. * How much to randomize the particle direction [0-1].
  18471. */
  18472. directionRandomizer?: number);
  18473. /**
  18474. * Called by the particle System when the direction is computed for the created particle.
  18475. * @param worldMatrix is the world matrix of the particle system
  18476. * @param directionToUpdate is the direction vector to update with the result
  18477. * @param particle is the particle we are computed the direction for
  18478. */
  18479. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18480. /**
  18481. * Called by the particle System when the position is computed for the created particle.
  18482. * @param worldMatrix is the world matrix of the particle system
  18483. * @param positionToUpdate is the position vector to update with the result
  18484. * @param particle is the particle we are computed the position for
  18485. */
  18486. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18487. /**
  18488. * Clones the current emitter and returns a copy of it
  18489. * @returns the new emitter
  18490. */
  18491. clone(): SphereParticleEmitter;
  18492. /**
  18493. * Called by the GPUParticleSystem to setup the update shader
  18494. * @param effect defines the update shader
  18495. */
  18496. applyToShader(effect: Effect): void;
  18497. /**
  18498. * Returns a string to use to update the GPU particles update shader
  18499. * @returns a string containng the defines string
  18500. */
  18501. getEffectDefines(): string;
  18502. /**
  18503. * Returns the string "SphereParticleEmitter"
  18504. * @returns a string containing the class name
  18505. */
  18506. getClassName(): string;
  18507. /**
  18508. * Serializes the particle system to a JSON object.
  18509. * @returns the JSON object
  18510. */
  18511. serialize(): any;
  18512. /**
  18513. * Parse properties from a JSON object
  18514. * @param serializationObject defines the JSON object
  18515. */
  18516. parse(serializationObject: any): void;
  18517. }
  18518. /**
  18519. * Particle emitter emitting particles from the inside of a sphere.
  18520. * It emits the particles randomly between two vectors.
  18521. */
  18522. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18523. /**
  18524. * The min limit of the emission direction.
  18525. */
  18526. direction1: Vector3;
  18527. /**
  18528. * The max limit of the emission direction.
  18529. */
  18530. direction2: Vector3;
  18531. /**
  18532. * Creates a new instance SphereDirectedParticleEmitter
  18533. * @param radius the radius of the emission sphere (1 by default)
  18534. * @param direction1 the min limit of the emission direction (up vector by default)
  18535. * @param direction2 the max limit of the emission direction (up vector by default)
  18536. */
  18537. constructor(radius?: number,
  18538. /**
  18539. * The min limit of the emission direction.
  18540. */
  18541. direction1?: Vector3,
  18542. /**
  18543. * The max limit of the emission direction.
  18544. */
  18545. direction2?: Vector3);
  18546. /**
  18547. * Called by the particle System when the direction is computed for the created particle.
  18548. * @param worldMatrix is the world matrix of the particle system
  18549. * @param directionToUpdate is the direction vector to update with the result
  18550. * @param particle is the particle we are computed the direction for
  18551. */
  18552. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18553. /**
  18554. * Clones the current emitter and returns a copy of it
  18555. * @returns the new emitter
  18556. */
  18557. clone(): SphereDirectedParticleEmitter;
  18558. /**
  18559. * Called by the GPUParticleSystem to setup the update shader
  18560. * @param effect defines the update shader
  18561. */
  18562. applyToShader(effect: Effect): void;
  18563. /**
  18564. * Returns a string to use to update the GPU particles update shader
  18565. * @returns a string containng the defines string
  18566. */
  18567. getEffectDefines(): string;
  18568. /**
  18569. * Returns the string "SphereDirectedParticleEmitter"
  18570. * @returns a string containing the class name
  18571. */
  18572. getClassName(): string;
  18573. /**
  18574. * Serializes the particle system to a JSON object.
  18575. * @returns the JSON object
  18576. */
  18577. serialize(): any;
  18578. /**
  18579. * Parse properties from a JSON object
  18580. * @param serializationObject defines the JSON object
  18581. */
  18582. parse(serializationObject: any): void;
  18583. }
  18584. }
  18585. declare module "babylonjs/Particles/EmitterTypes/index" {
  18586. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  18587. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  18588. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  18589. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  18590. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18591. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  18592. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  18593. }
  18594. declare module "babylonjs/Particles/IParticleSystem" {
  18595. import { Nullable } from "babylonjs/types";
  18596. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  18597. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  18598. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18599. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18600. import { Texture } from "babylonjs/Materials/Textures/texture";
  18601. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  18602. import { Scene } from "babylonjs/scene";
  18603. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  18604. import { Animation } from "babylonjs/Animations/animation";
  18605. /**
  18606. * Interface representing a particle system in Babylon.js.
  18607. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18608. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18609. */
  18610. export interface IParticleSystem {
  18611. /**
  18612. * List of animations used by the particle system.
  18613. */
  18614. animations: Animation[];
  18615. /**
  18616. * The id of the Particle system.
  18617. */
  18618. id: string;
  18619. /**
  18620. * The name of the Particle system.
  18621. */
  18622. name: string;
  18623. /**
  18624. * The emitter represents the Mesh or position we are attaching the particle system to.
  18625. */
  18626. emitter: Nullable<AbstractMesh | Vector3>;
  18627. /**
  18628. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18629. */
  18630. isBillboardBased: boolean;
  18631. /**
  18632. * The rendering group used by the Particle system to chose when to render.
  18633. */
  18634. renderingGroupId: number;
  18635. /**
  18636. * The layer mask we are rendering the particles through.
  18637. */
  18638. layerMask: number;
  18639. /**
  18640. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18641. */
  18642. updateSpeed: number;
  18643. /**
  18644. * The amount of time the particle system is running (depends of the overall update speed).
  18645. */
  18646. targetStopDuration: number;
  18647. /**
  18648. * The texture used to render each particle. (this can be a spritesheet)
  18649. */
  18650. particleTexture: Nullable<Texture>;
  18651. /**
  18652. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18653. */
  18654. blendMode: number;
  18655. /**
  18656. * Minimum life time of emitting particles.
  18657. */
  18658. minLifeTime: number;
  18659. /**
  18660. * Maximum life time of emitting particles.
  18661. */
  18662. maxLifeTime: number;
  18663. /**
  18664. * Minimum Size of emitting particles.
  18665. */
  18666. minSize: number;
  18667. /**
  18668. * Maximum Size of emitting particles.
  18669. */
  18670. maxSize: number;
  18671. /**
  18672. * Minimum scale of emitting particles on X axis.
  18673. */
  18674. minScaleX: number;
  18675. /**
  18676. * Maximum scale of emitting particles on X axis.
  18677. */
  18678. maxScaleX: number;
  18679. /**
  18680. * Minimum scale of emitting particles on Y axis.
  18681. */
  18682. minScaleY: number;
  18683. /**
  18684. * Maximum scale of emitting particles on Y axis.
  18685. */
  18686. maxScaleY: number;
  18687. /**
  18688. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18689. */
  18690. color1: Color4;
  18691. /**
  18692. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18693. */
  18694. color2: Color4;
  18695. /**
  18696. * Color the particle will have at the end of its lifetime.
  18697. */
  18698. colorDead: Color4;
  18699. /**
  18700. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18701. */
  18702. emitRate: number;
  18703. /**
  18704. * You can use gravity if you want to give an orientation to your particles.
  18705. */
  18706. gravity: Vector3;
  18707. /**
  18708. * Minimum power of emitting particles.
  18709. */
  18710. minEmitPower: number;
  18711. /**
  18712. * Maximum power of emitting particles.
  18713. */
  18714. maxEmitPower: number;
  18715. /**
  18716. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18717. */
  18718. minAngularSpeed: number;
  18719. /**
  18720. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18721. */
  18722. maxAngularSpeed: number;
  18723. /**
  18724. * Gets or sets the minimal initial rotation in radians.
  18725. */
  18726. minInitialRotation: number;
  18727. /**
  18728. * Gets or sets the maximal initial rotation in radians.
  18729. */
  18730. maxInitialRotation: number;
  18731. /**
  18732. * The particle emitter type defines the emitter used by the particle system.
  18733. * It can be for example box, sphere, or cone...
  18734. */
  18735. particleEmitterType: Nullable<IParticleEmitterType>;
  18736. /**
  18737. * Defines the delay in milliseconds before starting the system (0 by default)
  18738. */
  18739. startDelay: number;
  18740. /**
  18741. * Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0
  18742. */
  18743. preWarmCycles: number;
  18744. /**
  18745. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18746. */
  18747. preWarmStepOffset: number;
  18748. /**
  18749. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  18750. */
  18751. spriteCellChangeSpeed: number;
  18752. /**
  18753. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18754. */
  18755. startSpriteCellID: number;
  18756. /**
  18757. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18758. */
  18759. endSpriteCellID: number;
  18760. /**
  18761. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18762. */
  18763. spriteCellWidth: number;
  18764. /**
  18765. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18766. */
  18767. spriteCellHeight: number;
  18768. /**
  18769. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18770. */
  18771. spriteRandomStartCell: boolean;
  18772. /**
  18773. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18774. */
  18775. isAnimationSheetEnabled: boolean;
  18776. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18777. translationPivot: Vector2;
  18778. /**
  18779. * Gets or sets a texture used to add random noise to particle positions
  18780. */
  18781. noiseTexture: Nullable<BaseTexture>;
  18782. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18783. noiseStrength: Vector3;
  18784. /**
  18785. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18786. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18787. */
  18788. billboardMode: number;
  18789. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18790. limitVelocityDamping: number;
  18791. /**
  18792. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18793. */
  18794. beginAnimationOnStart: boolean;
  18795. /**
  18796. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18797. */
  18798. beginAnimationFrom: number;
  18799. /**
  18800. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18801. */
  18802. beginAnimationTo: number;
  18803. /**
  18804. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18805. */
  18806. beginAnimationLoop: boolean;
  18807. /**
  18808. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18809. */
  18810. disposeOnStop: boolean;
  18811. /**
  18812. * Gets the maximum number of particles active at the same time.
  18813. * @returns The max number of active particles.
  18814. */
  18815. getCapacity(): number;
  18816. /**
  18817. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18818. * @returns True if it has been started, otherwise false.
  18819. */
  18820. isStarted(): boolean;
  18821. /**
  18822. * Animates the particle system for this frame.
  18823. */
  18824. animate(): void;
  18825. /**
  18826. * Renders the particle system in its current state.
  18827. * @returns the current number of particles
  18828. */
  18829. render(): number;
  18830. /**
  18831. * Dispose the particle system and frees its associated resources.
  18832. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18833. */
  18834. dispose(disposeTexture?: boolean): void;
  18835. /**
  18836. * Clones the particle system.
  18837. * @param name The name of the cloned object
  18838. * @param newEmitter The new emitter to use
  18839. * @returns the cloned particle system
  18840. */
  18841. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18842. /**
  18843. * Serializes the particle system to a JSON object.
  18844. * @returns the JSON object
  18845. */
  18846. serialize(): any;
  18847. /**
  18848. * Rebuild the particle system
  18849. */
  18850. rebuild(): void;
  18851. /**
  18852. * Starts the particle system and begins to emit
  18853. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18854. */
  18855. start(delay?: number): void;
  18856. /**
  18857. * Stops the particle system.
  18858. */
  18859. stop(): void;
  18860. /**
  18861. * Remove all active particles
  18862. */
  18863. reset(): void;
  18864. /**
  18865. * Is this system ready to be used/rendered
  18866. * @return true if the system is ready
  18867. */
  18868. isReady(): boolean;
  18869. /**
  18870. * Adds a new color gradient
  18871. * @param gradient defines the gradient to use (between 0 and 1)
  18872. * @param color1 defines the color to affect to the specified gradient
  18873. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18874. * @returns the current particle system
  18875. */
  18876. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18877. /**
  18878. * Remove a specific color gradient
  18879. * @param gradient defines the gradient to remove
  18880. * @returns the current particle system
  18881. */
  18882. removeColorGradient(gradient: number): IParticleSystem;
  18883. /**
  18884. * Adds a new size gradient
  18885. * @param gradient defines the gradient to use (between 0 and 1)
  18886. * @param factor defines the size factor to affect to the specified gradient
  18887. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18888. * @returns the current particle system
  18889. */
  18890. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18891. /**
  18892. * Remove a specific size gradient
  18893. * @param gradient defines the gradient to remove
  18894. * @returns the current particle system
  18895. */
  18896. removeSizeGradient(gradient: number): IParticleSystem;
  18897. /**
  18898. * Gets the current list of color gradients.
  18899. * You must use addColorGradient and removeColorGradient to udpate this list
  18900. * @returns the list of color gradients
  18901. */
  18902. getColorGradients(): Nullable<Array<ColorGradient>>;
  18903. /**
  18904. * Gets the current list of size gradients.
  18905. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18906. * @returns the list of size gradients
  18907. */
  18908. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18909. /**
  18910. * Gets the current list of angular speed gradients.
  18911. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18912. * @returns the list of angular speed gradients
  18913. */
  18914. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18915. /**
  18916. * Adds a new angular speed gradient
  18917. * @param gradient defines the gradient to use (between 0 and 1)
  18918. * @param factor defines the angular speed to affect to the specified gradient
  18919. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18920. * @returns the current particle system
  18921. */
  18922. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18923. /**
  18924. * Remove a specific angular speed gradient
  18925. * @param gradient defines the gradient to remove
  18926. * @returns the current particle system
  18927. */
  18928. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18929. /**
  18930. * Gets the current list of velocity gradients.
  18931. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18932. * @returns the list of velocity gradients
  18933. */
  18934. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18935. /**
  18936. * Adds a new velocity gradient
  18937. * @param gradient defines the gradient to use (between 0 and 1)
  18938. * @param factor defines the velocity to affect to the specified gradient
  18939. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18940. * @returns the current particle system
  18941. */
  18942. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18943. /**
  18944. * Remove a specific velocity gradient
  18945. * @param gradient defines the gradient to remove
  18946. * @returns the current particle system
  18947. */
  18948. removeVelocityGradient(gradient: number): IParticleSystem;
  18949. /**
  18950. * Gets the current list of limit velocity gradients.
  18951. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18952. * @returns the list of limit velocity gradients
  18953. */
  18954. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18955. /**
  18956. * Adds a new limit velocity gradient
  18957. * @param gradient defines the gradient to use (between 0 and 1)
  18958. * @param factor defines the limit velocity to affect to the specified gradient
  18959. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18960. * @returns the current particle system
  18961. */
  18962. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18963. /**
  18964. * Remove a specific limit velocity gradient
  18965. * @param gradient defines the gradient to remove
  18966. * @returns the current particle system
  18967. */
  18968. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18969. /**
  18970. * Adds a new drag gradient
  18971. * @param gradient defines the gradient to use (between 0 and 1)
  18972. * @param factor defines the drag to affect to the specified gradient
  18973. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18974. * @returns the current particle system
  18975. */
  18976. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18977. /**
  18978. * Remove a specific drag gradient
  18979. * @param gradient defines the gradient to remove
  18980. * @returns the current particle system
  18981. */
  18982. removeDragGradient(gradient: number): IParticleSystem;
  18983. /**
  18984. * Gets the current list of drag gradients.
  18985. * You must use addDragGradient and removeDragGradient to udpate this list
  18986. * @returns the list of drag gradients
  18987. */
  18988. getDragGradients(): Nullable<Array<FactorGradient>>;
  18989. /**
  18990. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18991. * @param gradient defines the gradient to use (between 0 and 1)
  18992. * @param factor defines the emit rate to affect to the specified gradient
  18993. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18994. * @returns the current particle system
  18995. */
  18996. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18997. /**
  18998. * Remove a specific emit rate gradient
  18999. * @param gradient defines the gradient to remove
  19000. * @returns the current particle system
  19001. */
  19002. removeEmitRateGradient(gradient: number): IParticleSystem;
  19003. /**
  19004. * Gets the current list of emit rate gradients.
  19005. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19006. * @returns the list of emit rate gradients
  19007. */
  19008. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19009. /**
  19010. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  19011. * @param gradient defines the gradient to use (between 0 and 1)
  19012. * @param factor defines the start size to affect to the specified gradient
  19013. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19014. * @returns the current particle system
  19015. */
  19016. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19017. /**
  19018. * Remove a specific start size gradient
  19019. * @param gradient defines the gradient to remove
  19020. * @returns the current particle system
  19021. */
  19022. removeStartSizeGradient(gradient: number): IParticleSystem;
  19023. /**
  19024. * Gets the current list of start size gradients.
  19025. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19026. * @returns the list of start size gradients
  19027. */
  19028. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19029. /**
  19030. * Adds a new life time gradient
  19031. * @param gradient defines the gradient to use (between 0 and 1)
  19032. * @param factor defines the life time factor to affect to the specified gradient
  19033. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19034. * @returns the current particle system
  19035. */
  19036. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19037. /**
  19038. * Remove a specific life time gradient
  19039. * @param gradient defines the gradient to remove
  19040. * @returns the current particle system
  19041. */
  19042. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19043. /**
  19044. * Gets the current list of life time gradients.
  19045. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19046. * @returns the list of life time gradients
  19047. */
  19048. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19049. /**
  19050. * Gets the current list of color gradients.
  19051. * You must use addColorGradient and removeColorGradient to udpate this list
  19052. * @returns the list of color gradients
  19053. */
  19054. getColorGradients(): Nullable<Array<ColorGradient>>;
  19055. /**
  19056. * Adds a new ramp gradient used to remap particle colors
  19057. * @param gradient defines the gradient to use (between 0 and 1)
  19058. * @param color defines the color to affect to the specified gradient
  19059. * @returns the current particle system
  19060. */
  19061. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  19062. /**
  19063. * Gets the current list of ramp gradients.
  19064. * You must use addRampGradient and removeRampGradient to udpate this list
  19065. * @returns the list of ramp gradients
  19066. */
  19067. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19068. /** Gets or sets a boolean indicating that ramp gradients must be used
  19069. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19070. */
  19071. useRampGradients: boolean;
  19072. /**
  19073. * Adds a new color remap gradient
  19074. * @param gradient defines the gradient to use (between 0 and 1)
  19075. * @param min defines the color remap minimal range
  19076. * @param max defines the color remap maximal range
  19077. * @returns the current particle system
  19078. */
  19079. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19080. /**
  19081. * Gets the current list of color remap gradients.
  19082. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19083. * @returns the list of color remap gradients
  19084. */
  19085. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19086. /**
  19087. * Adds a new alpha remap gradient
  19088. * @param gradient defines the gradient to use (between 0 and 1)
  19089. * @param min defines the alpha remap minimal range
  19090. * @param max defines the alpha remap maximal range
  19091. * @returns the current particle system
  19092. */
  19093. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19094. /**
  19095. * Gets the current list of alpha remap gradients.
  19096. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19097. * @returns the list of alpha remap gradients
  19098. */
  19099. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19100. /**
  19101. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19102. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19103. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19104. * @returns the emitter
  19105. */
  19106. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19107. /**
  19108. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19109. * @param radius The radius of the hemisphere to emit from
  19110. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19111. * @returns the emitter
  19112. */
  19113. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19114. /**
  19115. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19116. * @param radius The radius of the sphere to emit from
  19117. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19118. * @returns the emitter
  19119. */
  19120. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19121. /**
  19122. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19123. * @param radius The radius of the sphere to emit from
  19124. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19125. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19126. * @returns the emitter
  19127. */
  19128. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19129. /**
  19130. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19131. * @param radius The radius of the emission cylinder
  19132. * @param height The height of the emission cylinder
  19133. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19134. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19135. * @returns the emitter
  19136. */
  19137. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19138. /**
  19139. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19140. * @param radius The radius of the cylinder to emit from
  19141. * @param height The height of the emission cylinder
  19142. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19143. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19144. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19145. * @returns the emitter
  19146. */
  19147. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19148. /**
  19149. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19150. * @param radius The radius of the cone to emit from
  19151. * @param angle The base angle of the cone
  19152. * @returns the emitter
  19153. */
  19154. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19155. /**
  19156. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19157. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19158. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19159. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19160. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19161. * @returns the emitter
  19162. */
  19163. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19164. /**
  19165. * Get hosting scene
  19166. * @returns the scene
  19167. */
  19168. getScene(): Scene;
  19169. }
  19170. }
  19171. declare module "babylonjs/Meshes/instancedMesh" {
  19172. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19173. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19174. import { Camera } from "babylonjs/Cameras/camera";
  19175. import { Node } from "babylonjs/node";
  19176. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19177. import { Mesh } from "babylonjs/Meshes/mesh";
  19178. import { Material } from "babylonjs/Materials/material";
  19179. import { Skeleton } from "babylonjs/Bones/skeleton";
  19180. import { Light } from "babylonjs/Lights/light";
  19181. /**
  19182. * Creates an instance based on a source mesh.
  19183. */
  19184. export class InstancedMesh extends AbstractMesh {
  19185. private _sourceMesh;
  19186. private _currentLOD;
  19187. /** @hidden */
  19188. _indexInSourceMeshInstanceArray: number;
  19189. constructor(name: string, source: Mesh);
  19190. /**
  19191. * Returns the string "InstancedMesh".
  19192. */
  19193. getClassName(): string;
  19194. /** Gets the list of lights affecting that mesh */
  19195. readonly lightSources: Light[];
  19196. _resyncLightSources(): void;
  19197. _resyncLighSource(light: Light): void;
  19198. _removeLightSource(light: Light, dispose: boolean): void;
  19199. /**
  19200. * If the source mesh receives shadows
  19201. */
  19202. readonly receiveShadows: boolean;
  19203. /**
  19204. * The material of the source mesh
  19205. */
  19206. readonly material: Nullable<Material>;
  19207. /**
  19208. * Visibility of the source mesh
  19209. */
  19210. readonly visibility: number;
  19211. /**
  19212. * Skeleton of the source mesh
  19213. */
  19214. readonly skeleton: Nullable<Skeleton>;
  19215. /**
  19216. * Rendering ground id of the source mesh
  19217. */
  19218. renderingGroupId: number;
  19219. /**
  19220. * Returns the total number of vertices (integer).
  19221. */
  19222. getTotalVertices(): number;
  19223. /**
  19224. * Returns a positive integer : the total number of indices in this mesh geometry.
  19225. * @returns the numner of indices or zero if the mesh has no geometry.
  19226. */
  19227. getTotalIndices(): number;
  19228. /**
  19229. * The source mesh of the instance
  19230. */
  19231. readonly sourceMesh: Mesh;
  19232. /**
  19233. * Is this node ready to be used/rendered
  19234. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19235. * @return {boolean} is it ready
  19236. */
  19237. isReady(completeCheck?: boolean): boolean;
  19238. /**
  19239. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19240. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19241. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  19242. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19243. */
  19244. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19245. /**
  19246. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19247. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19248. * The `data` are either a numeric array either a Float32Array.
  19249. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19250. * The parameter `stride` is an optional positive integer, it is usually automatically deducted from the `kind` (3 for positions or normals, 2 for UV, etc).
  19251. * Note that a new underlying VertexBuffer object is created each call.
  19252. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19253. *
  19254. * Possible `kind` values :
  19255. * - VertexBuffer.PositionKind
  19256. * - VertexBuffer.UVKind
  19257. * - VertexBuffer.UV2Kind
  19258. * - VertexBuffer.UV3Kind
  19259. * - VertexBuffer.UV4Kind
  19260. * - VertexBuffer.UV5Kind
  19261. * - VertexBuffer.UV6Kind
  19262. * - VertexBuffer.ColorKind
  19263. * - VertexBuffer.MatricesIndicesKind
  19264. * - VertexBuffer.MatricesIndicesExtraKind
  19265. * - VertexBuffer.MatricesWeightsKind
  19266. * - VertexBuffer.MatricesWeightsExtraKind
  19267. *
  19268. * Returns the Mesh.
  19269. */
  19270. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19271. /**
  19272. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19273. * If the mesh has no geometry, it is simply returned as it is.
  19274. * The `data` are either a numeric array either a Float32Array.
  19275. * No new underlying VertexBuffer object is created.
  19276. * If the `kind` is the `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19277. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19278. *
  19279. * Possible `kind` values :
  19280. * - VertexBuffer.PositionKind
  19281. * - VertexBuffer.UVKind
  19282. * - VertexBuffer.UV2Kind
  19283. * - VertexBuffer.UV3Kind
  19284. * - VertexBuffer.UV4Kind
  19285. * - VertexBuffer.UV5Kind
  19286. * - VertexBuffer.UV6Kind
  19287. * - VertexBuffer.ColorKind
  19288. * - VertexBuffer.MatricesIndicesKind
  19289. * - VertexBuffer.MatricesIndicesExtraKind
  19290. * - VertexBuffer.MatricesWeightsKind
  19291. * - VertexBuffer.MatricesWeightsExtraKind
  19292. *
  19293. * Returns the Mesh.
  19294. */
  19295. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19296. /**
  19297. * Sets the mesh indices.
  19298. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19299. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19300. * This method creates a new index buffer each call.
  19301. * Returns the Mesh.
  19302. */
  19303. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19304. /**
  19305. * Boolean : True if the mesh owns the requested kind of data.
  19306. */
  19307. isVerticesDataPresent(kind: string): boolean;
  19308. /**
  19309. * Returns an array of indices (IndicesArray).
  19310. */
  19311. getIndices(): Nullable<IndicesArray>;
  19312. readonly _positions: Nullable<Vector3[]>;
  19313. /**
  19314. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19315. * This means the mesh underlying bounding box and sphere are recomputed.
  19316. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19317. * @returns the current mesh
  19318. */
  19319. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19320. /** @hidden */
  19321. _preActivate(): InstancedMesh;
  19322. /** @hidden */
  19323. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19324. /** @hidden */
  19325. _postActivate(): void;
  19326. getWorldMatrix(): Matrix;
  19327. readonly isAnInstance: boolean;
  19328. /**
  19329. * Returns the current associated LOD AbstractMesh.
  19330. */
  19331. getLOD(camera: Camera): AbstractMesh;
  19332. /** @hidden */
  19333. _syncSubMeshes(): InstancedMesh;
  19334. /** @hidden */
  19335. _generatePointsArray(): boolean;
  19336. /**
  19337. * Creates a new InstancedMesh from the current mesh.
  19338. * - name (string) : the cloned mesh name
  19339. * - newParent (optional Node) : the optional Node to parent the clone to.
  19340. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19341. *
  19342. * Returns the clone.
  19343. */
  19344. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19345. /**
  19346. * Disposes the InstancedMesh.
  19347. * Returns nothing.
  19348. */
  19349. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19350. }
  19351. }
  19352. declare module "babylonjs/Materials/shaderMaterial" {
  19353. import { Scene } from "babylonjs/scene";
  19354. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19355. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19356. import { Mesh } from "babylonjs/Meshes/mesh";
  19357. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19358. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19359. import { Texture } from "babylonjs/Materials/Textures/texture";
  19360. import { Material } from "babylonjs/Materials/material";
  19361. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19362. /**
  19363. * Defines the options associated with the creation of a shader material.
  19364. */
  19365. export interface IShaderMaterialOptions {
  19366. /**
  19367. * Does the material work in alpha blend mode
  19368. */
  19369. needAlphaBlending: boolean;
  19370. /**
  19371. * Does the material work in alpha test mode
  19372. */
  19373. needAlphaTesting: boolean;
  19374. /**
  19375. * The list of attribute names used in the shader
  19376. */
  19377. attributes: string[];
  19378. /**
  19379. * The list of unifrom names used in the shader
  19380. */
  19381. uniforms: string[];
  19382. /**
  19383. * The list of UBO names used in the shader
  19384. */
  19385. uniformBuffers: string[];
  19386. /**
  19387. * The list of sampler names used in the shader
  19388. */
  19389. samplers: string[];
  19390. /**
  19391. * The list of defines used in the shader
  19392. */
  19393. defines: string[];
  19394. }
  19395. /**
  19396. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  19397. *
  19398. * This returned material effects how the mesh will look based on the code in the shaders.
  19399. *
  19400. * @see http://doc.babylonjs.com/how_to/shader_material
  19401. */
  19402. export class ShaderMaterial extends Material {
  19403. private _shaderPath;
  19404. private _options;
  19405. private _textures;
  19406. private _textureArrays;
  19407. private _floats;
  19408. private _ints;
  19409. private _floatsArrays;
  19410. private _colors3;
  19411. private _colors3Arrays;
  19412. private _colors4;
  19413. private _colors4Arrays;
  19414. private _vectors2;
  19415. private _vectors3;
  19416. private _vectors4;
  19417. private _matrices;
  19418. private _matrices3x3;
  19419. private _matrices2x2;
  19420. private _vectors2Arrays;
  19421. private _vectors3Arrays;
  19422. private _vectors4Arrays;
  19423. private _cachedWorldViewMatrix;
  19424. private _cachedWorldViewProjectionMatrix;
  19425. private _renderId;
  19426. /**
  19427. * Instantiate a new shader material.
  19428. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  19429. * This returned material effects how the mesh will look based on the code in the shaders.
  19430. * @see http://doc.babylonjs.com/how_to/shader_material
  19431. * @param name Define the name of the material in the scene
  19432. * @param scene Define the scene the material belongs to
  19433. * @param shaderPath Defines the route to the shader code in one of three ways:
  19434. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19435. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19436. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19437. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19438. * @param options Define the options used to create the shader
  19439. */
  19440. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19441. /**
  19442. * Gets the options used to compile the shader.
  19443. * They can be modified to trigger a new compilation
  19444. */
  19445. readonly options: IShaderMaterialOptions;
  19446. /**
  19447. * Gets the current class name of the material e.g. "ShaderMaterial"
  19448. * Mainly use in serialization.
  19449. * @returns the class name
  19450. */
  19451. getClassName(): string;
  19452. /**
  19453. * Specifies if the material will require alpha blending
  19454. * @returns a boolean specifying if alpha blending is needed
  19455. */
  19456. needAlphaBlending(): boolean;
  19457. /**
  19458. * Specifies if this material should be rendered in alpha test mode
  19459. * @returns a boolean specifying if an alpha test is needed.
  19460. */
  19461. needAlphaTesting(): boolean;
  19462. private _checkUniform;
  19463. /**
  19464. * Set a texture in the shader.
  19465. * @param name Define the name of the uniform samplers as defined in the shader
  19466. * @param texture Define the texture to bind to this sampler
  19467. * @return the material itself allowing "fluent" like uniform updates
  19468. */
  19469. setTexture(name: string, texture: Texture): ShaderMaterial;
  19470. /**
  19471. * Set a texture array in the shader.
  19472. * @param name Define the name of the uniform sampler array as defined in the shader
  19473. * @param textures Define the list of textures to bind to this sampler
  19474. * @return the material itself allowing "fluent" like uniform updates
  19475. */
  19476. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19477. /**
  19478. * Set a float in the shader.
  19479. * @param name Define the name of the uniform as defined in the shader
  19480. * @param value Define the value to give to the uniform
  19481. * @return the material itself allowing "fluent" like uniform updates
  19482. */
  19483. setFloat(name: string, value: number): ShaderMaterial;
  19484. /**
  19485. * Set a int in the shader.
  19486. * @param name Define the name of the uniform as defined in the shader
  19487. * @param value Define the value to give to the uniform
  19488. * @return the material itself allowing "fluent" like uniform updates
  19489. */
  19490. setInt(name: string, value: number): ShaderMaterial;
  19491. /**
  19492. * Set an array of floats in the shader.
  19493. * @param name Define the name of the uniform as defined in the shader
  19494. * @param value Define the value to give to the uniform
  19495. * @return the material itself allowing "fluent" like uniform updates
  19496. */
  19497. setFloats(name: string, value: number[]): ShaderMaterial;
  19498. /**
  19499. * Set a vec3 in the shader from a Color3.
  19500. * @param name Define the name of the uniform as defined in the shader
  19501. * @param value Define the value to give to the uniform
  19502. * @return the material itself allowing "fluent" like uniform updates
  19503. */
  19504. setColor3(name: string, value: Color3): ShaderMaterial;
  19505. /**
  19506. * Set a vec3 array in the shader from a Color3 array.
  19507. * @param name Define the name of the uniform as defined in the shader
  19508. * @param value Define the value to give to the uniform
  19509. * @return the material itself allowing "fluent" like uniform updates
  19510. */
  19511. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19512. /**
  19513. * Set a vec4 in the shader from a Color4.
  19514. * @param name Define the name of the uniform as defined in the shader
  19515. * @param value Define the value to give to the uniform
  19516. * @return the material itself allowing "fluent" like uniform updates
  19517. */
  19518. setColor4(name: string, value: Color4): ShaderMaterial;
  19519. /**
  19520. * Set a vec4 array in the shader from a Color4 array.
  19521. * @param name Define the name of the uniform as defined in the shader
  19522. * @param value Define the value to give to the uniform
  19523. * @return the material itself allowing "fluent" like uniform updates
  19524. */
  19525. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19526. /**
  19527. * Set a vec2 in the shader from a Vector2.
  19528. * @param name Define the name of the uniform as defined in the shader
  19529. * @param value Define the value to give to the uniform
  19530. * @return the material itself allowing "fluent" like uniform updates
  19531. */
  19532. setVector2(name: string, value: Vector2): ShaderMaterial;
  19533. /**
  19534. * Set a vec3 in the shader from a Vector3.
  19535. * @param name Define the name of the uniform as defined in the shader
  19536. * @param value Define the value to give to the uniform
  19537. * @return the material itself allowing "fluent" like uniform updates
  19538. */
  19539. setVector3(name: string, value: Vector3): ShaderMaterial;
  19540. /**
  19541. * Set a vec4 in the shader from a Vector4.
  19542. * @param name Define the name of the uniform as defined in the shader
  19543. * @param value Define the value to give to the uniform
  19544. * @return the material itself allowing "fluent" like uniform updates
  19545. */
  19546. setVector4(name: string, value: Vector4): ShaderMaterial;
  19547. /**
  19548. * Set a mat4 in the shader from a Matrix.
  19549. * @param name Define the name of the uniform as defined in the shader
  19550. * @param value Define the value to give to the uniform
  19551. * @return the material itself allowing "fluent" like uniform updates
  19552. */
  19553. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19554. /**
  19555. * Set a mat3 in the shader from a Float32Array.
  19556. * @param name Define the name of the uniform as defined in the shader
  19557. * @param value Define the value to give to the uniform
  19558. * @return the material itself allowing "fluent" like uniform updates
  19559. */
  19560. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19561. /**
  19562. * Set a mat2 in the shader from a Float32Array.
  19563. * @param name Define the name of the uniform as defined in the shader
  19564. * @param value Define the value to give to the uniform
  19565. * @return the material itself allowing "fluent" like uniform updates
  19566. */
  19567. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19568. /**
  19569. * Set a vec2 array in the shader from a number array.
  19570. * @param name Define the name of the uniform as defined in the shader
  19571. * @param value Define the value to give to the uniform
  19572. * @return the material itself allowing "fluent" like uniform updates
  19573. */
  19574. setArray2(name: string, value: number[]): ShaderMaterial;
  19575. /**
  19576. * Set a vec3 array in the shader from a number array.
  19577. * @param name Define the name of the uniform as defined in the shader
  19578. * @param value Define the value to give to the uniform
  19579. * @return the material itself allowing "fluent" like uniform updates
  19580. */
  19581. setArray3(name: string, value: number[]): ShaderMaterial;
  19582. /**
  19583. * Set a vec4 array in the shader from a number array.
  19584. * @param name Define the name of the uniform as defined in the shader
  19585. * @param value Define the value to give to the uniform
  19586. * @return the material itself allowing "fluent" like uniform updates
  19587. */
  19588. setArray4(name: string, value: number[]): ShaderMaterial;
  19589. private _checkCache;
  19590. /**
  19591. * Specifies that the submesh is ready to be used
  19592. * @param mesh defines the mesh to check
  19593. * @param subMesh defines which submesh to check
  19594. * @param useInstances specifies that instances should be used
  19595. * @returns a boolean indicating that the submesh is ready or not
  19596. */
  19597. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19598. /**
  19599. * Checks if the material is ready to render the requested mesh
  19600. * @param mesh Define the mesh to render
  19601. * @param useInstances Define whether or not the material is used with instances
  19602. * @returns true if ready, otherwise false
  19603. */
  19604. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19605. /**
  19606. * Binds the world matrix to the material
  19607. * @param world defines the world transformation matrix
  19608. */
  19609. bindOnlyWorldMatrix(world: Matrix): void;
  19610. /**
  19611. * Binds the material to the mesh
  19612. * @param world defines the world transformation matrix
  19613. * @param mesh defines the mesh to bind the material to
  19614. */
  19615. bind(world: Matrix, mesh?: Mesh): void;
  19616. /**
  19617. * Gets the active textures from the material
  19618. * @returns an array of textures
  19619. */
  19620. getActiveTextures(): BaseTexture[];
  19621. /**
  19622. * Specifies if the material uses a texture
  19623. * @param texture defines the texture to check against the material
  19624. * @returns a boolean specifying if the material uses the texture
  19625. */
  19626. hasTexture(texture: BaseTexture): boolean;
  19627. /**
  19628. * Makes a duplicate of the material, and gives it a new name
  19629. * @param name defines the new name for the duplicated material
  19630. * @returns the cloned material
  19631. */
  19632. clone(name: string): ShaderMaterial;
  19633. /**
  19634. * Disposes the material
  19635. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19636. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19637. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19638. */
  19639. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19640. /**
  19641. * Serializes this material in a JSON representation
  19642. * @returns the serialized material object
  19643. */
  19644. serialize(): any;
  19645. /**
  19646. * Creates a shader material from parsed shader material data
  19647. * @param source defines the JSON represnetation of the material
  19648. * @param scene defines the hosting scene
  19649. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19650. * @returns a new material
  19651. */
  19652. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19653. }
  19654. }
  19655. declare module "babylonjs/Shaders/color.fragment" {
  19656. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  19657. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  19658. /** @hidden */
  19659. export var colorPixelShader: {
  19660. name: string;
  19661. shader: string;
  19662. };
  19663. }
  19664. declare module "babylonjs/Shaders/color.vertex" {
  19665. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  19666. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  19667. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  19668. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  19669. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  19670. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  19671. /** @hidden */
  19672. export var colorVertexShader: {
  19673. name: string;
  19674. shader: string;
  19675. };
  19676. }
  19677. declare module "babylonjs/Meshes/linesMesh" {
  19678. import { Nullable } from "babylonjs/types";
  19679. import { Scene } from "babylonjs/scene";
  19680. import { Color3 } from "babylonjs/Maths/math.color";
  19681. import { Node } from "babylonjs/node";
  19682. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19683. import { Mesh } from "babylonjs/Meshes/mesh";
  19684. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  19685. import { Effect } from "babylonjs/Materials/effect";
  19686. import { Material } from "babylonjs/Materials/material";
  19687. import "babylonjs/Shaders/color.fragment";
  19688. import "babylonjs/Shaders/color.vertex";
  19689. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19690. /**
  19691. * Line mesh
  19692. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19693. */
  19694. export class LinesMesh extends Mesh {
  19695. /**
  19696. * If vertex color should be applied to the mesh
  19697. */
  19698. readonly useVertexColor?: boolean | undefined;
  19699. /**
  19700. * If vertex alpha should be applied to the mesh
  19701. */
  19702. readonly useVertexAlpha?: boolean | undefined;
  19703. /**
  19704. * Color of the line (Default: White)
  19705. */
  19706. color: Color3;
  19707. /**
  19708. * Alpha of the line (Default: 1)
  19709. */
  19710. alpha: number;
  19711. /**
  19712. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19713. * This margin is expressed in world space coordinates, so its value may vary.
  19714. * Default value is 0.1
  19715. */
  19716. intersectionThreshold: number;
  19717. private _colorShader;
  19718. private color4;
  19719. /**
  19720. * Creates a new LinesMesh
  19721. * @param name defines the name
  19722. * @param scene defines the hosting scene
  19723. * @param parent defines the parent mesh if any
  19724. * @param source defines the optional source LinesMesh used to clone data from
  19725. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19726. * When false, achieved by calling a clone(), also passing False.
  19727. * This will make creation of children, recursive.
  19728. * @param useVertexColor defines if this LinesMesh supports vertex color
  19729. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19730. */
  19731. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19732. /**
  19733. * If vertex color should be applied to the mesh
  19734. */
  19735. useVertexColor?: boolean | undefined,
  19736. /**
  19737. * If vertex alpha should be applied to the mesh
  19738. */
  19739. useVertexAlpha?: boolean | undefined);
  19740. private _addClipPlaneDefine;
  19741. private _removeClipPlaneDefine;
  19742. isReady(): boolean;
  19743. /**
  19744. * Returns the string "LineMesh"
  19745. */
  19746. getClassName(): string;
  19747. /**
  19748. * @hidden
  19749. */
  19750. /**
  19751. * @hidden
  19752. */
  19753. material: Material;
  19754. /**
  19755. * @hidden
  19756. */
  19757. readonly checkCollisions: boolean;
  19758. /** @hidden */
  19759. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19760. /** @hidden */
  19761. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19762. /**
  19763. * Disposes of the line mesh
  19764. * @param doNotRecurse If children should be disposed
  19765. */
  19766. dispose(doNotRecurse?: boolean): void;
  19767. /**
  19768. * Returns a new LineMesh object cloned from the current one.
  19769. */
  19770. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19771. /**
  19772. * Creates a new InstancedLinesMesh object from the mesh model.
  19773. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19774. * @param name defines the name of the new instance
  19775. * @returns a new InstancedLinesMesh
  19776. */
  19777. createInstance(name: string): InstancedLinesMesh;
  19778. }
  19779. /**
  19780. * Creates an instance based on a source LinesMesh
  19781. */
  19782. export class InstancedLinesMesh extends InstancedMesh {
  19783. /**
  19784. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19785. * This margin is expressed in world space coordinates, so its value may vary.
  19786. * Initilized with the intersectionThreshold value of the source LinesMesh
  19787. */
  19788. intersectionThreshold: number;
  19789. constructor(name: string, source: LinesMesh);
  19790. /**
  19791. * Returns the string "InstancedLinesMesh".
  19792. */
  19793. getClassName(): string;
  19794. }
  19795. }
  19796. declare module "babylonjs/Shaders/line.fragment" {
  19797. /** @hidden */
  19798. export var linePixelShader: {
  19799. name: string;
  19800. shader: string;
  19801. };
  19802. }
  19803. declare module "babylonjs/Shaders/line.vertex" {
  19804. /** @hidden */
  19805. export var lineVertexShader: {
  19806. name: string;
  19807. shader: string;
  19808. };
  19809. }
  19810. declare module "babylonjs/Rendering/edgesRenderer" {
  19811. import { Nullable } from "babylonjs/types";
  19812. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19813. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19814. import { Vector3 } from "babylonjs/Maths/math.vector";
  19815. import { IDisposable } from "babylonjs/scene";
  19816. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  19817. import "babylonjs/Shaders/line.fragment";
  19818. import "babylonjs/Shaders/line.vertex";
  19819. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  19820. module "babylonjs/Meshes/abstractMesh" {
  19821. interface AbstractMesh {
  19822. /**
  19823. * Gets the edgesRenderer associated with the mesh
  19824. */
  19825. edgesRenderer: Nullable<EdgesRenderer>;
  19826. }
  19827. }
  19828. module "babylonjs/Meshes/linesMesh" {
  19829. interface LinesMesh {
  19830. /**
  19831. * Enables the edge rendering mode on the mesh.
  19832. * This mode makes the mesh edges visible
  19833. * @param epsilon defines the maximal distance between two angles to detect a face
  19834. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19835. * @returns the currentAbstractMesh
  19836. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19837. */
  19838. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19839. }
  19840. }
  19841. module "babylonjs/Meshes/linesMesh" {
  19842. interface InstancedLinesMesh {
  19843. /**
  19844. * Enables the edge rendering mode on the mesh.
  19845. * This mode makes the mesh edges visible
  19846. * @param epsilon defines the maximal distance between two angles to detect a face
  19847. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19848. * @returns the current InstancedLinesMesh
  19849. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19850. */
  19851. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19852. }
  19853. }
  19854. /**
  19855. * Defines the minimum contract an Edges renderer should follow.
  19856. */
  19857. export interface IEdgesRenderer extends IDisposable {
  19858. /**
  19859. * Gets or sets a boolean indicating if the edgesRenderer is active
  19860. */
  19861. isEnabled: boolean;
  19862. /**
  19863. * Renders the edges of the attached mesh,
  19864. */
  19865. render(): void;
  19866. /**
  19867. * Checks wether or not the edges renderer is ready to render.
  19868. * @return true if ready, otherwise false.
  19869. */
  19870. isReady(): boolean;
  19871. }
  19872. /**
  19873. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19874. */
  19875. export class EdgesRenderer implements IEdgesRenderer {
  19876. /**
  19877. * Define the size of the edges with an orthographic camera
  19878. */
  19879. edgesWidthScalerForOrthographic: number;
  19880. /**
  19881. * Define the size of the edges with a perspective camera
  19882. */
  19883. edgesWidthScalerForPerspective: number;
  19884. protected _source: AbstractMesh;
  19885. protected _linesPositions: number[];
  19886. protected _linesNormals: number[];
  19887. protected _linesIndices: number[];
  19888. protected _epsilon: number;
  19889. protected _indicesCount: number;
  19890. protected _lineShader: ShaderMaterial;
  19891. protected _ib: DataBuffer;
  19892. protected _buffers: {
  19893. [key: string]: Nullable<VertexBuffer>;
  19894. };
  19895. protected _checkVerticesInsteadOfIndices: boolean;
  19896. private _meshRebuildObserver;
  19897. private _meshDisposeObserver;
  19898. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19899. isEnabled: boolean;
  19900. /**
  19901. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19902. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19903. * @param source Mesh used to create edges
  19904. * @param epsilon sum of angles in adjacency to check for edge
  19905. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19906. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19907. */
  19908. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19909. protected _prepareRessources(): void;
  19910. /** @hidden */
  19911. _rebuild(): void;
  19912. /**
  19913. * Releases the required resources for the edges renderer
  19914. */
  19915. dispose(): void;
  19916. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19917. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19918. /**
  19919. * Checks if the pair of p0 and p1 is en edge
  19920. * @param faceIndex
  19921. * @param edge
  19922. * @param faceNormals
  19923. * @param p0
  19924. * @param p1
  19925. * @private
  19926. */
  19927. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19928. /**
  19929. * push line into the position, normal and index buffer
  19930. * @protected
  19931. */
  19932. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19933. /**
  19934. * Generates lines edges from adjacencjes
  19935. * @private
  19936. */
  19937. _generateEdgesLines(): void;
  19938. /**
  19939. * Checks wether or not the edges renderer is ready to render.
  19940. * @return true if ready, otherwise false.
  19941. */
  19942. isReady(): boolean;
  19943. /**
  19944. * Renders the edges of the attached mesh,
  19945. */
  19946. render(): void;
  19947. }
  19948. /**
  19949. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19950. */
  19951. export class LineEdgesRenderer extends EdgesRenderer {
  19952. /**
  19953. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19954. * @param source LineMesh used to generate edges
  19955. * @param epsilon not important (specified angle for edge detection)
  19956. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19957. */
  19958. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19959. /**
  19960. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19961. */
  19962. _generateEdgesLines(): void;
  19963. }
  19964. }
  19965. declare module "babylonjs/Rendering/renderingGroup" {
  19966. import { SmartArray } from "babylonjs/Misc/smartArray";
  19967. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19968. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19969. import { Nullable } from "babylonjs/types";
  19970. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  19971. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  19972. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  19973. import { Material } from "babylonjs/Materials/material";
  19974. import { Scene } from "babylonjs/scene";
  19975. /**
  19976. * This represents the object necessary to create a rendering group.
  19977. * This is exclusively used and created by the rendering manager.
  19978. * To modify the behavior, you use the available helpers in your scene or meshes.
  19979. * @hidden
  19980. */
  19981. export class RenderingGroup {
  19982. index: number;
  19983. private static _zeroVector;
  19984. private _scene;
  19985. private _opaqueSubMeshes;
  19986. private _transparentSubMeshes;
  19987. private _alphaTestSubMeshes;
  19988. private _depthOnlySubMeshes;
  19989. private _particleSystems;
  19990. private _spriteManagers;
  19991. private _opaqueSortCompareFn;
  19992. private _alphaTestSortCompareFn;
  19993. private _transparentSortCompareFn;
  19994. private _renderOpaque;
  19995. private _renderAlphaTest;
  19996. private _renderTransparent;
  19997. /** @hidden */
  19998. _edgesRenderers: SmartArray<IEdgesRenderer>;
  19999. onBeforeTransparentRendering: () => void;
  20000. /**
  20001. * Set the opaque sort comparison function.
  20002. * If null the sub meshes will be render in the order they were created
  20003. */
  20004. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20005. /**
  20006. * Set the alpha test sort comparison function.
  20007. * If null the sub meshes will be render in the order they were created
  20008. */
  20009. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20010. /**
  20011. * Set the transparent sort comparison function.
  20012. * If null the sub meshes will be render in the order they were created
  20013. */
  20014. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20015. /**
  20016. * Creates a new rendering group.
  20017. * @param index The rendering group index
  20018. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  20019. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  20020. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  20021. */
  20022. constructor(index: number, scene: Scene, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>);
  20023. /**
  20024. * Render all the sub meshes contained in the group.
  20025. * @param customRenderFunction Used to override the default render behaviour of the group.
  20026. * @returns true if rendered some submeshes.
  20027. */
  20028. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  20029. /**
  20030. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  20031. * @param subMeshes The submeshes to render
  20032. */
  20033. private renderOpaqueSorted;
  20034. /**
  20035. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  20036. * @param subMeshes The submeshes to render
  20037. */
  20038. private renderAlphaTestSorted;
  20039. /**
  20040. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  20041. * @param subMeshes The submeshes to render
  20042. */
  20043. private renderTransparentSorted;
  20044. /**
  20045. * Renders the submeshes in a specified order.
  20046. * @param subMeshes The submeshes to sort before render
  20047. * @param sortCompareFn The comparison function use to sort
  20048. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  20049. * @param transparent Specifies to activate blending if true
  20050. */
  20051. private static renderSorted;
  20052. /**
  20053. * Renders the submeshes in the order they were dispatched (no sort applied).
  20054. * @param subMeshes The submeshes to render
  20055. */
  20056. private static renderUnsorted;
  20057. /**
  20058. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20059. * are rendered back to front if in the same alpha index.
  20060. *
  20061. * @param a The first submesh
  20062. * @param b The second submesh
  20063. * @returns The result of the comparison
  20064. */
  20065. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  20066. /**
  20067. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20068. * are rendered back to front.
  20069. *
  20070. * @param a The first submesh
  20071. * @param b The second submesh
  20072. * @returns The result of the comparison
  20073. */
  20074. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20075. /**
  20076. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20077. * are rendered front to back (prevent overdraw).
  20078. *
  20079. * @param a The first submesh
  20080. * @param b The second submesh
  20081. * @returns The result of the comparison
  20082. */
  20083. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20084. /**
  20085. * Resets the different lists of submeshes to prepare a new frame.
  20086. */
  20087. prepare(): void;
  20088. dispose(): void;
  20089. /**
  20090. * Inserts the submesh in its correct queue depending on its material.
  20091. * @param subMesh The submesh to dispatch
  20092. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20093. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20094. */
  20095. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20096. dispatchSprites(spriteManager: ISpriteManager): void;
  20097. dispatchParticles(particleSystem: IParticleSystem): void;
  20098. private _renderParticles;
  20099. private _renderSprites;
  20100. }
  20101. }
  20102. declare module "babylonjs/Rendering/renderingManager" {
  20103. import { Nullable } from "babylonjs/types";
  20104. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20105. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20106. import { SmartArray } from "babylonjs/Misc/smartArray";
  20107. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20108. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20109. import { Material } from "babylonjs/Materials/material";
  20110. import { Scene } from "babylonjs/scene";
  20111. import { Camera } from "babylonjs/Cameras/camera";
  20112. /**
  20113. * Interface describing the different options available in the rendering manager
  20114. * regarding Auto Clear between groups.
  20115. */
  20116. export interface IRenderingManagerAutoClearSetup {
  20117. /**
  20118. * Defines whether or not autoclear is enable.
  20119. */
  20120. autoClear: boolean;
  20121. /**
  20122. * Defines whether or not to autoclear the depth buffer.
  20123. */
  20124. depth: boolean;
  20125. /**
  20126. * Defines whether or not to autoclear the stencil buffer.
  20127. */
  20128. stencil: boolean;
  20129. }
  20130. /**
  20131. * This class is used by the onRenderingGroupObservable
  20132. */
  20133. export class RenderingGroupInfo {
  20134. /**
  20135. * The Scene that being rendered
  20136. */
  20137. scene: Scene;
  20138. /**
  20139. * The camera currently used for the rendering pass
  20140. */
  20141. camera: Nullable<Camera>;
  20142. /**
  20143. * The ID of the renderingGroup being processed
  20144. */
  20145. renderingGroupId: number;
  20146. }
  20147. /**
  20148. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20149. * It is enable to manage the different groups as well as the different necessary sort functions.
  20150. * This should not be used directly aside of the few static configurations
  20151. */
  20152. export class RenderingManager {
  20153. /**
  20154. * The max id used for rendering groups (not included)
  20155. */
  20156. static MAX_RENDERINGGROUPS: number;
  20157. /**
  20158. * The min id used for rendering groups (included)
  20159. */
  20160. static MIN_RENDERINGGROUPS: number;
  20161. /**
  20162. * Used to globally prevent autoclearing scenes.
  20163. */
  20164. static AUTOCLEAR: boolean;
  20165. /**
  20166. * @hidden
  20167. */
  20168. _useSceneAutoClearSetup: boolean;
  20169. private _scene;
  20170. private _renderingGroups;
  20171. private _depthStencilBufferAlreadyCleaned;
  20172. private _autoClearDepthStencil;
  20173. private _customOpaqueSortCompareFn;
  20174. private _customAlphaTestSortCompareFn;
  20175. private _customTransparentSortCompareFn;
  20176. private _renderingGroupInfo;
  20177. /**
  20178. * Instantiates a new rendering group for a particular scene
  20179. * @param scene Defines the scene the groups belongs to
  20180. */
  20181. constructor(scene: Scene);
  20182. private _clearDepthStencilBuffer;
  20183. /**
  20184. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20185. * @hidden
  20186. */
  20187. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20188. /**
  20189. * Resets the different information of the group to prepare a new frame
  20190. * @hidden
  20191. */
  20192. reset(): void;
  20193. /**
  20194. * Dispose and release the group and its associated resources.
  20195. * @hidden
  20196. */
  20197. dispose(): void;
  20198. /**
  20199. * Clear the info related to rendering groups preventing retention points during dispose.
  20200. */
  20201. freeRenderingGroups(): void;
  20202. private _prepareRenderingGroup;
  20203. /**
  20204. * Add a sprite manager to the rendering manager in order to render it this frame.
  20205. * @param spriteManager Define the sprite manager to render
  20206. */
  20207. dispatchSprites(spriteManager: ISpriteManager): void;
  20208. /**
  20209. * Add a particle system to the rendering manager in order to render it this frame.
  20210. * @param particleSystem Define the particle system to render
  20211. */
  20212. dispatchParticles(particleSystem: IParticleSystem): void;
  20213. /**
  20214. * Add a submesh to the manager in order to render it this frame
  20215. * @param subMesh The submesh to dispatch
  20216. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20217. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20218. */
  20219. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20220. /**
  20221. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20222. * This allowed control for front to back rendering or reversly depending of the special needs.
  20223. *
  20224. * @param renderingGroupId The rendering group id corresponding to its index
  20225. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20226. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20227. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20228. */
  20229. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  20230. /**
  20231. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20232. *
  20233. * @param renderingGroupId The rendering group id corresponding to its index
  20234. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20235. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20236. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20237. */
  20238. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20239. /**
  20240. * Gets the current auto clear configuration for one rendering group of the rendering
  20241. * manager.
  20242. * @param index the rendering group index to get the information for
  20243. * @returns The auto clear setup for the requested rendering group
  20244. */
  20245. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20246. }
  20247. }
  20248. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20249. import { Observable } from "babylonjs/Misc/observable";
  20250. import { SmartArray } from "babylonjs/Misc/smartArray";
  20251. import { Nullable } from "babylonjs/types";
  20252. import { Camera } from "babylonjs/Cameras/camera";
  20253. import { Scene } from "babylonjs/scene";
  20254. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20255. import { Color4 } from "babylonjs/Maths/math.color";
  20256. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20257. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20258. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20259. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20260. import { Texture } from "babylonjs/Materials/Textures/texture";
  20261. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20262. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20263. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20264. import { Engine } from "babylonjs/Engines/engine";
  20265. /**
  20266. * This Helps creating a texture that will be created from a camera in your scene.
  20267. * It is basically a dynamic texture that could be used to create special effects for instance.
  20268. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20269. */
  20270. export class RenderTargetTexture extends Texture {
  20271. isCube: boolean;
  20272. /**
  20273. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20274. */
  20275. static readonly REFRESHRATE_RENDER_ONCE: number;
  20276. /**
  20277. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20278. */
  20279. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20280. /**
  20281. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20282. * the central point of your effect and can save a lot of performances.
  20283. */
  20284. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20285. /**
  20286. * Use this predicate to dynamically define the list of mesh you want to render.
  20287. * If set, the renderList property will be overwritten.
  20288. */
  20289. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20290. private _renderList;
  20291. /**
  20292. * Use this list to define the list of mesh you want to render.
  20293. */
  20294. renderList: Nullable<Array<AbstractMesh>>;
  20295. private _hookArray;
  20296. /**
  20297. * Define if particles should be rendered in your texture.
  20298. */
  20299. renderParticles: boolean;
  20300. /**
  20301. * Define if sprites should be rendered in your texture.
  20302. */
  20303. renderSprites: boolean;
  20304. /**
  20305. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20306. */
  20307. coordinatesMode: number;
  20308. /**
  20309. * Define the camera used to render the texture.
  20310. */
  20311. activeCamera: Nullable<Camera>;
  20312. /**
  20313. * Override the render function of the texture with your own one.
  20314. */
  20315. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20316. /**
  20317. * Define if camera post processes should be use while rendering the texture.
  20318. */
  20319. useCameraPostProcesses: boolean;
  20320. /**
  20321. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20322. */
  20323. ignoreCameraViewport: boolean;
  20324. private _postProcessManager;
  20325. private _postProcesses;
  20326. private _resizeObserver;
  20327. /**
  20328. * An event triggered when the texture is unbind.
  20329. */
  20330. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20331. /**
  20332. * An event triggered when the texture is unbind.
  20333. */
  20334. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20335. private _onAfterUnbindObserver;
  20336. /**
  20337. * Set a after unbind callback in the texture.
  20338. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20339. */
  20340. onAfterUnbind: () => void;
  20341. /**
  20342. * An event triggered before rendering the texture
  20343. */
  20344. onBeforeRenderObservable: Observable<number>;
  20345. private _onBeforeRenderObserver;
  20346. /**
  20347. * Set a before render callback in the texture.
  20348. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20349. */
  20350. onBeforeRender: (faceIndex: number) => void;
  20351. /**
  20352. * An event triggered after rendering the texture
  20353. */
  20354. onAfterRenderObservable: Observable<number>;
  20355. private _onAfterRenderObserver;
  20356. /**
  20357. * Set a after render callback in the texture.
  20358. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20359. */
  20360. onAfterRender: (faceIndex: number) => void;
  20361. /**
  20362. * An event triggered after the texture clear
  20363. */
  20364. onClearObservable: Observable<Engine>;
  20365. private _onClearObserver;
  20366. /**
  20367. * Set a clear callback in the texture.
  20368. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20369. */
  20370. onClear: (Engine: Engine) => void;
  20371. /**
  20372. * An event triggered when the texture is resized.
  20373. */
  20374. onResizeObservable: Observable<RenderTargetTexture>;
  20375. /**
  20376. * Define the clear color of the Render Target if it should be different from the scene.
  20377. */
  20378. clearColor: Color4;
  20379. protected _size: number | {
  20380. width: number;
  20381. height: number;
  20382. };
  20383. protected _initialSizeParameter: number | {
  20384. width: number;
  20385. height: number;
  20386. } | {
  20387. ratio: number;
  20388. };
  20389. protected _sizeRatio: Nullable<number>;
  20390. /** @hidden */
  20391. _generateMipMaps: boolean;
  20392. protected _renderingManager: RenderingManager;
  20393. /** @hidden */
  20394. _waitingRenderList: string[];
  20395. protected _doNotChangeAspectRatio: boolean;
  20396. protected _currentRefreshId: number;
  20397. protected _refreshRate: number;
  20398. protected _textureMatrix: Matrix;
  20399. protected _samples: number;
  20400. protected _renderTargetOptions: RenderTargetCreationOptions;
  20401. /**
  20402. * Gets render target creation options that were used.
  20403. */
  20404. readonly renderTargetOptions: RenderTargetCreationOptions;
  20405. protected _engine: Engine;
  20406. protected _onRatioRescale(): void;
  20407. /**
  20408. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20409. * It must define where the camera used to render the texture is set
  20410. */
  20411. boundingBoxPosition: Vector3;
  20412. private _boundingBoxSize;
  20413. /**
  20414. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20415. * When defined, the cubemap will switch to local mode
  20416. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20417. * @example https://www.babylonjs-playground.com/#RNASML
  20418. */
  20419. boundingBoxSize: Vector3;
  20420. /**
  20421. * In case the RTT has been created with a depth texture, get the associated
  20422. * depth texture.
  20423. * Otherwise, return null.
  20424. */
  20425. depthStencilTexture: Nullable<InternalTexture>;
  20426. /**
  20427. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20428. * or used a shadow, depth texture...
  20429. * @param name The friendly name of the texture
  20430. * @param size The size of the RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  20431. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20432. * @param generateMipMaps True if mip maps need to be generated after render.
  20433. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20434. * @param type The type of the buffer in the RTT (int, half float, float...)
  20435. * @param isCube True if a cube texture needs to be created
  20436. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20437. * @param generateDepthBuffer True to generate a depth buffer
  20438. * @param generateStencilBuffer True to generate a stencil buffer
  20439. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20440. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20441. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20442. */
  20443. constructor(name: string, size: number | {
  20444. width: number;
  20445. height: number;
  20446. } | {
  20447. ratio: number;
  20448. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20449. /**
  20450. * Creates a depth stencil texture.
  20451. * This is only available in WebGL 2 or with the depth texture extension available.
  20452. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20453. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20454. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20455. */
  20456. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20457. private _processSizeParameter;
  20458. /**
  20459. * Define the number of samples to use in case of MSAA.
  20460. * It defaults to one meaning no MSAA has been enabled.
  20461. */
  20462. samples: number;
  20463. /**
  20464. * Resets the refresh counter of the texture and start bak from scratch.
  20465. * Could be useful to regenerate the texture if it is setup to render only once.
  20466. */
  20467. resetRefreshCounter(): void;
  20468. /**
  20469. * Define the refresh rate of the texture or the rendering frequency.
  20470. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20471. */
  20472. refreshRate: number;
  20473. /**
  20474. * Adds a post process to the render target rendering passes.
  20475. * @param postProcess define the post process to add
  20476. */
  20477. addPostProcess(postProcess: PostProcess): void;
  20478. /**
  20479. * Clear all the post processes attached to the render target
  20480. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20481. */
  20482. clearPostProcesses(dispose?: boolean): void;
  20483. /**
  20484. * Remove one of the post process from the list of attached post processes to the texture
  20485. * @param postProcess define the post process to remove from the list
  20486. */
  20487. removePostProcess(postProcess: PostProcess): void;
  20488. /** @hidden */
  20489. _shouldRender(): boolean;
  20490. /**
  20491. * Gets the actual render size of the texture.
  20492. * @returns the width of the render size
  20493. */
  20494. getRenderSize(): number;
  20495. /**
  20496. * Gets the actual render width of the texture.
  20497. * @returns the width of the render size
  20498. */
  20499. getRenderWidth(): number;
  20500. /**
  20501. * Gets the actual render height of the texture.
  20502. * @returns the height of the render size
  20503. */
  20504. getRenderHeight(): number;
  20505. /**
  20506. * Get if the texture can be rescaled or not.
  20507. */
  20508. readonly canRescale: boolean;
  20509. /**
  20510. * Resize the texture using a ratio.
  20511. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20512. */
  20513. scale(ratio: number): void;
  20514. /**
  20515. * Get the texture reflection matrix used to rotate/transform the reflection.
  20516. * @returns the reflection matrix
  20517. */
  20518. getReflectionTextureMatrix(): Matrix;
  20519. /**
  20520. * Resize the texture to a new desired size.
  20521. * Be carrefull as it will recreate all the data in the new texture.
  20522. * @param size Define the new size. It can be:
  20523. * - a number for squared texture,
  20524. * - an object containing { width: number, height: number }
  20525. * - or an object containing a ratio { ratio: number }
  20526. */
  20527. resize(size: number | {
  20528. width: number;
  20529. height: number;
  20530. } | {
  20531. ratio: number;
  20532. }): void;
  20533. /**
  20534. * Renders all the objects from the render list into the texture.
  20535. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20536. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20537. */
  20538. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20539. private _bestReflectionRenderTargetDimension;
  20540. /**
  20541. * @hidden
  20542. * @param faceIndex face index to bind to if this is a cubetexture
  20543. */
  20544. _bindFrameBuffer(faceIndex?: number): void;
  20545. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20546. private renderToTarget;
  20547. /**
  20548. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20549. * This allowed control for front to back rendering or reversly depending of the special needs.
  20550. *
  20551. * @param renderingGroupId The rendering group id corresponding to its index
  20552. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20553. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20554. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20555. */
  20556. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  20557. /**
  20558. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20559. *
  20560. * @param renderingGroupId The rendering group id corresponding to its index
  20561. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20562. */
  20563. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20564. /**
  20565. * Clones the texture.
  20566. * @returns the cloned texture
  20567. */
  20568. clone(): RenderTargetTexture;
  20569. /**
  20570. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20571. * @returns The JSON representation of the texture
  20572. */
  20573. serialize(): any;
  20574. /**
  20575. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20576. */
  20577. disposeFramebufferObjects(): void;
  20578. /**
  20579. * Dispose the texture and release its associated resources.
  20580. */
  20581. dispose(): void;
  20582. /** @hidden */
  20583. _rebuild(): void;
  20584. /**
  20585. * Clear the info related to rendering groups preventing retention point in material dispose.
  20586. */
  20587. freeRenderingGroups(): void;
  20588. /**
  20589. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20590. * @returns the view count
  20591. */
  20592. getViewCount(): number;
  20593. }
  20594. }
  20595. declare module "babylonjs/Materials/material" {
  20596. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20597. import { SmartArray } from "babylonjs/Misc/smartArray";
  20598. import { Observable } from "babylonjs/Misc/observable";
  20599. import { Nullable } from "babylonjs/types";
  20600. import { Scene } from "babylonjs/scene";
  20601. import { Matrix } from "babylonjs/Maths/math.vector";
  20602. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  20603. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20604. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20605. import { Effect } from "babylonjs/Materials/effect";
  20606. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20607. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20608. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20609. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20610. import { Mesh } from "babylonjs/Meshes/mesh";
  20611. import { Animation } from "babylonjs/Animations/animation";
  20612. /**
  20613. * Base class for the main features of a material in Babylon.js
  20614. */
  20615. export class Material implements IAnimatable {
  20616. /**
  20617. * Returns the triangle fill mode
  20618. */
  20619. static readonly TriangleFillMode: number;
  20620. /**
  20621. * Returns the wireframe mode
  20622. */
  20623. static readonly WireFrameFillMode: number;
  20624. /**
  20625. * Returns the point fill mode
  20626. */
  20627. static readonly PointFillMode: number;
  20628. /**
  20629. * Returns the point list draw mode
  20630. */
  20631. static readonly PointListDrawMode: number;
  20632. /**
  20633. * Returns the line list draw mode
  20634. */
  20635. static readonly LineListDrawMode: number;
  20636. /**
  20637. * Returns the line loop draw mode
  20638. */
  20639. static readonly LineLoopDrawMode: number;
  20640. /**
  20641. * Returns the line strip draw mode
  20642. */
  20643. static readonly LineStripDrawMode: number;
  20644. /**
  20645. * Returns the triangle strip draw mode
  20646. */
  20647. static readonly TriangleStripDrawMode: number;
  20648. /**
  20649. * Returns the triangle fan draw mode
  20650. */
  20651. static readonly TriangleFanDrawMode: number;
  20652. /**
  20653. * Stores the clock-wise side orientation
  20654. */
  20655. static readonly ClockWiseSideOrientation: number;
  20656. /**
  20657. * Stores the counter clock-wise side orientation
  20658. */
  20659. static readonly CounterClockWiseSideOrientation: number;
  20660. /**
  20661. * The dirty texture flag value
  20662. */
  20663. static readonly TextureDirtyFlag: number;
  20664. /**
  20665. * The dirty light flag value
  20666. */
  20667. static readonly LightDirtyFlag: number;
  20668. /**
  20669. * The dirty fresnel flag value
  20670. */
  20671. static readonly FresnelDirtyFlag: number;
  20672. /**
  20673. * The dirty attribute flag value
  20674. */
  20675. static readonly AttributesDirtyFlag: number;
  20676. /**
  20677. * The dirty misc flag value
  20678. */
  20679. static readonly MiscDirtyFlag: number;
  20680. /**
  20681. * The all dirty flag value
  20682. */
  20683. static readonly AllDirtyFlag: number;
  20684. /**
  20685. * The ID of the material
  20686. */
  20687. id: string;
  20688. /**
  20689. * Gets or sets the unique id of the material
  20690. */
  20691. uniqueId: number;
  20692. /**
  20693. * The name of the material
  20694. */
  20695. name: string;
  20696. /**
  20697. * Gets or sets user defined metadata
  20698. */
  20699. metadata: any;
  20700. /**
  20701. * For internal use only. Please do not use.
  20702. */
  20703. reservedDataStore: any;
  20704. /**
  20705. * Specifies if the ready state should be checked on each call
  20706. */
  20707. checkReadyOnEveryCall: boolean;
  20708. /**
  20709. * Specifies if the ready state should be checked once
  20710. */
  20711. checkReadyOnlyOnce: boolean;
  20712. /**
  20713. * The state of the material
  20714. */
  20715. state: string;
  20716. /**
  20717. * The alpha value of the material
  20718. */
  20719. protected _alpha: number;
  20720. /**
  20721. * List of inspectable custom properties (used by the Inspector)
  20722. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20723. */
  20724. inspectableCustomProperties: IInspectable[];
  20725. /**
  20726. * Sets the alpha value of the material
  20727. */
  20728. /**
  20729. * Gets the alpha value of the material
  20730. */
  20731. alpha: number;
  20732. /**
  20733. * Specifies if back face culling is enabled
  20734. */
  20735. protected _backFaceCulling: boolean;
  20736. /**
  20737. * Sets the back-face culling state
  20738. */
  20739. /**
  20740. * Gets the back-face culling state
  20741. */
  20742. backFaceCulling: boolean;
  20743. /**
  20744. * Stores the value for side orientation
  20745. */
  20746. sideOrientation: number;
  20747. /**
  20748. * Callback triggered when the material is compiled
  20749. */
  20750. onCompiled: Nullable<(effect: Effect) => void>;
  20751. /**
  20752. * Callback triggered when an error occurs
  20753. */
  20754. onError: Nullable<(effect: Effect, errors: string) => void>;
  20755. /**
  20756. * Callback triggered to get the render target textures
  20757. */
  20758. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20759. /**
  20760. * Gets a boolean indicating that current material needs to register RTT
  20761. */
  20762. readonly hasRenderTargetTextures: boolean;
  20763. /**
  20764. * Specifies if the material should be serialized
  20765. */
  20766. doNotSerialize: boolean;
  20767. /**
  20768. * @hidden
  20769. */
  20770. _storeEffectOnSubMeshes: boolean;
  20771. /**
  20772. * Stores the animations for the material
  20773. */
  20774. animations: Nullable<Array<Animation>>;
  20775. /**
  20776. * An event triggered when the material is disposed
  20777. */
  20778. onDisposeObservable: Observable<Material>;
  20779. /**
  20780. * An observer which watches for dispose events
  20781. */
  20782. private _onDisposeObserver;
  20783. private _onUnBindObservable;
  20784. /**
  20785. * Called during a dispose event
  20786. */
  20787. onDispose: () => void;
  20788. private _onBindObservable;
  20789. /**
  20790. * An event triggered when the material is bound
  20791. */
  20792. readonly onBindObservable: Observable<AbstractMesh>;
  20793. /**
  20794. * An observer which watches for bind events
  20795. */
  20796. private _onBindObserver;
  20797. /**
  20798. * Called during a bind event
  20799. */
  20800. onBind: (Mesh: AbstractMesh) => void;
  20801. /**
  20802. * An event triggered when the material is unbound
  20803. */
  20804. readonly onUnBindObservable: Observable<Material>;
  20805. /**
  20806. * Stores the value of the alpha mode
  20807. */
  20808. private _alphaMode;
  20809. /**
  20810. * Sets the value of the alpha mode.
  20811. *
  20812. * | Value | Type | Description |
  20813. * | --- | --- | --- |
  20814. * | 0 | ALPHA_DISABLE | |
  20815. * | 1 | ALPHA_ADD | |
  20816. * | 2 | ALPHA_COMBINE | |
  20817. * | 3 | ALPHA_SUBTRACT | |
  20818. * | 4 | ALPHA_MULTIPLY | |
  20819. * | 5 | ALPHA_MAXIMIZED | |
  20820. * | 6 | ALPHA_ONEONE | |
  20821. * | 7 | ALPHA_PREMULTIPLIED | |
  20822. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20823. * | 9 | ALPHA_INTERPOLATE | |
  20824. * | 10 | ALPHA_SCREENMODE | |
  20825. *
  20826. */
  20827. /**
  20828. * Gets the value of the alpha mode
  20829. */
  20830. alphaMode: number;
  20831. /**
  20832. * Stores the state of the need depth pre-pass value
  20833. */
  20834. private _needDepthPrePass;
  20835. /**
  20836. * Sets the need depth pre-pass value
  20837. */
  20838. /**
  20839. * Gets the depth pre-pass value
  20840. */
  20841. needDepthPrePass: boolean;
  20842. /**
  20843. * Specifies if depth writing should be disabled
  20844. */
  20845. disableDepthWrite: boolean;
  20846. /**
  20847. * Specifies if depth writing should be forced
  20848. */
  20849. forceDepthWrite: boolean;
  20850. /**
  20851. * Specifies if there should be a separate pass for culling
  20852. */
  20853. separateCullingPass: boolean;
  20854. /**
  20855. * Stores the state specifing if fog should be enabled
  20856. */
  20857. private _fogEnabled;
  20858. /**
  20859. * Sets the state for enabling fog
  20860. */
  20861. /**
  20862. * Gets the value of the fog enabled state
  20863. */
  20864. fogEnabled: boolean;
  20865. /**
  20866. * Stores the size of points
  20867. */
  20868. pointSize: number;
  20869. /**
  20870. * Stores the z offset value
  20871. */
  20872. zOffset: number;
  20873. /**
  20874. * Gets a value specifying if wireframe mode is enabled
  20875. */
  20876. /**
  20877. * Sets the state of wireframe mode
  20878. */
  20879. wireframe: boolean;
  20880. /**
  20881. * Gets the value specifying if point clouds are enabled
  20882. */
  20883. /**
  20884. * Sets the state of point cloud mode
  20885. */
  20886. pointsCloud: boolean;
  20887. /**
  20888. * Gets the material fill mode
  20889. */
  20890. /**
  20891. * Sets the material fill mode
  20892. */
  20893. fillMode: number;
  20894. /**
  20895. * @hidden
  20896. * Stores the effects for the material
  20897. */
  20898. _effect: Nullable<Effect>;
  20899. /**
  20900. * @hidden
  20901. * Specifies if the material was previously ready
  20902. */
  20903. _wasPreviouslyReady: boolean;
  20904. /**
  20905. * Specifies if uniform buffers should be used
  20906. */
  20907. private _useUBO;
  20908. /**
  20909. * Stores a reference to the scene
  20910. */
  20911. private _scene;
  20912. /**
  20913. * Stores the fill mode state
  20914. */
  20915. private _fillMode;
  20916. /**
  20917. * Specifies if the depth write state should be cached
  20918. */
  20919. private _cachedDepthWriteState;
  20920. /**
  20921. * Stores the uniform buffer
  20922. */
  20923. protected _uniformBuffer: UniformBuffer;
  20924. /** @hidden */
  20925. _indexInSceneMaterialArray: number;
  20926. /** @hidden */
  20927. meshMap: Nullable<{
  20928. [id: string]: AbstractMesh | undefined;
  20929. }>;
  20930. /**
  20931. * Creates a material instance
  20932. * @param name defines the name of the material
  20933. * @param scene defines the scene to reference
  20934. * @param doNotAdd specifies if the material should be added to the scene
  20935. */
  20936. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20937. /**
  20938. * Returns a string representation of the current material
  20939. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20940. * @returns a string with material information
  20941. */
  20942. toString(fullDetails?: boolean): string;
  20943. /**
  20944. * Gets the class name of the material
  20945. * @returns a string with the class name of the material
  20946. */
  20947. getClassName(): string;
  20948. /**
  20949. * Specifies if updates for the material been locked
  20950. */
  20951. readonly isFrozen: boolean;
  20952. /**
  20953. * Locks updates for the material
  20954. */
  20955. freeze(): void;
  20956. /**
  20957. * Unlocks updates for the material
  20958. */
  20959. unfreeze(): void;
  20960. /**
  20961. * Specifies if the material is ready to be used
  20962. * @param mesh defines the mesh to check
  20963. * @param useInstances specifies if instances should be used
  20964. * @returns a boolean indicating if the material is ready to be used
  20965. */
  20966. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20967. /**
  20968. * Specifies that the submesh is ready to be used
  20969. * @param mesh defines the mesh to check
  20970. * @param subMesh defines which submesh to check
  20971. * @param useInstances specifies that instances should be used
  20972. * @returns a boolean indicating that the submesh is ready or not
  20973. */
  20974. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20975. /**
  20976. * Returns the material effect
  20977. * @returns the effect associated with the material
  20978. */
  20979. getEffect(): Nullable<Effect>;
  20980. /**
  20981. * Returns the current scene
  20982. * @returns a Scene
  20983. */
  20984. getScene(): Scene;
  20985. /**
  20986. * Specifies if the material will require alpha blending
  20987. * @returns a boolean specifying if alpha blending is needed
  20988. */
  20989. needAlphaBlending(): boolean;
  20990. /**
  20991. * Specifies if the mesh will require alpha blending
  20992. * @param mesh defines the mesh to check
  20993. * @returns a boolean specifying if alpha blending is needed for the mesh
  20994. */
  20995. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20996. /**
  20997. * Specifies if this material should be rendered in alpha test mode
  20998. * @returns a boolean specifying if an alpha test is needed.
  20999. */
  21000. needAlphaTesting(): boolean;
  21001. /**
  21002. * Gets the texture used for the alpha test
  21003. * @returns the texture to use for alpha testing
  21004. */
  21005. getAlphaTestTexture(): Nullable<BaseTexture>;
  21006. /**
  21007. * Marks the material to indicate that it needs to be re-calculated
  21008. */
  21009. markDirty(): void;
  21010. /** @hidden */
  21011. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21012. /**
  21013. * Binds the material to the mesh
  21014. * @param world defines the world transformation matrix
  21015. * @param mesh defines the mesh to bind the material to
  21016. */
  21017. bind(world: Matrix, mesh?: Mesh): void;
  21018. /**
  21019. * Binds the submesh to the material
  21020. * @param world defines the world transformation matrix
  21021. * @param mesh defines the mesh containing the submesh
  21022. * @param subMesh defines the submesh to bind the material to
  21023. */
  21024. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21025. /**
  21026. * Binds the world matrix to the material
  21027. * @param world defines the world transformation matrix
  21028. */
  21029. bindOnlyWorldMatrix(world: Matrix): void;
  21030. /**
  21031. * Binds the scene's uniform buffer to the effect.
  21032. * @param effect defines the effect to bind to the scene uniform buffer
  21033. * @param sceneUbo defines the uniform buffer storing scene data
  21034. */
  21035. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21036. /**
  21037. * Binds the view matrix to the effect
  21038. * @param effect defines the effect to bind the view matrix to
  21039. */
  21040. bindView(effect: Effect): void;
  21041. /**
  21042. * Binds the view projection matrix to the effect
  21043. * @param effect defines the effect to bind the view projection matrix to
  21044. */
  21045. bindViewProjection(effect: Effect): void;
  21046. /**
  21047. * Specifies if material alpha testing should be turned on for the mesh
  21048. * @param mesh defines the mesh to check
  21049. */
  21050. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21051. /**
  21052. * Processes to execute after binding the material to a mesh
  21053. * @param mesh defines the rendered mesh
  21054. */
  21055. protected _afterBind(mesh?: Mesh): void;
  21056. /**
  21057. * Unbinds the material from the mesh
  21058. */
  21059. unbind(): void;
  21060. /**
  21061. * Gets the active textures from the material
  21062. * @returns an array of textures
  21063. */
  21064. getActiveTextures(): BaseTexture[];
  21065. /**
  21066. * Specifies if the material uses a texture
  21067. * @param texture defines the texture to check against the material
  21068. * @returns a boolean specifying if the material uses the texture
  21069. */
  21070. hasTexture(texture: BaseTexture): boolean;
  21071. /**
  21072. * Makes a duplicate of the material, and gives it a new name
  21073. * @param name defines the new name for the duplicated material
  21074. * @returns the cloned material
  21075. */
  21076. clone(name: string): Nullable<Material>;
  21077. /**
  21078. * Gets the meshes bound to the material
  21079. * @returns an array of meshes bound to the material
  21080. */
  21081. getBindedMeshes(): AbstractMesh[];
  21082. /**
  21083. * Force shader compilation
  21084. * @param mesh defines the mesh associated with this material
  21085. * @param onCompiled defines a function to execute once the material is compiled
  21086. * @param options defines the options to configure the compilation
  21087. */
  21088. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  21089. clipPlane: boolean;
  21090. }>): void;
  21091. /**
  21092. * Force shader compilation
  21093. * @param mesh defines the mesh that will use this material
  21094. * @param options defines additional options for compiling the shaders
  21095. * @returns a promise that resolves when the compilation completes
  21096. */
  21097. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  21098. clipPlane: boolean;
  21099. }>): Promise<void>;
  21100. private static readonly _AllDirtyCallBack;
  21101. private static readonly _ImageProcessingDirtyCallBack;
  21102. private static readonly _TextureDirtyCallBack;
  21103. private static readonly _FresnelDirtyCallBack;
  21104. private static readonly _MiscDirtyCallBack;
  21105. private static readonly _LightsDirtyCallBack;
  21106. private static readonly _AttributeDirtyCallBack;
  21107. private static _FresnelAndMiscDirtyCallBack;
  21108. private static _TextureAndMiscDirtyCallBack;
  21109. private static readonly _DirtyCallbackArray;
  21110. private static readonly _RunDirtyCallBacks;
  21111. /**
  21112. * Marks a define in the material to indicate that it needs to be re-computed
  21113. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21114. */
  21115. markAsDirty(flag: number): void;
  21116. /**
  21117. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21118. * @param func defines a function which checks material defines against the submeshes
  21119. */
  21120. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21121. /**
  21122. * Indicates that we need to re-calculated for all submeshes
  21123. */
  21124. protected _markAllSubMeshesAsAllDirty(): void;
  21125. /**
  21126. * Indicates that image processing needs to be re-calculated for all submeshes
  21127. */
  21128. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21129. /**
  21130. * Indicates that textures need to be re-calculated for all submeshes
  21131. */
  21132. protected _markAllSubMeshesAsTexturesDirty(): void;
  21133. /**
  21134. * Indicates that fresnel needs to be re-calculated for all submeshes
  21135. */
  21136. protected _markAllSubMeshesAsFresnelDirty(): void;
  21137. /**
  21138. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21139. */
  21140. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21141. /**
  21142. * Indicates that lights need to be re-calculated for all submeshes
  21143. */
  21144. protected _markAllSubMeshesAsLightsDirty(): void;
  21145. /**
  21146. * Indicates that attributes need to be re-calculated for all submeshes
  21147. */
  21148. protected _markAllSubMeshesAsAttributesDirty(): void;
  21149. /**
  21150. * Indicates that misc needs to be re-calculated for all submeshes
  21151. */
  21152. protected _markAllSubMeshesAsMiscDirty(): void;
  21153. /**
  21154. * Indicates that textures and misc need to be re-calculated for all submeshes
  21155. */
  21156. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21157. /**
  21158. * Disposes the material
  21159. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21160. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21161. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21162. */
  21163. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21164. /** @hidden */
  21165. private releaseVertexArrayObject;
  21166. /**
  21167. * Serializes this material
  21168. * @returns the serialized material object
  21169. */
  21170. serialize(): any;
  21171. /**
  21172. * Creates a material from parsed material data
  21173. * @param parsedMaterial defines parsed material data
  21174. * @param scene defines the hosting scene
  21175. * @param rootUrl defines the root URL to use to load textures
  21176. * @returns a new material
  21177. */
  21178. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21179. }
  21180. }
  21181. declare module "babylonjs/Materials/multiMaterial" {
  21182. import { Nullable } from "babylonjs/types";
  21183. import { Scene } from "babylonjs/scene";
  21184. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21185. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21186. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21187. import { Material } from "babylonjs/Materials/material";
  21188. /**
  21189. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21190. * separate meshes. This can be use to improve performances.
  21191. * @see http://doc.babylonjs.com/how_to/multi_materials
  21192. */
  21193. export class MultiMaterial extends Material {
  21194. private _subMaterials;
  21195. /**
  21196. * Gets or Sets the list of Materials used within the multi material.
  21197. * They need to be ordered according to the submeshes order in the associated mesh
  21198. */
  21199. subMaterials: Nullable<Material>[];
  21200. /**
  21201. * Function used to align with Node.getChildren()
  21202. * @returns the list of Materials used within the multi material
  21203. */
  21204. getChildren(): Nullable<Material>[];
  21205. /**
  21206. * Instantiates a new Multi Material
  21207. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21208. * separate meshes. This can be use to improve performances.
  21209. * @see http://doc.babylonjs.com/how_to/multi_materials
  21210. * @param name Define the name in the scene
  21211. * @param scene Define the scene the material belongs to
  21212. */
  21213. constructor(name: string, scene: Scene);
  21214. private _hookArray;
  21215. /**
  21216. * Get one of the submaterial by its index in the submaterials array
  21217. * @param index The index to look the sub material at
  21218. * @returns The Material if the index has been defined
  21219. */
  21220. getSubMaterial(index: number): Nullable<Material>;
  21221. /**
  21222. * Get the list of active textures for the whole sub materials list.
  21223. * @returns All the textures that will be used during the rendering
  21224. */
  21225. getActiveTextures(): BaseTexture[];
  21226. /**
  21227. * Gets the current class name of the material e.g. "MultiMaterial"
  21228. * Mainly use in serialization.
  21229. * @returns the class name
  21230. */
  21231. getClassName(): string;
  21232. /**
  21233. * Checks if the material is ready to render the requested sub mesh
  21234. * @param mesh Define the mesh the submesh belongs to
  21235. * @param subMesh Define the sub mesh to look readyness for
  21236. * @param useInstances Define whether or not the material is used with instances
  21237. * @returns true if ready, otherwise false
  21238. */
  21239. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21240. /**
  21241. * Clones the current material and its related sub materials
  21242. * @param name Define the name of the newly cloned material
  21243. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21244. * @returns the cloned material
  21245. */
  21246. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21247. /**
  21248. * Serializes the materials into a JSON representation.
  21249. * @returns the JSON representation
  21250. */
  21251. serialize(): any;
  21252. /**
  21253. * Dispose the material and release its associated resources
  21254. * @param forceDisposeEffect Define if we want to force disposing the associated effect (if false the shader is not released and could be reuse later on)
  21255. * @param forceDisposeTextures Define if we want to force disposing the associated textures (if false, they will not be disposed and can still be use elsewhere in the app)
  21256. * @param forceDisposeChildren Define if we want to force disposing the associated submaterials (if false, they will not be disposed and can still be use elsewhere in the app)
  21257. */
  21258. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21259. /**
  21260. * Creates a MultiMaterial from parsed MultiMaterial data.
  21261. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21262. * @param scene defines the hosting scene
  21263. * @returns a new MultiMaterial
  21264. */
  21265. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21266. }
  21267. }
  21268. declare module "babylonjs/Meshes/subMesh" {
  21269. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21270. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21271. import { Engine } from "babylonjs/Engines/engine";
  21272. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21273. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21274. import { Effect } from "babylonjs/Materials/effect";
  21275. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21276. import { Plane } from "babylonjs/Maths/math.plane";
  21277. import { Collider } from "babylonjs/Collisions/collider";
  21278. import { Material } from "babylonjs/Materials/material";
  21279. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21280. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21281. import { Mesh } from "babylonjs/Meshes/mesh";
  21282. import { Ray } from "babylonjs/Culling/ray";
  21283. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21284. /**
  21285. * Base class for submeshes
  21286. */
  21287. export class BaseSubMesh {
  21288. /** @hidden */
  21289. _materialDefines: Nullable<MaterialDefines>;
  21290. /** @hidden */
  21291. _materialEffect: Nullable<Effect>;
  21292. /**
  21293. * Gets associated effect
  21294. */
  21295. readonly effect: Nullable<Effect>;
  21296. /**
  21297. * Sets associated effect (effect used to render this submesh)
  21298. * @param effect defines the effect to associate with
  21299. * @param defines defines the set of defines used to compile this effect
  21300. */
  21301. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21302. }
  21303. /**
  21304. * Defines a subdivision inside a mesh
  21305. */
  21306. export class SubMesh extends BaseSubMesh implements ICullable {
  21307. /** the material index to use */
  21308. materialIndex: number;
  21309. /** vertex index start */
  21310. verticesStart: number;
  21311. /** vertices count */
  21312. verticesCount: number;
  21313. /** index start */
  21314. indexStart: number;
  21315. /** indices count */
  21316. indexCount: number;
  21317. /** @hidden */
  21318. _linesIndexCount: number;
  21319. private _mesh;
  21320. private _renderingMesh;
  21321. private _boundingInfo;
  21322. private _linesIndexBuffer;
  21323. /** @hidden */
  21324. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21325. /** @hidden */
  21326. _trianglePlanes: Plane[];
  21327. /** @hidden */
  21328. _lastColliderTransformMatrix: Nullable<Matrix>;
  21329. /** @hidden */
  21330. _renderId: number;
  21331. /** @hidden */
  21332. _alphaIndex: number;
  21333. /** @hidden */
  21334. _distanceToCamera: number;
  21335. /** @hidden */
  21336. _id: number;
  21337. private _currentMaterial;
  21338. /**
  21339. * Add a new submesh to a mesh
  21340. * @param materialIndex defines the material index to use
  21341. * @param verticesStart defines vertex index start
  21342. * @param verticesCount defines vertices count
  21343. * @param indexStart defines index start
  21344. * @param indexCount defines indices count
  21345. * @param mesh defines the parent mesh
  21346. * @param renderingMesh defines an optional rendering mesh
  21347. * @param createBoundingBox defines if bounding box should be created for this submesh
  21348. * @returns the new submesh
  21349. */
  21350. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21351. /**
  21352. * Creates a new submesh
  21353. * @param materialIndex defines the material index to use
  21354. * @param verticesStart defines vertex index start
  21355. * @param verticesCount defines vertices count
  21356. * @param indexStart defines index start
  21357. * @param indexCount defines indices count
  21358. * @param mesh defines the parent mesh
  21359. * @param renderingMesh defines an optional rendering mesh
  21360. * @param createBoundingBox defines if bounding box should be created for this submesh
  21361. */
  21362. constructor(
  21363. /** the material index to use */
  21364. materialIndex: number,
  21365. /** vertex index start */
  21366. verticesStart: number,
  21367. /** vertices count */
  21368. verticesCount: number,
  21369. /** index start */
  21370. indexStart: number,
  21371. /** indices count */
  21372. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21373. /**
  21374. * Returns true if this submesh covers the entire parent mesh
  21375. * @ignorenaming
  21376. */
  21377. readonly IsGlobal: boolean;
  21378. /**
  21379. * Returns the submesh BoudingInfo object
  21380. * @returns current bounding info (or mesh's one if the submesh is global)
  21381. */
  21382. getBoundingInfo(): BoundingInfo;
  21383. /**
  21384. * Sets the submesh BoundingInfo
  21385. * @param boundingInfo defines the new bounding info to use
  21386. * @returns the SubMesh
  21387. */
  21388. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21389. /**
  21390. * Returns the mesh of the current submesh
  21391. * @return the parent mesh
  21392. */
  21393. getMesh(): AbstractMesh;
  21394. /**
  21395. * Returns the rendering mesh of the submesh
  21396. * @returns the rendering mesh (could be different from parent mesh)
  21397. */
  21398. getRenderingMesh(): Mesh;
  21399. /**
  21400. * Returns the submesh material
  21401. * @returns null or the current material
  21402. */
  21403. getMaterial(): Nullable<Material>;
  21404. /**
  21405. * Sets a new updated BoundingInfo object to the submesh
  21406. * @param data defines an optional position array to use to determine the bounding info
  21407. * @returns the SubMesh
  21408. */
  21409. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21410. /** @hidden */
  21411. _checkCollision(collider: Collider): boolean;
  21412. /**
  21413. * Updates the submesh BoundingInfo
  21414. * @param world defines the world matrix to use to update the bounding info
  21415. * @returns the submesh
  21416. */
  21417. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21418. /**
  21419. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21420. * @param frustumPlanes defines the frustum planes
  21421. * @returns true if the submesh is intersecting with the frustum
  21422. */
  21423. isInFrustum(frustumPlanes: Plane[]): boolean;
  21424. /**
  21425. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21426. * @param frustumPlanes defines the frustum planes
  21427. * @returns true if the submesh is inside the frustum
  21428. */
  21429. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21430. /**
  21431. * Renders the submesh
  21432. * @param enableAlphaMode defines if alpha needs to be used
  21433. * @returns the submesh
  21434. */
  21435. render(enableAlphaMode: boolean): SubMesh;
  21436. /**
  21437. * @hidden
  21438. */
  21439. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21440. /**
  21441. * Checks if the submesh intersects with a ray
  21442. * @param ray defines the ray to test
  21443. * @returns true is the passed ray intersects the submesh bounding box
  21444. */
  21445. canIntersects(ray: Ray): boolean;
  21446. /**
  21447. * Intersects current submesh with a ray
  21448. * @param ray defines the ray to test
  21449. * @param positions defines mesh's positions array
  21450. * @param indices defines mesh's indices array
  21451. * @param fastCheck defines if only bounding info should be used
  21452. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21453. * @returns intersection info or null if no intersection
  21454. */
  21455. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21456. /** @hidden */
  21457. private _intersectLines;
  21458. /** @hidden */
  21459. private _intersectUnIndexedLines;
  21460. /** @hidden */
  21461. private _intersectTriangles;
  21462. /** @hidden */
  21463. private _intersectUnIndexedTriangles;
  21464. /** @hidden */
  21465. _rebuild(): void;
  21466. /**
  21467. * Creates a new submesh from the passed mesh
  21468. * @param newMesh defines the new hosting mesh
  21469. * @param newRenderingMesh defines an optional rendering mesh
  21470. * @returns the new submesh
  21471. */
  21472. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21473. /**
  21474. * Release associated resources
  21475. */
  21476. dispose(): void;
  21477. /**
  21478. * Gets the class name
  21479. * @returns the string "SubMesh".
  21480. */
  21481. getClassName(): string;
  21482. /**
  21483. * Creates a new submesh from indices data
  21484. * @param materialIndex the index of the main mesh material
  21485. * @param startIndex the index where to start the copy in the mesh indices array
  21486. * @param indexCount the number of indices to copy then from the startIndex
  21487. * @param mesh the main mesh to create the submesh from
  21488. * @param renderingMesh the optional rendering mesh
  21489. * @returns a new submesh
  21490. */
  21491. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21492. }
  21493. }
  21494. declare module "babylonjs/Loading/sceneLoaderFlags" {
  21495. /**
  21496. * Class used to represent data loading progression
  21497. */
  21498. export class SceneLoaderFlags {
  21499. private static _ForceFullSceneLoadingForIncremental;
  21500. private static _ShowLoadingScreen;
  21501. private static _CleanBoneMatrixWeights;
  21502. private static _loggingLevel;
  21503. /**
  21504. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21505. */
  21506. static ForceFullSceneLoadingForIncremental: boolean;
  21507. /**
  21508. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21509. */
  21510. static ShowLoadingScreen: boolean;
  21511. /**
  21512. * Defines the current logging level (while loading the scene)
  21513. * @ignorenaming
  21514. */
  21515. static loggingLevel: number;
  21516. /**
  21517. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21518. */
  21519. static CleanBoneMatrixWeights: boolean;
  21520. }
  21521. }
  21522. declare module "babylonjs/Meshes/geometry" {
  21523. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21524. import { Scene } from "babylonjs/scene";
  21525. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  21526. import { Engine } from "babylonjs/Engines/engine";
  21527. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21528. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21529. import { Effect } from "babylonjs/Materials/effect";
  21530. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21531. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21532. import { Mesh } from "babylonjs/Meshes/mesh";
  21533. /**
  21534. * Class used to store geometry data (vertex buffers + index buffer)
  21535. */
  21536. export class Geometry implements IGetSetVerticesData {
  21537. /**
  21538. * Gets or sets the ID of the geometry
  21539. */
  21540. id: string;
  21541. /**
  21542. * Gets or sets the unique ID of the geometry
  21543. */
  21544. uniqueId: number;
  21545. /**
  21546. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21547. */
  21548. delayLoadState: number;
  21549. /**
  21550. * Gets the file containing the data to load when running in delay load state
  21551. */
  21552. delayLoadingFile: Nullable<string>;
  21553. /**
  21554. * Callback called when the geometry is updated
  21555. */
  21556. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21557. private _scene;
  21558. private _engine;
  21559. private _meshes;
  21560. private _totalVertices;
  21561. /** @hidden */
  21562. _indices: IndicesArray;
  21563. /** @hidden */
  21564. _vertexBuffers: {
  21565. [key: string]: VertexBuffer;
  21566. };
  21567. private _isDisposed;
  21568. private _extend;
  21569. private _boundingBias;
  21570. /** @hidden */
  21571. _delayInfo: Array<string>;
  21572. private _indexBuffer;
  21573. private _indexBufferIsUpdatable;
  21574. /** @hidden */
  21575. _boundingInfo: Nullable<BoundingInfo>;
  21576. /** @hidden */
  21577. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21578. /** @hidden */
  21579. _softwareSkinningFrameId: number;
  21580. private _vertexArrayObjects;
  21581. private _updatable;
  21582. /** @hidden */
  21583. _positions: Nullable<Vector3[]>;
  21584. /**
  21585. * Gets or sets the Bias Vector to apply on the bounding elements (box/sphere), the max extend is computed as v += v * bias.x + bias.y, the min is computed as v -= v * bias.x + bias.y
  21586. */
  21587. /**
  21588. * Gets or sets the Bias Vector to apply on the bounding elements (box/sphere), the max extend is computed as v += v * bias.x + bias.y, the min is computed as v -= v * bias.x + bias.y
  21589. */
  21590. boundingBias: Vector2;
  21591. /**
  21592. * Static function used to attach a new empty geometry to a mesh
  21593. * @param mesh defines the mesh to attach the geometry to
  21594. * @returns the new Geometry
  21595. */
  21596. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21597. /**
  21598. * Creates a new geometry
  21599. * @param id defines the unique ID
  21600. * @param scene defines the hosting scene
  21601. * @param vertexData defines the VertexData used to get geometry data
  21602. * @param updatable defines if geometry must be updatable (false by default)
  21603. * @param mesh defines the mesh that will be associated with the geometry
  21604. */
  21605. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21606. /**
  21607. * Gets the current extend of the geometry
  21608. */
  21609. readonly extend: {
  21610. minimum: Vector3;
  21611. maximum: Vector3;
  21612. };
  21613. /**
  21614. * Gets the hosting scene
  21615. * @returns the hosting Scene
  21616. */
  21617. getScene(): Scene;
  21618. /**
  21619. * Gets the hosting engine
  21620. * @returns the hosting Engine
  21621. */
  21622. getEngine(): Engine;
  21623. /**
  21624. * Defines if the geometry is ready to use
  21625. * @returns true if the geometry is ready to be used
  21626. */
  21627. isReady(): boolean;
  21628. /**
  21629. * Gets a value indicating that the geometry should not be serialized
  21630. */
  21631. readonly doNotSerialize: boolean;
  21632. /** @hidden */
  21633. _rebuild(): void;
  21634. /**
  21635. * Affects all geometry data in one call
  21636. * @param vertexData defines the geometry data
  21637. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21638. */
  21639. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21640. /**
  21641. * Set specific vertex data
  21642. * @param kind defines the data kind (Position, normal, etc...)
  21643. * @param data defines the vertex data to use
  21644. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21645. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21646. */
  21647. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21648. /**
  21649. * Removes a specific vertex data
  21650. * @param kind defines the data kind (Position, normal, etc...)
  21651. */
  21652. removeVerticesData(kind: string): void;
  21653. /**
  21654. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21655. * @param buffer defines the vertex buffer to use
  21656. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21657. */
  21658. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21659. /**
  21660. * Update a specific vertex buffer
  21661. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21662. * It will do nothing if the buffer is not updatable
  21663. * @param kind defines the data kind (Position, normal, etc...)
  21664. * @param data defines the data to use
  21665. * @param offset defines the offset in the target buffer where to store the data
  21666. * @param useBytes set to true if the offset is in bytes
  21667. */
  21668. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21669. /**
  21670. * Update a specific vertex buffer
  21671. * This function will create a new buffer if the current one is not updatable
  21672. * @param kind defines the data kind (Position, normal, etc...)
  21673. * @param data defines the data to use
  21674. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21675. */
  21676. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21677. private _updateBoundingInfo;
  21678. /** @hidden */
  21679. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21680. /**
  21681. * Gets total number of vertices
  21682. * @returns the total number of vertices
  21683. */
  21684. getTotalVertices(): number;
  21685. /**
  21686. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21687. * @param kind defines the data kind (Position, normal, etc...)
  21688. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21689. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21690. * @returns a float array containing vertex data
  21691. */
  21692. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21693. /**
  21694. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21695. * @param kind defines the data kind (Position, normal, etc...)
  21696. * @returns true if the vertex buffer with the specified kind is updatable
  21697. */
  21698. isVertexBufferUpdatable(kind: string): boolean;
  21699. /**
  21700. * Gets a specific vertex buffer
  21701. * @param kind defines the data kind (Position, normal, etc...)
  21702. * @returns a VertexBuffer
  21703. */
  21704. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21705. /**
  21706. * Returns all vertex buffers
  21707. * @return an object holding all vertex buffers indexed by kind
  21708. */
  21709. getVertexBuffers(): Nullable<{
  21710. [key: string]: VertexBuffer;
  21711. }>;
  21712. /**
  21713. * Gets a boolean indicating if specific vertex buffer is present
  21714. * @param kind defines the data kind (Position, normal, etc...)
  21715. * @returns true if data is present
  21716. */
  21717. isVerticesDataPresent(kind: string): boolean;
  21718. /**
  21719. * Gets a list of all attached data kinds (Position, normal, etc...)
  21720. * @returns a list of string containing all kinds
  21721. */
  21722. getVerticesDataKinds(): string[];
  21723. /**
  21724. * Update index buffer
  21725. * @param indices defines the indices to store in the index buffer
  21726. * @param offset defines the offset in the target buffer where to store the data
  21727. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  21728. */
  21729. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21730. /**
  21731. * Creates a new index buffer
  21732. * @param indices defines the indices to store in the index buffer
  21733. * @param totalVertices defines the total number of vertices (could be null)
  21734. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21735. */
  21736. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21737. /**
  21738. * Return the total number of indices
  21739. * @returns the total number of indices
  21740. */
  21741. getTotalIndices(): number;
  21742. /**
  21743. * Gets the index buffer array
  21744. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21745. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21746. * @returns the index buffer array
  21747. */
  21748. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21749. /**
  21750. * Gets the index buffer
  21751. * @return the index buffer
  21752. */
  21753. getIndexBuffer(): Nullable<DataBuffer>;
  21754. /** @hidden */
  21755. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21756. /**
  21757. * Release the associated resources for a specific mesh
  21758. * @param mesh defines the source mesh
  21759. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21760. */
  21761. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21762. /**
  21763. * Apply current geometry to a given mesh
  21764. * @param mesh defines the mesh to apply geometry to
  21765. */
  21766. applyToMesh(mesh: Mesh): void;
  21767. private _updateExtend;
  21768. private _applyToMesh;
  21769. private notifyUpdate;
  21770. /**
  21771. * Load the geometry if it was flagged as delay loaded
  21772. * @param scene defines the hosting scene
  21773. * @param onLoaded defines a callback called when the geometry is loaded
  21774. */
  21775. load(scene: Scene, onLoaded?: () => void): void;
  21776. private _queueLoad;
  21777. /**
  21778. * Invert the geometry to move from a right handed system to a left handed one.
  21779. */
  21780. toLeftHanded(): void;
  21781. /** @hidden */
  21782. _resetPointsArrayCache(): void;
  21783. /** @hidden */
  21784. _generatePointsArray(): boolean;
  21785. /**
  21786. * Gets a value indicating if the geometry is disposed
  21787. * @returns true if the geometry was disposed
  21788. */
  21789. isDisposed(): boolean;
  21790. private _disposeVertexArrayObjects;
  21791. /**
  21792. * Free all associated resources
  21793. */
  21794. dispose(): void;
  21795. /**
  21796. * Clone the current geometry into a new geometry
  21797. * @param id defines the unique ID of the new geometry
  21798. * @returns a new geometry object
  21799. */
  21800. copy(id: string): Geometry;
  21801. /**
  21802. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21803. * @return a JSON representation of the current geometry data (without the vertices data)
  21804. */
  21805. serialize(): any;
  21806. private toNumberArray;
  21807. /**
  21808. * Serialize all vertices data into a JSON oject
  21809. * @returns a JSON representation of the current geometry data
  21810. */
  21811. serializeVerticeData(): any;
  21812. /**
  21813. * Extracts a clone of a mesh geometry
  21814. * @param mesh defines the source mesh
  21815. * @param id defines the unique ID of the new geometry object
  21816. * @returns the new geometry object
  21817. */
  21818. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21819. /**
  21820. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21821. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21822. * Be aware Math.random() could cause collisions, but:
  21823. * "All but 6 of the 128 bits of the ID are randomly generated, which means that for any two ids, there's a 1 in 2^^122 (or 5.3x10^^36) chance they'll collide"
  21824. * @returns a string containing a new GUID
  21825. */
  21826. static RandomId(): string;
  21827. /** @hidden */
  21828. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21829. private static _CleanMatricesWeights;
  21830. /**
  21831. * Create a new geometry from persisted data (Using .babylon file format)
  21832. * @param parsedVertexData defines the persisted data
  21833. * @param scene defines the hosting scene
  21834. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21835. * @returns the new geometry object
  21836. */
  21837. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21838. }
  21839. }
  21840. declare module "babylonjs/Meshes/mesh.vertexData" {
  21841. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  21842. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  21843. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  21844. import { Geometry } from "babylonjs/Meshes/geometry";
  21845. import { Mesh } from "babylonjs/Meshes/mesh";
  21846. /**
  21847. * Define an interface for all classes that will get and set the data on vertices
  21848. */
  21849. export interface IGetSetVerticesData {
  21850. /**
  21851. * Gets a boolean indicating if specific vertex data is present
  21852. * @param kind defines the vertex data kind to use
  21853. * @returns true is data kind is present
  21854. */
  21855. isVerticesDataPresent(kind: string): boolean;
  21856. /**
  21857. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21858. * @param kind defines the data kind (Position, normal, etc...)
  21859. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21860. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21861. * @returns a float array containing vertex data
  21862. */
  21863. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21864. /**
  21865. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21866. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  21867. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21868. * @returns the indices array or an empty array if the mesh has no geometry
  21869. */
  21870. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21871. /**
  21872. * Set specific vertex data
  21873. * @param kind defines the data kind (Position, normal, etc...)
  21874. * @param data defines the vertex data to use
  21875. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21876. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21877. */
  21878. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21879. /**
  21880. * Update a specific associated vertex buffer
  21881. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21882. * - VertexBuffer.PositionKind
  21883. * - VertexBuffer.UVKind
  21884. * - VertexBuffer.UV2Kind
  21885. * - VertexBuffer.UV3Kind
  21886. * - VertexBuffer.UV4Kind
  21887. * - VertexBuffer.UV5Kind
  21888. * - VertexBuffer.UV6Kind
  21889. * - VertexBuffer.ColorKind
  21890. * - VertexBuffer.MatricesIndicesKind
  21891. * - VertexBuffer.MatricesIndicesExtraKind
  21892. * - VertexBuffer.MatricesWeightsKind
  21893. * - VertexBuffer.MatricesWeightsExtraKind
  21894. * @param data defines the data source
  21895. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21896. * @param makeItUnique defines if the geometry associated with the mesh must be cloned to make the change only for this mesh (and not all meshes associated with the same geometry)
  21897. */
  21898. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21899. /**
  21900. * Creates a new index buffer
  21901. * @param indices defines the indices to store in the index buffer
  21902. * @param totalVertices defines the total number of vertices (could be null)
  21903. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21904. */
  21905. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21906. }
  21907. /**
  21908. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21909. */
  21910. export class VertexData {
  21911. /**
  21912. * Mesh side orientation : usually the external or front surface
  21913. */
  21914. static readonly FRONTSIDE: number;
  21915. /**
  21916. * Mesh side orientation : usually the internal or back surface
  21917. */
  21918. static readonly BACKSIDE: number;
  21919. /**
  21920. * Mesh side orientation : both internal and external or front and back surfaces
  21921. */
  21922. static readonly DOUBLESIDE: number;
  21923. /**
  21924. * Mesh side orientation : by default, `FRONTSIDE`
  21925. */
  21926. static readonly DEFAULTSIDE: number;
  21927. /**
  21928. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21929. */
  21930. positions: Nullable<FloatArray>;
  21931. /**
  21932. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21933. */
  21934. normals: Nullable<FloatArray>;
  21935. /**
  21936. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21937. */
  21938. tangents: Nullable<FloatArray>;
  21939. /**
  21940. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21941. */
  21942. uvs: Nullable<FloatArray>;
  21943. /**
  21944. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21945. */
  21946. uvs2: Nullable<FloatArray>;
  21947. /**
  21948. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21949. */
  21950. uvs3: Nullable<FloatArray>;
  21951. /**
  21952. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21953. */
  21954. uvs4: Nullable<FloatArray>;
  21955. /**
  21956. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21957. */
  21958. uvs5: Nullable<FloatArray>;
  21959. /**
  21960. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21961. */
  21962. uvs6: Nullable<FloatArray>;
  21963. /**
  21964. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21965. */
  21966. colors: Nullable<FloatArray>;
  21967. /**
  21968. * An array containing the list of indices to the array of matrices produced by bones, each vertex have up to 4 indices (8 if the matricesIndicesExtra is set).
  21969. */
  21970. matricesIndices: Nullable<FloatArray>;
  21971. /**
  21972. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21973. */
  21974. matricesWeights: Nullable<FloatArray>;
  21975. /**
  21976. * An array extending the number of possible indices
  21977. */
  21978. matricesIndicesExtra: Nullable<FloatArray>;
  21979. /**
  21980. * An array extending the number of possible weights when the number of indices is extended
  21981. */
  21982. matricesWeightsExtra: Nullable<FloatArray>;
  21983. /**
  21984. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21985. */
  21986. indices: Nullable<IndicesArray>;
  21987. /**
  21988. * Uses the passed data array to set the set the values for the specified kind of data
  21989. * @param data a linear array of floating numbers
  21990. * @param kind the type of data that is being set, eg positions, colors etc
  21991. */
  21992. set(data: FloatArray, kind: string): void;
  21993. /**
  21994. * Associates the vertexData to the passed Mesh.
  21995. * Sets it as updatable or not (default `false`)
  21996. * @param mesh the mesh the vertexData is applied to
  21997. * @param updatable when used and having the value true allows new data to update the vertexData
  21998. * @returns the VertexData
  21999. */
  22000. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22001. /**
  22002. * Associates the vertexData to the passed Geometry.
  22003. * Sets it as updatable or not (default `false`)
  22004. * @param geometry the geometry the vertexData is applied to
  22005. * @param updatable when used and having the value true allows new data to update the vertexData
  22006. * @returns VertexData
  22007. */
  22008. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22009. /**
  22010. * Updates the associated mesh
  22011. * @param mesh the mesh to be updated
  22012. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22013. * @param makeItUnique when true, and when and if position kind is updated, a new global geometry will be created from these positions and set to the mesh, optional with default false
  22014. * @returns VertexData
  22015. */
  22016. updateMesh(mesh: Mesh): VertexData;
  22017. /**
  22018. * Updates the associated geometry
  22019. * @param geometry the geometry to be updated
  22020. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22021. * @param makeItUnique when true, and when and if position kind is updated, a new global geometry will be created from these positions and set to the mesh, optional with default false
  22022. * @returns VertexData.
  22023. */
  22024. updateGeometry(geometry: Geometry): VertexData;
  22025. private _applyTo;
  22026. private _update;
  22027. /**
  22028. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22029. * @param matrix the transforming matrix
  22030. * @returns the VertexData
  22031. */
  22032. transform(matrix: Matrix): VertexData;
  22033. /**
  22034. * Merges the passed VertexData into the current one
  22035. * @param other the VertexData to be merged into the current one
  22036. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22037. * @returns the modified VertexData
  22038. */
  22039. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22040. private _mergeElement;
  22041. private _validate;
  22042. /**
  22043. * Serializes the VertexData
  22044. * @returns a serialized object
  22045. */
  22046. serialize(): any;
  22047. /**
  22048. * Extracts the vertexData from a mesh
  22049. * @param mesh the mesh from which to extract the VertexData
  22050. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22051. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22052. * @returns the object VertexData associated to the passed mesh
  22053. */
  22054. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22055. /**
  22056. * Extracts the vertexData from the geometry
  22057. * @param geometry the geometry from which to extract the VertexData
  22058. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22059. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22060. * @returns the object VertexData associated to the passed mesh
  22061. */
  22062. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22063. private static _ExtractFrom;
  22064. /**
  22065. * Creates the VertexData for a Ribbon
  22066. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22067. * * pathArray array of paths, each of which an array of successive Vector3
  22068. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22069. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22070. * * offset a positive integer, only used when pathArray contains a single path (offset = 10 means the point 1 is joined to the point 11), default rounded half size of the pathArray length
  22071. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22072. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22073. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22074. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22075. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22076. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22077. * @returns the VertexData of the ribbon
  22078. */
  22079. static CreateRibbon(options: {
  22080. pathArray: Vector3[][];
  22081. closeArray?: boolean;
  22082. closePath?: boolean;
  22083. offset?: number;
  22084. sideOrientation?: number;
  22085. frontUVs?: Vector4;
  22086. backUVs?: Vector4;
  22087. invertUV?: boolean;
  22088. uvs?: Vector2[];
  22089. colors?: Color4[];
  22090. }): VertexData;
  22091. /**
  22092. * Creates the VertexData for a box
  22093. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22094. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22095. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22096. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22097. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22098. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22099. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22100. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22101. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22102. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22103. * @returns the VertexData of the box
  22104. */
  22105. static CreateBox(options: {
  22106. size?: number;
  22107. width?: number;
  22108. height?: number;
  22109. depth?: number;
  22110. faceUV?: Vector4[];
  22111. faceColors?: Color4[];
  22112. sideOrientation?: number;
  22113. frontUVs?: Vector4;
  22114. backUVs?: Vector4;
  22115. }): VertexData;
  22116. /**
  22117. * Creates the VertexData for a tiled box
  22118. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22119. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22120. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22121. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22122. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22123. * @returns the VertexData of the box
  22124. */
  22125. static CreateTiledBox(options: {
  22126. pattern?: number;
  22127. width?: number;
  22128. height?: number;
  22129. depth?: number;
  22130. tileSize?: number;
  22131. tileWidth?: number;
  22132. tileHeight?: number;
  22133. alignHorizontal?: number;
  22134. alignVertical?: number;
  22135. faceUV?: Vector4[];
  22136. faceColors?: Color4[];
  22137. sideOrientation?: number;
  22138. }): VertexData;
  22139. /**
  22140. * Creates the VertexData for a tiled plane
  22141. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22142. * * pattern a limited pattern arrangement depending on the number
  22143. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22144. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22145. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22146. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22147. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22148. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22149. * @returns the VertexData of the tiled plane
  22150. */
  22151. static CreateTiledPlane(options: {
  22152. pattern?: number;
  22153. tileSize?: number;
  22154. tileWidth?: number;
  22155. tileHeight?: number;
  22156. size?: number;
  22157. width?: number;
  22158. height?: number;
  22159. alignHorizontal?: number;
  22160. alignVertical?: number;
  22161. sideOrientation?: number;
  22162. frontUVs?: Vector4;
  22163. backUVs?: Vector4;
  22164. }): VertexData;
  22165. /**
  22166. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22167. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22168. * * segments sets the number of horizontal strips optional, default 32
  22169. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22170. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22171. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22172. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22173. * * arc a number from 0 to 1, to create an unclosed ellipsoid based on the fraction of the circumference (latitude) given by the arc value, optional, default 1
  22174. * * slice a number from 0 to 1, to create an unclosed ellipsoid based on the fraction of the height (latitude) given by the arc value, optional, default 1
  22175. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22176. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22177. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22178. * @returns the VertexData of the ellipsoid
  22179. */
  22180. static CreateSphere(options: {
  22181. segments?: number;
  22182. diameter?: number;
  22183. diameterX?: number;
  22184. diameterY?: number;
  22185. diameterZ?: number;
  22186. arc?: number;
  22187. slice?: number;
  22188. sideOrientation?: number;
  22189. frontUVs?: Vector4;
  22190. backUVs?: Vector4;
  22191. }): VertexData;
  22192. /**
  22193. * Creates the VertexData for a cylinder, cone or prism
  22194. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22195. * * height sets the height (y direction) of the cylinder, optional, default 2
  22196. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22197. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22198. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22199. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22200. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22201. * * arc a number from 0 to 1, to create an unclosed cylinder based on the fraction of the circumference given by the arc value, optional, default 1
  22202. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22203. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22204. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22205. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22206. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22207. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22208. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22209. * @returns the VertexData of the cylinder, cone or prism
  22210. */
  22211. static CreateCylinder(options: {
  22212. height?: number;
  22213. diameterTop?: number;
  22214. diameterBottom?: number;
  22215. diameter?: number;
  22216. tessellation?: number;
  22217. subdivisions?: number;
  22218. arc?: number;
  22219. faceColors?: Color4[];
  22220. faceUV?: Vector4[];
  22221. hasRings?: boolean;
  22222. enclose?: boolean;
  22223. sideOrientation?: number;
  22224. frontUVs?: Vector4;
  22225. backUVs?: Vector4;
  22226. }): VertexData;
  22227. /**
  22228. * Creates the VertexData for a torus
  22229. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22230. * * diameter the diameter of the torus, optional default 1
  22231. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22232. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22233. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22234. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22235. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22236. * @returns the VertexData of the torus
  22237. */
  22238. static CreateTorus(options: {
  22239. diameter?: number;
  22240. thickness?: number;
  22241. tessellation?: number;
  22242. sideOrientation?: number;
  22243. frontUVs?: Vector4;
  22244. backUVs?: Vector4;
  22245. }): VertexData;
  22246. /**
  22247. * Creates the VertexData of the LineSystem
  22248. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22249. * - lines an array of lines, each line being an array of successive Vector3
  22250. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22251. * @returns the VertexData of the LineSystem
  22252. */
  22253. static CreateLineSystem(options: {
  22254. lines: Vector3[][];
  22255. colors?: Nullable<Color4[][]>;
  22256. }): VertexData;
  22257. /**
  22258. * Create the VertexData for a DashedLines
  22259. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22260. * - points an array successive Vector3
  22261. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22262. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22263. * - dashNb the intended total number of dashes, optional, default 200
  22264. * @returns the VertexData for the DashedLines
  22265. */
  22266. static CreateDashedLines(options: {
  22267. points: Vector3[];
  22268. dashSize?: number;
  22269. gapSize?: number;
  22270. dashNb?: number;
  22271. }): VertexData;
  22272. /**
  22273. * Creates the VertexData for a Ground
  22274. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22275. * - width the width (x direction) of the ground, optional, default 1
  22276. * - height the height (z direction) of the ground, optional, default 1
  22277. * - subdivisions the number of subdivisions per side, optional, default 1
  22278. * @returns the VertexData of the Ground
  22279. */
  22280. static CreateGround(options: {
  22281. width?: number;
  22282. height?: number;
  22283. subdivisions?: number;
  22284. subdivisionsX?: number;
  22285. subdivisionsY?: number;
  22286. }): VertexData;
  22287. /**
  22288. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22289. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22290. * * xmin the ground minimum X coordinate, optional, default -1
  22291. * * zmin the ground minimum Z coordinate, optional, default -1
  22292. * * xmax the ground maximum X coordinate, optional, default 1
  22293. * * zmax the ground maximum Z coordinate, optional, default 1
  22294. * * subdivisions a javascript object {w: positive integer, h: positive integer}, `w` and `h` are the numbers of subdivisions on the ground width and height creating 'tiles', default {w: 6, h: 6}
  22295. * * precision a javascript object {w: positive integer, h: positive integer}, `w` and `h` are the numbers of subdivisions on the tile width and height, default {w: 2, h: 2}
  22296. * @returns the VertexData of the TiledGround
  22297. */
  22298. static CreateTiledGround(options: {
  22299. xmin: number;
  22300. zmin: number;
  22301. xmax: number;
  22302. zmax: number;
  22303. subdivisions?: {
  22304. w: number;
  22305. h: number;
  22306. };
  22307. precision?: {
  22308. w: number;
  22309. h: number;
  22310. };
  22311. }): VertexData;
  22312. /**
  22313. * Creates the VertexData of the Ground designed from a heightmap
  22314. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22315. * * width the width (x direction) of the ground
  22316. * * height the height (z direction) of the ground
  22317. * * subdivisions the number of subdivisions per side
  22318. * * minHeight the minimum altitude on the ground, optional, default 0
  22319. * * maxHeight the maximum altitude on the ground, optional default 1
  22320. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22321. * * buffer the array holding the image color data
  22322. * * bufferWidth the width of image
  22323. * * bufferHeight the height of image
  22324. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22325. * @returns the VertexData of the Ground designed from a heightmap
  22326. */
  22327. static CreateGroundFromHeightMap(options: {
  22328. width: number;
  22329. height: number;
  22330. subdivisions: number;
  22331. minHeight: number;
  22332. maxHeight: number;
  22333. colorFilter: Color3;
  22334. buffer: Uint8Array;
  22335. bufferWidth: number;
  22336. bufferHeight: number;
  22337. alphaFilter: number;
  22338. }): VertexData;
  22339. /**
  22340. * Creates the VertexData for a Plane
  22341. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22342. * * size sets the width and height of the plane to the value of size, optional default 1
  22343. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22344. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22345. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22346. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22347. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22348. * @returns the VertexData of the box
  22349. */
  22350. static CreatePlane(options: {
  22351. size?: number;
  22352. width?: number;
  22353. height?: number;
  22354. sideOrientation?: number;
  22355. frontUVs?: Vector4;
  22356. backUVs?: Vector4;
  22357. }): VertexData;
  22358. /**
  22359. * Creates the VertexData of the Disc or regular Polygon
  22360. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22361. * * radius the radius of the disc, optional default 0.5
  22362. * * tessellation the number of polygon sides, optional, default 64
  22363. * * arc a number from 0 to 1, to create an unclosed polygon based on the fraction of the circumference given by the arc value, optional, default 1
  22364. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22365. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22366. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22367. * @returns the VertexData of the box
  22368. */
  22369. static CreateDisc(options: {
  22370. radius?: number;
  22371. tessellation?: number;
  22372. arc?: number;
  22373. sideOrientation?: number;
  22374. frontUVs?: Vector4;
  22375. backUVs?: Vector4;
  22376. }): VertexData;
  22377. /**
  22378. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22379. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22380. * @param polygon a mesh built from polygonTriangulation.build()
  22381. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22382. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22383. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22384. * @param frontUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22385. * @param backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22386. * @returns the VertexData of the Polygon
  22387. */
  22388. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22389. /**
  22390. * Creates the VertexData of the IcoSphere
  22391. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22392. * * radius the radius of the IcoSphere, optional default 1
  22393. * * radiusX allows stretching in the x direction, optional, default radius
  22394. * * radiusY allows stretching in the y direction, optional, default radius
  22395. * * radiusZ allows stretching in the z direction, optional, default radius
  22396. * * flat when true creates a flat shaded mesh, optional, default true
  22397. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22398. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22399. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22400. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22401. * @returns the VertexData of the IcoSphere
  22402. */
  22403. static CreateIcoSphere(options: {
  22404. radius?: number;
  22405. radiusX?: number;
  22406. radiusY?: number;
  22407. radiusZ?: number;
  22408. flat?: boolean;
  22409. subdivisions?: number;
  22410. sideOrientation?: number;
  22411. frontUVs?: Vector4;
  22412. backUVs?: Vector4;
  22413. }): VertexData;
  22414. /**
  22415. * Creates the VertexData for a Polyhedron
  22416. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22417. * * type provided types are:
  22418. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22419. * * 9 : Pentagonal Pyramid (J2), 10 : Triangular Dipyramid (J12), 11 : Pentagonal Dipyramid (J13), 12 : Elongated Square Dipyramid (J15), 13 : Elongated Pentagonal Dipyramid (J16), 14 : Elongated Pentagonal Cupola (J20)
  22420. * * size the size of the IcoSphere, optional default 1
  22421. * * sizeX allows stretching in the x direction, optional, default size
  22422. * * sizeY allows stretching in the y direction, optional, default size
  22423. * * sizeZ allows stretching in the z direction, optional, default size
  22424. * * custom a number that overwrites the type to create from an extended set of polyhedron from https://www.babylonjs-playground.com/#21QRSK#15 with minimised editor
  22425. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22426. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22427. * * flat when true creates a flat shaded mesh, optional, default true
  22428. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22429. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22430. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22431. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22432. * @returns the VertexData of the Polyhedron
  22433. */
  22434. static CreatePolyhedron(options: {
  22435. type?: number;
  22436. size?: number;
  22437. sizeX?: number;
  22438. sizeY?: number;
  22439. sizeZ?: number;
  22440. custom?: any;
  22441. faceUV?: Vector4[];
  22442. faceColors?: Color4[];
  22443. flat?: boolean;
  22444. sideOrientation?: number;
  22445. frontUVs?: Vector4;
  22446. backUVs?: Vector4;
  22447. }): VertexData;
  22448. /**
  22449. * Creates the VertexData for a TorusKnot
  22450. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22451. * * radius the radius of the torus knot, optional, default 2
  22452. * * tube the thickness of the tube, optional, default 0.5
  22453. * * radialSegments the number of sides on each tube segments, optional, default 32
  22454. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22455. * * p the number of windings around the z axis, optional, default 2
  22456. * * q the number of windings around the x axis, optional, default 3
  22457. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22458. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22459. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22460. * @returns the VertexData of the Torus Knot
  22461. */
  22462. static CreateTorusKnot(options: {
  22463. radius?: number;
  22464. tube?: number;
  22465. radialSegments?: number;
  22466. tubularSegments?: number;
  22467. p?: number;
  22468. q?: number;
  22469. sideOrientation?: number;
  22470. frontUVs?: Vector4;
  22471. backUVs?: Vector4;
  22472. }): VertexData;
  22473. /**
  22474. * Compute normals for given positions and indices
  22475. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22476. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22477. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22478. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22479. * * facetNormals : optional array of facet normals (vector3)
  22480. * * facetPositions : optional array of facet positions (vector3)
  22481. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22482. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22483. * * bInfo : optional bounding info, required for facetPartitioning computation
  22484. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22485. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22486. * * useRightHandedSystem: optional boolean to for right handed system computation
  22487. * * depthSort : optional boolean to enable the facet depth sort computation
  22488. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22489. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22490. */
  22491. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22492. facetNormals?: any;
  22493. facetPositions?: any;
  22494. facetPartitioning?: any;
  22495. ratio?: number;
  22496. bInfo?: any;
  22497. bbSize?: Vector3;
  22498. subDiv?: any;
  22499. useRightHandedSystem?: boolean;
  22500. depthSort?: boolean;
  22501. distanceTo?: Vector3;
  22502. depthSortedFacets?: any;
  22503. }): void;
  22504. /** @hidden */
  22505. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22506. /**
  22507. * Applies VertexData created from the imported parameters to the geometry
  22508. * @param parsedVertexData the parsed data from an imported file
  22509. * @param geometry the geometry to apply the VertexData to
  22510. */
  22511. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22512. }
  22513. }
  22514. declare module "babylonjs/Morph/morphTarget" {
  22515. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22516. import { Observable } from "babylonjs/Misc/observable";
  22517. import { Nullable, FloatArray } from "babylonjs/types";
  22518. import { Scene } from "babylonjs/scene";
  22519. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22520. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  22521. /**
  22522. * Defines a target to use with MorphTargetManager
  22523. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22524. */
  22525. export class MorphTarget implements IAnimatable {
  22526. /** defines the name of the target */
  22527. name: string;
  22528. /**
  22529. * Gets or sets the list of animations
  22530. */
  22531. animations: import("babylonjs/Animations/animation").Animation[];
  22532. private _scene;
  22533. private _positions;
  22534. private _normals;
  22535. private _tangents;
  22536. private _uvs;
  22537. private _influence;
  22538. /**
  22539. * Observable raised when the influence changes
  22540. */
  22541. onInfluenceChanged: Observable<boolean>;
  22542. /** @hidden */
  22543. _onDataLayoutChanged: Observable<void>;
  22544. /**
  22545. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22546. */
  22547. influence: number;
  22548. /**
  22549. * Gets or sets the id of the morph Target
  22550. */
  22551. id: string;
  22552. private _animationPropertiesOverride;
  22553. /**
  22554. * Gets or sets the animation properties override
  22555. */
  22556. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22557. /**
  22558. * Creates a new MorphTarget
  22559. * @param name defines the name of the target
  22560. * @param influence defines the influence to use
  22561. * @param scene defines the scene the morphtarget belongs to
  22562. */
  22563. constructor(
  22564. /** defines the name of the target */
  22565. name: string, influence?: number, scene?: Nullable<Scene>);
  22566. /**
  22567. * Gets a boolean defining if the target contains position data
  22568. */
  22569. readonly hasPositions: boolean;
  22570. /**
  22571. * Gets a boolean defining if the target contains normal data
  22572. */
  22573. readonly hasNormals: boolean;
  22574. /**
  22575. * Gets a boolean defining if the target contains tangent data
  22576. */
  22577. readonly hasTangents: boolean;
  22578. /**
  22579. * Gets a boolean defining if the target contains texture coordinates data
  22580. */
  22581. readonly hasUVs: boolean;
  22582. /**
  22583. * Affects position data to this target
  22584. * @param data defines the position data to use
  22585. */
  22586. setPositions(data: Nullable<FloatArray>): void;
  22587. /**
  22588. * Gets the position data stored in this target
  22589. * @returns a FloatArray containing the position data (or null if not present)
  22590. */
  22591. getPositions(): Nullable<FloatArray>;
  22592. /**
  22593. * Affects normal data to this target
  22594. * @param data defines the normal data to use
  22595. */
  22596. setNormals(data: Nullable<FloatArray>): void;
  22597. /**
  22598. * Gets the normal data stored in this target
  22599. * @returns a FloatArray containing the normal data (or null if not present)
  22600. */
  22601. getNormals(): Nullable<FloatArray>;
  22602. /**
  22603. * Affects tangent data to this target
  22604. * @param data defines the tangent data to use
  22605. */
  22606. setTangents(data: Nullable<FloatArray>): void;
  22607. /**
  22608. * Gets the tangent data stored in this target
  22609. * @returns a FloatArray containing the tangent data (or null if not present)
  22610. */
  22611. getTangents(): Nullable<FloatArray>;
  22612. /**
  22613. * Affects texture coordinates data to this target
  22614. * @param data defines the texture coordinates data to use
  22615. */
  22616. setUVs(data: Nullable<FloatArray>): void;
  22617. /**
  22618. * Gets the texture coordinates data stored in this target
  22619. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22620. */
  22621. getUVs(): Nullable<FloatArray>;
  22622. /**
  22623. * Serializes the current target into a Serialization object
  22624. * @returns the serialized object
  22625. */
  22626. serialize(): any;
  22627. /**
  22628. * Returns the string "MorphTarget"
  22629. * @returns "MorphTarget"
  22630. */
  22631. getClassName(): string;
  22632. /**
  22633. * Creates a new target from serialized data
  22634. * @param serializationObject defines the serialized data to use
  22635. * @returns a new MorphTarget
  22636. */
  22637. static Parse(serializationObject: any): MorphTarget;
  22638. /**
  22639. * Creates a MorphTarget from mesh data
  22640. * @param mesh defines the source mesh
  22641. * @param name defines the name to use for the new target
  22642. * @param influence defines the influence to attach to the target
  22643. * @returns a new MorphTarget
  22644. */
  22645. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22646. }
  22647. }
  22648. declare module "babylonjs/Morph/morphTargetManager" {
  22649. import { Nullable } from "babylonjs/types";
  22650. import { Scene } from "babylonjs/scene";
  22651. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  22652. /**
  22653. * This class is used to deform meshes using morphing between different targets
  22654. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22655. */
  22656. export class MorphTargetManager {
  22657. private _targets;
  22658. private _targetInfluenceChangedObservers;
  22659. private _targetDataLayoutChangedObservers;
  22660. private _activeTargets;
  22661. private _scene;
  22662. private _influences;
  22663. private _supportsNormals;
  22664. private _supportsTangents;
  22665. private _supportsUVs;
  22666. private _vertexCount;
  22667. private _uniqueId;
  22668. private _tempInfluences;
  22669. /**
  22670. * Gets or sets a boolean indicating if normals must be morphed
  22671. */
  22672. enableNormalMorphing: boolean;
  22673. /**
  22674. * Gets or sets a boolean indicating if tangents must be morphed
  22675. */
  22676. enableTangentMorphing: boolean;
  22677. /**
  22678. * Gets or sets a boolean indicating if UV must be morphed
  22679. */
  22680. enableUVMorphing: boolean;
  22681. /**
  22682. * Creates a new MorphTargetManager
  22683. * @param scene defines the current scene
  22684. */
  22685. constructor(scene?: Nullable<Scene>);
  22686. /**
  22687. * Gets the unique ID of this manager
  22688. */
  22689. readonly uniqueId: number;
  22690. /**
  22691. * Gets the number of vertices handled by this manager
  22692. */
  22693. readonly vertexCount: number;
  22694. /**
  22695. * Gets a boolean indicating if this manager supports morphing of normals
  22696. */
  22697. readonly supportsNormals: boolean;
  22698. /**
  22699. * Gets a boolean indicating if this manager supports morphing of tangents
  22700. */
  22701. readonly supportsTangents: boolean;
  22702. /**
  22703. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22704. */
  22705. readonly supportsUVs: boolean;
  22706. /**
  22707. * Gets the number of targets stored in this manager
  22708. */
  22709. readonly numTargets: number;
  22710. /**
  22711. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22712. */
  22713. readonly numInfluencers: number;
  22714. /**
  22715. * Gets the list of influences (one per target)
  22716. */
  22717. readonly influences: Float32Array;
  22718. /**
  22719. * Gets the active target at specified index. An active target is a target with an influence > 0
  22720. * @param index defines the index to check
  22721. * @returns the requested target
  22722. */
  22723. getActiveTarget(index: number): MorphTarget;
  22724. /**
  22725. * Gets the target at specified index
  22726. * @param index defines the index to check
  22727. * @returns the requested target
  22728. */
  22729. getTarget(index: number): MorphTarget;
  22730. /**
  22731. * Add a new target to this manager
  22732. * @param target defines the target to add
  22733. */
  22734. addTarget(target: MorphTarget): void;
  22735. /**
  22736. * Removes a target from the manager
  22737. * @param target defines the target to remove
  22738. */
  22739. removeTarget(target: MorphTarget): void;
  22740. /**
  22741. * Serializes the current manager into a Serialization object
  22742. * @returns the serialized object
  22743. */
  22744. serialize(): any;
  22745. private _syncActiveTargets;
  22746. /**
  22747. * Syncrhonize the targets with all the meshes using this morph target manager
  22748. */
  22749. synchronize(): void;
  22750. /**
  22751. * Creates a new MorphTargetManager from serialized data
  22752. * @param serializationObject defines the serialized data
  22753. * @param scene defines the hosting scene
  22754. * @returns the new MorphTargetManager
  22755. */
  22756. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22757. }
  22758. }
  22759. declare module "babylonjs/Meshes/meshLODLevel" {
  22760. import { Mesh } from "babylonjs/Meshes/mesh";
  22761. import { Nullable } from "babylonjs/types";
  22762. /**
  22763. * Class used to represent a specific level of detail of a mesh
  22764. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22765. */
  22766. export class MeshLODLevel {
  22767. /** Defines the distance where this level should start being displayed */
  22768. distance: number;
  22769. /** Defines the mesh to use to render this level */
  22770. mesh: Nullable<Mesh>;
  22771. /**
  22772. * Creates a new LOD level
  22773. * @param distance defines the distance where this level should star being displayed
  22774. * @param mesh defines the mesh to use to render this level
  22775. */
  22776. constructor(
  22777. /** Defines the distance where this level should start being displayed */
  22778. distance: number,
  22779. /** Defines the mesh to use to render this level */
  22780. mesh: Nullable<Mesh>);
  22781. }
  22782. }
  22783. declare module "babylonjs/Meshes/groundMesh" {
  22784. import { Scene } from "babylonjs/scene";
  22785. import { Vector3 } from "babylonjs/Maths/math.vector";
  22786. import { Mesh } from "babylonjs/Meshes/mesh";
  22787. /**
  22788. * Mesh representing the gorund
  22789. */
  22790. export class GroundMesh extends Mesh {
  22791. /** If octree should be generated */
  22792. generateOctree: boolean;
  22793. private _heightQuads;
  22794. /** @hidden */
  22795. _subdivisionsX: number;
  22796. /** @hidden */
  22797. _subdivisionsY: number;
  22798. /** @hidden */
  22799. _width: number;
  22800. /** @hidden */
  22801. _height: number;
  22802. /** @hidden */
  22803. _minX: number;
  22804. /** @hidden */
  22805. _maxX: number;
  22806. /** @hidden */
  22807. _minZ: number;
  22808. /** @hidden */
  22809. _maxZ: number;
  22810. constructor(name: string, scene: Scene);
  22811. /**
  22812. * "GroundMesh"
  22813. * @returns "GroundMesh"
  22814. */
  22815. getClassName(): string;
  22816. /**
  22817. * The minimum of x and y subdivisions
  22818. */
  22819. readonly subdivisions: number;
  22820. /**
  22821. * X subdivisions
  22822. */
  22823. readonly subdivisionsX: number;
  22824. /**
  22825. * Y subdivisions
  22826. */
  22827. readonly subdivisionsY: number;
  22828. /**
  22829. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22830. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22831. * @param chunksCount the number of subdivisions for x and y
  22832. * @param octreeBlocksSize (Default: 32)
  22833. */
  22834. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22835. /**
  22836. * Returns a height (y) value in the Worl system :
  22837. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22838. * @param x x coordinate
  22839. * @param z z coordinate
  22840. * @returns the ground y position if (x, z) are outside the ground surface.
  22841. */
  22842. getHeightAtCoordinates(x: number, z: number): number;
  22843. /**
  22844. * Returns a normalized vector (Vector3) orthogonal to the ground
  22845. * at the ground coordinates (x, z) expressed in the World system.
  22846. * @param x x coordinate
  22847. * @param z z coordinate
  22848. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22849. */
  22850. getNormalAtCoordinates(x: number, z: number): Vector3;
  22851. /**
  22852. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22853. * at the ground coordinates (x, z) expressed in the World system.
  22854. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22855. * @param x x coordinate
  22856. * @param z z coordinate
  22857. * @param ref vector to store the result
  22858. * @returns the GroundMesh.
  22859. */
  22860. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22861. /**
  22862. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22863. * if the ground has been updated.
  22864. * This can be used in the render loop.
  22865. * @returns the GroundMesh.
  22866. */
  22867. updateCoordinateHeights(): GroundMesh;
  22868. private _getFacetAt;
  22869. private _initHeightQuads;
  22870. private _computeHeightQuads;
  22871. /**
  22872. * Serializes this ground mesh
  22873. * @param serializationObject object to write serialization to
  22874. */
  22875. serialize(serializationObject: any): void;
  22876. /**
  22877. * Parses a serialized ground mesh
  22878. * @param parsedMesh the serialized mesh
  22879. * @param scene the scene to create the ground mesh in
  22880. * @returns the created ground mesh
  22881. */
  22882. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22883. }
  22884. }
  22885. declare module "babylonjs/Physics/physicsJoint" {
  22886. import { Vector3 } from "babylonjs/Maths/math.vector";
  22887. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  22888. /**
  22889. * Interface for Physics-Joint data
  22890. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22891. */
  22892. export interface PhysicsJointData {
  22893. /**
  22894. * The main pivot of the joint
  22895. */
  22896. mainPivot?: Vector3;
  22897. /**
  22898. * The connected pivot of the joint
  22899. */
  22900. connectedPivot?: Vector3;
  22901. /**
  22902. * The main axis of the joint
  22903. */
  22904. mainAxis?: Vector3;
  22905. /**
  22906. * The connected axis of the joint
  22907. */
  22908. connectedAxis?: Vector3;
  22909. /**
  22910. * The collision of the joint
  22911. */
  22912. collision?: boolean;
  22913. /**
  22914. * Native Oimo/Cannon/Energy data
  22915. */
  22916. nativeParams?: any;
  22917. }
  22918. /**
  22919. * This is a holder class for the physics joint created by the physics plugin
  22920. * It holds a set of functions to control the underlying joint
  22921. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22922. */
  22923. export class PhysicsJoint {
  22924. /**
  22925. * The type of the physics joint
  22926. */
  22927. type: number;
  22928. /**
  22929. * The data for the physics joint
  22930. */
  22931. jointData: PhysicsJointData;
  22932. private _physicsJoint;
  22933. protected _physicsPlugin: IPhysicsEnginePlugin;
  22934. /**
  22935. * Initializes the physics joint
  22936. * @param type The type of the physics joint
  22937. * @param jointData The data for the physics joint
  22938. */
  22939. constructor(
  22940. /**
  22941. * The type of the physics joint
  22942. */
  22943. type: number,
  22944. /**
  22945. * The data for the physics joint
  22946. */
  22947. jointData: PhysicsJointData);
  22948. /**
  22949. * Gets the physics joint
  22950. */
  22951. /**
  22952. * Sets the physics joint
  22953. */
  22954. physicsJoint: any;
  22955. /**
  22956. * Sets the physics plugin
  22957. */
  22958. physicsPlugin: IPhysicsEnginePlugin;
  22959. /**
  22960. * Execute a function that is physics-plugin specific.
  22961. * @param {Function} func the function that will be executed.
  22962. * It accepts two parameters: the physics world and the physics joint
  22963. */
  22964. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22965. /**
  22966. * Distance-Joint type
  22967. */
  22968. static DistanceJoint: number;
  22969. /**
  22970. * Hinge-Joint type
  22971. */
  22972. static HingeJoint: number;
  22973. /**
  22974. * Ball-and-Socket joint type
  22975. */
  22976. static BallAndSocketJoint: number;
  22977. /**
  22978. * Wheel-Joint type
  22979. */
  22980. static WheelJoint: number;
  22981. /**
  22982. * Slider-Joint type
  22983. */
  22984. static SliderJoint: number;
  22985. /**
  22986. * Prismatic-Joint type
  22987. */
  22988. static PrismaticJoint: number;
  22989. /**
  22990. * Universal-Joint type
  22991. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22992. */
  22993. static UniversalJoint: number;
  22994. /**
  22995. * Hinge-Joint 2 type
  22996. */
  22997. static Hinge2Joint: number;
  22998. /**
  22999. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23000. */
  23001. static PointToPointJoint: number;
  23002. /**
  23003. * Spring-Joint type
  23004. */
  23005. static SpringJoint: number;
  23006. /**
  23007. * Lock-Joint type
  23008. */
  23009. static LockJoint: number;
  23010. }
  23011. /**
  23012. * A class representing a physics distance joint
  23013. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23014. */
  23015. export class DistanceJoint extends PhysicsJoint {
  23016. /**
  23017. *
  23018. * @param jointData The data for the Distance-Joint
  23019. */
  23020. constructor(jointData: DistanceJointData);
  23021. /**
  23022. * Update the predefined distance.
  23023. * @param maxDistance The maximum preferred distance
  23024. * @param minDistance The minimum preferred distance
  23025. */
  23026. updateDistance(maxDistance: number, minDistance?: number): void;
  23027. }
  23028. /**
  23029. * Represents a Motor-Enabled Joint
  23030. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23031. */
  23032. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23033. /**
  23034. * Initializes the Motor-Enabled Joint
  23035. * @param type The type of the joint
  23036. * @param jointData The physica joint data for the joint
  23037. */
  23038. constructor(type: number, jointData: PhysicsJointData);
  23039. /**
  23040. * Set the motor values.
  23041. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23042. * @param force the force to apply
  23043. * @param maxForce max force for this motor.
  23044. */
  23045. setMotor(force?: number, maxForce?: number): void;
  23046. /**
  23047. * Set the motor's limits.
  23048. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23049. * @param upperLimit The upper limit of the motor
  23050. * @param lowerLimit The lower limit of the motor
  23051. */
  23052. setLimit(upperLimit: number, lowerLimit?: number): void;
  23053. }
  23054. /**
  23055. * This class represents a single physics Hinge-Joint
  23056. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23057. */
  23058. export class HingeJoint extends MotorEnabledJoint {
  23059. /**
  23060. * Initializes the Hinge-Joint
  23061. * @param jointData The joint data for the Hinge-Joint
  23062. */
  23063. constructor(jointData: PhysicsJointData);
  23064. /**
  23065. * Set the motor values.
  23066. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23067. * @param {number} force the force to apply
  23068. * @param {number} maxForce max force for this motor.
  23069. */
  23070. setMotor(force?: number, maxForce?: number): void;
  23071. /**
  23072. * Set the motor's limits.
  23073. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23074. * @param upperLimit The upper limit of the motor
  23075. * @param lowerLimit The lower limit of the motor
  23076. */
  23077. setLimit(upperLimit: number, lowerLimit?: number): void;
  23078. }
  23079. /**
  23080. * This class represents a dual hinge physics joint (same as wheel joint)
  23081. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23082. */
  23083. export class Hinge2Joint extends MotorEnabledJoint {
  23084. /**
  23085. * Initializes the Hinge2-Joint
  23086. * @param jointData The joint data for the Hinge2-Joint
  23087. */
  23088. constructor(jointData: PhysicsJointData);
  23089. /**
  23090. * Set the motor values.
  23091. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23092. * @param {number} targetSpeed the speed the motor is to reach
  23093. * @param {number} maxForce max force for this motor.
  23094. * @param {motorIndex} the motor's index, 0 or 1.
  23095. */
  23096. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23097. /**
  23098. * Set the motor limits.
  23099. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23100. * @param {number} upperLimit the upper limit
  23101. * @param {number} lowerLimit lower limit
  23102. * @param {motorIndex} the motor's index, 0 or 1.
  23103. */
  23104. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23105. }
  23106. /**
  23107. * Interface for a motor enabled joint
  23108. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23109. */
  23110. export interface IMotorEnabledJoint {
  23111. /**
  23112. * Physics joint
  23113. */
  23114. physicsJoint: any;
  23115. /**
  23116. * Sets the motor of the motor-enabled joint
  23117. * @param force The force of the motor
  23118. * @param maxForce The maximum force of the motor
  23119. * @param motorIndex The index of the motor
  23120. */
  23121. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23122. /**
  23123. * Sets the limit of the motor
  23124. * @param upperLimit The upper limit of the motor
  23125. * @param lowerLimit The lower limit of the motor
  23126. * @param motorIndex The index of the motor
  23127. */
  23128. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23129. }
  23130. /**
  23131. * Joint data for a Distance-Joint
  23132. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23133. */
  23134. export interface DistanceJointData extends PhysicsJointData {
  23135. /**
  23136. * Max distance the 2 joint objects can be apart
  23137. */
  23138. maxDistance: number;
  23139. }
  23140. /**
  23141. * Joint data from a spring joint
  23142. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23143. */
  23144. export interface SpringJointData extends PhysicsJointData {
  23145. /**
  23146. * Length of the spring
  23147. */
  23148. length: number;
  23149. /**
  23150. * Stiffness of the spring
  23151. */
  23152. stiffness: number;
  23153. /**
  23154. * Damping of the spring
  23155. */
  23156. damping: number;
  23157. /** this callback will be called when applying the force to the impostors. */
  23158. forceApplicationCallback: () => void;
  23159. }
  23160. }
  23161. declare module "babylonjs/Physics/physicsRaycastResult" {
  23162. import { Vector3 } from "babylonjs/Maths/math.vector";
  23163. /**
  23164. * Holds the data for the raycast result
  23165. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23166. */
  23167. export class PhysicsRaycastResult {
  23168. private _hasHit;
  23169. private _hitDistance;
  23170. private _hitNormalWorld;
  23171. private _hitPointWorld;
  23172. private _rayFromWorld;
  23173. private _rayToWorld;
  23174. /**
  23175. * Gets if there was a hit
  23176. */
  23177. readonly hasHit: boolean;
  23178. /**
  23179. * Gets the distance from the hit
  23180. */
  23181. readonly hitDistance: number;
  23182. /**
  23183. * Gets the hit normal/direction in the world
  23184. */
  23185. readonly hitNormalWorld: Vector3;
  23186. /**
  23187. * Gets the hit point in the world
  23188. */
  23189. readonly hitPointWorld: Vector3;
  23190. /**
  23191. * Gets the ray "start point" of the ray in the world
  23192. */
  23193. readonly rayFromWorld: Vector3;
  23194. /**
  23195. * Gets the ray "end point" of the ray in the world
  23196. */
  23197. readonly rayToWorld: Vector3;
  23198. /**
  23199. * Sets the hit data (normal & point in world space)
  23200. * @param hitNormalWorld defines the normal in world space
  23201. * @param hitPointWorld defines the point in world space
  23202. */
  23203. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23204. /**
  23205. * Sets the distance from the start point to the hit point
  23206. * @param distance
  23207. */
  23208. setHitDistance(distance: number): void;
  23209. /**
  23210. * Calculates the distance manually
  23211. */
  23212. calculateHitDistance(): void;
  23213. /**
  23214. * Resets all the values to default
  23215. * @param from The from point on world space
  23216. * @param to The to point on world space
  23217. */
  23218. reset(from?: Vector3, to?: Vector3): void;
  23219. }
  23220. /**
  23221. * Interface for the size containing width and height
  23222. */
  23223. interface IXYZ {
  23224. /**
  23225. * X
  23226. */
  23227. x: number;
  23228. /**
  23229. * Y
  23230. */
  23231. y: number;
  23232. /**
  23233. * Z
  23234. */
  23235. z: number;
  23236. }
  23237. }
  23238. declare module "babylonjs/Physics/IPhysicsEngine" {
  23239. import { Nullable } from "babylonjs/types";
  23240. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23241. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23242. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23243. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23244. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23245. /**
  23246. * Interface used to describe a physics joint
  23247. */
  23248. export interface PhysicsImpostorJoint {
  23249. /** Defines the main impostor to which the joint is linked */
  23250. mainImpostor: PhysicsImpostor;
  23251. /** Defines the impostor that is connected to the main impostor using this joint */
  23252. connectedImpostor: PhysicsImpostor;
  23253. /** Defines the joint itself */
  23254. joint: PhysicsJoint;
  23255. }
  23256. /** @hidden */
  23257. export interface IPhysicsEnginePlugin {
  23258. world: any;
  23259. name: string;
  23260. setGravity(gravity: Vector3): void;
  23261. setTimeStep(timeStep: number): void;
  23262. getTimeStep(): number;
  23263. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23264. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23265. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23266. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23267. removePhysicsBody(impostor: PhysicsImpostor): void;
  23268. generateJoint(joint: PhysicsImpostorJoint): void;
  23269. removeJoint(joint: PhysicsImpostorJoint): void;
  23270. isSupported(): boolean;
  23271. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23272. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23273. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23274. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23275. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23276. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23277. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23278. getBodyMass(impostor: PhysicsImpostor): number;
  23279. getBodyFriction(impostor: PhysicsImpostor): number;
  23280. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23281. getBodyRestitution(impostor: PhysicsImpostor): number;
  23282. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23283. getBodyPressure?(impostor: PhysicsImpostor): number;
  23284. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23285. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23286. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23287. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23288. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23289. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23290. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23291. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23292. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23293. sleepBody(impostor: PhysicsImpostor): void;
  23294. wakeUpBody(impostor: PhysicsImpostor): void;
  23295. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23296. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23297. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23298. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23299. getRadius(impostor: PhysicsImpostor): number;
  23300. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23301. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23302. dispose(): void;
  23303. }
  23304. /**
  23305. * Interface used to define a physics engine
  23306. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23307. */
  23308. export interface IPhysicsEngine {
  23309. /**
  23310. * Gets the gravity vector used by the simulation
  23311. */
  23312. gravity: Vector3;
  23313. /**
  23314. * Sets the gravity vector used by the simulation
  23315. * @param gravity defines the gravity vector to use
  23316. */
  23317. setGravity(gravity: Vector3): void;
  23318. /**
  23319. * Set the time step of the physics engine.
  23320. * Default is 1/60.
  23321. * To slow it down, enter 1/600 for example.
  23322. * To speed it up, 1/30
  23323. * @param newTimeStep the new timestep to apply to this world.
  23324. */
  23325. setTimeStep(newTimeStep: number): void;
  23326. /**
  23327. * Get the time step of the physics engine.
  23328. * @returns the current time step
  23329. */
  23330. getTimeStep(): number;
  23331. /**
  23332. * Release all resources
  23333. */
  23334. dispose(): void;
  23335. /**
  23336. * Gets the name of the current physics plugin
  23337. * @returns the name of the plugin
  23338. */
  23339. getPhysicsPluginName(): string;
  23340. /**
  23341. * Adding a new impostor for the impostor tracking.
  23342. * This will be done by the impostor itself.
  23343. * @param impostor the impostor to add
  23344. */
  23345. addImpostor(impostor: PhysicsImpostor): void;
  23346. /**
  23347. * Remove an impostor from the engine.
  23348. * This impostor and its mesh will not longer be updated by the physics engine.
  23349. * @param impostor the impostor to remove
  23350. */
  23351. removeImpostor(impostor: PhysicsImpostor): void;
  23352. /**
  23353. * Add a joint to the physics engine
  23354. * @param mainImpostor defines the main impostor to which the joint is added.
  23355. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23356. * @param joint defines the joint that will connect both impostors.
  23357. */
  23358. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23359. /**
  23360. * Removes a joint from the simulation
  23361. * @param mainImpostor defines the impostor used with the joint
  23362. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23363. * @param joint defines the joint to remove
  23364. */
  23365. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23366. /**
  23367. * Gets the current plugin used to run the simulation
  23368. * @returns current plugin
  23369. */
  23370. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23371. /**
  23372. * Gets the list of physic impostors
  23373. * @returns an array of PhysicsImpostor
  23374. */
  23375. getImpostors(): Array<PhysicsImpostor>;
  23376. /**
  23377. * Gets the impostor for a physics enabled object
  23378. * @param object defines the object impersonated by the impostor
  23379. * @returns the PhysicsImpostor or null if not found
  23380. */
  23381. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23382. /**
  23383. * Gets the impostor for a physics body object
  23384. * @param body defines physics body used by the impostor
  23385. * @returns the PhysicsImpostor or null if not found
  23386. */
  23387. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23388. /**
  23389. * Does a raycast in the physics world
  23390. * @param from when should the ray start?
  23391. * @param to when should the ray end?
  23392. * @returns PhysicsRaycastResult
  23393. */
  23394. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23395. /**
  23396. * Called by the scene. No need to call it.
  23397. * @param delta defines the timespam between frames
  23398. */
  23399. _step(delta: number): void;
  23400. }
  23401. }
  23402. declare module "babylonjs/Physics/physicsImpostor" {
  23403. import { Nullable, IndicesArray } from "babylonjs/types";
  23404. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  23405. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23406. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23407. import { Scene } from "babylonjs/scene";
  23408. import { Bone } from "babylonjs/Bones/bone";
  23409. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23410. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  23411. import { Space } from "babylonjs/Maths/math.axis";
  23412. /**
  23413. * The interface for the physics imposter parameters
  23414. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23415. */
  23416. export interface PhysicsImpostorParameters {
  23417. /**
  23418. * The mass of the physics imposter
  23419. */
  23420. mass: number;
  23421. /**
  23422. * The friction of the physics imposter
  23423. */
  23424. friction?: number;
  23425. /**
  23426. * The coefficient of restitution of the physics imposter
  23427. */
  23428. restitution?: number;
  23429. /**
  23430. * The native options of the physics imposter
  23431. */
  23432. nativeOptions?: any;
  23433. /**
  23434. * Specifies if the parent should be ignored
  23435. */
  23436. ignoreParent?: boolean;
  23437. /**
  23438. * Specifies if bi-directional transformations should be disabled
  23439. */
  23440. disableBidirectionalTransformation?: boolean;
  23441. /**
  23442. * The pressure inside the physics imposter, soft object only
  23443. */
  23444. pressure?: number;
  23445. /**
  23446. * The stiffness the physics imposter, soft object only
  23447. */
  23448. stiffness?: number;
  23449. /**
  23450. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23451. */
  23452. velocityIterations?: number;
  23453. /**
  23454. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23455. */
  23456. positionIterations?: number;
  23457. /**
  23458. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23459. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23460. * Add to fix multiple points
  23461. */
  23462. fixedPoints?: number;
  23463. /**
  23464. * The collision margin around a soft object
  23465. */
  23466. margin?: number;
  23467. /**
  23468. * The collision margin around a soft object
  23469. */
  23470. damping?: number;
  23471. /**
  23472. * The path for a rope based on an extrusion
  23473. */
  23474. path?: any;
  23475. /**
  23476. * The shape of an extrusion used for a rope based on an extrusion
  23477. */
  23478. shape?: any;
  23479. }
  23480. /**
  23481. * Interface for a physics-enabled object
  23482. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23483. */
  23484. export interface IPhysicsEnabledObject {
  23485. /**
  23486. * The position of the physics-enabled object
  23487. */
  23488. position: Vector3;
  23489. /**
  23490. * The rotation of the physics-enabled object
  23491. */
  23492. rotationQuaternion: Nullable<Quaternion>;
  23493. /**
  23494. * The scale of the physics-enabled object
  23495. */
  23496. scaling: Vector3;
  23497. /**
  23498. * The rotation of the physics-enabled object
  23499. */
  23500. rotation?: Vector3;
  23501. /**
  23502. * The parent of the physics-enabled object
  23503. */
  23504. parent?: any;
  23505. /**
  23506. * The bounding info of the physics-enabled object
  23507. * @returns The bounding info of the physics-enabled object
  23508. */
  23509. getBoundingInfo(): BoundingInfo;
  23510. /**
  23511. * Computes the world matrix
  23512. * @param force Specifies if the world matrix should be computed by force
  23513. * @returns A world matrix
  23514. */
  23515. computeWorldMatrix(force: boolean): Matrix;
  23516. /**
  23517. * Gets the world matrix
  23518. * @returns A world matrix
  23519. */
  23520. getWorldMatrix?(): Matrix;
  23521. /**
  23522. * Gets the child meshes
  23523. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23524. * @returns An array of abstract meshes
  23525. */
  23526. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23527. /**
  23528. * Gets the vertex data
  23529. * @param kind The type of vertex data
  23530. * @returns A nullable array of numbers, or a float32 array
  23531. */
  23532. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23533. /**
  23534. * Gets the indices from the mesh
  23535. * @returns A nullable array of index arrays
  23536. */
  23537. getIndices?(): Nullable<IndicesArray>;
  23538. /**
  23539. * Gets the scene from the mesh
  23540. * @returns the indices array or null
  23541. */
  23542. getScene?(): Scene;
  23543. /**
  23544. * Gets the absolute position from the mesh
  23545. * @returns the absolute position
  23546. */
  23547. getAbsolutePosition(): Vector3;
  23548. /**
  23549. * Gets the absolute pivot point from the mesh
  23550. * @returns the absolute pivot point
  23551. */
  23552. getAbsolutePivotPoint(): Vector3;
  23553. /**
  23554. * Rotates the mesh
  23555. * @param axis The axis of rotation
  23556. * @param amount The amount of rotation
  23557. * @param space The space of the rotation
  23558. * @returns The rotation transform node
  23559. */
  23560. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23561. /**
  23562. * Translates the mesh
  23563. * @param axis The axis of translation
  23564. * @param distance The distance of translation
  23565. * @param space The space of the translation
  23566. * @returns The transform node
  23567. */
  23568. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23569. /**
  23570. * Sets the absolute position of the mesh
  23571. * @param absolutePosition The absolute position of the mesh
  23572. * @returns The transform node
  23573. */
  23574. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23575. /**
  23576. * Gets the class name of the mesh
  23577. * @returns The class name
  23578. */
  23579. getClassName(): string;
  23580. }
  23581. /**
  23582. * Represents a physics imposter
  23583. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23584. */
  23585. export class PhysicsImpostor {
  23586. /**
  23587. * The physics-enabled object used as the physics imposter
  23588. */
  23589. object: IPhysicsEnabledObject;
  23590. /**
  23591. * The type of the physics imposter
  23592. */
  23593. type: number;
  23594. private _options;
  23595. private _scene?;
  23596. /**
  23597. * The default object size of the imposter
  23598. */
  23599. static DEFAULT_OBJECT_SIZE: Vector3;
  23600. /**
  23601. * The identity quaternion of the imposter
  23602. */
  23603. static IDENTITY_QUATERNION: Quaternion;
  23604. /** @hidden */
  23605. _pluginData: any;
  23606. private _physicsEngine;
  23607. private _physicsBody;
  23608. private _bodyUpdateRequired;
  23609. private _onBeforePhysicsStepCallbacks;
  23610. private _onAfterPhysicsStepCallbacks;
  23611. /** @hidden */
  23612. _onPhysicsCollideCallbacks: Array<{
  23613. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23614. otherImpostors: Array<PhysicsImpostor>;
  23615. }>;
  23616. private _deltaPosition;
  23617. private _deltaRotation;
  23618. private _deltaRotationConjugated;
  23619. /** @hidden */
  23620. _isFromLine: boolean;
  23621. private _parent;
  23622. private _isDisposed;
  23623. private static _tmpVecs;
  23624. private static _tmpQuat;
  23625. /**
  23626. * Specifies if the physics imposter is disposed
  23627. */
  23628. readonly isDisposed: boolean;
  23629. /**
  23630. * Gets the mass of the physics imposter
  23631. */
  23632. mass: number;
  23633. /**
  23634. * Gets the coefficient of friction
  23635. */
  23636. /**
  23637. * Sets the coefficient of friction
  23638. */
  23639. friction: number;
  23640. /**
  23641. * Gets the coefficient of restitution
  23642. */
  23643. /**
  23644. * Sets the coefficient of restitution
  23645. */
  23646. restitution: number;
  23647. /**
  23648. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23649. */
  23650. /**
  23651. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23652. */
  23653. pressure: number;
  23654. /**
  23655. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23656. */
  23657. /**
  23658. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23659. */
  23660. stiffness: number;
  23661. /**
  23662. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23663. */
  23664. /**
  23665. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23666. */
  23667. velocityIterations: number;
  23668. /**
  23669. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23670. */
  23671. /**
  23672. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23673. */
  23674. positionIterations: number;
  23675. /**
  23676. * The unique id of the physics imposter
  23677. * set by the physics engine when adding this impostor to the array
  23678. */
  23679. uniqueId: number;
  23680. /**
  23681. * @hidden
  23682. */
  23683. soft: boolean;
  23684. /**
  23685. * @hidden
  23686. */
  23687. segments: number;
  23688. private _joints;
  23689. /**
  23690. * Initializes the physics imposter
  23691. * @param object The physics-enabled object used as the physics imposter
  23692. * @param type The type of the physics imposter
  23693. * @param _options The options for the physics imposter
  23694. * @param _scene The Babylon scene
  23695. */
  23696. constructor(
  23697. /**
  23698. * The physics-enabled object used as the physics imposter
  23699. */
  23700. object: IPhysicsEnabledObject,
  23701. /**
  23702. * The type of the physics imposter
  23703. */
  23704. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23705. /**
  23706. * This function will completly initialize this impostor.
  23707. * It will create a new body - but only if this mesh has no parent.
  23708. * If it has, this impostor will not be used other than to define the impostor
  23709. * of the child mesh.
  23710. * @hidden
  23711. */
  23712. _init(): void;
  23713. private _getPhysicsParent;
  23714. /**
  23715. * Should a new body be generated.
  23716. * @returns boolean specifying if body initialization is required
  23717. */
  23718. isBodyInitRequired(): boolean;
  23719. /**
  23720. * Sets the updated scaling
  23721. * @param updated Specifies if the scaling is updated
  23722. */
  23723. setScalingUpdated(): void;
  23724. /**
  23725. * Force a regeneration of this or the parent's impostor's body.
  23726. * Use under cautious - This will remove all joints already implemented.
  23727. */
  23728. forceUpdate(): void;
  23729. /**
  23730. * Gets the body that holds this impostor. Either its own, or its parent.
  23731. */
  23732. /**
  23733. * Set the physics body. Used mainly by the physics engine/plugin
  23734. */
  23735. physicsBody: any;
  23736. /**
  23737. * Get the parent of the physics imposter
  23738. * @returns Physics imposter or null
  23739. */
  23740. /**
  23741. * Sets the parent of the physics imposter
  23742. */
  23743. parent: Nullable<PhysicsImpostor>;
  23744. /**
  23745. * Resets the update flags
  23746. */
  23747. resetUpdateFlags(): void;
  23748. /**
  23749. * Gets the object extend size
  23750. * @returns the object extend size
  23751. */
  23752. getObjectExtendSize(): Vector3;
  23753. /**
  23754. * Gets the object center
  23755. * @returns The object center
  23756. */
  23757. getObjectCenter(): Vector3;
  23758. /**
  23759. * Get a specific parametes from the options parameter
  23760. * @param paramName The object parameter name
  23761. * @returns The object parameter
  23762. */
  23763. getParam(paramName: string): any;
  23764. /**
  23765. * Sets a specific parameter in the options given to the physics plugin
  23766. * @param paramName The parameter name
  23767. * @param value The value of the parameter
  23768. */
  23769. setParam(paramName: string, value: number): void;
  23770. /**
  23771. * Specifically change the body's mass option. Won't recreate the physics body object
  23772. * @param mass The mass of the physics imposter
  23773. */
  23774. setMass(mass: number): void;
  23775. /**
  23776. * Gets the linear velocity
  23777. * @returns linear velocity or null
  23778. */
  23779. getLinearVelocity(): Nullable<Vector3>;
  23780. /**
  23781. * Sets the linear velocity
  23782. * @param velocity linear velocity or null
  23783. */
  23784. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23785. /**
  23786. * Gets the angular velocity
  23787. * @returns angular velocity or null
  23788. */
  23789. getAngularVelocity(): Nullable<Vector3>;
  23790. /**
  23791. * Sets the angular velocity
  23792. * @param velocity The velocity or null
  23793. */
  23794. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23795. /**
  23796. * Execute a function with the physics plugin native code
  23797. * Provide a function the will have two variables - the world object and the physics body object
  23798. * @param func The function to execute with the physics plugin native code
  23799. */
  23800. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23801. /**
  23802. * Register a function that will be executed before the physics world is stepping forward
  23803. * @param func The function to execute before the physics world is stepped forward
  23804. */
  23805. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23806. /**
  23807. * Unregister a function that will be executed before the physics world is stepping forward
  23808. * @param func The function to execute before the physics world is stepped forward
  23809. */
  23810. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23811. /**
  23812. * Register a function that will be executed after the physics step
  23813. * @param func The function to execute after physics step
  23814. */
  23815. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23816. /**
  23817. * Unregisters a function that will be executed after the physics step
  23818. * @param func The function to execute after physics step
  23819. */
  23820. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23821. /**
  23822. * register a function that will be executed when this impostor collides against a different body
  23823. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23824. * @param func Callback that is executed on collision
  23825. */
  23826. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23827. /**
  23828. * Unregisters the physics imposter on contact
  23829. * @param collideAgainst The physics object to collide against
  23830. * @param func Callback to execute on collision
  23831. */
  23832. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23833. private _tmpQuat;
  23834. private _tmpQuat2;
  23835. /**
  23836. * Get the parent rotation
  23837. * @returns The parent rotation
  23838. */
  23839. getParentsRotation(): Quaternion;
  23840. /**
  23841. * this function is executed by the physics engine.
  23842. */
  23843. beforeStep: () => void;
  23844. /**
  23845. * this function is executed by the physics engine
  23846. */
  23847. afterStep: () => void;
  23848. /**
  23849. * Legacy collision detection event support
  23850. */
  23851. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23852. /**
  23853. * event and body object due to cannon's event-based architecture.
  23854. */
  23855. onCollide: (e: {
  23856. body: any;
  23857. }) => void;
  23858. /**
  23859. * Apply a force
  23860. * @param force The force to apply
  23861. * @param contactPoint The contact point for the force
  23862. * @returns The physics imposter
  23863. */
  23864. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23865. /**
  23866. * Apply an impulse
  23867. * @param force The impulse force
  23868. * @param contactPoint The contact point for the impulse force
  23869. * @returns The physics imposter
  23870. */
  23871. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23872. /**
  23873. * A help function to create a joint
  23874. * @param otherImpostor A physics imposter used to create a joint
  23875. * @param jointType The type of joint
  23876. * @param jointData The data for the joint
  23877. * @returns The physics imposter
  23878. */
  23879. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23880. /**
  23881. * Add a joint to this impostor with a different impostor
  23882. * @param otherImpostor A physics imposter used to add a joint
  23883. * @param joint The joint to add
  23884. * @returns The physics imposter
  23885. */
  23886. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23887. /**
  23888. * Add an anchor to a cloth impostor
  23889. * @param otherImpostor rigid impostor to anchor to
  23890. * @param width ratio across width from 0 to 1
  23891. * @param height ratio up height from 0 to 1
  23892. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23893. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23894. * @returns impostor the soft imposter
  23895. */
  23896. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23897. /**
  23898. * Add a hook to a rope impostor
  23899. * @param otherImpostor rigid impostor to anchor to
  23900. * @param length ratio across rope from 0 to 1
  23901. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23902. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23903. * @returns impostor the rope imposter
  23904. */
  23905. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23906. /**
  23907. * Will keep this body still, in a sleep mode.
  23908. * @returns the physics imposter
  23909. */
  23910. sleep(): PhysicsImpostor;
  23911. /**
  23912. * Wake the body up.
  23913. * @returns The physics imposter
  23914. */
  23915. wakeUp(): PhysicsImpostor;
  23916. /**
  23917. * Clones the physics imposter
  23918. * @param newObject The physics imposter clones to this physics-enabled object
  23919. * @returns A nullable physics imposter
  23920. */
  23921. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23922. /**
  23923. * Disposes the physics imposter
  23924. */
  23925. dispose(): void;
  23926. /**
  23927. * Sets the delta position
  23928. * @param position The delta position amount
  23929. */
  23930. setDeltaPosition(position: Vector3): void;
  23931. /**
  23932. * Sets the delta rotation
  23933. * @param rotation The delta rotation amount
  23934. */
  23935. setDeltaRotation(rotation: Quaternion): void;
  23936. /**
  23937. * Gets the box size of the physics imposter and stores the result in the input parameter
  23938. * @param result Stores the box size
  23939. * @returns The physics imposter
  23940. */
  23941. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23942. /**
  23943. * Gets the radius of the physics imposter
  23944. * @returns Radius of the physics imposter
  23945. */
  23946. getRadius(): number;
  23947. /**
  23948. * Sync a bone with this impostor
  23949. * @param bone The bone to sync to the impostor.
  23950. * @param boneMesh The mesh that the bone is influencing.
  23951. * @param jointPivot The pivot of the joint / bone in local space.
  23952. * @param distToJoint Optional distance from the impostor to the joint.
  23953. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23954. */
  23955. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23956. /**
  23957. * Sync impostor to a bone
  23958. * @param bone The bone that the impostor will be synced to.
  23959. * @param boneMesh The mesh that the bone is influencing.
  23960. * @param jointPivot The pivot of the joint / bone in local space.
  23961. * @param distToJoint Optional distance from the impostor to the joint.
  23962. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23963. * @param boneAxis Optional vector3 axis the bone is aligned with
  23964. */
  23965. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23966. /**
  23967. * No-Imposter type
  23968. */
  23969. static NoImpostor: number;
  23970. /**
  23971. * Sphere-Imposter type
  23972. */
  23973. static SphereImpostor: number;
  23974. /**
  23975. * Box-Imposter type
  23976. */
  23977. static BoxImpostor: number;
  23978. /**
  23979. * Plane-Imposter type
  23980. */
  23981. static PlaneImpostor: number;
  23982. /**
  23983. * Mesh-imposter type
  23984. */
  23985. static MeshImpostor: number;
  23986. /**
  23987. * Capsule-Impostor type (Ammo.js plugin only)
  23988. */
  23989. static CapsuleImpostor: number;
  23990. /**
  23991. * Cylinder-Imposter type
  23992. */
  23993. static CylinderImpostor: number;
  23994. /**
  23995. * Particle-Imposter type
  23996. */
  23997. static ParticleImpostor: number;
  23998. /**
  23999. * Heightmap-Imposter type
  24000. */
  24001. static HeightmapImpostor: number;
  24002. /**
  24003. * ConvexHull-Impostor type (Ammo.js plugin only)
  24004. */
  24005. static ConvexHullImpostor: number;
  24006. /**
  24007. * Rope-Imposter type
  24008. */
  24009. static RopeImpostor: number;
  24010. /**
  24011. * Cloth-Imposter type
  24012. */
  24013. static ClothImpostor: number;
  24014. /**
  24015. * Softbody-Imposter type
  24016. */
  24017. static SoftbodyImpostor: number;
  24018. }
  24019. }
  24020. declare module "babylonjs/Meshes/mesh" {
  24021. import { Observable } from "babylonjs/Misc/observable";
  24022. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24023. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24024. import { Camera } from "babylonjs/Cameras/camera";
  24025. import { Scene } from "babylonjs/scene";
  24026. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24027. import { Color4 } from "babylonjs/Maths/math.color";
  24028. import { Engine } from "babylonjs/Engines/engine";
  24029. import { Node } from "babylonjs/node";
  24030. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24031. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24032. import { Buffer } from "babylonjs/Meshes/buffer";
  24033. import { Geometry } from "babylonjs/Meshes/geometry";
  24034. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24035. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24036. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24037. import { Effect } from "babylonjs/Materials/effect";
  24038. import { Material } from "babylonjs/Materials/material";
  24039. import { Skeleton } from "babylonjs/Bones/skeleton";
  24040. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24041. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24042. import { Path3D } from "babylonjs/Maths/math.path";
  24043. import { Plane } from "babylonjs/Maths/math.plane";
  24044. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24045. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24046. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24047. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24048. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24049. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24050. /**
  24051. * @hidden
  24052. **/
  24053. export class _CreationDataStorage {
  24054. closePath?: boolean;
  24055. closeArray?: boolean;
  24056. idx: number[];
  24057. dashSize: number;
  24058. gapSize: number;
  24059. path3D: Path3D;
  24060. pathArray: Vector3[][];
  24061. arc: number;
  24062. radius: number;
  24063. cap: number;
  24064. tessellation: number;
  24065. }
  24066. /**
  24067. * @hidden
  24068. **/
  24069. class _InstanceDataStorage {
  24070. visibleInstances: any;
  24071. batchCache: _InstancesBatch;
  24072. instancesBufferSize: number;
  24073. instancesBuffer: Nullable<Buffer>;
  24074. instancesData: Float32Array;
  24075. overridenInstanceCount: number;
  24076. isFrozen: boolean;
  24077. previousBatch: Nullable<_InstancesBatch>;
  24078. hardwareInstancedRendering: boolean;
  24079. sideOrientation: number;
  24080. }
  24081. /**
  24082. * @hidden
  24083. **/
  24084. export class _InstancesBatch {
  24085. mustReturn: boolean;
  24086. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24087. renderSelf: boolean[];
  24088. hardwareInstancedRendering: boolean[];
  24089. }
  24090. /**
  24091. * Class used to represent renderable models
  24092. */
  24093. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24094. /**
  24095. * Mesh side orientation : usually the external or front surface
  24096. */
  24097. static readonly FRONTSIDE: number;
  24098. /**
  24099. * Mesh side orientation : usually the internal or back surface
  24100. */
  24101. static readonly BACKSIDE: number;
  24102. /**
  24103. * Mesh side orientation : both internal and external or front and back surfaces
  24104. */
  24105. static readonly DOUBLESIDE: number;
  24106. /**
  24107. * Mesh side orientation : by default, `FRONTSIDE`
  24108. */
  24109. static readonly DEFAULTSIDE: number;
  24110. /**
  24111. * Mesh cap setting : no cap
  24112. */
  24113. static readonly NO_CAP: number;
  24114. /**
  24115. * Mesh cap setting : one cap at the beginning of the mesh
  24116. */
  24117. static readonly CAP_START: number;
  24118. /**
  24119. * Mesh cap setting : one cap at the end of the mesh
  24120. */
  24121. static readonly CAP_END: number;
  24122. /**
  24123. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24124. */
  24125. static readonly CAP_ALL: number;
  24126. /**
  24127. * Mesh pattern setting : no flip or rotate
  24128. */
  24129. static readonly NO_FLIP: number;
  24130. /**
  24131. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24132. */
  24133. static readonly FLIP_TILE: number;
  24134. /**
  24135. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24136. */
  24137. static readonly ROTATE_TILE: number;
  24138. /**
  24139. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24140. */
  24141. static readonly FLIP_ROW: number;
  24142. /**
  24143. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24144. */
  24145. static readonly ROTATE_ROW: number;
  24146. /**
  24147. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24148. */
  24149. static readonly FLIP_N_ROTATE_TILE: number;
  24150. /**
  24151. * Mesh pattern setting : rotate pattern and rotate
  24152. */
  24153. static readonly FLIP_N_ROTATE_ROW: number;
  24154. /**
  24155. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24156. */
  24157. static readonly CENTER: number;
  24158. /**
  24159. * Mesh tile positioning : part tiles on left
  24160. */
  24161. static readonly LEFT: number;
  24162. /**
  24163. * Mesh tile positioning : part tiles on right
  24164. */
  24165. static readonly RIGHT: number;
  24166. /**
  24167. * Mesh tile positioning : part tiles on top
  24168. */
  24169. static readonly TOP: number;
  24170. /**
  24171. * Mesh tile positioning : part tiles on bottom
  24172. */
  24173. static readonly BOTTOM: number;
  24174. /**
  24175. * Gets the default side orientation.
  24176. * @param orientation the orientation to value to attempt to get
  24177. * @returns the default orientation
  24178. * @hidden
  24179. */
  24180. static _GetDefaultSideOrientation(orientation?: number): number;
  24181. private _internalMeshDataInfo;
  24182. /**
  24183. * An event triggered before rendering the mesh
  24184. */
  24185. readonly onBeforeRenderObservable: Observable<Mesh>;
  24186. /**
  24187. * An event triggered before binding the mesh
  24188. */
  24189. readonly onBeforeBindObservable: Observable<Mesh>;
  24190. /**
  24191. * An event triggered after rendering the mesh
  24192. */
  24193. readonly onAfterRenderObservable: Observable<Mesh>;
  24194. /**
  24195. * An event triggered before drawing the mesh
  24196. */
  24197. readonly onBeforeDrawObservable: Observable<Mesh>;
  24198. private _onBeforeDrawObserver;
  24199. /**
  24200. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24201. */
  24202. onBeforeDraw: () => void;
  24203. readonly hasInstances: boolean;
  24204. /**
  24205. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24206. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24207. */
  24208. delayLoadState: number;
  24209. /**
  24210. * Gets the list of instances created from this mesh
  24211. * it is not supposed to be modified manually.
  24212. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24213. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24214. */
  24215. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24216. /**
  24217. * Gets the file containing delay loading data for this mesh
  24218. */
  24219. delayLoadingFile: string;
  24220. /** @hidden */
  24221. _binaryInfo: any;
  24222. /**
  24223. * User defined function used to change how LOD level selection is done
  24224. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24225. */
  24226. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24227. /**
  24228. * Gets or sets the morph target manager
  24229. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24230. */
  24231. morphTargetManager: Nullable<MorphTargetManager>;
  24232. /** @hidden */
  24233. _creationDataStorage: Nullable<_CreationDataStorage>;
  24234. /** @hidden */
  24235. _geometry: Nullable<Geometry>;
  24236. /** @hidden */
  24237. _delayInfo: Array<string>;
  24238. /** @hidden */
  24239. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24240. /** @hidden */
  24241. _instanceDataStorage: _InstanceDataStorage;
  24242. private _effectiveMaterial;
  24243. /** @hidden */
  24244. _shouldGenerateFlatShading: boolean;
  24245. /** @hidden */
  24246. _originalBuilderSideOrientation: number;
  24247. /**
  24248. * Use this property to change the original side orientation defined at construction time
  24249. */
  24250. overrideMaterialSideOrientation: Nullable<number>;
  24251. /**
  24252. * Gets the source mesh (the one used to clone this one from)
  24253. */
  24254. readonly source: Nullable<Mesh>;
  24255. /**
  24256. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24257. */
  24258. isUnIndexed: boolean;
  24259. /**
  24260. * @constructor
  24261. * @param name The value used by scene.getMeshByName() to do a lookup.
  24262. * @param scene The scene to add this mesh to.
  24263. * @param parent The parent of this mesh, if it has one
  24264. * @param source An optional Mesh from which geometry is shared, cloned.
  24265. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24266. * When false, achieved by calling a clone(), also passing False.
  24267. * This will make creation of children, recursive.
  24268. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24269. */
  24270. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24271. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  24272. /**
  24273. * Gets the class name
  24274. * @returns the string "Mesh".
  24275. */
  24276. getClassName(): string;
  24277. /** @hidden */
  24278. readonly _isMesh: boolean;
  24279. /**
  24280. * Returns a description of this mesh
  24281. * @param fullDetails define if full details about this mesh must be used
  24282. * @returns a descriptive string representing this mesh
  24283. */
  24284. toString(fullDetails?: boolean): string;
  24285. /** @hidden */
  24286. _unBindEffect(): void;
  24287. /**
  24288. * Gets a boolean indicating if this mesh has LOD
  24289. */
  24290. readonly hasLODLevels: boolean;
  24291. /**
  24292. * Gets the list of MeshLODLevel associated with the current mesh
  24293. * @returns an array of MeshLODLevel
  24294. */
  24295. getLODLevels(): MeshLODLevel[];
  24296. private _sortLODLevels;
  24297. /**
  24298. * Add a mesh as LOD level triggered at the given distance.
  24299. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24300. * @param distance The distance from the center of the object to show this level
  24301. * @param mesh The mesh to be added as LOD level (can be null)
  24302. * @return This mesh (for chaining)
  24303. */
  24304. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24305. /**
  24306. * Returns the LOD level mesh at the passed distance or null if not found.
  24307. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24308. * @param distance The distance from the center of the object to show this level
  24309. * @returns a Mesh or `null`
  24310. */
  24311. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24312. /**
  24313. * Remove a mesh from the LOD array
  24314. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24315. * @param mesh defines the mesh to be removed
  24316. * @return This mesh (for chaining)
  24317. */
  24318. removeLODLevel(mesh: Mesh): Mesh;
  24319. /**
  24320. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24321. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24322. * @param camera defines the camera to use to compute distance
  24323. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24324. * @return This mesh (for chaining)
  24325. */
  24326. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24327. /**
  24328. * Gets the mesh internal Geometry object
  24329. */
  24330. readonly geometry: Nullable<Geometry>;
  24331. /**
  24332. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24333. * @returns the total number of vertices
  24334. */
  24335. getTotalVertices(): number;
  24336. /**
  24337. * Returns the content of an associated vertex buffer
  24338. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24339. * - VertexBuffer.PositionKind
  24340. * - VertexBuffer.UVKind
  24341. * - VertexBuffer.UV2Kind
  24342. * - VertexBuffer.UV3Kind
  24343. * - VertexBuffer.UV4Kind
  24344. * - VertexBuffer.UV5Kind
  24345. * - VertexBuffer.UV6Kind
  24346. * - VertexBuffer.ColorKind
  24347. * - VertexBuffer.MatricesIndicesKind
  24348. * - VertexBuffer.MatricesIndicesExtraKind
  24349. * - VertexBuffer.MatricesWeightsKind
  24350. * - VertexBuffer.MatricesWeightsExtraKind
  24351. * @param copyWhenShared defines a boolean indicating that if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one
  24352. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24353. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24354. */
  24355. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24356. /**
  24357. * Returns the mesh VertexBuffer object from the requested `kind`
  24358. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24359. * - VertexBuffer.PositionKind
  24360. * - VertexBuffer.NormalKind
  24361. * - VertexBuffer.UVKind
  24362. * - VertexBuffer.UV2Kind
  24363. * - VertexBuffer.UV3Kind
  24364. * - VertexBuffer.UV4Kind
  24365. * - VertexBuffer.UV5Kind
  24366. * - VertexBuffer.UV6Kind
  24367. * - VertexBuffer.ColorKind
  24368. * - VertexBuffer.MatricesIndicesKind
  24369. * - VertexBuffer.MatricesIndicesExtraKind
  24370. * - VertexBuffer.MatricesWeightsKind
  24371. * - VertexBuffer.MatricesWeightsExtraKind
  24372. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24373. */
  24374. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24375. /**
  24376. * Tests if a specific vertex buffer is associated with this mesh
  24377. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24378. * - VertexBuffer.PositionKind
  24379. * - VertexBuffer.NormalKind
  24380. * - VertexBuffer.UVKind
  24381. * - VertexBuffer.UV2Kind
  24382. * - VertexBuffer.UV3Kind
  24383. * - VertexBuffer.UV4Kind
  24384. * - VertexBuffer.UV5Kind
  24385. * - VertexBuffer.UV6Kind
  24386. * - VertexBuffer.ColorKind
  24387. * - VertexBuffer.MatricesIndicesKind
  24388. * - VertexBuffer.MatricesIndicesExtraKind
  24389. * - VertexBuffer.MatricesWeightsKind
  24390. * - VertexBuffer.MatricesWeightsExtraKind
  24391. * @returns a boolean
  24392. */
  24393. isVerticesDataPresent(kind: string): boolean;
  24394. /**
  24395. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24396. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24397. * - VertexBuffer.PositionKind
  24398. * - VertexBuffer.UVKind
  24399. * - VertexBuffer.UV2Kind
  24400. * - VertexBuffer.UV3Kind
  24401. * - VertexBuffer.UV4Kind
  24402. * - VertexBuffer.UV5Kind
  24403. * - VertexBuffer.UV6Kind
  24404. * - VertexBuffer.ColorKind
  24405. * - VertexBuffer.MatricesIndicesKind
  24406. * - VertexBuffer.MatricesIndicesExtraKind
  24407. * - VertexBuffer.MatricesWeightsKind
  24408. * - VertexBuffer.MatricesWeightsExtraKind
  24409. * @returns a boolean
  24410. */
  24411. isVertexBufferUpdatable(kind: string): boolean;
  24412. /**
  24413. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24414. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24415. * - VertexBuffer.PositionKind
  24416. * - VertexBuffer.NormalKind
  24417. * - VertexBuffer.UVKind
  24418. * - VertexBuffer.UV2Kind
  24419. * - VertexBuffer.UV3Kind
  24420. * - VertexBuffer.UV4Kind
  24421. * - VertexBuffer.UV5Kind
  24422. * - VertexBuffer.UV6Kind
  24423. * - VertexBuffer.ColorKind
  24424. * - VertexBuffer.MatricesIndicesKind
  24425. * - VertexBuffer.MatricesIndicesExtraKind
  24426. * - VertexBuffer.MatricesWeightsKind
  24427. * - VertexBuffer.MatricesWeightsExtraKind
  24428. * @returns an array of strings
  24429. */
  24430. getVerticesDataKinds(): string[];
  24431. /**
  24432. * Returns a positive integer : the total number of indices in this mesh geometry.
  24433. * @returns the numner of indices or zero if the mesh has no geometry.
  24434. */
  24435. getTotalIndices(): number;
  24436. /**
  24437. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24438. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  24439. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24440. * @returns the indices array or an empty array if the mesh has no geometry
  24441. */
  24442. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24443. readonly isBlocked: boolean;
  24444. /**
  24445. * Determine if the current mesh is ready to be rendered
  24446. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24447. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24448. * @returns true if all associated assets are ready (material, textures, shaders)
  24449. */
  24450. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24451. /**
  24452. * Gets a boolean indicating if the normals aren't to be recomputed on next mesh `positions` array update. This property is pertinent only for updatable parametric shapes.
  24453. */
  24454. readonly areNormalsFrozen: boolean;
  24455. /**
  24456. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc. It has no effect at all on other shapes. It prevents the mesh normals from being recomputed on next `positions` array update.
  24457. * @returns the current mesh
  24458. */
  24459. freezeNormals(): Mesh;
  24460. /**
  24461. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc. It has no effect at all on other shapes. It reactivates the mesh normals computation if it was previously frozen
  24462. * @returns the current mesh
  24463. */
  24464. unfreezeNormals(): Mesh;
  24465. /**
  24466. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24467. */
  24468. overridenInstanceCount: number;
  24469. /** @hidden */
  24470. _preActivate(): Mesh;
  24471. /** @hidden */
  24472. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24473. /** @hidden */
  24474. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24475. /**
  24476. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24477. * This means the mesh underlying bounding box and sphere are recomputed.
  24478. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24479. * @returns the current mesh
  24480. */
  24481. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24482. /** @hidden */
  24483. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24484. /**
  24485. * This function will subdivide the mesh into multiple submeshes
  24486. * @param count defines the expected number of submeshes
  24487. */
  24488. subdivide(count: number): void;
  24489. /**
  24490. * Copy a FloatArray into a specific associated vertex buffer
  24491. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24492. * - VertexBuffer.PositionKind
  24493. * - VertexBuffer.UVKind
  24494. * - VertexBuffer.UV2Kind
  24495. * - VertexBuffer.UV3Kind
  24496. * - VertexBuffer.UV4Kind
  24497. * - VertexBuffer.UV5Kind
  24498. * - VertexBuffer.UV6Kind
  24499. * - VertexBuffer.ColorKind
  24500. * - VertexBuffer.MatricesIndicesKind
  24501. * - VertexBuffer.MatricesIndicesExtraKind
  24502. * - VertexBuffer.MatricesWeightsKind
  24503. * - VertexBuffer.MatricesWeightsExtraKind
  24504. * @param data defines the data source
  24505. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24506. * @param stride defines the data stride size (can be null)
  24507. * @returns the current mesh
  24508. */
  24509. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24510. /**
  24511. * Flags an associated vertex buffer as updatable
  24512. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24513. * - VertexBuffer.PositionKind
  24514. * - VertexBuffer.UVKind
  24515. * - VertexBuffer.UV2Kind
  24516. * - VertexBuffer.UV3Kind
  24517. * - VertexBuffer.UV4Kind
  24518. * - VertexBuffer.UV5Kind
  24519. * - VertexBuffer.UV6Kind
  24520. * - VertexBuffer.ColorKind
  24521. * - VertexBuffer.MatricesIndicesKind
  24522. * - VertexBuffer.MatricesIndicesExtraKind
  24523. * - VertexBuffer.MatricesWeightsKind
  24524. * - VertexBuffer.MatricesWeightsExtraKind
  24525. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24526. */
  24527. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24528. /**
  24529. * Sets the mesh global Vertex Buffer
  24530. * @param buffer defines the buffer to use
  24531. * @returns the current mesh
  24532. */
  24533. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24534. /**
  24535. * Update a specific associated vertex buffer
  24536. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24537. * - VertexBuffer.PositionKind
  24538. * - VertexBuffer.UVKind
  24539. * - VertexBuffer.UV2Kind
  24540. * - VertexBuffer.UV3Kind
  24541. * - VertexBuffer.UV4Kind
  24542. * - VertexBuffer.UV5Kind
  24543. * - VertexBuffer.UV6Kind
  24544. * - VertexBuffer.ColorKind
  24545. * - VertexBuffer.MatricesIndicesKind
  24546. * - VertexBuffer.MatricesIndicesExtraKind
  24547. * - VertexBuffer.MatricesWeightsKind
  24548. * - VertexBuffer.MatricesWeightsExtraKind
  24549. * @param data defines the data source
  24550. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24551. * @param makeItUnique defines if the geometry associated with the mesh must be cloned to make the change only for this mesh (and not all meshes associated with the same geometry)
  24552. * @returns the current mesh
  24553. */
  24554. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24555. /**
  24556. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24557. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24558. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24559. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24560. * @returns the current mesh
  24561. */
  24562. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24563. /**
  24564. * Creates a un-shared specific occurence of the geometry for the mesh.
  24565. * @returns the current mesh
  24566. */
  24567. makeGeometryUnique(): Mesh;
  24568. /**
  24569. * Set the index buffer of this mesh
  24570. * @param indices defines the source data
  24571. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24572. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24573. * @returns the current mesh
  24574. */
  24575. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24576. /**
  24577. * Update the current index buffer
  24578. * @param indices defines the source data
  24579. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24580. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  24581. * @returns the current mesh
  24582. */
  24583. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24584. /**
  24585. * Invert the geometry to move from a right handed system to a left handed one.
  24586. * @returns the current mesh
  24587. */
  24588. toLeftHanded(): Mesh;
  24589. /** @hidden */
  24590. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24591. /** @hidden */
  24592. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24593. /**
  24594. * Registers for this mesh a javascript function called just before the rendering process
  24595. * @param func defines the function to call before rendering this mesh
  24596. * @returns the current mesh
  24597. */
  24598. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24599. /**
  24600. * Disposes a previously registered javascript function called before the rendering
  24601. * @param func defines the function to remove
  24602. * @returns the current mesh
  24603. */
  24604. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24605. /**
  24606. * Registers for this mesh a javascript function called just after the rendering is complete
  24607. * @param func defines the function to call after rendering this mesh
  24608. * @returns the current mesh
  24609. */
  24610. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24611. /**
  24612. * Disposes a previously registered javascript function called after the rendering.
  24613. * @param func defines the function to remove
  24614. * @returns the current mesh
  24615. */
  24616. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24617. /** @hidden */
  24618. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  24619. /** @hidden */
  24620. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24621. /** @hidden */
  24622. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24623. /** @hidden */
  24624. _rebuild(): void;
  24625. /** @hidden */
  24626. _freeze(): void;
  24627. /** @hidden */
  24628. _unFreeze(): void;
  24629. /**
  24630. * Triggers the draw call for the mesh. Usually, you don't need to call this method by your own because the mesh rendering is handled by the scene rendering manager
  24631. * @param subMesh defines the subMesh to render
  24632. * @param enableAlphaMode defines if alpha mode can be changed
  24633. * @returns the current mesh
  24634. */
  24635. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  24636. private _onBeforeDraw;
  24637. /**
  24638. * Renormalize the mesh and patch it up if there are no weights
  24639. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24640. * However in the case of zero weights then we set just a single influence to 1.
  24641. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24642. */
  24643. cleanMatrixWeights(): void;
  24644. private normalizeSkinFourWeights;
  24645. private normalizeSkinWeightsAndExtra;
  24646. /**
  24647. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24648. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24649. * the user know there was an issue with importing the mesh
  24650. * @returns a validation object with skinned, valid and report string
  24651. */
  24652. validateSkinning(): {
  24653. skinned: boolean;
  24654. valid: boolean;
  24655. report: string;
  24656. };
  24657. /** @hidden */
  24658. _checkDelayState(): Mesh;
  24659. private _queueLoad;
  24660. /**
  24661. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24662. * A mesh is in the frustum if its bounding box intersects the frustum
  24663. * @param frustumPlanes defines the frustum to test
  24664. * @returns true if the mesh is in the frustum planes
  24665. */
  24666. isInFrustum(frustumPlanes: Plane[]): boolean;
  24667. /**
  24668. * Sets the mesh material by the material or multiMaterial `id` property
  24669. * @param id is a string identifying the material or the multiMaterial
  24670. * @returns the current mesh
  24671. */
  24672. setMaterialByID(id: string): Mesh;
  24673. /**
  24674. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24675. * @returns an array of IAnimatable
  24676. */
  24677. getAnimatables(): IAnimatable[];
  24678. /**
  24679. * Modifies the mesh geometry according to the passed transformation matrix.
  24680. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24681. * The mesh normals are modified using the same transformation.
  24682. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24683. * @param transform defines the transform matrix to use
  24684. * @see http://doc.babylonjs.com/resources/baking_transformations
  24685. * @returns the current mesh
  24686. */
  24687. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24688. /**
  24689. * Modifies the mesh geometry according to its own current World Matrix.
  24690. * The mesh World Matrix is then reset.
  24691. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24692. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24693. * @see http://doc.babylonjs.com/resources/baking_transformations
  24694. * @returns the current mesh
  24695. */
  24696. bakeCurrentTransformIntoVertices(): Mesh;
  24697. /** @hidden */
  24698. readonly _positions: Nullable<Vector3[]>;
  24699. /** @hidden */
  24700. _resetPointsArrayCache(): Mesh;
  24701. /** @hidden */
  24702. _generatePointsArray(): boolean;
  24703. /**
  24704. * Returns a new Mesh object generated from the current mesh properties.
  24705. * This method must not get confused with createInstance()
  24706. * @param name is a string, the name given to the new mesh
  24707. * @param newParent can be any Node object (default `null`)
  24708. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24709. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24710. * @returns a new mesh
  24711. */
  24712. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  24713. /**
  24714. * Releases resources associated with this mesh.
  24715. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24716. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24717. */
  24718. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24719. /**
  24720. * Modifies the mesh geometry according to a displacement map.
  24721. * A displacement map is a colored image. Each pixel color value (actually a gradient computed from red, green, blue values) will give the displacement to apply to each mesh vertex.
  24722. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24723. * @param url is a string, the URL from the image file is to be downloaded.
  24724. * @param minHeight is the lower limit of the displacement.
  24725. * @param maxHeight is the upper limit of the displacement.
  24726. * @param onSuccess is an optional Javascript function to be called just after the mesh is modified. It is passed the modified mesh and must return nothing.
  24727. * @param uvOffset is an optional vector2 used to offset UV.
  24728. * @param uvScale is an optional vector2 used to scale UV.
  24729. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is useful to apply on a deserialized model for instance.
  24730. * @returns the Mesh.
  24731. */
  24732. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24733. /**
  24734. * Modifies the mesh geometry according to a displacementMap buffer.
  24735. * A displacement map is a colored image. Each pixel color value (actually a gradient computed from red, green, blue values) will give the displacement to apply to each mesh vertex.
  24736. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24737. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24738. * @param heightMapWidth is the width of the buffer image.
  24739. * @param heightMapHeight is the height of the buffer image.
  24740. * @param minHeight is the lower limit of the displacement.
  24741. * @param maxHeight is the upper limit of the displacement.
  24742. * @param onSuccess is an optional Javascript function to be called just after the mesh is modified. It is passed the modified mesh and must return nothing.
  24743. * @param uvOffset is an optional vector2 used to offset UV.
  24744. * @param uvScale is an optional vector2 used to scale UV.
  24745. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is useful to apply on a deserialized model for instance.
  24746. * @returns the Mesh.
  24747. */
  24748. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24749. /**
  24750. * Modify the mesh to get a flat shading rendering.
  24751. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24752. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24753. * @returns current mesh
  24754. */
  24755. convertToFlatShadedMesh(): Mesh;
  24756. /**
  24757. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24758. * In other words, more vertices, no more indices and a single bigger VBO.
  24759. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24760. * @returns current mesh
  24761. */
  24762. convertToUnIndexedMesh(): Mesh;
  24763. /**
  24764. * Inverses facet orientations.
  24765. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24766. * @param flipNormals will also inverts the normals
  24767. * @returns current mesh
  24768. */
  24769. flipFaces(flipNormals?: boolean): Mesh;
  24770. /**
  24771. * Increase the number of facets and hence vertices in a mesh
  24772. * Vertex normals are interpolated from existing vertex normals
  24773. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24774. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24775. */
  24776. increaseVertices(numberPerEdge: number): void;
  24777. /**
  24778. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24779. * This will undo any application of covertToFlatShadedMesh
  24780. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24781. */
  24782. forceSharedVertices(): void;
  24783. /** @hidden */
  24784. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24785. /** @hidden */
  24786. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24787. /**
  24788. * Creates a new InstancedMesh object from the mesh model.
  24789. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24790. * @param name defines the name of the new instance
  24791. * @returns a new InstancedMesh
  24792. */
  24793. createInstance(name: string): InstancedMesh;
  24794. /**
  24795. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24796. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24797. * @returns the current mesh
  24798. */
  24799. synchronizeInstances(): Mesh;
  24800. /**
  24801. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24802. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24803. * This should be used together with the simplification to avoid disappearing triangles.
  24804. * @param successCallback an optional success callback to be called after the optimization finished.
  24805. * @returns the current mesh
  24806. */
  24807. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24808. /**
  24809. * Serialize current mesh
  24810. * @param serializationObject defines the object which will receive the serialization data
  24811. */
  24812. serialize(serializationObject: any): void;
  24813. /** @hidden */
  24814. _syncGeometryWithMorphTargetManager(): void;
  24815. /** @hidden */
  24816. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24817. /**
  24818. * Returns a new Mesh object parsed from the source provided.
  24819. * @param parsedMesh is the source
  24820. * @param scene defines the hosting scene
  24821. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24822. * @returns a new Mesh
  24823. */
  24824. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24825. /**
  24826. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24827. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24828. * @param name defines the name of the mesh to create
  24829. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24830. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24831. * @param closePath creates a seam between the first and the last points of each path of the path array
  24832. * @param offset is taken in account only if the `pathArray` is containing a single path
  24833. * @param scene defines the hosting scene
  24834. * @param updatable defines if the mesh must be flagged as updatable
  24835. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24836. * @param instance defines an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#ribbon)
  24837. * @returns a new Mesh
  24838. */
  24839. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24840. /**
  24841. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24842. * @param name defines the name of the mesh to create
  24843. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24844. * @param tessellation sets the number of polygon sides (positive integer, default 64). So a tessellation valued to 3 will build a triangle, to 4 a square, etc
  24845. * @param scene defines the hosting scene
  24846. * @param updatable defines if the mesh must be flagged as updatable
  24847. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24848. * @returns a new Mesh
  24849. */
  24850. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24851. /**
  24852. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24853. * @param name defines the name of the mesh to create
  24854. * @param size sets the size (float) of each box side (default 1)
  24855. * @param scene defines the hosting scene
  24856. * @param updatable defines if the mesh must be flagged as updatable
  24857. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24858. * @returns a new Mesh
  24859. */
  24860. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24861. /**
  24862. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24863. * @param name defines the name of the mesh to create
  24864. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24865. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24866. * @param scene defines the hosting scene
  24867. * @param updatable defines if the mesh must be flagged as updatable
  24868. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24869. * @returns a new Mesh
  24870. */
  24871. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24872. /**
  24873. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24874. * @param name defines the name of the mesh to create
  24875. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24876. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24877. * @param scene defines the hosting scene
  24878. * @returns a new Mesh
  24879. */
  24880. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24881. /**
  24882. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24883. * @param name defines the name of the mesh to create
  24884. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24885. * @param diameterTop set the top cap diameter (floats, default 1)
  24886. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24887. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24888. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24889. * @param scene defines the hosting scene
  24890. * @param updatable defines if the mesh must be flagged as updatable
  24891. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24892. * @returns a new Mesh
  24893. */
  24894. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24895. /**
  24896. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24897. * @param name defines the name of the mesh to create
  24898. * @param diameter sets the diameter size (float) of the torus (default 1)
  24899. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24900. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24901. * @param scene defines the hosting scene
  24902. * @param updatable defines if the mesh must be flagged as updatable
  24903. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24904. * @returns a new Mesh
  24905. */
  24906. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24907. /**
  24908. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24909. * @param name defines the name of the mesh to create
  24910. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24911. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24912. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24913. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24914. * @param p the number of windings on X axis (positive integers, default 2)
  24915. * @param q the number of windings on Y axis (positive integers, default 3)
  24916. * @param scene defines the hosting scene
  24917. * @param updatable defines if the mesh must be flagged as updatable
  24918. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24919. * @returns a new Mesh
  24920. */
  24921. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24922. /**
  24923. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24924. * @param name defines the name of the mesh to create
  24925. * @param points is an array successive Vector3
  24926. * @param scene defines the hosting scene
  24927. * @param updatable defines if the mesh must be flagged as updatable
  24928. * @param instance is an instance of an existing LineMesh object to be updated with the passed `points` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#lines-and-dashedlines).
  24929. * @returns a new Mesh
  24930. */
  24931. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24932. /**
  24933. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24934. * @param name defines the name of the mesh to create
  24935. * @param points is an array successive Vector3
  24936. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24937. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24938. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24939. * @param scene defines the hosting scene
  24940. * @param updatable defines if the mesh must be flagged as updatable
  24941. * @param instance is an instance of an existing LineMesh object to be updated with the passed `points` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#lines-and-dashedlines)
  24942. * @returns a new Mesh
  24943. */
  24944. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24945. /**
  24946. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24947. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24948. * The parameter `shape` is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors.
  24949. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24950. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24951. * Remember you can only change the shape positions, not their number when updating a polygon.
  24952. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24953. * @param name defines the name of the mesh to create
  24954. * @param shape is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors
  24955. * @param scene defines the hosting scene
  24956. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24957. * @param updatable defines if the mesh must be flagged as updatable
  24958. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24959. * @param earcutInjection can be used to inject your own earcut reference
  24960. * @returns a new Mesh
  24961. */
  24962. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24963. /**
  24964. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24965. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24966. * @param name defines the name of the mesh to create
  24967. * @param shape is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors
  24968. * @param depth defines the height of extrusion
  24969. * @param scene defines the hosting scene
  24970. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24971. * @param updatable defines if the mesh must be flagged as updatable
  24972. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24973. * @param earcutInjection can be used to inject your own earcut reference
  24974. * @returns a new Mesh
  24975. */
  24976. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24977. /**
  24978. * Creates an extruded shape mesh.
  24979. * The extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters. Please consider using the same method from the MeshBuilder class instead
  24980. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24981. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24982. * @param name defines the name of the mesh to create
  24983. * @param shape is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis
  24984. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24985. * @param scale is the value to scale the shape
  24986. * @param rotation is the angle value to rotate the shape each step (each path point), from the former step (so rotation added each step) along the curve
  24987. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  24988. * @param scene defines the hosting scene
  24989. * @param updatable defines if the mesh must be flagged as updatable
  24990. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24991. * @param instance is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#extruded-shape)
  24992. * @returns a new Mesh
  24993. */
  24994. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24995. /**
  24996. * Creates an custom extruded shape mesh.
  24997. * The custom extrusion is a parametric shape.
  24998. * It has no predefined shape. Its final shape will depend on the input parameters.
  24999. * Please consider using the same method from the MeshBuilder class instead
  25000. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25001. * @param name defines the name of the mesh to create
  25002. * @param shape is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis
  25003. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25004. * @param scaleFunction is a custom Javascript function called on each path point
  25005. * @param rotationFunction is a custom Javascript function called on each path point
  25006. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25007. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25008. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  25009. * @param scene defines the hosting scene
  25010. * @param updatable defines if the mesh must be flagged as updatable
  25011. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25012. * @param instance is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters (http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape)
  25013. * @returns a new Mesh
  25014. */
  25015. static ExtrudeShapeCustom(name: string, shape: Vector3[], path: Vector3[], scaleFunction: Function, rotationFunction: Function, ribbonCloseArray: boolean, ribbonClosePath: boolean, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25016. /**
  25017. * Creates lathe mesh.
  25018. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25019. * Please consider using the same method from the MeshBuilder class instead
  25020. * @param name defines the name of the mesh to create
  25021. * @param shape is a required array of successive Vector3. This array depicts the shape to be rotated in its local space : the shape must be designed in the xOy plane and will be rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero
  25022. * @param radius is the radius value of the lathe
  25023. * @param tessellation is the side number of the lathe.
  25024. * @param scene defines the hosting scene
  25025. * @param updatable defines if the mesh must be flagged as updatable
  25026. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25027. * @returns a new Mesh
  25028. */
  25029. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25030. /**
  25031. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25032. * @param name defines the name of the mesh to create
  25033. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25034. * @param scene defines the hosting scene
  25035. * @param updatable defines if the mesh must be flagged as updatable
  25036. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25037. * @returns a new Mesh
  25038. */
  25039. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25040. /**
  25041. * Creates a ground mesh.
  25042. * Please consider using the same method from the MeshBuilder class instead
  25043. * @param name defines the name of the mesh to create
  25044. * @param width set the width of the ground
  25045. * @param height set the height of the ground
  25046. * @param subdivisions sets the number of subdivisions per side
  25047. * @param scene defines the hosting scene
  25048. * @param updatable defines if the mesh must be flagged as updatable
  25049. * @returns a new Mesh
  25050. */
  25051. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25052. /**
  25053. * Creates a tiled ground mesh.
  25054. * Please consider using the same method from the MeshBuilder class instead
  25055. * @param name defines the name of the mesh to create
  25056. * @param xmin set the ground minimum X coordinate
  25057. * @param zmin set the ground minimum Y coordinate
  25058. * @param xmax set the ground maximum X coordinate
  25059. * @param zmax set the ground maximum Z coordinate
  25060. * @param subdivisions is an object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the numbers of subdivisions on the ground width and height. Each subdivision is called a tile
  25061. * @param precision is an object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the numbers of subdivisions on the ground width and height of each tile
  25062. * @param scene defines the hosting scene
  25063. * @param updatable defines if the mesh must be flagged as updatable
  25064. * @returns a new Mesh
  25065. */
  25066. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25067. w: number;
  25068. h: number;
  25069. }, precision: {
  25070. w: number;
  25071. h: number;
  25072. }, scene: Scene, updatable?: boolean): Mesh;
  25073. /**
  25074. * Creates a ground mesh from a height map.
  25075. * Please consider using the same method from the MeshBuilder class instead
  25076. * @see http://doc.babylonjs.com/babylon101/height_map
  25077. * @param name defines the name of the mesh to create
  25078. * @param url sets the URL of the height map image resource
  25079. * @param width set the ground width size
  25080. * @param height set the ground height size
  25081. * @param subdivisions sets the number of subdivision per side
  25082. * @param minHeight is the minimum altitude on the ground
  25083. * @param maxHeight is the maximum altitude on the ground
  25084. * @param scene defines the hosting scene
  25085. * @param updatable defines if the mesh must be flagged as updatable
  25086. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25087. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25088. * @returns a new Mesh
  25089. */
  25090. static CreateGroundFromHeightMap(name: string, url: string, width: number, height: number, subdivisions: number, minHeight: number, maxHeight: number, scene: Scene, updatable?: boolean, onReady?: (mesh: GroundMesh) => void, alphaFilter?: number): GroundMesh;
  25091. /**
  25092. * Creates a tube mesh.
  25093. * The tube is a parametric shape.
  25094. * It has no predefined shape. Its final shape will depend on the input parameters.
  25095. * Please consider using the same method from the MeshBuilder class instead
  25096. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25097. * @param name defines the name of the mesh to create
  25098. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25099. * @param radius sets the tube radius size
  25100. * @param tessellation is the number of sides on the tubular surface
  25101. * @param radiusFunction is a custom function. If it is not null, it overwrittes the parameter `radius`. This function is called on each point of the tube path and is passed the index `i` of the i-th point and the distance of this point from the first point of the path
  25102. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  25103. * @param scene defines the hosting scene
  25104. * @param updatable defines if the mesh must be flagged as updatable
  25105. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25106. * @param instance is an instance of an existing Tube object to be updated with the passed `pathArray` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#tube)
  25107. * @returns a new Mesh
  25108. */
  25109. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25110. (i: number, distance: number): number;
  25111. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25112. /**
  25113. * Creates a polyhedron mesh.
  25114. * Please consider using the same method from the MeshBuilder class instead.
  25115. * * The parameter `type` (positive integer, max 14, default 0) sets the polyhedron type to build among the 15 embbeded types. Please refer to the type sheet in the tutorial to choose the wanted type
  25116. * * The parameter `size` (positive float, default 1) sets the polygon size
  25117. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25118. * * You can build other polyhedron types than the 15 embbeded ones by setting the parameter `custom` (`polyhedronObject`, default null). If you set the parameter `custom`, this overwrittes the parameter `type`
  25119. * * A `polyhedronObject` is a formatted javascript object. You'll find a full file with pre-set polyhedra here : https://github.com/BabylonJS/Extensions/tree/master/Polyhedron
  25120. * * You can set the color and the UV of each side of the polyhedron with the parameters `faceColors` (Color4, default `(1, 1, 1, 1)`) and faceUV (Vector4, default `(0, 0, 1, 1)`)
  25121. * * To understand how to set `faceUV` or `faceColors`, please read this by considering the right number of faces of your polyhedron, instead of only 6 for the box : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  25122. * * The parameter `flat` (boolean, default true). If set to false, it gives the polyhedron a single global face, so less vertices and shared normals. In this case, `faceColors` and `faceUV` are ignored
  25123. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25124. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  25125. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25126. * @param name defines the name of the mesh to create
  25127. * @param options defines the options used to create the mesh
  25128. * @param scene defines the hosting scene
  25129. * @returns a new Mesh
  25130. */
  25131. static CreatePolyhedron(name: string, options: {
  25132. type?: number;
  25133. size?: number;
  25134. sizeX?: number;
  25135. sizeY?: number;
  25136. sizeZ?: number;
  25137. custom?: any;
  25138. faceUV?: Vector4[];
  25139. faceColors?: Color4[];
  25140. updatable?: boolean;
  25141. sideOrientation?: number;
  25142. }, scene: Scene): Mesh;
  25143. /**
  25144. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25145. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25146. * * You can set some different icosphere dimensions, for instance to build an ellipsoid, by using the parameters `radiusX`, `radiusY` and `radiusZ` (all by default have the same value than `radius`)
  25147. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25148. * * The parameter `flat` (boolean, default true) gives each side its own normals. Set it to false to get a smooth continuous light reflection on the surface
  25149. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25150. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  25151. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25152. * @param name defines the name of the mesh
  25153. * @param options defines the options used to create the mesh
  25154. * @param scene defines the hosting scene
  25155. * @returns a new Mesh
  25156. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25157. */
  25158. static CreateIcoSphere(name: string, options: {
  25159. radius?: number;
  25160. flat?: boolean;
  25161. subdivisions?: number;
  25162. sideOrientation?: number;
  25163. updatable?: boolean;
  25164. }, scene: Scene): Mesh;
  25165. /**
  25166. * Creates a decal mesh.
  25167. * Please consider using the same method from the MeshBuilder class instead.
  25168. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25169. * @param name defines the name of the mesh
  25170. * @param sourceMesh defines the mesh receiving the decal
  25171. * @param position sets the position of the decal in world coordinates
  25172. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25173. * @param size sets the decal scaling
  25174. * @param angle sets the angle to rotate the decal
  25175. * @returns a new Mesh
  25176. */
  25177. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25178. /**
  25179. * Prepare internal position array for software CPU skinning
  25180. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25181. */
  25182. setPositionsForCPUSkinning(): Float32Array;
  25183. /**
  25184. * Prepare internal normal array for software CPU skinning
  25185. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25186. */
  25187. setNormalsForCPUSkinning(): Float32Array;
  25188. /**
  25189. * Updates the vertex buffer by applying transformation from the bones
  25190. * @param skeleton defines the skeleton to apply to current mesh
  25191. * @returns the current mesh
  25192. */
  25193. applySkeleton(skeleton: Skeleton): Mesh;
  25194. /**
  25195. * Returns an object containing a min and max Vector3 which are the minimum and maximum vectors of each mesh bounding box from the passed array, in the world coordinates
  25196. * @param meshes defines the list of meshes to scan
  25197. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25198. */
  25199. static MinMax(meshes: AbstractMesh[]): {
  25200. min: Vector3;
  25201. max: Vector3;
  25202. };
  25203. /**
  25204. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25205. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25206. * @returns a vector3
  25207. */
  25208. static Center(meshesOrMinMaxVector: {
  25209. min: Vector3;
  25210. max: Vector3;
  25211. } | AbstractMesh[]): Vector3;
  25212. /**
  25213. * Merge the array of meshes into a single mesh for performance reasons.
  25214. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25215. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25216. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25217. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25218. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25219. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25220. * @returns a new mesh
  25221. */
  25222. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25223. /** @hidden */
  25224. addInstance(instance: InstancedMesh): void;
  25225. /** @hidden */
  25226. removeInstance(instance: InstancedMesh): void;
  25227. }
  25228. }
  25229. declare module "babylonjs/Cameras/camera" {
  25230. import { SmartArray } from "babylonjs/Misc/smartArray";
  25231. import { Observable } from "babylonjs/Misc/observable";
  25232. import { Nullable } from "babylonjs/types";
  25233. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25234. import { Scene } from "babylonjs/scene";
  25235. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  25236. import { Node } from "babylonjs/node";
  25237. import { Mesh } from "babylonjs/Meshes/mesh";
  25238. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25239. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25240. import { Viewport } from "babylonjs/Maths/math.viewport";
  25241. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25242. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25243. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25244. import { Ray } from "babylonjs/Culling/ray";
  25245. /**
  25246. * This is the base class of all the camera used in the application.
  25247. * @see http://doc.babylonjs.com/features/cameras
  25248. */
  25249. export class Camera extends Node {
  25250. /** @hidden */
  25251. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25252. /**
  25253. * This is the default projection mode used by the cameras.
  25254. * It helps recreating a feeling of perspective and better appreciate depth.
  25255. * This is the best way to simulate real life cameras.
  25256. */
  25257. static readonly PERSPECTIVE_CAMERA: number;
  25258. /**
  25259. * This helps creating camera with an orthographic mode.
  25260. * Orthographic is commonly used in engineering as a means to produce object specifications that communicate dimensions unambiguously, each line of 1 unit length (cm, meter..whatever) will appear to have the same length everywhere on the drawing. This allows the drafter to dimension only a subset of lines and let the reader know that other lines of that length on the drawing are also that length in reality. Every parallel line in the drawing is also parallel in the object.
  25261. */
  25262. static readonly ORTHOGRAPHIC_CAMERA: number;
  25263. /**
  25264. * This is the default FOV mode for perspective cameras.
  25265. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25266. */
  25267. static readonly FOVMODE_VERTICAL_FIXED: number;
  25268. /**
  25269. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25270. */
  25271. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25272. /**
  25273. * This specifies ther is no need for a camera rig.
  25274. * Basically only one eye is rendered corresponding to the camera.
  25275. */
  25276. static readonly RIG_MODE_NONE: number;
  25277. /**
  25278. * Simulates a camera Rig with one blue eye and one red eye.
  25279. * This can be use with 3d blue and red glasses.
  25280. */
  25281. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25282. /**
  25283. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25284. */
  25285. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25286. /**
  25287. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25288. */
  25289. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25290. /**
  25291. * Defines that both eyes of the camera will be rendered over under each other.
  25292. */
  25293. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25294. /**
  25295. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25296. */
  25297. static readonly RIG_MODE_VR: number;
  25298. /**
  25299. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25300. */
  25301. static readonly RIG_MODE_WEBVR: number;
  25302. /**
  25303. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25304. */
  25305. static readonly RIG_MODE_CUSTOM: number;
  25306. /**
  25307. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25308. */
  25309. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25310. /**
  25311. * Define the input manager associated with the camera.
  25312. */
  25313. inputs: CameraInputsManager<Camera>;
  25314. /** @hidden */
  25315. _position: Vector3;
  25316. /**
  25317. * Define the current local position of the camera in the scene
  25318. */
  25319. position: Vector3;
  25320. /**
  25321. * The vector the camera should consider as up.
  25322. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25323. */
  25324. upVector: Vector3;
  25325. /**
  25326. * Define the current limit on the left side for an orthographic camera
  25327. * In scene unit
  25328. */
  25329. orthoLeft: Nullable<number>;
  25330. /**
  25331. * Define the current limit on the right side for an orthographic camera
  25332. * In scene unit
  25333. */
  25334. orthoRight: Nullable<number>;
  25335. /**
  25336. * Define the current limit on the bottom side for an orthographic camera
  25337. * In scene unit
  25338. */
  25339. orthoBottom: Nullable<number>;
  25340. /**
  25341. * Define the current limit on the top side for an orthographic camera
  25342. * In scene unit
  25343. */
  25344. orthoTop: Nullable<number>;
  25345. /**
  25346. * Field Of View is set in Radians. (default is 0.8)
  25347. */
  25348. fov: number;
  25349. /**
  25350. * Define the minimum distance the camera can see from.
  25351. * This is important to note that the depth buffer are not infinite and the closer it starts
  25352. * the more your scene might encounter depth fighting issue.
  25353. */
  25354. minZ: number;
  25355. /**
  25356. * Define the maximum distance the camera can see to.
  25357. * This is important to note that the depth buffer are not infinite and the further it end
  25358. * the more your scene might encounter depth fighting issue.
  25359. */
  25360. maxZ: number;
  25361. /**
  25362. * Define the default inertia of the camera.
  25363. * This helps giving a smooth feeling to the camera movement.
  25364. */
  25365. inertia: number;
  25366. /**
  25367. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25368. */
  25369. mode: number;
  25370. /**
  25371. * Define wether the camera is intermediate.
  25372. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25373. */
  25374. isIntermediate: boolean;
  25375. /**
  25376. * Define the viewport of the camera.
  25377. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25378. */
  25379. viewport: Viewport;
  25380. /**
  25381. * Restricts the camera to viewing objects with the same layerMask.
  25382. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25383. */
  25384. layerMask: number;
  25385. /**
  25386. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25387. */
  25388. fovMode: number;
  25389. /**
  25390. * Rig mode of the camera.
  25391. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25392. * This is normally controlled byt the camera themselves as internal use.
  25393. */
  25394. cameraRigMode: number;
  25395. /**
  25396. * Defines the distance between both "eyes" in case of a RIG
  25397. */
  25398. interaxialDistance: number;
  25399. /**
  25400. * Defines if stereoscopic rendering is done side by side or over under.
  25401. */
  25402. isStereoscopicSideBySide: boolean;
  25403. /**
  25404. * Defines the list of custom render target which are rendered to and then used as the input to this camera's render. Eg. display another camera view on a TV in the main scene
  25405. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25406. * else in the scene. (Eg. security camera)
  25407. *
  25408. * To change the final output target of the camera, camera.outputRenderTarget should be used instead (eg. webXR renders to a render target corrisponding to an HMD)
  25409. */
  25410. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  25411. /**
  25412. * When set, the camera will render to this render target instead of the default canvas
  25413. *
  25414. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25415. */
  25416. outputRenderTarget: Nullable<RenderTargetTexture>;
  25417. /**
  25418. * Observable triggered when the camera view matrix has changed.
  25419. */
  25420. onViewMatrixChangedObservable: Observable<Camera>;
  25421. /**
  25422. * Observable triggered when the camera Projection matrix has changed.
  25423. */
  25424. onProjectionMatrixChangedObservable: Observable<Camera>;
  25425. /**
  25426. * Observable triggered when the inputs have been processed.
  25427. */
  25428. onAfterCheckInputsObservable: Observable<Camera>;
  25429. /**
  25430. * Observable triggered when reset has been called and applied to the camera.
  25431. */
  25432. onRestoreStateObservable: Observable<Camera>;
  25433. /** @hidden */
  25434. _cameraRigParams: any;
  25435. /** @hidden */
  25436. _rigCameras: Camera[];
  25437. /** @hidden */
  25438. _rigPostProcess: Nullable<PostProcess>;
  25439. protected _webvrViewMatrix: Matrix;
  25440. /** @hidden */
  25441. _skipRendering: boolean;
  25442. /** @hidden */
  25443. _projectionMatrix: Matrix;
  25444. /** @hidden */
  25445. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  25446. /** @hidden */
  25447. _activeMeshes: SmartArray<AbstractMesh>;
  25448. protected _globalPosition: Vector3;
  25449. /** @hidden */
  25450. _computedViewMatrix: Matrix;
  25451. private _doNotComputeProjectionMatrix;
  25452. private _transformMatrix;
  25453. private _frustumPlanes;
  25454. private _refreshFrustumPlanes;
  25455. private _storedFov;
  25456. private _stateStored;
  25457. /**
  25458. * Instantiates a new camera object.
  25459. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25460. * @see http://doc.babylonjs.com/features/cameras
  25461. * @param name Defines the name of the camera in the scene
  25462. * @param position Defines the position of the camera
  25463. * @param scene Defines the scene the camera belongs too
  25464. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25465. */
  25466. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25467. /**
  25468. * Store current camera state (fov, position, etc..)
  25469. * @returns the camera
  25470. */
  25471. storeState(): Camera;
  25472. /**
  25473. * Restores the camera state values if it has been stored. You must call storeState() first
  25474. */
  25475. protected _restoreStateValues(): boolean;
  25476. /**
  25477. * Restored camera state. You must call storeState() first.
  25478. * @returns true if restored and false otherwise
  25479. */
  25480. restoreState(): boolean;
  25481. /**
  25482. * Gets the class name of the camera.
  25483. * @returns the class name
  25484. */
  25485. getClassName(): string;
  25486. /** @hidden */
  25487. readonly _isCamera: boolean;
  25488. /**
  25489. * Gets a string representation of the camera useful for debug purpose.
  25490. * @param fullDetails Defines that a more verboe level of logging is required
  25491. * @returns the string representation
  25492. */
  25493. toString(fullDetails?: boolean): string;
  25494. /**
  25495. * Gets the current world space position of the camera.
  25496. */
  25497. readonly globalPosition: Vector3;
  25498. /**
  25499. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25500. * @returns the active meshe list
  25501. */
  25502. getActiveMeshes(): SmartArray<AbstractMesh>;
  25503. /**
  25504. * Check wether a mesh is part of the current active mesh list of the camera
  25505. * @param mesh Defines the mesh to check
  25506. * @returns true if active, false otherwise
  25507. */
  25508. isActiveMesh(mesh: Mesh): boolean;
  25509. /**
  25510. * Is this camera ready to be used/rendered
  25511. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25512. * @return true if the camera is ready
  25513. */
  25514. isReady(completeCheck?: boolean): boolean;
  25515. /** @hidden */
  25516. _initCache(): void;
  25517. /** @hidden */
  25518. _updateCache(ignoreParentClass?: boolean): void;
  25519. /** @hidden */
  25520. _isSynchronized(): boolean;
  25521. /** @hidden */
  25522. _isSynchronizedViewMatrix(): boolean;
  25523. /** @hidden */
  25524. _isSynchronizedProjectionMatrix(): boolean;
  25525. /**
  25526. * Attach the input controls to a specific dom element to get the input from.
  25527. * @param element Defines the element the controls should be listened from
  25528. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25529. */
  25530. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25531. /**
  25532. * Detach the current controls from the specified dom element.
  25533. * @param element Defines the element to stop listening the inputs from
  25534. */
  25535. detachControl(element: HTMLElement): void;
  25536. /**
  25537. * Update the camera state according to the different inputs gathered during the frame.
  25538. */
  25539. update(): void;
  25540. /** @hidden */
  25541. _checkInputs(): void;
  25542. /** @hidden */
  25543. readonly rigCameras: Camera[];
  25544. /**
  25545. * Gets the post process used by the rig cameras
  25546. */
  25547. readonly rigPostProcess: Nullable<PostProcess>;
  25548. /**
  25549. * Internal, gets the first post proces.
  25550. * @returns the first post process to be run on this camera.
  25551. */
  25552. _getFirstPostProcess(): Nullable<PostProcess>;
  25553. private _cascadePostProcessesToRigCams;
  25554. /**
  25555. * Attach a post process to the camera.
  25556. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25557. * @param postProcess The post process to attach to the camera
  25558. * @param insertAt The position of the post process in case several of them are in use in the scene
  25559. * @returns the position the post process has been inserted at
  25560. */
  25561. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25562. /**
  25563. * Detach a post process to the camera.
  25564. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25565. * @param postProcess The post process to detach from the camera
  25566. */
  25567. detachPostProcess(postProcess: PostProcess): void;
  25568. /**
  25569. * Gets the current world matrix of the camera
  25570. */
  25571. getWorldMatrix(): Matrix;
  25572. /** @hidden */
  25573. _getViewMatrix(): Matrix;
  25574. /**
  25575. * Gets the current view matrix of the camera.
  25576. * @param force forces the camera to recompute the matrix without looking at the cached state
  25577. * @returns the view matrix
  25578. */
  25579. getViewMatrix(force?: boolean): Matrix;
  25580. /**
  25581. * Freeze the projection matrix.
  25582. * It will prevent the cache check of the camera projection compute and can speed up perf
  25583. * if no parameter of the camera are meant to change
  25584. * @param projection Defines manually a projection if necessary
  25585. */
  25586. freezeProjectionMatrix(projection?: Matrix): void;
  25587. /**
  25588. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25589. */
  25590. unfreezeProjectionMatrix(): void;
  25591. /**
  25592. * Gets the current projection matrix of the camera.
  25593. * @param force forces the camera to recompute the matrix without looking at the cached state
  25594. * @returns the projection matrix
  25595. */
  25596. getProjectionMatrix(force?: boolean): Matrix;
  25597. /**
  25598. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25599. * @returns a Matrix
  25600. */
  25601. getTransformationMatrix(): Matrix;
  25602. private _updateFrustumPlanes;
  25603. /**
  25604. * Checks if a cullable object (mesh...) is in the camera frustum
  25605. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25606. * @param target The object to check
  25607. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25608. * @returns true if the object is in frustum otherwise false
  25609. */
  25610. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25611. /**
  25612. * Checks if a cullable object (mesh...) is in the camera frustum
  25613. * Unlike isInFrustum this cheks the full bounding box
  25614. * @param target The object to check
  25615. * @returns true if the object is in frustum otherwise false
  25616. */
  25617. isCompletelyInFrustum(target: ICullable): boolean;
  25618. /**
  25619. * Gets a ray in the forward direction from the camera.
  25620. * @param length Defines the length of the ray to create
  25621. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25622. * @param origin Defines the start point of the ray which defaults to the camera position
  25623. * @returns the forward ray
  25624. */
  25625. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25626. /**
  25627. * Releases resources associated with this node.
  25628. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25629. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25630. */
  25631. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25632. /** @hidden */
  25633. _isLeftCamera: boolean;
  25634. /**
  25635. * Gets the left camera of a rig setup in case of Rigged Camera
  25636. */
  25637. readonly isLeftCamera: boolean;
  25638. /** @hidden */
  25639. _isRightCamera: boolean;
  25640. /**
  25641. * Gets the right camera of a rig setup in case of Rigged Camera
  25642. */
  25643. readonly isRightCamera: boolean;
  25644. /**
  25645. * Gets the left camera of a rig setup in case of Rigged Camera
  25646. */
  25647. readonly leftCamera: Nullable<FreeCamera>;
  25648. /**
  25649. * Gets the right camera of a rig setup in case of Rigged Camera
  25650. */
  25651. readonly rightCamera: Nullable<FreeCamera>;
  25652. /**
  25653. * Gets the left camera target of a rig setup in case of Rigged Camera
  25654. * @returns the target position
  25655. */
  25656. getLeftTarget(): Nullable<Vector3>;
  25657. /**
  25658. * Gets the right camera target of a rig setup in case of Rigged Camera
  25659. * @returns the target position
  25660. */
  25661. getRightTarget(): Nullable<Vector3>;
  25662. /**
  25663. * @hidden
  25664. */
  25665. setCameraRigMode(mode: number, rigParams: any): void;
  25666. /** @hidden */
  25667. static _setStereoscopicRigMode(camera: Camera): void;
  25668. /** @hidden */
  25669. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25670. /** @hidden */
  25671. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25672. /** @hidden */
  25673. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25674. /** @hidden */
  25675. _getVRProjectionMatrix(): Matrix;
  25676. protected _updateCameraRotationMatrix(): void;
  25677. protected _updateWebVRCameraRotationMatrix(): void;
  25678. /**
  25679. * This function MUST be overwritten by the different WebVR cameras available.
  25680. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25681. * @hidden
  25682. */
  25683. _getWebVRProjectionMatrix(): Matrix;
  25684. /**
  25685. * This function MUST be overwritten by the different WebVR cameras available.
  25686. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25687. * @hidden
  25688. */
  25689. _getWebVRViewMatrix(): Matrix;
  25690. /** @hidden */
  25691. setCameraRigParameter(name: string, value: any): void;
  25692. /**
  25693. * needs to be overridden by children so sub has required properties to be copied
  25694. * @hidden
  25695. */
  25696. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25697. /**
  25698. * May need to be overridden by children
  25699. * @hidden
  25700. */
  25701. _updateRigCameras(): void;
  25702. /** @hidden */
  25703. _setupInputs(): void;
  25704. /**
  25705. * Serialiaze the camera setup to a json represention
  25706. * @returns the JSON representation
  25707. */
  25708. serialize(): any;
  25709. /**
  25710. * Clones the current camera.
  25711. * @param name The cloned camera name
  25712. * @returns the cloned camera
  25713. */
  25714. clone(name: string): Camera;
  25715. /**
  25716. * Gets the direction of the camera relative to a given local axis.
  25717. * @param localAxis Defines the reference axis to provide a relative direction.
  25718. * @return the direction
  25719. */
  25720. getDirection(localAxis: Vector3): Vector3;
  25721. /**
  25722. * Returns the current camera absolute rotation
  25723. */
  25724. readonly absoluteRotation: Quaternion;
  25725. /**
  25726. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25727. * @param localAxis Defines the reference axis to provide a relative direction.
  25728. * @param result Defines the vector to store the result in
  25729. */
  25730. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25731. /**
  25732. * Gets a camera constructor for a given camera type
  25733. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25734. * @param name The name of the camera the result will be able to instantiate
  25735. * @param scene The scene the result will construct the camera in
  25736. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25737. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25738. * @returns a factory method to construc the camera
  25739. */
  25740. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25741. /**
  25742. * Compute the world matrix of the camera.
  25743. * @returns the camera workd matrix
  25744. */
  25745. computeWorldMatrix(): Matrix;
  25746. /**
  25747. * Parse a JSON and creates the camera from the parsed information
  25748. * @param parsedCamera The JSON to parse
  25749. * @param scene The scene to instantiate the camera in
  25750. * @returns the newly constructed camera
  25751. */
  25752. static Parse(parsedCamera: any, scene: Scene): Camera;
  25753. }
  25754. }
  25755. declare module "babylonjs/Meshes/Builders/discBuilder" {
  25756. import { Nullable } from "babylonjs/types";
  25757. import { Scene } from "babylonjs/scene";
  25758. import { Vector4 } from "babylonjs/Maths/math.vector";
  25759. import { Mesh } from "babylonjs/Meshes/mesh";
  25760. /**
  25761. * Class containing static functions to help procedurally build meshes
  25762. */
  25763. export class DiscBuilder {
  25764. /**
  25765. * Creates a plane polygonal mesh. By default, this is a disc
  25766. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25767. * * The parameter `tessellation` sets the number of polygon sides (positive integer, default 64). So a tessellation valued to 3 will build a triangle, to 4 a square, etc
  25768. * * You can create an unclosed polygon with the parameter `arc` (positive float, default 1), valued between 0 and 1, what is the ratio of the circumference : 2 x PI x ratio
  25769. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25770. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  25771. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25772. * @param name defines the name of the mesh
  25773. * @param options defines the options used to create the mesh
  25774. * @param scene defines the hosting scene
  25775. * @returns the plane polygonal mesh
  25776. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25777. */
  25778. static CreateDisc(name: string, options: {
  25779. radius?: number;
  25780. tessellation?: number;
  25781. arc?: number;
  25782. updatable?: boolean;
  25783. sideOrientation?: number;
  25784. frontUVs?: Vector4;
  25785. backUVs?: Vector4;
  25786. }, scene?: Nullable<Scene>): Mesh;
  25787. }
  25788. }
  25789. declare module "babylonjs/Particles/solidParticleSystem" {
  25790. import { Vector3 } from "babylonjs/Maths/math.vector";
  25791. import { Mesh } from "babylonjs/Meshes/mesh";
  25792. import { Scene, IDisposable } from "babylonjs/scene";
  25793. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  25794. /**
  25795. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  25796. *As it is just a mesh, the SPS has all the same properties than any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  25797. * The SPS is also a particle system. It provides some methods to manage the particles.
  25798. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  25799. *
  25800. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  25801. */
  25802. export class SolidParticleSystem implements IDisposable {
  25803. /**
  25804. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  25805. * Example : var p = SPS.particles[i];
  25806. */
  25807. particles: SolidParticle[];
  25808. /**
  25809. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  25810. */
  25811. nbParticles: number;
  25812. /**
  25813. * If the particles must ever face the camera (default false). Useful for planar particles.
  25814. */
  25815. billboard: boolean;
  25816. /**
  25817. * Recompute normals when adding a shape
  25818. */
  25819. recomputeNormals: boolean;
  25820. /**
  25821. * This a counter ofr your own usage. It's not set by any SPS functions.
  25822. */
  25823. counter: number;
  25824. /**
  25825. * The SPS name. This name is also given to the underlying mesh.
  25826. */
  25827. name: string;
  25828. /**
  25829. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  25830. */
  25831. mesh: Mesh;
  25832. /**
  25833. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  25834. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  25835. */
  25836. vars: any;
  25837. /**
  25838. * This array is populated when the SPS is set as 'pickable'.
  25839. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  25840. * Each element of this array is an object `{idx: int, faceId: int}`.
  25841. * `idx` is the picked particle index in the `SPS.particles` array
  25842. * `faceId` is the picked face index counted within this particle.
  25843. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  25844. */
  25845. pickedParticles: {
  25846. idx: number;
  25847. faceId: number;
  25848. }[];
  25849. /**
  25850. * This array is populated when `enableDepthSort` is set to true.
  25851. * Each element of this array is an instance of the class DepthSortedParticle.
  25852. */
  25853. depthSortedParticles: DepthSortedParticle[];
  25854. /**
  25855. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  25856. * @hidden
  25857. */
  25858. _bSphereOnly: boolean;
  25859. /**
  25860. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  25861. * @hidden
  25862. */
  25863. _bSphereRadiusFactor: number;
  25864. private _scene;
  25865. private _positions;
  25866. private _indices;
  25867. private _normals;
  25868. private _colors;
  25869. private _uvs;
  25870. private _indices32;
  25871. private _positions32;
  25872. private _normals32;
  25873. private _fixedNormal32;
  25874. private _colors32;
  25875. private _uvs32;
  25876. private _index;
  25877. private _updatable;
  25878. private _pickable;
  25879. private _isVisibilityBoxLocked;
  25880. private _alwaysVisible;
  25881. private _depthSort;
  25882. private _shapeCounter;
  25883. private _copy;
  25884. private _color;
  25885. private _computeParticleColor;
  25886. private _computeParticleTexture;
  25887. private _computeParticleRotation;
  25888. private _computeParticleVertex;
  25889. private _computeBoundingBox;
  25890. private _depthSortParticles;
  25891. private _camera;
  25892. private _mustUnrotateFixedNormals;
  25893. private _particlesIntersect;
  25894. private _needs32Bits;
  25895. /**
  25896. * Creates a SPS (Solid Particle System) object.
  25897. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25898. * @param scene (Scene) is the scene in which the SPS is added.
  25899. * @param options defines the options of the sps e.g.
  25900. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25901. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25902. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25903. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25904. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25905. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25906. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25907. */
  25908. constructor(name: string, scene: Scene, options?: {
  25909. updatable?: boolean;
  25910. isPickable?: boolean;
  25911. enableDepthSort?: boolean;
  25912. particleIntersection?: boolean;
  25913. boundingSphereOnly?: boolean;
  25914. bSphereRadiusFactor?: number;
  25915. });
  25916. /**
  25917. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25918. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25919. * @returns the created mesh
  25920. */
  25921. buildMesh(): Mesh;
  25922. /**
  25923. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25924. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25925. * Thus the particles generated from `digest()` have their property `position` set yet.
  25926. * @param mesh ( Mesh ) is the mesh to be digested
  25927. * @param options {facetNb} (optional integer, default 1) is the number of mesh facets per particle, this parameter is overriden by the parameter `number` if any
  25928. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  25929. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25930. * @returns the current SPS
  25931. */
  25932. digest(mesh: Mesh, options?: {
  25933. facetNb?: number;
  25934. number?: number;
  25935. delta?: number;
  25936. }): SolidParticleSystem;
  25937. private _unrotateFixedNormals;
  25938. private _resetCopy;
  25939. private _meshBuilder;
  25940. private _posToShape;
  25941. private _uvsToShapeUV;
  25942. private _addParticle;
  25943. /**
  25944. * Adds some particles to the SPS from the model shape. Returns the shape id.
  25945. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  25946. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  25947. * @param nb (positive integer) the number of particles to be created from this model
  25948. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  25949. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  25950. * @returns the number of shapes in the system
  25951. */
  25952. addShape(mesh: Mesh, nb: number, options?: {
  25953. positionFunction?: any;
  25954. vertexFunction?: any;
  25955. }): number;
  25956. private _rebuildParticle;
  25957. /**
  25958. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  25959. * @returns the SPS.
  25960. */
  25961. rebuildMesh(): SolidParticleSystem;
  25962. /**
  25963. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  25964. * This method calls `updateParticle()` for each particle of the SPS.
  25965. * For an animated SPS, it is usually called within the render loop.
  25966. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  25967. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  25968. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  25969. * @returns the SPS.
  25970. */
  25971. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  25972. /**
  25973. * Disposes the SPS.
  25974. */
  25975. dispose(): void;
  25976. /**
  25977. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  25978. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25979. * @returns the SPS.
  25980. */
  25981. refreshVisibleSize(): SolidParticleSystem;
  25982. /**
  25983. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  25984. * @param size the size (float) of the visibility box
  25985. * note : this doesn't lock the SPS mesh bounding box.
  25986. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25987. */
  25988. setVisibilityBox(size: number): void;
  25989. /**
  25990. * Gets whether the SPS as always visible or not
  25991. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25992. */
  25993. /**
  25994. * Sets the SPS as always visible or not
  25995. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25996. */
  25997. isAlwaysVisible: boolean;
  25998. /**
  25999. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26000. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26001. */
  26002. /**
  26003. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26004. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26005. */
  26006. isVisibilityBoxLocked: boolean;
  26007. /**
  26008. * Tells to `setParticles()` to compute the particle rotations or not.
  26009. * Default value : true. The SPS is faster when it's set to false.
  26010. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26011. */
  26012. /**
  26013. * Gets if `setParticles()` computes the particle rotations or not.
  26014. * Default value : true. The SPS is faster when it's set to false.
  26015. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26016. */
  26017. computeParticleRotation: boolean;
  26018. /**
  26019. * Tells to `setParticles()` to compute the particle colors or not.
  26020. * Default value : true. The SPS is faster when it's set to false.
  26021. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26022. */
  26023. /**
  26024. * Gets if `setParticles()` computes the particle colors or not.
  26025. * Default value : true. The SPS is faster when it's set to false.
  26026. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26027. */
  26028. computeParticleColor: boolean;
  26029. /**
  26030. * Gets if `setParticles()` computes the particle textures or not.
  26031. * Default value : true. The SPS is faster when it's set to false.
  26032. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  26033. */
  26034. computeParticleTexture: boolean;
  26035. /**
  26036. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  26037. * Default value : false. The SPS is faster when it's set to false.
  26038. * Note : the particle custom vertex positions aren't stored values.
  26039. */
  26040. /**
  26041. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  26042. * Default value : false. The SPS is faster when it's set to false.
  26043. * Note : the particle custom vertex positions aren't stored values.
  26044. */
  26045. computeParticleVertex: boolean;
  26046. /**
  26047. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  26048. */
  26049. /**
  26050. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  26051. */
  26052. computeBoundingBox: boolean;
  26053. /**
  26054. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  26055. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26056. * Default : `true`
  26057. */
  26058. /**
  26059. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  26060. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26061. * Default : `true`
  26062. */
  26063. depthSortParticles: boolean;
  26064. /**
  26065. * This function does nothing. It may be overwritten to set all the particle first values.
  26066. * The SPS doesn't call this function, you may have to call it by your own.
  26067. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26068. */
  26069. initParticles(): void;
  26070. /**
  26071. * This function does nothing. It may be overwritten to recycle a particle.
  26072. * The SPS doesn't call this function, you may have to call it by your own.
  26073. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26074. * @param particle The particle to recycle
  26075. * @returns the recycled particle
  26076. */
  26077. recycleParticle(particle: SolidParticle): SolidParticle;
  26078. /**
  26079. * Updates a particle : this function should be overwritten by the user.
  26080. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  26081. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26082. * @example : just set a particle position or velocity and recycle conditions
  26083. * @param particle The particle to update
  26084. * @returns the updated particle
  26085. */
  26086. updateParticle(particle: SolidParticle): SolidParticle;
  26087. /**
  26088. * Updates a vertex of a particle : it can be overwritten by the user.
  26089. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  26090. * @param particle the current particle
  26091. * @param vertex the current index of the current particle
  26092. * @param pt the index of the current vertex in the particle shape
  26093. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  26094. * @example : just set a vertex particle position
  26095. * @returns the updated vertex
  26096. */
  26097. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  26098. /**
  26099. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  26100. * This does nothing and may be overwritten by the user.
  26101. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26102. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26103. * @param update the boolean update value actually passed to setParticles()
  26104. */
  26105. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26106. /**
  26107. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  26108. * This will be passed three parameters.
  26109. * This does nothing and may be overwritten by the user.
  26110. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26111. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26112. * @param update the boolean update value actually passed to setParticles()
  26113. */
  26114. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26115. }
  26116. }
  26117. declare module "babylonjs/Particles/solidParticle" {
  26118. import { Nullable } from "babylonjs/types";
  26119. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  26120. import { Color4 } from "babylonjs/Maths/math.color";
  26121. import { Mesh } from "babylonjs/Meshes/mesh";
  26122. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26123. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  26124. import { Plane } from "babylonjs/Maths/math.plane";
  26125. /**
  26126. * Represents one particle of a solid particle system.
  26127. */
  26128. export class SolidParticle {
  26129. /**
  26130. * particle global index
  26131. */
  26132. idx: number;
  26133. /**
  26134. * The color of the particle
  26135. */
  26136. color: Nullable<Color4>;
  26137. /**
  26138. * The world space position of the particle.
  26139. */
  26140. position: Vector3;
  26141. /**
  26142. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  26143. */
  26144. rotation: Vector3;
  26145. /**
  26146. * The world space rotation quaternion of the particle.
  26147. */
  26148. rotationQuaternion: Nullable<Quaternion>;
  26149. /**
  26150. * The scaling of the particle.
  26151. */
  26152. scaling: Vector3;
  26153. /**
  26154. * The uvs of the particle.
  26155. */
  26156. uvs: Vector4;
  26157. /**
  26158. * The current speed of the particle.
  26159. */
  26160. velocity: Vector3;
  26161. /**
  26162. * The pivot point in the particle local space.
  26163. */
  26164. pivot: Vector3;
  26165. /**
  26166. * Must the particle be translated from its pivot point in its local space ?
  26167. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  26168. * Default : false
  26169. */
  26170. translateFromPivot: boolean;
  26171. /**
  26172. * Is the particle active or not ?
  26173. */
  26174. alive: boolean;
  26175. /**
  26176. * Is the particle visible or not ?
  26177. */
  26178. isVisible: boolean;
  26179. /**
  26180. * Index of this particle in the global "positions" array (Internal use)
  26181. * @hidden
  26182. */
  26183. _pos: number;
  26184. /**
  26185. * @hidden Index of this particle in the global "indices" array (Internal use)
  26186. */
  26187. _ind: number;
  26188. /**
  26189. * @hidden ModelShape of this particle (Internal use)
  26190. */
  26191. _model: ModelShape;
  26192. /**
  26193. * ModelShape id of this particle
  26194. */
  26195. shapeId: number;
  26196. /**
  26197. * Index of the particle in its shape id
  26198. */
  26199. idxInShape: number;
  26200. /**
  26201. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  26202. */
  26203. _modelBoundingInfo: BoundingInfo;
  26204. /**
  26205. * @hidden Particle BoundingInfo object (Internal use)
  26206. */
  26207. _boundingInfo: BoundingInfo;
  26208. /**
  26209. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  26210. */
  26211. _sps: SolidParticleSystem;
  26212. /**
  26213. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  26214. */
  26215. _stillInvisible: boolean;
  26216. /**
  26217. * @hidden Last computed particle rotation matrix
  26218. */
  26219. _rotationMatrix: number[];
  26220. /**
  26221. * Parent particle Id, if any.
  26222. * Default null.
  26223. */
  26224. parentId: Nullable<number>;
  26225. /**
  26226. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  26227. * The possible values are :
  26228. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26229. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26230. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26231. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26232. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26233. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  26234. * */
  26235. cullingStrategy: number;
  26236. /**
  26237. * @hidden Internal global position in the SPS.
  26238. */
  26239. _globalPosition: Vector3;
  26240. /**
  26241. * Creates a Solid Particle object.
  26242. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  26243. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  26244. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  26245. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  26246. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  26247. * @param shapeId (integer) is the model shape identifier in the SPS.
  26248. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  26249. * @param sps defines the sps it is associated to
  26250. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  26251. */
  26252. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  26253. /**
  26254. * Legacy support, changed scale to scaling
  26255. */
  26256. /**
  26257. * Legacy support, changed scale to scaling
  26258. */
  26259. scale: Vector3;
  26260. /**
  26261. * Legacy support, changed quaternion to rotationQuaternion
  26262. */
  26263. /**
  26264. * Legacy support, changed quaternion to rotationQuaternion
  26265. */
  26266. quaternion: Nullable<Quaternion>;
  26267. /**
  26268. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  26269. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  26270. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  26271. * @returns true if it intersects
  26272. */
  26273. intersectsMesh(target: Mesh | SolidParticle): boolean;
  26274. /**
  26275. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  26276. * A particle is in the frustum if its bounding box intersects the frustum
  26277. * @param frustumPlanes defines the frustum to test
  26278. * @returns true if the particle is in the frustum planes
  26279. */
  26280. isInFrustum(frustumPlanes: Plane[]): boolean;
  26281. /**
  26282. * get the rotation matrix of the particle
  26283. * @hidden
  26284. */
  26285. getRotationMatrix(m: Matrix): void;
  26286. }
  26287. /**
  26288. * Represents the shape of the model used by one particle of a solid particle system.
  26289. * SPS internal tool, don't use it manually.
  26290. */
  26291. export class ModelShape {
  26292. /**
  26293. * The shape id
  26294. * @hidden
  26295. */
  26296. shapeID: number;
  26297. /**
  26298. * flat array of model positions (internal use)
  26299. * @hidden
  26300. */
  26301. _shape: Vector3[];
  26302. /**
  26303. * flat array of model UVs (internal use)
  26304. * @hidden
  26305. */
  26306. _shapeUV: number[];
  26307. /**
  26308. * length of the shape in the model indices array (internal use)
  26309. * @hidden
  26310. */
  26311. _indicesLength: number;
  26312. /**
  26313. * Custom position function (internal use)
  26314. * @hidden
  26315. */
  26316. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  26317. /**
  26318. * Custom vertex function (internal use)
  26319. * @hidden
  26320. */
  26321. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  26322. /**
  26323. * Creates a ModelShape object. This is an internal simplified reference to a mesh used as for a model to replicate particles from by the SPS.
  26324. * SPS internal tool, don't use it manually.
  26325. * @hidden
  26326. */
  26327. constructor(id: number, shape: Vector3[], indicesLength: number, shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  26328. }
  26329. /**
  26330. * Represents a Depth Sorted Particle in the solid particle system.
  26331. */
  26332. export class DepthSortedParticle {
  26333. /**
  26334. * Index of the particle in the "indices" array
  26335. */
  26336. ind: number;
  26337. /**
  26338. * Length of the particle shape in the "indices" array
  26339. */
  26340. indicesLength: number;
  26341. /**
  26342. * Squared distance from the particle to the camera
  26343. */
  26344. sqDistance: number;
  26345. }
  26346. }
  26347. declare module "babylonjs/Collisions/meshCollisionData" {
  26348. import { Collider } from "babylonjs/Collisions/collider";
  26349. import { Vector3 } from "babylonjs/Maths/math.vector";
  26350. import { Nullable } from "babylonjs/types";
  26351. import { Observer } from "babylonjs/Misc/observable";
  26352. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26353. /**
  26354. * @hidden
  26355. */
  26356. export class _MeshCollisionData {
  26357. _checkCollisions: boolean;
  26358. _collisionMask: number;
  26359. _collisionGroup: number;
  26360. _collider: Nullable<Collider>;
  26361. _oldPositionForCollisions: Vector3;
  26362. _diffPositionForCollisions: Vector3;
  26363. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  26364. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  26365. }
  26366. }
  26367. declare module "babylonjs/Meshes/abstractMesh" {
  26368. import { Observable } from "babylonjs/Misc/observable";
  26369. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  26370. import { Camera } from "babylonjs/Cameras/camera";
  26371. import { Scene, IDisposable } from "babylonjs/scene";
  26372. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26373. import { Node } from "babylonjs/node";
  26374. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  26375. import { TransformNode } from "babylonjs/Meshes/transformNode";
  26376. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26377. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  26378. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26379. import { Material } from "babylonjs/Materials/material";
  26380. import { Light } from "babylonjs/Lights/light";
  26381. import { Skeleton } from "babylonjs/Bones/skeleton";
  26382. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  26383. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  26384. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26385. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  26386. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  26387. import { Plane } from "babylonjs/Maths/math.plane";
  26388. import { Ray } from "babylonjs/Culling/ray";
  26389. import { Collider } from "babylonjs/Collisions/collider";
  26390. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26391. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  26392. /** @hidden */
  26393. class _FacetDataStorage {
  26394. facetPositions: Vector3[];
  26395. facetNormals: Vector3[];
  26396. facetPartitioning: number[][];
  26397. facetNb: number;
  26398. partitioningSubdivisions: number;
  26399. partitioningBBoxRatio: number;
  26400. facetDataEnabled: boolean;
  26401. facetParameters: any;
  26402. bbSize: Vector3;
  26403. subDiv: {
  26404. max: number;
  26405. X: number;
  26406. Y: number;
  26407. Z: number;
  26408. };
  26409. facetDepthSort: boolean;
  26410. facetDepthSortEnabled: boolean;
  26411. depthSortedIndices: IndicesArray;
  26412. depthSortedFacets: {
  26413. ind: number;
  26414. sqDistance: number;
  26415. }[];
  26416. facetDepthSortFunction: (f1: {
  26417. ind: number;
  26418. sqDistance: number;
  26419. }, f2: {
  26420. ind: number;
  26421. sqDistance: number;
  26422. }) => number;
  26423. facetDepthSortFrom: Vector3;
  26424. facetDepthSortOrigin: Vector3;
  26425. invertedMatrix: Matrix;
  26426. }
  26427. /**
  26428. * @hidden
  26429. **/
  26430. class _InternalAbstractMeshDataInfo {
  26431. _hasVertexAlpha: boolean;
  26432. _useVertexColors: boolean;
  26433. _numBoneInfluencers: number;
  26434. _applyFog: boolean;
  26435. _receiveShadows: boolean;
  26436. _facetData: _FacetDataStorage;
  26437. _visibility: number;
  26438. _skeleton: Nullable<Skeleton>;
  26439. _layerMask: number;
  26440. _computeBonesUsingShaders: boolean;
  26441. _isActive: boolean;
  26442. _onlyForInstances: boolean;
  26443. _isActiveIntermediate: boolean;
  26444. _onlyForInstancesIntermediate: boolean;
  26445. }
  26446. /**
  26447. * Class used to store all common mesh properties
  26448. */
  26449. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  26450. /** No occlusion */
  26451. static OCCLUSION_TYPE_NONE: number;
  26452. /** Occlusion set to optimisitic */
  26453. static OCCLUSION_TYPE_OPTIMISTIC: number;
  26454. /** Occlusion set to strict */
  26455. static OCCLUSION_TYPE_STRICT: number;
  26456. /** Use an accurante occlusion algorithm */
  26457. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  26458. /** Use a conservative occlusion algorithm */
  26459. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  26460. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  26461. * Test order :
  26462. * Is the bounding sphere outside the frustum ?
  26463. * If not, are the bounding box vertices outside the frustum ?
  26464. * It not, then the cullable object is in the frustum.
  26465. */
  26466. static readonly CULLINGSTRATEGY_STANDARD: number;
  26467. /** Culling strategy : Bounding Sphere Only.
  26468. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  26469. * It's also less accurate than the standard because some not visible objects can still be selected.
  26470. * Test : is the bounding sphere outside the frustum ?
  26471. * If not, then the cullable object is in the frustum.
  26472. */
  26473. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  26474. /** Culling strategy : Optimistic Inclusion.
  26475. * This in an inclusion test first, then the standard exclusion test.
  26476. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  26477. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  26478. * Anyway, it's as accurate as the standard strategy.
  26479. * Test :
  26480. * Is the cullable object bounding sphere center in the frustum ?
  26481. * If not, apply the default culling strategy.
  26482. */
  26483. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  26484. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  26485. * This in an inclusion test first, then the bounding sphere only exclusion test.
  26486. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  26487. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  26488. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  26489. * Test :
  26490. * Is the cullable object bounding sphere center in the frustum ?
  26491. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  26492. */
  26493. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  26494. /**
  26495. * No billboard
  26496. */
  26497. static readonly BILLBOARDMODE_NONE: number;
  26498. /** Billboard on X axis */
  26499. static readonly BILLBOARDMODE_X: number;
  26500. /** Billboard on Y axis */
  26501. static readonly BILLBOARDMODE_Y: number;
  26502. /** Billboard on Z axis */
  26503. static readonly BILLBOARDMODE_Z: number;
  26504. /** Billboard on all axes */
  26505. static readonly BILLBOARDMODE_ALL: number;
  26506. /** Billboard on using position instead of orientation */
  26507. static readonly BILLBOARDMODE_USE_POSITION: number;
  26508. /** @hidden */
  26509. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  26510. /**
  26511. * The culling strategy to use to check whether the mesh must be rendered or not.
  26512. * This value can be changed at any time and will be used on the next render mesh selection.
  26513. * The possible values are :
  26514. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26515. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26516. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26517. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26518. * Please read each static variable documentation to get details about the culling process.
  26519. * */
  26520. cullingStrategy: number;
  26521. /**
  26522. * Gets the number of facets in the mesh
  26523. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26524. */
  26525. readonly facetNb: number;
  26526. /**
  26527. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  26528. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26529. */
  26530. partitioningSubdivisions: number;
  26531. /**
  26532. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  26533. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  26534. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26535. */
  26536. partitioningBBoxRatio: number;
  26537. /**
  26538. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  26539. * Works only for updatable meshes.
  26540. * Doesn't work with multi-materials
  26541. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26542. */
  26543. mustDepthSortFacets: boolean;
  26544. /**
  26545. * The location (Vector3) where the facet depth sort must be computed from.
  26546. * By default, the active camera position.
  26547. * Used only when facet depth sort is enabled
  26548. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26549. */
  26550. facetDepthSortFrom: Vector3;
  26551. /**
  26552. * gets a boolean indicating if facetData is enabled
  26553. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26554. */
  26555. readonly isFacetDataEnabled: boolean;
  26556. /** @hidden */
  26557. _updateNonUniformScalingState(value: boolean): boolean;
  26558. /**
  26559. * An event triggered when this mesh collides with another one
  26560. */
  26561. onCollideObservable: Observable<AbstractMesh>;
  26562. /** Set a function to call when this mesh collides with another one */
  26563. onCollide: () => void;
  26564. /**
  26565. * An event triggered when the collision's position changes
  26566. */
  26567. onCollisionPositionChangeObservable: Observable<Vector3>;
  26568. /** Set a function to call when the collision's position changes */
  26569. onCollisionPositionChange: () => void;
  26570. /**
  26571. * An event triggered when material is changed
  26572. */
  26573. onMaterialChangedObservable: Observable<AbstractMesh>;
  26574. /**
  26575. * Gets or sets the orientation for POV movement & rotation
  26576. */
  26577. definedFacingForward: boolean;
  26578. /** @hidden */
  26579. _occlusionQuery: Nullable<WebGLQuery>;
  26580. /** @hidden */
  26581. _renderingGroup: Nullable<RenderingGroup>;
  26582. /**
  26583. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26584. */
  26585. /**
  26586. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26587. */
  26588. visibility: number;
  26589. /** Gets or sets the alpha index used to sort transparent meshes
  26590. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  26591. */
  26592. alphaIndex: number;
  26593. /**
  26594. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  26595. */
  26596. isVisible: boolean;
  26597. /**
  26598. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  26599. */
  26600. isPickable: boolean;
  26601. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  26602. showSubMeshesBoundingBox: boolean;
  26603. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  26604. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  26605. */
  26606. isBlocker: boolean;
  26607. /**
  26608. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  26609. */
  26610. enablePointerMoveEvents: boolean;
  26611. /**
  26612. * Specifies the rendering group id for this mesh (0 by default)
  26613. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  26614. */
  26615. renderingGroupId: number;
  26616. private _material;
  26617. /** Gets or sets current material */
  26618. material: Nullable<Material>;
  26619. /**
  26620. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  26621. * @see http://doc.babylonjs.com/babylon101/shadows
  26622. */
  26623. receiveShadows: boolean;
  26624. /** Defines color to use when rendering outline */
  26625. outlineColor: Color3;
  26626. /** Define width to use when rendering outline */
  26627. outlineWidth: number;
  26628. /** Defines color to use when rendering overlay */
  26629. overlayColor: Color3;
  26630. /** Defines alpha to use when rendering overlay */
  26631. overlayAlpha: number;
  26632. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  26633. hasVertexAlpha: boolean;
  26634. /** Gets or sets a boolean indicating that this mesh needs to use vertex color data to render (if this kind of vertex data is available in the geometry) */
  26635. useVertexColors: boolean;
  26636. /**
  26637. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  26638. */
  26639. computeBonesUsingShaders: boolean;
  26640. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  26641. numBoneInfluencers: number;
  26642. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  26643. applyFog: boolean;
  26644. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  26645. useOctreeForRenderingSelection: boolean;
  26646. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  26647. useOctreeForPicking: boolean;
  26648. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  26649. useOctreeForCollisions: boolean;
  26650. /**
  26651. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  26652. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  26653. */
  26654. layerMask: number;
  26655. /**
  26656. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  26657. */
  26658. alwaysSelectAsActiveMesh: boolean;
  26659. /**
  26660. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  26661. */
  26662. doNotSyncBoundingInfo: boolean;
  26663. /**
  26664. * Gets or sets the current action manager
  26665. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26666. */
  26667. actionManager: Nullable<AbstractActionManager>;
  26668. private _meshCollisionData;
  26669. /**
  26670. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  26671. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26672. */
  26673. ellipsoid: Vector3;
  26674. /**
  26675. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  26676. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26677. */
  26678. ellipsoidOffset: Vector3;
  26679. /**
  26680. * Gets or sets a collision mask used to mask collisions (default is -1).
  26681. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26682. */
  26683. collisionMask: number;
  26684. /**
  26685. * Gets or sets the current collision group mask (-1 by default).
  26686. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26687. */
  26688. collisionGroup: number;
  26689. /**
  26690. * Defines edge width used when edgesRenderer is enabled
  26691. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26692. */
  26693. edgesWidth: number;
  26694. /**
  26695. * Defines edge color used when edgesRenderer is enabled
  26696. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26697. */
  26698. edgesColor: Color4;
  26699. /** @hidden */
  26700. _edgesRenderer: Nullable<IEdgesRenderer>;
  26701. /** @hidden */
  26702. _masterMesh: Nullable<AbstractMesh>;
  26703. /** @hidden */
  26704. _boundingInfo: Nullable<BoundingInfo>;
  26705. /** @hidden */
  26706. _renderId: number;
  26707. /**
  26708. * Gets or sets the list of subMeshes
  26709. * @see http://doc.babylonjs.com/how_to/multi_materials
  26710. */
  26711. subMeshes: SubMesh[];
  26712. /** @hidden */
  26713. _intersectionsInProgress: AbstractMesh[];
  26714. /** @hidden */
  26715. _unIndexed: boolean;
  26716. /** @hidden */
  26717. _lightSources: Light[];
  26718. /** Gets the list of lights affecting that mesh */
  26719. readonly lightSources: Light[];
  26720. /** @hidden */
  26721. readonly _positions: Nullable<Vector3[]>;
  26722. /** @hidden */
  26723. _waitingData: {
  26724. lods: Nullable<any>;
  26725. actions: Nullable<any>;
  26726. freezeWorldMatrix: Nullable<boolean>;
  26727. };
  26728. /** @hidden */
  26729. _bonesTransformMatrices: Nullable<Float32Array>;
  26730. /** @hidden */
  26731. _transformMatrixTexture: Nullable<RawTexture>;
  26732. /**
  26733. * Gets or sets a skeleton to apply skining transformations
  26734. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26735. */
  26736. skeleton: Nullable<Skeleton>;
  26737. /**
  26738. * An event triggered when the mesh is rebuilt.
  26739. */
  26740. onRebuildObservable: Observable<AbstractMesh>;
  26741. /**
  26742. * Creates a new AbstractMesh
  26743. * @param name defines the name of the mesh
  26744. * @param scene defines the hosting scene
  26745. */
  26746. constructor(name: string, scene?: Nullable<Scene>);
  26747. /**
  26748. * Returns the string "AbstractMesh"
  26749. * @returns "AbstractMesh"
  26750. */
  26751. getClassName(): string;
  26752. /**
  26753. * Gets a string representation of the current mesh
  26754. * @param fullDetails defines a boolean indicating if full details must be included
  26755. * @returns a string representation of the current mesh
  26756. */
  26757. toString(fullDetails?: boolean): string;
  26758. /**
  26759. * @hidden
  26760. */
  26761. protected _getEffectiveParent(): Nullable<Node>;
  26762. /** @hidden */
  26763. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26764. /** @hidden */
  26765. _rebuild(): void;
  26766. /** @hidden */
  26767. _resyncLightSources(): void;
  26768. /** @hidden */
  26769. _resyncLighSource(light: Light): void;
  26770. /** @hidden */
  26771. _unBindEffect(): void;
  26772. /** @hidden */
  26773. _removeLightSource(light: Light, dispose: boolean): void;
  26774. private _markSubMeshesAsDirty;
  26775. /** @hidden */
  26776. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  26777. /** @hidden */
  26778. _markSubMeshesAsAttributesDirty(): void;
  26779. /** @hidden */
  26780. _markSubMeshesAsMiscDirty(): void;
  26781. /**
  26782. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  26783. */
  26784. scaling: Vector3;
  26785. /**
  26786. * Returns true if the mesh is blocked. Implemented by child classes
  26787. */
  26788. readonly isBlocked: boolean;
  26789. /**
  26790. * Returns the mesh itself by default. Implemented by child classes
  26791. * @param camera defines the camera to use to pick the right LOD level
  26792. * @returns the currentAbstractMesh
  26793. */
  26794. getLOD(camera: Camera): Nullable<AbstractMesh>;
  26795. /**
  26796. * Returns 0 by default. Implemented by child classes
  26797. * @returns an integer
  26798. */
  26799. getTotalVertices(): number;
  26800. /**
  26801. * Returns a positive integer : the total number of indices in this mesh geometry.
  26802. * @returns the numner of indices or zero if the mesh has no geometry.
  26803. */
  26804. getTotalIndices(): number;
  26805. /**
  26806. * Returns null by default. Implemented by child classes
  26807. * @returns null
  26808. */
  26809. getIndices(): Nullable<IndicesArray>;
  26810. /**
  26811. * Returns the array of the requested vertex data kind. Implemented by child classes
  26812. * @param kind defines the vertex data kind to use
  26813. * @returns null
  26814. */
  26815. getVerticesData(kind: string): Nullable<FloatArray>;
  26816. /**
  26817. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26818. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26819. * Note that a new underlying VertexBuffer object is created each call.
  26820. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26821. * @param kind defines vertex data kind:
  26822. * * VertexBuffer.PositionKind
  26823. * * VertexBuffer.UVKind
  26824. * * VertexBuffer.UV2Kind
  26825. * * VertexBuffer.UV3Kind
  26826. * * VertexBuffer.UV4Kind
  26827. * * VertexBuffer.UV5Kind
  26828. * * VertexBuffer.UV6Kind
  26829. * * VertexBuffer.ColorKind
  26830. * * VertexBuffer.MatricesIndicesKind
  26831. * * VertexBuffer.MatricesIndicesExtraKind
  26832. * * VertexBuffer.MatricesWeightsKind
  26833. * * VertexBuffer.MatricesWeightsExtraKind
  26834. * @param data defines the data source
  26835. * @param updatable defines if the data must be flagged as updatable (or static)
  26836. * @param stride defines the vertex stride (size of an entire vertex). Can be null and in this case will be deduced from vertex data kind
  26837. * @returns the current mesh
  26838. */
  26839. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  26840. /**
  26841. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26842. * If the mesh has no geometry, it is simply returned as it is.
  26843. * @param kind defines vertex data kind:
  26844. * * VertexBuffer.PositionKind
  26845. * * VertexBuffer.UVKind
  26846. * * VertexBuffer.UV2Kind
  26847. * * VertexBuffer.UV3Kind
  26848. * * VertexBuffer.UV4Kind
  26849. * * VertexBuffer.UV5Kind
  26850. * * VertexBuffer.UV6Kind
  26851. * * VertexBuffer.ColorKind
  26852. * * VertexBuffer.MatricesIndicesKind
  26853. * * VertexBuffer.MatricesIndicesExtraKind
  26854. * * VertexBuffer.MatricesWeightsKind
  26855. * * VertexBuffer.MatricesWeightsExtraKind
  26856. * @param data defines the data source
  26857. * @param updateExtends If `kind` is `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed
  26858. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  26859. * @returns the current mesh
  26860. */
  26861. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  26862. /**
  26863. * Sets the mesh indices,
  26864. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26865. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  26866. * @param totalVertices Defines the total number of vertices
  26867. * @returns the current mesh
  26868. */
  26869. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  26870. /**
  26871. * Gets a boolean indicating if specific vertex data is present
  26872. * @param kind defines the vertex data kind to use
  26873. * @returns true is data kind is present
  26874. */
  26875. isVerticesDataPresent(kind: string): boolean;
  26876. /**
  26877. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  26878. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  26879. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  26880. * @returns a BoundingInfo
  26881. */
  26882. getBoundingInfo(): BoundingInfo;
  26883. /**
  26884. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26885. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26886. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26887. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26888. * @returns the current mesh
  26889. */
  26890. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  26891. /**
  26892. * Overwrite the current bounding info
  26893. * @param boundingInfo defines the new bounding info
  26894. * @returns the current mesh
  26895. */
  26896. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  26897. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  26898. readonly useBones: boolean;
  26899. /** @hidden */
  26900. _preActivate(): void;
  26901. /** @hidden */
  26902. _preActivateForIntermediateRendering(renderId: number): void;
  26903. /** @hidden */
  26904. _activate(renderId: number, intermediateRendering: boolean): boolean;
  26905. /** @hidden */
  26906. _postActivate(): void;
  26907. /** @hidden */
  26908. _freeze(): void;
  26909. /** @hidden */
  26910. _unFreeze(): void;
  26911. /**
  26912. * Gets the current world matrix
  26913. * @returns a Matrix
  26914. */
  26915. getWorldMatrix(): Matrix;
  26916. /** @hidden */
  26917. _getWorldMatrixDeterminant(): number;
  26918. /**
  26919. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  26920. */
  26921. readonly isAnInstance: boolean;
  26922. /**
  26923. * Gets a boolean indicating if this mesh has instances
  26924. */
  26925. readonly hasInstances: boolean;
  26926. /**
  26927. * Perform relative position change from the point of view of behind the front of the mesh.
  26928. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26929. * Supports definition of mesh facing forward or backward
  26930. * @param amountRight defines the distance on the right axis
  26931. * @param amountUp defines the distance on the up axis
  26932. * @param amountForward defines the distance on the forward axis
  26933. * @returns the current mesh
  26934. */
  26935. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  26936. /**
  26937. * Calculate relative position change from the point of view of behind the front of the mesh.
  26938. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26939. * Supports definition of mesh facing forward or backward
  26940. * @param amountRight defines the distance on the right axis
  26941. * @param amountUp defines the distance on the up axis
  26942. * @param amountForward defines the distance on the forward axis
  26943. * @returns the new displacement vector
  26944. */
  26945. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  26946. /**
  26947. * Perform relative rotation change from the point of view of behind the front of the mesh.
  26948. * Supports definition of mesh facing forward or backward
  26949. * @param flipBack defines the flip
  26950. * @param twirlClockwise defines the twirl
  26951. * @param tiltRight defines the tilt
  26952. * @returns the current mesh
  26953. */
  26954. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  26955. /**
  26956. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  26957. * Supports definition of mesh facing forward or backward.
  26958. * @param flipBack defines the flip
  26959. * @param twirlClockwise defines the twirl
  26960. * @param tiltRight defines the tilt
  26961. * @returns the new rotation vector
  26962. */
  26963. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  26964. /**
  26965. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26966. * This means the mesh underlying bounding box and sphere are recomputed.
  26967. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26968. * @returns the current mesh
  26969. */
  26970. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  26971. /** @hidden */
  26972. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  26973. /** @hidden */
  26974. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  26975. /** @hidden */
  26976. _updateBoundingInfo(): AbstractMesh;
  26977. /** @hidden */
  26978. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  26979. /** @hidden */
  26980. protected _afterComputeWorldMatrix(): void;
  26981. /** @hidden */
  26982. readonly _effectiveMesh: AbstractMesh;
  26983. /**
  26984. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26985. * A mesh is in the frustum if its bounding box intersects the frustum
  26986. * @param frustumPlanes defines the frustum to test
  26987. * @returns true if the mesh is in the frustum planes
  26988. */
  26989. isInFrustum(frustumPlanes: Plane[]): boolean;
  26990. /**
  26991. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  26992. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  26993. * @param frustumPlanes defines the frustum to test
  26994. * @returns true if the mesh is completely in the frustum planes
  26995. */
  26996. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26997. /**
  26998. * True if the mesh intersects another mesh or a SolidParticle object
  26999. * @param mesh defines a target mesh or SolidParticle to test
  27000. * @param precise Unless the parameter `precise` is set to `true` the intersection is computed according to Axis Aligned Bounding Boxes (AABB), else according to OBB (Oriented BBoxes)
  27001. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  27002. * @returns true if there is an intersection
  27003. */
  27004. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  27005. /**
  27006. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  27007. * @param point defines the point to test
  27008. * @returns true if there is an intersection
  27009. */
  27010. intersectsPoint(point: Vector3): boolean;
  27011. /**
  27012. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  27013. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27014. */
  27015. checkCollisions: boolean;
  27016. /**
  27017. * Gets Collider object used to compute collisions (not physics)
  27018. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27019. */
  27020. readonly collider: Nullable<Collider>;
  27021. /**
  27022. * Move the mesh using collision engine
  27023. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27024. * @param displacement defines the requested displacement vector
  27025. * @returns the current mesh
  27026. */
  27027. moveWithCollisions(displacement: Vector3): AbstractMesh;
  27028. private _onCollisionPositionChange;
  27029. /** @hidden */
  27030. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  27031. /** @hidden */
  27032. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  27033. /** @hidden */
  27034. _checkCollision(collider: Collider): AbstractMesh;
  27035. /** @hidden */
  27036. _generatePointsArray(): boolean;
  27037. /**
  27038. * Checks if the passed Ray intersects with the mesh
  27039. * @param ray defines the ray to use
  27040. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  27041. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  27042. * @returns the picking info
  27043. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  27044. */
  27045. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  27046. /**
  27047. * Clones the current mesh
  27048. * @param name defines the mesh name
  27049. * @param newParent defines the new mesh parent
  27050. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  27051. * @returns the new mesh
  27052. */
  27053. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  27054. /**
  27055. * Disposes all the submeshes of the current meshnp
  27056. * @returns the current mesh
  27057. */
  27058. releaseSubMeshes(): AbstractMesh;
  27059. /**
  27060. * Releases resources associated with this abstract mesh.
  27061. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27062. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27063. */
  27064. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27065. /**
  27066. * Adds the passed mesh as a child to the current mesh
  27067. * @param mesh defines the child mesh
  27068. * @returns the current mesh
  27069. */
  27070. addChild(mesh: AbstractMesh): AbstractMesh;
  27071. /**
  27072. * Removes the passed mesh from the current mesh children list
  27073. * @param mesh defines the child mesh
  27074. * @returns the current mesh
  27075. */
  27076. removeChild(mesh: AbstractMesh): AbstractMesh;
  27077. /** @hidden */
  27078. private _initFacetData;
  27079. /**
  27080. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  27081. * This method can be called within the render loop.
  27082. * You don't need to call this method by yourself in the render loop when you update/morph a mesh with the methods CreateXXX() as they automatically manage this computation
  27083. * @returns the current mesh
  27084. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27085. */
  27086. updateFacetData(): AbstractMesh;
  27087. /**
  27088. * Returns the facetLocalNormals array.
  27089. * The normals are expressed in the mesh local spac
  27090. * @returns an array of Vector3
  27091. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27092. */
  27093. getFacetLocalNormals(): Vector3[];
  27094. /**
  27095. * Returns the facetLocalPositions array.
  27096. * The facet positions are expressed in the mesh local space
  27097. * @returns an array of Vector3
  27098. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27099. */
  27100. getFacetLocalPositions(): Vector3[];
  27101. /**
  27102. * Returns the facetLocalPartioning array
  27103. * @returns an array of array of numbers
  27104. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27105. */
  27106. getFacetLocalPartitioning(): number[][];
  27107. /**
  27108. * Returns the i-th facet position in the world system.
  27109. * This method allocates a new Vector3 per call
  27110. * @param i defines the facet index
  27111. * @returns a new Vector3
  27112. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27113. */
  27114. getFacetPosition(i: number): Vector3;
  27115. /**
  27116. * Sets the reference Vector3 with the i-th facet position in the world system
  27117. * @param i defines the facet index
  27118. * @param ref defines the target vector
  27119. * @returns the current mesh
  27120. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27121. */
  27122. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  27123. /**
  27124. * Returns the i-th facet normal in the world system.
  27125. * This method allocates a new Vector3 per call
  27126. * @param i defines the facet index
  27127. * @returns a new Vector3
  27128. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27129. */
  27130. getFacetNormal(i: number): Vector3;
  27131. /**
  27132. * Sets the reference Vector3 with the i-th facet normal in the world system
  27133. * @param i defines the facet index
  27134. * @param ref defines the target vector
  27135. * @returns the current mesh
  27136. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27137. */
  27138. getFacetNormalToRef(i: number, ref: Vector3): this;
  27139. /**
  27140. * Returns the facets (in an array) in the same partitioning block than the one the passed coordinates are located (expressed in the mesh local system)
  27141. * @param x defines x coordinate
  27142. * @param y defines y coordinate
  27143. * @param z defines z coordinate
  27144. * @returns the array of facet indexes
  27145. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27146. */
  27147. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  27148. /**
  27149. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  27150. * @param projected sets as the (x,y,z) world projection on the facet
  27151. * @param checkFace if true (default false), only the facet "facing" to (x,y,z) or only the ones "turning their backs", according to the parameter "facing" are returned
  27152. * @param facing if facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position. If facing si false and checkFace is true, only the facet "turning their backs" to (x, y, z) are returned : negative dot (x, y, z) * facet position
  27153. * @param x defines x coordinate
  27154. * @param y defines y coordinate
  27155. * @param z defines z coordinate
  27156. * @returns the face index if found (or null instead)
  27157. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27158. */
  27159. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27160. /**
  27161. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  27162. * @param projected sets as the (x,y,z) local projection on the facet
  27163. * @param checkFace if true (default false), only the facet "facing" to (x,y,z) or only the ones "turning their backs", according to the parameter "facing" are returned
  27164. * @param facing if facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position. If facing si false and checkFace is true, only the facet "turning their backs" to (x, y, z) are returned : negative dot (x, y, z) * facet position
  27165. * @param x defines x coordinate
  27166. * @param y defines y coordinate
  27167. * @param z defines z coordinate
  27168. * @returns the face index if found (or null instead)
  27169. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27170. */
  27171. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27172. /**
  27173. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  27174. * @returns the parameters
  27175. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27176. */
  27177. getFacetDataParameters(): any;
  27178. /**
  27179. * Disables the feature FacetData and frees the related memory
  27180. * @returns the current mesh
  27181. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27182. */
  27183. disableFacetData(): AbstractMesh;
  27184. /**
  27185. * Updates the AbstractMesh indices array
  27186. * @param indices defines the data source
  27187. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27188. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  27189. * @returns the current mesh
  27190. */
  27191. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27192. /**
  27193. * Creates new normals data for the mesh
  27194. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  27195. * @returns the current mesh
  27196. */
  27197. createNormals(updatable: boolean): AbstractMesh;
  27198. /**
  27199. * Align the mesh with a normal
  27200. * @param normal defines the normal to use
  27201. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  27202. * @returns the current mesh
  27203. */
  27204. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  27205. /** @hidden */
  27206. _checkOcclusionQuery(): boolean;
  27207. /**
  27208. * Disables the mesh edge rendering mode
  27209. * @returns the currentAbstractMesh
  27210. */
  27211. disableEdgesRendering(): AbstractMesh;
  27212. /**
  27213. * Enables the edge rendering mode on the mesh.
  27214. * This mode makes the mesh edges visible
  27215. * @param epsilon defines the maximal distance between two angles to detect a face
  27216. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  27217. * @returns the currentAbstractMesh
  27218. * @see https://www.babylonjs-playground.com/#19O9TU#0
  27219. */
  27220. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  27221. }
  27222. }
  27223. declare module "babylonjs/Actions/actionEvent" {
  27224. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27225. import { Nullable } from "babylonjs/types";
  27226. import { Sprite } from "babylonjs/Sprites/sprite";
  27227. import { Scene } from "babylonjs/scene";
  27228. import { Vector2 } from "babylonjs/Maths/math.vector";
  27229. /**
  27230. * Interface used to define ActionEvent
  27231. */
  27232. export interface IActionEvent {
  27233. /** The mesh or sprite that triggered the action */
  27234. source: any;
  27235. /** The X mouse cursor position at the time of the event */
  27236. pointerX: number;
  27237. /** The Y mouse cursor position at the time of the event */
  27238. pointerY: number;
  27239. /** The mesh that is currently pointed at (can be null) */
  27240. meshUnderPointer: Nullable<AbstractMesh>;
  27241. /** the original (browser) event that triggered the ActionEvent */
  27242. sourceEvent?: any;
  27243. /** additional data for the event */
  27244. additionalData?: any;
  27245. }
  27246. /**
  27247. * ActionEvent is the event being sent when an action is triggered.
  27248. */
  27249. export class ActionEvent implements IActionEvent {
  27250. /** The mesh or sprite that triggered the action */
  27251. source: any;
  27252. /** The X mouse cursor position at the time of the event */
  27253. pointerX: number;
  27254. /** The Y mouse cursor position at the time of the event */
  27255. pointerY: number;
  27256. /** The mesh that is currently pointed at (can be null) */
  27257. meshUnderPointer: Nullable<AbstractMesh>;
  27258. /** the original (browser) event that triggered the ActionEvent */
  27259. sourceEvent?: any;
  27260. /** additional data for the event */
  27261. additionalData?: any;
  27262. /**
  27263. * Creates a new ActionEvent
  27264. * @param source The mesh or sprite that triggered the action
  27265. * @param pointerX The X mouse cursor position at the time of the event
  27266. * @param pointerY The Y mouse cursor position at the time of the event
  27267. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  27268. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  27269. * @param additionalData additional data for the event
  27270. */
  27271. constructor(
  27272. /** The mesh or sprite that triggered the action */
  27273. source: any,
  27274. /** The X mouse cursor position at the time of the event */
  27275. pointerX: number,
  27276. /** The Y mouse cursor position at the time of the event */
  27277. pointerY: number,
  27278. /** The mesh that is currently pointed at (can be null) */
  27279. meshUnderPointer: Nullable<AbstractMesh>,
  27280. /** the original (browser) event that triggered the ActionEvent */
  27281. sourceEvent?: any,
  27282. /** additional data for the event */
  27283. additionalData?: any);
  27284. /**
  27285. * Helper function to auto-create an ActionEvent from a source mesh.
  27286. * @param source The source mesh that triggered the event
  27287. * @param evt The original (browser) event
  27288. * @param additionalData additional data for the event
  27289. * @returns the new ActionEvent
  27290. */
  27291. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  27292. /**
  27293. * Helper function to auto-create an ActionEvent from a source sprite
  27294. * @param source The source sprite that triggered the event
  27295. * @param scene Scene associated with the sprite
  27296. * @param evt The original (browser) event
  27297. * @param additionalData additional data for the event
  27298. * @returns the new ActionEvent
  27299. */
  27300. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  27301. /**
  27302. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  27303. * @param scene the scene where the event occurred
  27304. * @param evt The original (browser) event
  27305. * @returns the new ActionEvent
  27306. */
  27307. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  27308. /**
  27309. * Helper function to auto-create an ActionEvent from a primitive
  27310. * @param prim defines the target primitive
  27311. * @param pointerPos defines the pointer position
  27312. * @param evt The original (browser) event
  27313. * @param additionalData additional data for the event
  27314. * @returns the new ActionEvent
  27315. */
  27316. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  27317. }
  27318. }
  27319. declare module "babylonjs/Actions/abstractActionManager" {
  27320. import { IDisposable } from "babylonjs/scene";
  27321. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  27322. import { IAction } from "babylonjs/Actions/action";
  27323. import { Nullable } from "babylonjs/types";
  27324. /**
  27325. * Abstract class used to decouple action Manager from scene and meshes.
  27326. * Do not instantiate.
  27327. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27328. */
  27329. export abstract class AbstractActionManager implements IDisposable {
  27330. /** Gets the list of active triggers */
  27331. static Triggers: {
  27332. [key: string]: number;
  27333. };
  27334. /** Gets the cursor to use when hovering items */
  27335. hoverCursor: string;
  27336. /** Gets the list of actions */
  27337. actions: IAction[];
  27338. /**
  27339. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  27340. */
  27341. isRecursive: boolean;
  27342. /**
  27343. * Releases all associated resources
  27344. */
  27345. abstract dispose(): void;
  27346. /**
  27347. * Does this action manager has pointer triggers
  27348. */
  27349. abstract readonly hasPointerTriggers: boolean;
  27350. /**
  27351. * Does this action manager has pick triggers
  27352. */
  27353. abstract readonly hasPickTriggers: boolean;
  27354. /**
  27355. * Process a specific trigger
  27356. * @param trigger defines the trigger to process
  27357. * @param evt defines the event details to be processed
  27358. */
  27359. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  27360. /**
  27361. * Does this action manager handles actions of any of the given triggers
  27362. * @param triggers defines the triggers to be tested
  27363. * @return a boolean indicating whether one (or more) of the triggers is handled
  27364. */
  27365. abstract hasSpecificTriggers(triggers: number[]): boolean;
  27366. /**
  27367. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  27368. * speed.
  27369. * @param triggerA defines the trigger to be tested
  27370. * @param triggerB defines the trigger to be tested
  27371. * @return a boolean indicating whether one (or more) of the triggers is handled
  27372. */
  27373. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  27374. /**
  27375. * Does this action manager handles actions of a given trigger
  27376. * @param trigger defines the trigger to be tested
  27377. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  27378. * @return whether the trigger is handled
  27379. */
  27380. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  27381. /**
  27382. * Serialize this manager to a JSON object
  27383. * @param name defines the property name to store this manager
  27384. * @returns a JSON representation of this manager
  27385. */
  27386. abstract serialize(name: string): any;
  27387. /**
  27388. * Registers an action to this action manager
  27389. * @param action defines the action to be registered
  27390. * @return the action amended (prepared) after registration
  27391. */
  27392. abstract registerAction(action: IAction): Nullable<IAction>;
  27393. /**
  27394. * Unregisters an action to this action manager
  27395. * @param action defines the action to be unregistered
  27396. * @return a boolean indicating whether the action has been unregistered
  27397. */
  27398. abstract unregisterAction(action: IAction): Boolean;
  27399. /**
  27400. * Does exist one action manager with at least one trigger
  27401. **/
  27402. static readonly HasTriggers: boolean;
  27403. /**
  27404. * Does exist one action manager with at least one pick trigger
  27405. **/
  27406. static readonly HasPickTriggers: boolean;
  27407. /**
  27408. * Does exist one action manager that handles actions of a given trigger
  27409. * @param trigger defines the trigger to be tested
  27410. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  27411. **/
  27412. static HasSpecificTrigger(trigger: number): boolean;
  27413. }
  27414. }
  27415. declare module "babylonjs/node" {
  27416. import { Scene } from "babylonjs/scene";
  27417. import { Nullable } from "babylonjs/types";
  27418. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27419. import { Engine } from "babylonjs/Engines/engine";
  27420. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  27421. import { Observable } from "babylonjs/Misc/observable";
  27422. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  27423. import { IInspectable } from "babylonjs/Misc/iInspectable";
  27424. import { Animatable } from "babylonjs/Animations/animatable";
  27425. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27426. import { Animation } from "babylonjs/Animations/animation";
  27427. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27428. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27429. /**
  27430. * Defines how a node can be built from a string name.
  27431. */
  27432. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  27433. /**
  27434. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  27435. */
  27436. export class Node implements IBehaviorAware<Node> {
  27437. /** @hidden */
  27438. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  27439. private static _NodeConstructors;
  27440. /**
  27441. * Add a new node constructor
  27442. * @param type defines the type name of the node to construct
  27443. * @param constructorFunc defines the constructor function
  27444. */
  27445. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  27446. /**
  27447. * Returns a node constructor based on type name
  27448. * @param type defines the type name
  27449. * @param name defines the new node name
  27450. * @param scene defines the hosting scene
  27451. * @param options defines optional options to transmit to constructors
  27452. * @returns the new constructor or null
  27453. */
  27454. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  27455. /**
  27456. * Gets or sets the name of the node
  27457. */
  27458. name: string;
  27459. /**
  27460. * Gets or sets the id of the node
  27461. */
  27462. id: string;
  27463. /**
  27464. * Gets or sets the unique id of the node
  27465. */
  27466. uniqueId: number;
  27467. /**
  27468. * Gets or sets a string used to store user defined state for the node
  27469. */
  27470. state: string;
  27471. /**
  27472. * Gets or sets an object used to store user defined information for the node
  27473. */
  27474. metadata: any;
  27475. /**
  27476. * For internal use only. Please do not use.
  27477. */
  27478. reservedDataStore: any;
  27479. /**
  27480. * List of inspectable custom properties (used by the Inspector)
  27481. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27482. */
  27483. inspectableCustomProperties: IInspectable[];
  27484. /**
  27485. * Gets or sets a boolean used to define if the node must be serialized
  27486. */
  27487. doNotSerialize: boolean;
  27488. /** @hidden */
  27489. _isDisposed: boolean;
  27490. /**
  27491. * Gets a list of Animations associated with the node
  27492. */
  27493. animations: import("babylonjs/Animations/animation").Animation[];
  27494. protected _ranges: {
  27495. [name: string]: Nullable<AnimationRange>;
  27496. };
  27497. /**
  27498. * Callback raised when the node is ready to be used
  27499. */
  27500. onReady: Nullable<(node: Node) => void>;
  27501. private _isEnabled;
  27502. private _isParentEnabled;
  27503. private _isReady;
  27504. /** @hidden */
  27505. _currentRenderId: number;
  27506. private _parentUpdateId;
  27507. /** @hidden */
  27508. _childUpdateId: number;
  27509. /** @hidden */
  27510. _waitingParentId: Nullable<string>;
  27511. /** @hidden */
  27512. _scene: Scene;
  27513. /** @hidden */
  27514. _cache: any;
  27515. private _parentNode;
  27516. private _children;
  27517. /** @hidden */
  27518. _worldMatrix: Matrix;
  27519. /** @hidden */
  27520. _worldMatrixDeterminant: number;
  27521. /** @hidden */
  27522. _worldMatrixDeterminantIsDirty: boolean;
  27523. /** @hidden */
  27524. private _sceneRootNodesIndex;
  27525. /**
  27526. * Gets a boolean indicating if the node has been disposed
  27527. * @returns true if the node was disposed
  27528. */
  27529. isDisposed(): boolean;
  27530. /**
  27531. * Gets or sets the parent of the node (without keeping the current position in the scene)
  27532. * @see https://doc.babylonjs.com/how_to/parenting
  27533. */
  27534. parent: Nullable<Node>;
  27535. private addToSceneRootNodes;
  27536. private removeFromSceneRootNodes;
  27537. private _animationPropertiesOverride;
  27538. /**
  27539. * Gets or sets the animation properties override
  27540. */
  27541. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  27542. /**
  27543. * Gets a string idenfifying the name of the class
  27544. * @returns "Node" string
  27545. */
  27546. getClassName(): string;
  27547. /** @hidden */
  27548. readonly _isNode: boolean;
  27549. /**
  27550. * An event triggered when the mesh is disposed
  27551. */
  27552. onDisposeObservable: Observable<Node>;
  27553. private _onDisposeObserver;
  27554. /**
  27555. * Sets a callback that will be raised when the node will be disposed
  27556. */
  27557. onDispose: () => void;
  27558. /**
  27559. * Creates a new Node
  27560. * @param name the name and id to be given to this node
  27561. * @param scene the scene this node will be added to
  27562. * @param addToRootNodes the node will be added to scene.rootNodes
  27563. */
  27564. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  27565. /**
  27566. * Gets the scene of the node
  27567. * @returns a scene
  27568. */
  27569. getScene(): Scene;
  27570. /**
  27571. * Gets the engine of the node
  27572. * @returns a Engine
  27573. */
  27574. getEngine(): Engine;
  27575. private _behaviors;
  27576. /**
  27577. * Attach a behavior to the node
  27578. * @see http://doc.babylonjs.com/features/behaviour
  27579. * @param behavior defines the behavior to attach
  27580. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  27581. * @returns the current Node
  27582. */
  27583. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  27584. /**
  27585. * Remove an attached behavior
  27586. * @see http://doc.babylonjs.com/features/behaviour
  27587. * @param behavior defines the behavior to attach
  27588. * @returns the current Node
  27589. */
  27590. removeBehavior(behavior: Behavior<Node>): Node;
  27591. /**
  27592. * Gets the list of attached behaviors
  27593. * @see http://doc.babylonjs.com/features/behaviour
  27594. */
  27595. readonly behaviors: Behavior<Node>[];
  27596. /**
  27597. * Gets an attached behavior by name
  27598. * @param name defines the name of the behavior to look for
  27599. * @see http://doc.babylonjs.com/features/behaviour
  27600. * @returns null if behavior was not found else the requested behavior
  27601. */
  27602. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  27603. /**
  27604. * Returns the latest update of the World matrix
  27605. * @returns a Matrix
  27606. */
  27607. getWorldMatrix(): Matrix;
  27608. /** @hidden */
  27609. _getWorldMatrixDeterminant(): number;
  27610. /**
  27611. * Returns directly the latest state of the mesh World matrix.
  27612. * A Matrix is returned.
  27613. */
  27614. readonly worldMatrixFromCache: Matrix;
  27615. /** @hidden */
  27616. _initCache(): void;
  27617. /** @hidden */
  27618. updateCache(force?: boolean): void;
  27619. /** @hidden */
  27620. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27621. /** @hidden */
  27622. _updateCache(ignoreParentClass?: boolean): void;
  27623. /** @hidden */
  27624. _isSynchronized(): boolean;
  27625. /** @hidden */
  27626. _markSyncedWithParent(): void;
  27627. /** @hidden */
  27628. isSynchronizedWithParent(): boolean;
  27629. /** @hidden */
  27630. isSynchronized(): boolean;
  27631. /**
  27632. * Is this node ready to be used/rendered
  27633. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27634. * @return true if the node is ready
  27635. */
  27636. isReady(completeCheck?: boolean): boolean;
  27637. /**
  27638. * Is this node enabled?
  27639. * If the node has a parent, all ancestors will be checked and false will be returned if any are false (not enabled), otherwise will return true
  27640. * @param checkAncestors indicates if this method should check the ancestors. The default is to check the ancestors. If set to false, the method will return the value of this node without checking ancestors
  27641. * @return whether this node (and its parent) is enabled
  27642. */
  27643. isEnabled(checkAncestors?: boolean): boolean;
  27644. /** @hidden */
  27645. protected _syncParentEnabledState(): void;
  27646. /**
  27647. * Set the enabled state of this node
  27648. * @param value defines the new enabled state
  27649. */
  27650. setEnabled(value: boolean): void;
  27651. /**
  27652. * Is this node a descendant of the given node?
  27653. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  27654. * @param ancestor defines the parent node to inspect
  27655. * @returns a boolean indicating if this node is a descendant of the given node
  27656. */
  27657. isDescendantOf(ancestor: Node): boolean;
  27658. /** @hidden */
  27659. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  27660. /**
  27661. * Will return all nodes that have this node as ascendant
  27662. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  27663. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  27664. * @return all children nodes of all types
  27665. */
  27666. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  27667. /**
  27668. * Get all child-meshes of this node
  27669. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: false)
  27670. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  27671. * @returns an array of AbstractMesh
  27672. */
  27673. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  27674. /**
  27675. * Get all direct children of this node
  27676. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  27677. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: true)
  27678. * @returns an array of Node
  27679. */
  27680. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  27681. /** @hidden */
  27682. _setReady(state: boolean): void;
  27683. /**
  27684. * Get an animation by name
  27685. * @param name defines the name of the animation to look for
  27686. * @returns null if not found else the requested animation
  27687. */
  27688. getAnimationByName(name: string): Nullable<Animation>;
  27689. /**
  27690. * Creates an animation range for this node
  27691. * @param name defines the name of the range
  27692. * @param from defines the starting key
  27693. * @param to defines the end key
  27694. */
  27695. createAnimationRange(name: string, from: number, to: number): void;
  27696. /**
  27697. * Delete a specific animation range
  27698. * @param name defines the name of the range to delete
  27699. * @param deleteFrames defines if animation frames from the range must be deleted as well
  27700. */
  27701. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  27702. /**
  27703. * Get an animation range by name
  27704. * @param name defines the name of the animation range to look for
  27705. * @returns null if not found else the requested animation range
  27706. */
  27707. getAnimationRange(name: string): Nullable<AnimationRange>;
  27708. /**
  27709. * Gets the list of all animation ranges defined on this node
  27710. * @returns an array
  27711. */
  27712. getAnimationRanges(): Nullable<AnimationRange>[];
  27713. /**
  27714. * Will start the animation sequence
  27715. * @param name defines the range frames for animation sequence
  27716. * @param loop defines if the animation should loop (false by default)
  27717. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  27718. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  27719. * @returns the object created for this animation. If range does not exist, it will return null
  27720. */
  27721. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  27722. /**
  27723. * Serialize animation ranges into a JSON compatible object
  27724. * @returns serialization object
  27725. */
  27726. serializeAnimationRanges(): any;
  27727. /**
  27728. * Computes the world matrix of the node
  27729. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27730. * @returns the world matrix
  27731. */
  27732. computeWorldMatrix(force?: boolean): Matrix;
  27733. /**
  27734. * Releases resources associated with this node.
  27735. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27736. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27737. */
  27738. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27739. /**
  27740. * Parse animation range data from a serialization object and store them into a given node
  27741. * @param node defines where to store the animation ranges
  27742. * @param parsedNode defines the serialization object to read data from
  27743. * @param scene defines the hosting scene
  27744. */
  27745. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  27746. /**
  27747. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  27748. * @param includeDescendants Include bounding info from descendants as well (true by default)
  27749. * @param predicate defines a callback function that can be customize to filter what meshes should be included in the list used to compute the bounding vectors
  27750. * @returns the new bounding vectors
  27751. */
  27752. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  27753. min: Vector3;
  27754. max: Vector3;
  27755. };
  27756. }
  27757. }
  27758. declare module "babylonjs/Animations/animation" {
  27759. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  27760. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  27761. import { Color3 } from "babylonjs/Maths/math.color";
  27762. import { Nullable } from "babylonjs/types";
  27763. import { Scene } from "babylonjs/scene";
  27764. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  27765. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27766. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  27767. import { Node } from "babylonjs/node";
  27768. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27769. import { Size } from "babylonjs/Maths/math.size";
  27770. import { Animatable } from "babylonjs/Animations/animatable";
  27771. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  27772. /**
  27773. * @hidden
  27774. */
  27775. export class _IAnimationState {
  27776. key: number;
  27777. repeatCount: number;
  27778. workValue?: any;
  27779. loopMode?: number;
  27780. offsetValue?: any;
  27781. highLimitValue?: any;
  27782. }
  27783. /**
  27784. * Class used to store any kind of animation
  27785. */
  27786. export class Animation {
  27787. /**Name of the animation */
  27788. name: string;
  27789. /**Property to animate */
  27790. targetProperty: string;
  27791. /**The frames per second of the animation */
  27792. framePerSecond: number;
  27793. /**The data type of the animation */
  27794. dataType: number;
  27795. /**The loop mode of the animation */
  27796. loopMode?: number | undefined;
  27797. /**Specifies if blending should be enabled */
  27798. enableBlending?: boolean | undefined;
  27799. /**
  27800. * Use matrix interpolation instead of using direct key value when animating matrices
  27801. */
  27802. static AllowMatricesInterpolation: boolean;
  27803. /**
  27804. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  27805. */
  27806. static AllowMatrixDecomposeForInterpolation: boolean;
  27807. /**
  27808. * Stores the key frames of the animation
  27809. */
  27810. private _keys;
  27811. /**
  27812. * Stores the easing function of the animation
  27813. */
  27814. private _easingFunction;
  27815. /**
  27816. * @hidden Internal use only
  27817. */
  27818. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  27819. /**
  27820. * The set of event that will be linked to this animation
  27821. */
  27822. private _events;
  27823. /**
  27824. * Stores an array of target property paths
  27825. */
  27826. targetPropertyPath: string[];
  27827. /**
  27828. * Stores the blending speed of the animation
  27829. */
  27830. blendingSpeed: number;
  27831. /**
  27832. * Stores the animation ranges for the animation
  27833. */
  27834. private _ranges;
  27835. /**
  27836. * @hidden Internal use
  27837. */
  27838. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  27839. /**
  27840. * Sets up an animation
  27841. * @param property The property to animate
  27842. * @param animationType The animation type to apply
  27843. * @param framePerSecond The frames per second of the animation
  27844. * @param easingFunction The easing function used in the animation
  27845. * @returns The created animation
  27846. */
  27847. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  27848. /**
  27849. * Create and start an animation on a node
  27850. * @param name defines the name of the global animation that will be run on all nodes
  27851. * @param node defines the root node where the animation will take place
  27852. * @param targetProperty defines property to animate
  27853. * @param framePerSecond defines the number of frame per second yo use
  27854. * @param totalFrame defines the number of frames in total
  27855. * @param from defines the initial value
  27856. * @param to defines the final value
  27857. * @param loopMode defines which loop mode you want to use (off by default)
  27858. * @param easingFunction defines the easing function to use (linear by default)
  27859. * @param onAnimationEnd defines the callback to call when animation end
  27860. * @returns the animatable created for this animation
  27861. */
  27862. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27863. /**
  27864. * Create and start an animation on a node and its descendants
  27865. * @param name defines the name of the global animation that will be run on all nodes
  27866. * @param node defines the root node where the animation will take place
  27867. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used
  27868. * @param targetProperty defines property to animate
  27869. * @param framePerSecond defines the number of frame per second to use
  27870. * @param totalFrame defines the number of frames in total
  27871. * @param from defines the initial value
  27872. * @param to defines the final value
  27873. * @param loopMode defines which loop mode you want to use (off by default)
  27874. * @param easingFunction defines the easing function to use (linear by default)
  27875. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  27876. * @returns the list of animatables created for all nodes
  27877. * @example https://www.babylonjs-playground.com/#MH0VLI
  27878. */
  27879. static CreateAndStartHierarchyAnimation(name: string, node: Node, directDescendantsOnly: boolean, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable[]>;
  27880. /**
  27881. * Creates a new animation, merges it with the existing animations and starts it
  27882. * @param name Name of the animation
  27883. * @param node Node which contains the scene that begins the animations
  27884. * @param targetProperty Specifies which property to animate
  27885. * @param framePerSecond The frames per second of the animation
  27886. * @param totalFrame The total number of frames
  27887. * @param from The frame at the beginning of the animation
  27888. * @param to The frame at the end of the animation
  27889. * @param loopMode Specifies the loop mode of the animation
  27890. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  27891. * @param onAnimationEnd Callback to run once the animation is complete
  27892. * @returns Nullable animation
  27893. */
  27894. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27895. /**
  27896. * Transition property of an host to the target Value
  27897. * @param property The property to transition
  27898. * @param targetValue The target Value of the property
  27899. * @param host The object where the property to animate belongs
  27900. * @param scene Scene used to run the animation
  27901. * @param frameRate Framerate (in frame/s) to use
  27902. * @param transition The transition type we want to use
  27903. * @param duration The duration of the animation, in milliseconds
  27904. * @param onAnimationEnd Callback trigger at the end of the animation
  27905. * @returns Nullable animation
  27906. */
  27907. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  27908. /**
  27909. * Return the array of runtime animations currently using this animation
  27910. */
  27911. readonly runtimeAnimations: RuntimeAnimation[];
  27912. /**
  27913. * Specifies if any of the runtime animations are currently running
  27914. */
  27915. readonly hasRunningRuntimeAnimations: boolean;
  27916. /**
  27917. * Initializes the animation
  27918. * @param name Name of the animation
  27919. * @param targetProperty Property to animate
  27920. * @param framePerSecond The frames per second of the animation
  27921. * @param dataType The data type of the animation
  27922. * @param loopMode The loop mode of the animation
  27923. * @param enableBlending Specifies if blending should be enabled
  27924. */
  27925. constructor(
  27926. /**Name of the animation */
  27927. name: string,
  27928. /**Property to animate */
  27929. targetProperty: string,
  27930. /**The frames per second of the animation */
  27931. framePerSecond: number,
  27932. /**The data type of the animation */
  27933. dataType: number,
  27934. /**The loop mode of the animation */
  27935. loopMode?: number | undefined,
  27936. /**Specifies if blending should be enabled */
  27937. enableBlending?: boolean | undefined);
  27938. /**
  27939. * Converts the animation to a string
  27940. * @param fullDetails support for multiple levels of logging within scene loading
  27941. * @returns String form of the animation
  27942. */
  27943. toString(fullDetails?: boolean): string;
  27944. /**
  27945. * Add an event to this animation
  27946. * @param event Event to add
  27947. */
  27948. addEvent(event: AnimationEvent): void;
  27949. /**
  27950. * Remove all events found at the given frame
  27951. * @param frame The frame to remove events from
  27952. */
  27953. removeEvents(frame: number): void;
  27954. /**
  27955. * Retrieves all the events from the animation
  27956. * @returns Events from the animation
  27957. */
  27958. getEvents(): AnimationEvent[];
  27959. /**
  27960. * Creates an animation range
  27961. * @param name Name of the animation range
  27962. * @param from Starting frame of the animation range
  27963. * @param to Ending frame of the animation
  27964. */
  27965. createRange(name: string, from: number, to: number): void;
  27966. /**
  27967. * Deletes an animation range by name
  27968. * @param name Name of the animation range to delete
  27969. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  27970. */
  27971. deleteRange(name: string, deleteFrames?: boolean): void;
  27972. /**
  27973. * Gets the animation range by name, or null if not defined
  27974. * @param name Name of the animation range
  27975. * @returns Nullable animation range
  27976. */
  27977. getRange(name: string): Nullable<AnimationRange>;
  27978. /**
  27979. * Gets the key frames from the animation
  27980. * @returns The key frames of the animation
  27981. */
  27982. getKeys(): Array<IAnimationKey>;
  27983. /**
  27984. * Gets the highest frame rate of the animation
  27985. * @returns Highest frame rate of the animation
  27986. */
  27987. getHighestFrame(): number;
  27988. /**
  27989. * Gets the easing function of the animation
  27990. * @returns Easing function of the animation
  27991. */
  27992. getEasingFunction(): IEasingFunction;
  27993. /**
  27994. * Sets the easing function of the animation
  27995. * @param easingFunction A custom mathematical formula for animation
  27996. */
  27997. setEasingFunction(easingFunction: EasingFunction): void;
  27998. /**
  27999. * Interpolates a scalar linearly
  28000. * @param startValue Start value of the animation curve
  28001. * @param endValue End value of the animation curve
  28002. * @param gradient Scalar amount to interpolate
  28003. * @returns Interpolated scalar value
  28004. */
  28005. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  28006. /**
  28007. * Interpolates a scalar cubically
  28008. * @param startValue Start value of the animation curve
  28009. * @param outTangent End tangent of the animation
  28010. * @param endValue End value of the animation curve
  28011. * @param inTangent Start tangent of the animation curve
  28012. * @param gradient Scalar amount to interpolate
  28013. * @returns Interpolated scalar value
  28014. */
  28015. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  28016. /**
  28017. * Interpolates a quaternion using a spherical linear interpolation
  28018. * @param startValue Start value of the animation curve
  28019. * @param endValue End value of the animation curve
  28020. * @param gradient Scalar amount to interpolate
  28021. * @returns Interpolated quaternion value
  28022. */
  28023. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  28024. /**
  28025. * Interpolates a quaternion cubically
  28026. * @param startValue Start value of the animation curve
  28027. * @param outTangent End tangent of the animation curve
  28028. * @param endValue End value of the animation curve
  28029. * @param inTangent Start tangent of the animation curve
  28030. * @param gradient Scalar amount to interpolate
  28031. * @returns Interpolated quaternion value
  28032. */
  28033. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  28034. /**
  28035. * Interpolates a Vector3 linearl
  28036. * @param startValue Start value of the animation curve
  28037. * @param endValue End value of the animation curve
  28038. * @param gradient Scalar amount to interpolate
  28039. * @returns Interpolated scalar value
  28040. */
  28041. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  28042. /**
  28043. * Interpolates a Vector3 cubically
  28044. * @param startValue Start value of the animation curve
  28045. * @param outTangent End tangent of the animation
  28046. * @param endValue End value of the animation curve
  28047. * @param inTangent Start tangent of the animation curve
  28048. * @param gradient Scalar amount to interpolate
  28049. * @returns InterpolatedVector3 value
  28050. */
  28051. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  28052. /**
  28053. * Interpolates a Vector2 linearly
  28054. * @param startValue Start value of the animation curve
  28055. * @param endValue End value of the animation curve
  28056. * @param gradient Scalar amount to interpolate
  28057. * @returns Interpolated Vector2 value
  28058. */
  28059. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  28060. /**
  28061. * Interpolates a Vector2 cubically
  28062. * @param startValue Start value of the animation curve
  28063. * @param outTangent End tangent of the animation
  28064. * @param endValue End value of the animation curve
  28065. * @param inTangent Start tangent of the animation curve
  28066. * @param gradient Scalar amount to interpolate
  28067. * @returns Interpolated Vector2 value
  28068. */
  28069. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  28070. /**
  28071. * Interpolates a size linearly
  28072. * @param startValue Start value of the animation curve
  28073. * @param endValue End value of the animation curve
  28074. * @param gradient Scalar amount to interpolate
  28075. * @returns Interpolated Size value
  28076. */
  28077. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  28078. /**
  28079. * Interpolates a Color3 linearly
  28080. * @param startValue Start value of the animation curve
  28081. * @param endValue End value of the animation curve
  28082. * @param gradient Scalar amount to interpolate
  28083. * @returns Interpolated Color3 value
  28084. */
  28085. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  28086. /**
  28087. * @hidden Internal use only
  28088. */
  28089. _getKeyValue(value: any): any;
  28090. /**
  28091. * @hidden Internal use only
  28092. */
  28093. _interpolate(currentFrame: number, state: _IAnimationState): any;
  28094. /**
  28095. * Defines the function to use to interpolate matrices
  28096. * @param startValue defines the start matrix
  28097. * @param endValue defines the end matrix
  28098. * @param gradient defines the gradient between both matrices
  28099. * @param result defines an optional target matrix where to store the interpolation
  28100. * @returns the interpolated matrix
  28101. */
  28102. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  28103. /**
  28104. * Makes a copy of the animation
  28105. * @returns Cloned animation
  28106. */
  28107. clone(): Animation;
  28108. /**
  28109. * Sets the key frames of the animation
  28110. * @param values The animation key frames to set
  28111. */
  28112. setKeys(values: Array<IAnimationKey>): void;
  28113. /**
  28114. * Serializes the animation to an object
  28115. * @returns Serialized object
  28116. */
  28117. serialize(): any;
  28118. /**
  28119. * Float animation type
  28120. */
  28121. private static _ANIMATIONTYPE_FLOAT;
  28122. /**
  28123. * Vector3 animation type
  28124. */
  28125. private static _ANIMATIONTYPE_VECTOR3;
  28126. /**
  28127. * Quaternion animation type
  28128. */
  28129. private static _ANIMATIONTYPE_QUATERNION;
  28130. /**
  28131. * Matrix animation type
  28132. */
  28133. private static _ANIMATIONTYPE_MATRIX;
  28134. /**
  28135. * Color3 animation type
  28136. */
  28137. private static _ANIMATIONTYPE_COLOR3;
  28138. /**
  28139. * Vector2 animation type
  28140. */
  28141. private static _ANIMATIONTYPE_VECTOR2;
  28142. /**
  28143. * Size animation type
  28144. */
  28145. private static _ANIMATIONTYPE_SIZE;
  28146. /**
  28147. * Relative Loop Mode
  28148. */
  28149. private static _ANIMATIONLOOPMODE_RELATIVE;
  28150. /**
  28151. * Cycle Loop Mode
  28152. */
  28153. private static _ANIMATIONLOOPMODE_CYCLE;
  28154. /**
  28155. * Constant Loop Mode
  28156. */
  28157. private static _ANIMATIONLOOPMODE_CONSTANT;
  28158. /**
  28159. * Get the float animation type
  28160. */
  28161. static readonly ANIMATIONTYPE_FLOAT: number;
  28162. /**
  28163. * Get the Vector3 animation type
  28164. */
  28165. static readonly ANIMATIONTYPE_VECTOR3: number;
  28166. /**
  28167. * Get the Vector2 animation type
  28168. */
  28169. static readonly ANIMATIONTYPE_VECTOR2: number;
  28170. /**
  28171. * Get the Size animation type
  28172. */
  28173. static readonly ANIMATIONTYPE_SIZE: number;
  28174. /**
  28175. * Get the Quaternion animation type
  28176. */
  28177. static readonly ANIMATIONTYPE_QUATERNION: number;
  28178. /**
  28179. * Get the Matrix animation type
  28180. */
  28181. static readonly ANIMATIONTYPE_MATRIX: number;
  28182. /**
  28183. * Get the Color3 animation type
  28184. */
  28185. static readonly ANIMATIONTYPE_COLOR3: number;
  28186. /**
  28187. * Get the Relative Loop Mode
  28188. */
  28189. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  28190. /**
  28191. * Get the Cycle Loop Mode
  28192. */
  28193. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  28194. /**
  28195. * Get the Constant Loop Mode
  28196. */
  28197. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  28198. /** @hidden */
  28199. static _UniversalLerp(left: any, right: any, amount: number): any;
  28200. /**
  28201. * Parses an animation object and creates an animation
  28202. * @param parsedAnimation Parsed animation object
  28203. * @returns Animation object
  28204. */
  28205. static Parse(parsedAnimation: any): Animation;
  28206. /**
  28207. * Appends the serialized animations from the source animations
  28208. * @param source Source containing the animations
  28209. * @param destination Target to store the animations
  28210. */
  28211. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28212. }
  28213. }
  28214. declare module "babylonjs/Animations/animatable.interface" {
  28215. import { Nullable } from "babylonjs/types";
  28216. import { Animation } from "babylonjs/Animations/animation";
  28217. /**
  28218. * Interface containing an array of animations
  28219. */
  28220. export interface IAnimatable {
  28221. /**
  28222. * Array of animations
  28223. */
  28224. animations: Nullable<Array<Animation>>;
  28225. }
  28226. }
  28227. declare module "babylonjs/Materials/fresnelParameters" {
  28228. import { Color3 } from "babylonjs/Maths/math.color";
  28229. /**
  28230. * This represents all the required information to add a fresnel effect on a material:
  28231. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28232. */
  28233. export class FresnelParameters {
  28234. private _isEnabled;
  28235. /**
  28236. * Define if the fresnel effect is enable or not.
  28237. */
  28238. isEnabled: boolean;
  28239. /**
  28240. * Define the color used on edges (grazing angle)
  28241. */
  28242. leftColor: Color3;
  28243. /**
  28244. * Define the color used on center
  28245. */
  28246. rightColor: Color3;
  28247. /**
  28248. * Define bias applied to computed fresnel term
  28249. */
  28250. bias: number;
  28251. /**
  28252. * Defined the power exponent applied to fresnel term
  28253. */
  28254. power: number;
  28255. /**
  28256. * Clones the current fresnel and its valuues
  28257. * @returns a clone fresnel configuration
  28258. */
  28259. clone(): FresnelParameters;
  28260. /**
  28261. * Serializes the current fresnel parameters to a JSON representation.
  28262. * @return the JSON serialization
  28263. */
  28264. serialize(): any;
  28265. /**
  28266. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28267. * @param parsedFresnelParameters Define the JSON representation
  28268. * @returns the parsed parameters
  28269. */
  28270. static Parse(parsedFresnelParameters: any): FresnelParameters;
  28271. }
  28272. }
  28273. declare module "babylonjs/Misc/decorators" {
  28274. import { Nullable } from "babylonjs/types";
  28275. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28276. import { Scene } from "babylonjs/scene";
  28277. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  28278. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28279. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28280. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28281. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28282. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28283. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28284. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28285. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28286. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28287. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28288. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28289. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28290. /**
  28291. * Decorator used to define property that can be serialized as reference to a camera
  28292. * @param sourceName defines the name of the property to decorate
  28293. */
  28294. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28295. /**
  28296. * Class used to help serialization objects
  28297. */
  28298. export class SerializationHelper {
  28299. /** @hidden */
  28300. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  28301. /** @hidden */
  28302. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  28303. /** @hidden */
  28304. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  28305. /** @hidden */
  28306. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  28307. /**
  28308. * Appends the serialized animations from the source animations
  28309. * @param source Source containing the animations
  28310. * @param destination Target to store the animations
  28311. */
  28312. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28313. /**
  28314. * Static function used to serialized a specific entity
  28315. * @param entity defines the entity to serialize
  28316. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  28317. * @returns a JSON compatible object representing the serialization of the entity
  28318. */
  28319. static Serialize<T>(entity: T, serializationObject?: any): any;
  28320. /**
  28321. * Creates a new entity from a serialization data object
  28322. * @param creationFunction defines a function used to instanciated the new entity
  28323. * @param source defines the source serialization data
  28324. * @param scene defines the hosting scene
  28325. * @param rootUrl defines the root url for resources
  28326. * @returns a new entity
  28327. */
  28328. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  28329. /**
  28330. * Clones an object
  28331. * @param creationFunction defines the function used to instanciate the new object
  28332. * @param source defines the source object
  28333. * @returns the cloned object
  28334. */
  28335. static Clone<T>(creationFunction: () => T, source: T): T;
  28336. /**
  28337. * Instanciates a new object based on a source one (some data will be shared between both object)
  28338. * @param creationFunction defines the function used to instanciate the new object
  28339. * @param source defines the source object
  28340. * @returns the new object
  28341. */
  28342. static Instanciate<T>(creationFunction: () => T, source: T): T;
  28343. }
  28344. }
  28345. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  28346. import { Nullable } from "babylonjs/types";
  28347. /**
  28348. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  28349. */
  28350. export interface CubeMapInfo {
  28351. /**
  28352. * The pixel array for the front face.
  28353. * This is stored in format, left to right, up to down format.
  28354. */
  28355. front: Nullable<ArrayBufferView>;
  28356. /**
  28357. * The pixel array for the back face.
  28358. * This is stored in format, left to right, up to down format.
  28359. */
  28360. back: Nullable<ArrayBufferView>;
  28361. /**
  28362. * The pixel array for the left face.
  28363. * This is stored in format, left to right, up to down format.
  28364. */
  28365. left: Nullable<ArrayBufferView>;
  28366. /**
  28367. * The pixel array for the right face.
  28368. * This is stored in format, left to right, up to down format.
  28369. */
  28370. right: Nullable<ArrayBufferView>;
  28371. /**
  28372. * The pixel array for the up face.
  28373. * This is stored in format, left to right, up to down format.
  28374. */
  28375. up: Nullable<ArrayBufferView>;
  28376. /**
  28377. * The pixel array for the down face.
  28378. * This is stored in format, left to right, up to down format.
  28379. */
  28380. down: Nullable<ArrayBufferView>;
  28381. /**
  28382. * The size of the cubemap stored.
  28383. *
  28384. * Each faces will be size * size pixels.
  28385. */
  28386. size: number;
  28387. /**
  28388. * The format of the texture.
  28389. *
  28390. * RGBA, RGB.
  28391. */
  28392. format: number;
  28393. /**
  28394. * The type of the texture data.
  28395. *
  28396. * UNSIGNED_INT, FLOAT.
  28397. */
  28398. type: number;
  28399. /**
  28400. * Specifies whether the texture is in gamma space.
  28401. */
  28402. gammaSpace: boolean;
  28403. }
  28404. /**
  28405. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  28406. */
  28407. export class PanoramaToCubeMapTools {
  28408. private static FACE_FRONT;
  28409. private static FACE_BACK;
  28410. private static FACE_RIGHT;
  28411. private static FACE_LEFT;
  28412. private static FACE_DOWN;
  28413. private static FACE_UP;
  28414. /**
  28415. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  28416. *
  28417. * @param float32Array The source data.
  28418. * @param inputWidth The width of the input panorama.
  28419. * @param inputHeight The height of the input panorama.
  28420. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  28421. * @return The cubemap data
  28422. */
  28423. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  28424. private static CreateCubemapTexture;
  28425. private static CalcProjectionSpherical;
  28426. }
  28427. }
  28428. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  28429. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28430. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28431. import { Nullable } from "babylonjs/types";
  28432. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  28433. /**
  28434. * Helper class dealing with the extraction of spherical polynomial dataArray
  28435. * from a cube map.
  28436. */
  28437. export class CubeMapToSphericalPolynomialTools {
  28438. private static FileFaces;
  28439. /**
  28440. * Converts a texture to the according Spherical Polynomial data.
  28441. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28442. *
  28443. * @param texture The texture to extract the information from.
  28444. * @return The Spherical Polynomial data.
  28445. */
  28446. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  28447. /**
  28448. * Converts a cubemap to the according Spherical Polynomial data.
  28449. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28450. *
  28451. * @param cubeInfo The Cube map to extract the information from.
  28452. * @return The Spherical Polynomial data.
  28453. */
  28454. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  28455. }
  28456. }
  28457. declare module "babylonjs/Misc/guid" {
  28458. /**
  28459. * Class used to manipulate GUIDs
  28460. */
  28461. export class GUID {
  28462. /**
  28463. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28464. * Be aware Math.random() could cause collisions, but:
  28465. * "All but 6 of the 128 bits of the ID are randomly generated, which means that for any two ids, there's a 1 in 2^^122 (or 5.3x10^^36) chance they'll collide"
  28466. * @returns a pseudo random id
  28467. */
  28468. static RandomId(): string;
  28469. }
  28470. }
  28471. declare module "babylonjs/Materials/Textures/baseTexture" {
  28472. import { Observable } from "babylonjs/Misc/observable";
  28473. import { Nullable } from "babylonjs/types";
  28474. import { Scene } from "babylonjs/scene";
  28475. import { Matrix } from "babylonjs/Maths/math.vector";
  28476. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28477. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28478. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28479. import { ISize } from "babylonjs/Maths/math.size";
  28480. /**
  28481. * Base class of all the textures in babylon.
  28482. * It groups all the common properties the materials, post process, lights... might need
  28483. * in order to make a correct use of the texture.
  28484. */
  28485. export class BaseTexture implements IAnimatable {
  28486. /**
  28487. * Default anisotropic filtering level for the application.
  28488. * It is set to 4 as a good tradeoff between perf and quality.
  28489. */
  28490. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  28491. /**
  28492. * Gets or sets the unique id of the texture
  28493. */
  28494. uniqueId: number;
  28495. /**
  28496. * Define the name of the texture.
  28497. */
  28498. name: string;
  28499. /**
  28500. * Gets or sets an object used to store user defined information.
  28501. */
  28502. metadata: any;
  28503. /**
  28504. * For internal use only. Please do not use.
  28505. */
  28506. reservedDataStore: any;
  28507. private _hasAlpha;
  28508. /**
  28509. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  28510. */
  28511. hasAlpha: boolean;
  28512. /**
  28513. * Defines if the alpha value should be determined via the rgb values.
  28514. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  28515. */
  28516. getAlphaFromRGB: boolean;
  28517. /**
  28518. * Intensity or strength of the texture.
  28519. * It is commonly used by materials to fine tune the intensity of the texture
  28520. */
  28521. level: number;
  28522. /**
  28523. * Define the UV chanel to use starting from 0 and defaulting to 0.
  28524. * This is part of the texture as textures usually maps to one uv set.
  28525. */
  28526. coordinatesIndex: number;
  28527. private _coordinatesMode;
  28528. /**
  28529. * How a texture is mapped.
  28530. *
  28531. * | Value | Type | Description |
  28532. * | ----- | ----------------------------------- | ----------- |
  28533. * | 0 | EXPLICIT_MODE | |
  28534. * | 1 | SPHERICAL_MODE | |
  28535. * | 2 | PLANAR_MODE | |
  28536. * | 3 | CUBIC_MODE | |
  28537. * | 4 | PROJECTION_MODE | |
  28538. * | 5 | SKYBOX_MODE | |
  28539. * | 6 | INVCUBIC_MODE | |
  28540. * | 7 | EQUIRECTANGULAR_MODE | |
  28541. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  28542. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  28543. */
  28544. coordinatesMode: number;
  28545. /**
  28546. * | Value | Type | Description |
  28547. * | ----- | ------------------ | ----------- |
  28548. * | 0 | CLAMP_ADDRESSMODE | |
  28549. * | 1 | WRAP_ADDRESSMODE | |
  28550. * | 2 | MIRROR_ADDRESSMODE | |
  28551. */
  28552. wrapU: number;
  28553. /**
  28554. * | Value | Type | Description |
  28555. * | ----- | ------------------ | ----------- |
  28556. * | 0 | CLAMP_ADDRESSMODE | |
  28557. * | 1 | WRAP_ADDRESSMODE | |
  28558. * | 2 | MIRROR_ADDRESSMODE | |
  28559. */
  28560. wrapV: number;
  28561. /**
  28562. * | Value | Type | Description |
  28563. * | ----- | ------------------ | ----------- |
  28564. * | 0 | CLAMP_ADDRESSMODE | |
  28565. * | 1 | WRAP_ADDRESSMODE | |
  28566. * | 2 | MIRROR_ADDRESSMODE | |
  28567. */
  28568. wrapR: number;
  28569. /**
  28570. * With compliant hardware and browser (supporting anisotropic filtering)
  28571. * this defines the level of anisotropic filtering in the texture.
  28572. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  28573. */
  28574. anisotropicFilteringLevel: number;
  28575. /**
  28576. * Define if the texture is a cube texture or if false a 2d texture.
  28577. */
  28578. isCube: boolean;
  28579. /**
  28580. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  28581. */
  28582. is3D: boolean;
  28583. /**
  28584. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  28585. * HDR texture are usually stored in linear space.
  28586. * This only impacts the PBR and Background materials
  28587. */
  28588. gammaSpace: boolean;
  28589. /**
  28590. * Gets or sets whether or not the texture contains RGBD data.
  28591. */
  28592. isRGBD: boolean;
  28593. /**
  28594. * Is Z inverted in the texture (useful in a cube texture).
  28595. */
  28596. invertZ: boolean;
  28597. /**
  28598. * Are mip maps generated for this texture or not.
  28599. */
  28600. readonly noMipmap: boolean;
  28601. /**
  28602. * @hidden
  28603. */
  28604. lodLevelInAlpha: boolean;
  28605. /**
  28606. * With prefiltered texture, defined the offset used during the prefiltering steps.
  28607. */
  28608. lodGenerationOffset: number;
  28609. /**
  28610. * With prefiltered texture, defined the scale used during the prefiltering steps.
  28611. */
  28612. lodGenerationScale: number;
  28613. /**
  28614. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  28615. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  28616. * average roughness values.
  28617. */
  28618. linearSpecularLOD: boolean;
  28619. /**
  28620. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  28621. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  28622. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  28623. */
  28624. irradianceTexture: Nullable<BaseTexture>;
  28625. /**
  28626. * Define if the texture is a render target.
  28627. */
  28628. isRenderTarget: boolean;
  28629. /**
  28630. * Define the unique id of the texture in the scene.
  28631. */
  28632. readonly uid: string;
  28633. /**
  28634. * Return a string representation of the texture.
  28635. * @returns the texture as a string
  28636. */
  28637. toString(): string;
  28638. /**
  28639. * Get the class name of the texture.
  28640. * @returns "BaseTexture"
  28641. */
  28642. getClassName(): string;
  28643. /**
  28644. * Define the list of animation attached to the texture.
  28645. */
  28646. animations: import("babylonjs/Animations/animation").Animation[];
  28647. /**
  28648. * An event triggered when the texture is disposed.
  28649. */
  28650. onDisposeObservable: Observable<BaseTexture>;
  28651. private _onDisposeObserver;
  28652. /**
  28653. * Callback triggered when the texture has been disposed.
  28654. * Kept for back compatibility, you can use the onDisposeObservable instead.
  28655. */
  28656. onDispose: () => void;
  28657. /**
  28658. * Define the current state of the loading sequence when in delayed load mode.
  28659. */
  28660. delayLoadState: number;
  28661. private _scene;
  28662. /** @hidden */
  28663. _texture: Nullable<InternalTexture>;
  28664. private _uid;
  28665. /**
  28666. * Define if the texture is preventinga material to render or not.
  28667. * If not and the texture is not ready, the engine will use a default black texture instead.
  28668. */
  28669. readonly isBlocking: boolean;
  28670. /**
  28671. * Instantiates a new BaseTexture.
  28672. * Base class of all the textures in babylon.
  28673. * It groups all the common properties the materials, post process, lights... might need
  28674. * in order to make a correct use of the texture.
  28675. * @param scene Define the scene the texture blongs to
  28676. */
  28677. constructor(scene: Nullable<Scene>);
  28678. /**
  28679. * Get the scene the texture belongs to.
  28680. * @returns the scene or null if undefined
  28681. */
  28682. getScene(): Nullable<Scene>;
  28683. /**
  28684. * Get the texture transform matrix used to offset tile the texture for istance.
  28685. * @returns the transformation matrix
  28686. */
  28687. getTextureMatrix(): Matrix;
  28688. /**
  28689. * Get the texture reflection matrix used to rotate/transform the reflection.
  28690. * @returns the reflection matrix
  28691. */
  28692. getReflectionTextureMatrix(): Matrix;
  28693. /**
  28694. * Get the underlying lower level texture from Babylon.
  28695. * @returns the insternal texture
  28696. */
  28697. getInternalTexture(): Nullable<InternalTexture>;
  28698. /**
  28699. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  28700. * @returns true if ready or not blocking
  28701. */
  28702. isReadyOrNotBlocking(): boolean;
  28703. /**
  28704. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  28705. * @returns true if fully ready
  28706. */
  28707. isReady(): boolean;
  28708. private _cachedSize;
  28709. /**
  28710. * Get the size of the texture.
  28711. * @returns the texture size.
  28712. */
  28713. getSize(): ISize;
  28714. /**
  28715. * Get the base size of the texture.
  28716. * It can be different from the size if the texture has been resized for POT for instance
  28717. * @returns the base size
  28718. */
  28719. getBaseSize(): ISize;
  28720. /**
  28721. * Update the sampling mode of the texture.
  28722. * Default is Trilinear mode.
  28723. *
  28724. * | Value | Type | Description |
  28725. * | ----- | ------------------ | ----------- |
  28726. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  28727. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  28728. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  28729. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  28730. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  28731. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  28732. * | 7 | NEAREST_LINEAR | |
  28733. * | 8 | NEAREST_NEAREST | |
  28734. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  28735. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  28736. * | 11 | LINEAR_LINEAR | |
  28737. * | 12 | LINEAR_NEAREST | |
  28738. *
  28739. * > _mag_: magnification filter (close to the viewer)
  28740. * > _min_: minification filter (far from the viewer)
  28741. * > _mip_: filter used between mip map levels
  28742. *@param samplingMode Define the new sampling mode of the texture
  28743. */
  28744. updateSamplingMode(samplingMode: number): void;
  28745. /**
  28746. * Scales the texture if is `canRescale()`
  28747. * @param ratio the resize factor we want to use to rescale
  28748. */
  28749. scale(ratio: number): void;
  28750. /**
  28751. * Get if the texture can rescale.
  28752. */
  28753. readonly canRescale: boolean;
  28754. /** @hidden */
  28755. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  28756. /** @hidden */
  28757. _rebuild(): void;
  28758. /**
  28759. * Triggers the load sequence in delayed load mode.
  28760. */
  28761. delayLoad(): void;
  28762. /**
  28763. * Clones the texture.
  28764. * @returns the cloned texture
  28765. */
  28766. clone(): Nullable<BaseTexture>;
  28767. /**
  28768. * Get the texture underlying type (INT, FLOAT...)
  28769. */
  28770. readonly textureType: number;
  28771. /**
  28772. * Get the texture underlying format (RGB, RGBA...)
  28773. */
  28774. readonly textureFormat: number;
  28775. /**
  28776. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  28777. * This will returns an RGBA array buffer containing either in values (0-255) or
  28778. * float values (0-1) depending of the underlying buffer type.
  28779. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  28780. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  28781. * @param buffer defines a user defined buffer to fill with data (can be null)
  28782. * @returns The Array buffer containing the pixels data.
  28783. */
  28784. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  28785. /**
  28786. * Release and destroy the underlying lower level texture aka internalTexture.
  28787. */
  28788. releaseInternalTexture(): void;
  28789. /**
  28790. * Get the polynomial representation of the texture data.
  28791. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  28792. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  28793. */
  28794. sphericalPolynomial: Nullable<SphericalPolynomial>;
  28795. /** @hidden */
  28796. readonly _lodTextureHigh: Nullable<BaseTexture>;
  28797. /** @hidden */
  28798. readonly _lodTextureMid: Nullable<BaseTexture>;
  28799. /** @hidden */
  28800. readonly _lodTextureLow: Nullable<BaseTexture>;
  28801. /**
  28802. * Dispose the texture and release its associated resources.
  28803. */
  28804. dispose(): void;
  28805. /**
  28806. * Serialize the texture into a JSON representation that can be parsed later on.
  28807. * @returns the JSON representation of the texture
  28808. */
  28809. serialize(): any;
  28810. /**
  28811. * Helper function to be called back once a list of texture contains only ready textures.
  28812. * @param textures Define the list of textures to wait for
  28813. * @param callback Define the callback triggered once the entire list will be ready
  28814. */
  28815. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  28816. }
  28817. }
  28818. declare module "babylonjs/Materials/Textures/internalTexture" {
  28819. import { Observable } from "babylonjs/Misc/observable";
  28820. import { Nullable, int } from "babylonjs/types";
  28821. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28822. import { Engine } from "babylonjs/Engines/engine";
  28823. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28824. /**
  28825. * Class used to store data associated with WebGL texture data for the engine
  28826. * This class should not be used directly
  28827. */
  28828. export class InternalTexture {
  28829. /** @hidden */
  28830. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  28831. /**
  28832. * The source of the texture data is unknown
  28833. */
  28834. static DATASOURCE_UNKNOWN: number;
  28835. /**
  28836. * Texture data comes from an URL
  28837. */
  28838. static DATASOURCE_URL: number;
  28839. /**
  28840. * Texture data is only used for temporary storage
  28841. */
  28842. static DATASOURCE_TEMP: number;
  28843. /**
  28844. * Texture data comes from raw data (ArrayBuffer)
  28845. */
  28846. static DATASOURCE_RAW: number;
  28847. /**
  28848. * Texture content is dynamic (video or dynamic texture)
  28849. */
  28850. static DATASOURCE_DYNAMIC: number;
  28851. /**
  28852. * Texture content is generated by rendering to it
  28853. */
  28854. static DATASOURCE_RENDERTARGET: number;
  28855. /**
  28856. * Texture content is part of a multi render target process
  28857. */
  28858. static DATASOURCE_MULTIRENDERTARGET: number;
  28859. /**
  28860. * Texture data comes from a cube data file
  28861. */
  28862. static DATASOURCE_CUBE: number;
  28863. /**
  28864. * Texture data comes from a raw cube data
  28865. */
  28866. static DATASOURCE_CUBERAW: number;
  28867. /**
  28868. * Texture data come from a prefiltered cube data file
  28869. */
  28870. static DATASOURCE_CUBEPREFILTERED: number;
  28871. /**
  28872. * Texture content is raw 3D data
  28873. */
  28874. static DATASOURCE_RAW3D: number;
  28875. /**
  28876. * Texture content is a depth texture
  28877. */
  28878. static DATASOURCE_DEPTHTEXTURE: number;
  28879. /**
  28880. * Texture data comes from a raw cube data encoded with RGBD
  28881. */
  28882. static DATASOURCE_CUBERAW_RGBD: number;
  28883. /**
  28884. * Defines if the texture is ready
  28885. */
  28886. isReady: boolean;
  28887. /**
  28888. * Defines if the texture is a cube texture
  28889. */
  28890. isCube: boolean;
  28891. /**
  28892. * Defines if the texture contains 3D data
  28893. */
  28894. is3D: boolean;
  28895. /**
  28896. * Defines if the texture contains multiview data
  28897. */
  28898. isMultiview: boolean;
  28899. /**
  28900. * Gets the URL used to load this texture
  28901. */
  28902. url: string;
  28903. /**
  28904. * Gets the sampling mode of the texture
  28905. */
  28906. samplingMode: number;
  28907. /**
  28908. * Gets a boolean indicating if the texture needs mipmaps generation
  28909. */
  28910. generateMipMaps: boolean;
  28911. /**
  28912. * Gets the number of samples used by the texture (WebGL2+ only)
  28913. */
  28914. samples: number;
  28915. /**
  28916. * Gets the type of the texture (int, float...)
  28917. */
  28918. type: number;
  28919. /**
  28920. * Gets the format of the texture (RGB, RGBA...)
  28921. */
  28922. format: number;
  28923. /**
  28924. * Observable called when the texture is loaded
  28925. */
  28926. onLoadedObservable: Observable<InternalTexture>;
  28927. /**
  28928. * Gets the width of the texture
  28929. */
  28930. width: number;
  28931. /**
  28932. * Gets the height of the texture
  28933. */
  28934. height: number;
  28935. /**
  28936. * Gets the depth of the texture
  28937. */
  28938. depth: number;
  28939. /**
  28940. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  28941. */
  28942. baseWidth: number;
  28943. /**
  28944. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  28945. */
  28946. baseHeight: number;
  28947. /**
  28948. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  28949. */
  28950. baseDepth: number;
  28951. /**
  28952. * Gets a boolean indicating if the texture is inverted on Y axis
  28953. */
  28954. invertY: boolean;
  28955. /** @hidden */
  28956. _invertVScale: boolean;
  28957. /** @hidden */
  28958. _associatedChannel: number;
  28959. /** @hidden */
  28960. _dataSource: number;
  28961. /** @hidden */
  28962. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  28963. /** @hidden */
  28964. _bufferView: Nullable<ArrayBufferView>;
  28965. /** @hidden */
  28966. _bufferViewArray: Nullable<ArrayBufferView[]>;
  28967. /** @hidden */
  28968. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  28969. /** @hidden */
  28970. _size: number;
  28971. /** @hidden */
  28972. _extension: string;
  28973. /** @hidden */
  28974. _files: Nullable<string[]>;
  28975. /** @hidden */
  28976. _workingCanvas: Nullable<HTMLCanvasElement>;
  28977. /** @hidden */
  28978. _workingContext: Nullable<CanvasRenderingContext2D>;
  28979. /** @hidden */
  28980. _framebuffer: Nullable<WebGLFramebuffer>;
  28981. /** @hidden */
  28982. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  28983. /** @hidden */
  28984. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  28985. /** @hidden */
  28986. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  28987. /** @hidden */
  28988. _attachments: Nullable<number[]>;
  28989. /** @hidden */
  28990. _cachedCoordinatesMode: Nullable<number>;
  28991. /** @hidden */
  28992. _cachedWrapU: Nullable<number>;
  28993. /** @hidden */
  28994. _cachedWrapV: Nullable<number>;
  28995. /** @hidden */
  28996. _cachedWrapR: Nullable<number>;
  28997. /** @hidden */
  28998. _cachedAnisotropicFilteringLevel: Nullable<number>;
  28999. /** @hidden */
  29000. _isDisabled: boolean;
  29001. /** @hidden */
  29002. _compression: Nullable<string>;
  29003. /** @hidden */
  29004. _generateStencilBuffer: boolean;
  29005. /** @hidden */
  29006. _generateDepthBuffer: boolean;
  29007. /** @hidden */
  29008. _comparisonFunction: number;
  29009. /** @hidden */
  29010. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  29011. /** @hidden */
  29012. _lodGenerationScale: number;
  29013. /** @hidden */
  29014. _lodGenerationOffset: number;
  29015. /** @hidden */
  29016. _colorTextureArray: Nullable<WebGLTexture>;
  29017. /** @hidden */
  29018. _depthStencilTextureArray: Nullable<WebGLTexture>;
  29019. /** @hidden */
  29020. _lodTextureHigh: Nullable<BaseTexture>;
  29021. /** @hidden */
  29022. _lodTextureMid: Nullable<BaseTexture>;
  29023. /** @hidden */
  29024. _lodTextureLow: Nullable<BaseTexture>;
  29025. /** @hidden */
  29026. _isRGBD: boolean;
  29027. /** @hidden */
  29028. _linearSpecularLOD: boolean;
  29029. /** @hidden */
  29030. _irradianceTexture: Nullable<BaseTexture>;
  29031. /** @hidden */
  29032. _webGLTexture: Nullable<WebGLTexture>;
  29033. /** @hidden */
  29034. _references: number;
  29035. private _engine;
  29036. /**
  29037. * Gets the Engine the texture belongs to.
  29038. * @returns The babylon engine
  29039. */
  29040. getEngine(): Engine;
  29041. /**
  29042. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  29043. */
  29044. readonly dataSource: number;
  29045. /**
  29046. * Creates a new InternalTexture
  29047. * @param engine defines the engine to use
  29048. * @param dataSource defines the type of data that will be used
  29049. * @param delayAllocation if the texture allocation should be delayed (default: false)
  29050. */
  29051. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  29052. /**
  29053. * Increments the number of references (ie. the number of Texture that point to it)
  29054. */
  29055. incrementReferences(): void;
  29056. /**
  29057. * Change the size of the texture (not the size of the content)
  29058. * @param width defines the new width
  29059. * @param height defines the new height
  29060. * @param depth defines the new depth (1 by default)
  29061. */
  29062. updateSize(width: int, height: int, depth?: int): void;
  29063. /** @hidden */
  29064. _rebuild(): void;
  29065. /** @hidden */
  29066. _swapAndDie(target: InternalTexture): void;
  29067. /**
  29068. * Dispose the current allocated resources
  29069. */
  29070. dispose(): void;
  29071. }
  29072. }
  29073. declare module "babylonjs/Materials/effect" {
  29074. import { Observable } from "babylonjs/Misc/observable";
  29075. import { Nullable } from "babylonjs/types";
  29076. import { IDisposable } from "babylonjs/scene";
  29077. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  29078. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29079. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  29080. import { Engine } from "babylonjs/Engines/engine";
  29081. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29082. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29083. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29084. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29085. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29086. /**
  29087. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  29088. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  29089. */
  29090. export class EffectFallbacks {
  29091. private _defines;
  29092. private _currentRank;
  29093. private _maxRank;
  29094. private _mesh;
  29095. /**
  29096. * Removes the fallback from the bound mesh.
  29097. */
  29098. unBindMesh(): void;
  29099. /**
  29100. * Adds a fallback on the specified property.
  29101. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29102. * @param define The name of the define in the shader
  29103. */
  29104. addFallback(rank: number, define: string): void;
  29105. /**
  29106. * Sets the mesh to use CPU skinning when needing to fallback.
  29107. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29108. * @param mesh The mesh to use the fallbacks.
  29109. */
  29110. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  29111. /**
  29112. * Checks to see if more fallbacks are still availible.
  29113. */
  29114. readonly hasMoreFallbacks: boolean;
  29115. /**
  29116. * Removes the defines that should be removed when falling back.
  29117. * @param currentDefines defines the current define statements for the shader.
  29118. * @param effect defines the current effect we try to compile
  29119. * @returns The resulting defines with defines of the current rank removed.
  29120. */
  29121. reduce(currentDefines: string, effect: Effect): string;
  29122. }
  29123. /**
  29124. * Options to be used when creating an effect.
  29125. */
  29126. export class EffectCreationOptions {
  29127. /**
  29128. * Atrributes that will be used in the shader.
  29129. */
  29130. attributes: string[];
  29131. /**
  29132. * Uniform varible names that will be set in the shader.
  29133. */
  29134. uniformsNames: string[];
  29135. /**
  29136. * Uniform buffer varible names that will be set in the shader.
  29137. */
  29138. uniformBuffersNames: string[];
  29139. /**
  29140. * Sampler texture variable names that will be set in the shader.
  29141. */
  29142. samplers: string[];
  29143. /**
  29144. * Define statements that will be set in the shader.
  29145. */
  29146. defines: any;
  29147. /**
  29148. * Possible fallbacks for this effect to improve performance when needed.
  29149. */
  29150. fallbacks: Nullable<EffectFallbacks>;
  29151. /**
  29152. * Callback that will be called when the shader is compiled.
  29153. */
  29154. onCompiled: Nullable<(effect: Effect) => void>;
  29155. /**
  29156. * Callback that will be called if an error occurs during shader compilation.
  29157. */
  29158. onError: Nullable<(effect: Effect, errors: string) => void>;
  29159. /**
  29160. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29161. */
  29162. indexParameters: any;
  29163. /**
  29164. * Max number of lights that can be used in the shader.
  29165. */
  29166. maxSimultaneousLights: number;
  29167. /**
  29168. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29169. */
  29170. transformFeedbackVaryings: Nullable<string[]>;
  29171. }
  29172. /**
  29173. * Effect containing vertex and fragment shader that can be executed on an object.
  29174. */
  29175. export class Effect implements IDisposable {
  29176. /**
  29177. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29178. */
  29179. static ShadersRepository: string;
  29180. /**
  29181. * Name of the effect.
  29182. */
  29183. name: any;
  29184. /**
  29185. * String container all the define statements that should be set on the shader.
  29186. */
  29187. defines: string;
  29188. /**
  29189. * Callback that will be called when the shader is compiled.
  29190. */
  29191. onCompiled: Nullable<(effect: Effect) => void>;
  29192. /**
  29193. * Callback that will be called if an error occurs during shader compilation.
  29194. */
  29195. onError: Nullable<(effect: Effect, errors: string) => void>;
  29196. /**
  29197. * Callback that will be called when effect is bound.
  29198. */
  29199. onBind: Nullable<(effect: Effect) => void>;
  29200. /**
  29201. * Unique ID of the effect.
  29202. */
  29203. uniqueId: number;
  29204. /**
  29205. * Observable that will be called when the shader is compiled.
  29206. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29207. */
  29208. onCompileObservable: Observable<Effect>;
  29209. /**
  29210. * Observable that will be called if an error occurs during shader compilation.
  29211. */
  29212. onErrorObservable: Observable<Effect>;
  29213. /** @hidden */
  29214. _onBindObservable: Nullable<Observable<Effect>>;
  29215. /**
  29216. * Observable that will be called when effect is bound.
  29217. */
  29218. readonly onBindObservable: Observable<Effect>;
  29219. /** @hidden */
  29220. _bonesComputationForcedToCPU: boolean;
  29221. private static _uniqueIdSeed;
  29222. private _engine;
  29223. private _uniformBuffersNames;
  29224. private _uniformsNames;
  29225. private _samplerList;
  29226. private _samplers;
  29227. private _isReady;
  29228. private _compilationError;
  29229. private _attributesNames;
  29230. private _attributes;
  29231. private _uniforms;
  29232. /**
  29233. * Key for the effect.
  29234. * @hidden
  29235. */
  29236. _key: string;
  29237. private _indexParameters;
  29238. private _fallbacks;
  29239. private _vertexSourceCode;
  29240. private _fragmentSourceCode;
  29241. private _vertexSourceCodeOverride;
  29242. private _fragmentSourceCodeOverride;
  29243. private _transformFeedbackVaryings;
  29244. /**
  29245. * Compiled shader to webGL program.
  29246. * @hidden
  29247. */
  29248. _pipelineContext: Nullable<IPipelineContext>;
  29249. private _valueCache;
  29250. private static _baseCache;
  29251. /**
  29252. * Instantiates an effect.
  29253. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29254. * @param baseName Name of the effect.
  29255. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29256. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29257. * @param samplers List of sampler variables that will be passed to the shader.
  29258. * @param engine Engine to be used to render the effect
  29259. * @param defines Define statements to be added to the shader.
  29260. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29261. * @param onCompiled Callback that will be called when the shader is compiled.
  29262. * @param onError Callback that will be called if an error occurs during shader compilation.
  29263. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29264. */
  29265. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: Nullable<string[]>, engine?: Engine, defines?: Nullable<string>, fallbacks?: Nullable<EffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  29266. private _useFinalCode;
  29267. /**
  29268. * Unique key for this effect
  29269. */
  29270. readonly key: string;
  29271. /**
  29272. * If the effect has been compiled and prepared.
  29273. * @returns if the effect is compiled and prepared.
  29274. */
  29275. isReady(): boolean;
  29276. private _isReadyInternal;
  29277. /**
  29278. * The engine the effect was initialized with.
  29279. * @returns the engine.
  29280. */
  29281. getEngine(): Engine;
  29282. /**
  29283. * The pipeline context for this effect
  29284. * @returns the associated pipeline context
  29285. */
  29286. getPipelineContext(): Nullable<IPipelineContext>;
  29287. /**
  29288. * The set of names of attribute variables for the shader.
  29289. * @returns An array of attribute names.
  29290. */
  29291. getAttributesNames(): string[];
  29292. /**
  29293. * Returns the attribute at the given index.
  29294. * @param index The index of the attribute.
  29295. * @returns The location of the attribute.
  29296. */
  29297. getAttributeLocation(index: number): number;
  29298. /**
  29299. * Returns the attribute based on the name of the variable.
  29300. * @param name of the attribute to look up.
  29301. * @returns the attribute location.
  29302. */
  29303. getAttributeLocationByName(name: string): number;
  29304. /**
  29305. * The number of attributes.
  29306. * @returns the numnber of attributes.
  29307. */
  29308. getAttributesCount(): number;
  29309. /**
  29310. * Gets the index of a uniform variable.
  29311. * @param uniformName of the uniform to look up.
  29312. * @returns the index.
  29313. */
  29314. getUniformIndex(uniformName: string): number;
  29315. /**
  29316. * Returns the attribute based on the name of the variable.
  29317. * @param uniformName of the uniform to look up.
  29318. * @returns the location of the uniform.
  29319. */
  29320. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29321. /**
  29322. * Returns an array of sampler variable names
  29323. * @returns The array of sampler variable neames.
  29324. */
  29325. getSamplers(): string[];
  29326. /**
  29327. * The error from the last compilation.
  29328. * @returns the error string.
  29329. */
  29330. getCompilationError(): string;
  29331. /**
  29332. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29333. * @param func The callback to be used.
  29334. */
  29335. executeWhenCompiled(func: (effect: Effect) => void): void;
  29336. private _checkIsReady;
  29337. /** @hidden */
  29338. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29339. /** @hidden */
  29340. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29341. /** @hidden */
  29342. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29343. /**
  29344. * Recompiles the webGL program
  29345. * @param vertexSourceCode The source code for the vertex shader.
  29346. * @param fragmentSourceCode The source code for the fragment shader.
  29347. * @param onCompiled Callback called when completed.
  29348. * @param onError Callback called on error.
  29349. * @hidden
  29350. */
  29351. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29352. /**
  29353. * Prepares the effect
  29354. * @hidden
  29355. */
  29356. _prepareEffect(): void;
  29357. private _processCompilationErrors;
  29358. /**
  29359. * Checks if the effect is supported. (Must be called after compilation)
  29360. */
  29361. readonly isSupported: boolean;
  29362. /**
  29363. * Binds a texture to the engine to be used as output of the shader.
  29364. * @param channel Name of the output variable.
  29365. * @param texture Texture to bind.
  29366. * @hidden
  29367. */
  29368. _bindTexture(channel: string, texture: InternalTexture): void;
  29369. /**
  29370. * Sets a texture on the engine to be used in the shader.
  29371. * @param channel Name of the sampler variable.
  29372. * @param texture Texture to set.
  29373. */
  29374. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29375. /**
  29376. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29377. * @param channel Name of the sampler variable.
  29378. * @param texture Texture to set.
  29379. */
  29380. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29381. /**
  29382. * Sets an array of textures on the engine to be used in the shader.
  29383. * @param channel Name of the variable.
  29384. * @param textures Textures to set.
  29385. */
  29386. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29387. /**
  29388. * Sets a texture to be the input of the specified post process. (To use the output, pass in the next post process in the pipeline)
  29389. * @param channel Name of the sampler variable.
  29390. * @param postProcess Post process to get the input texture from.
  29391. */
  29392. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29393. /**
  29394. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29395. * Sets the input texture of the passed in post process to be input of this effect. (To use the output of the passed in post process use setTextureFromPostProcessOutput)
  29396. * @param channel Name of the sampler variable.
  29397. * @param postProcess Post process to get the output texture from.
  29398. */
  29399. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29400. /** @hidden */
  29401. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29402. /** @hidden */
  29403. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29404. /** @hidden */
  29405. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29406. /** @hidden */
  29407. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29408. /**
  29409. * Binds a buffer to a uniform.
  29410. * @param buffer Buffer to bind.
  29411. * @param name Name of the uniform variable to bind to.
  29412. */
  29413. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29414. /**
  29415. * Binds block to a uniform.
  29416. * @param blockName Name of the block to bind.
  29417. * @param index Index to bind.
  29418. */
  29419. bindUniformBlock(blockName: string, index: number): void;
  29420. /**
  29421. * Sets an interger value on a uniform variable.
  29422. * @param uniformName Name of the variable.
  29423. * @param value Value to be set.
  29424. * @returns this effect.
  29425. */
  29426. setInt(uniformName: string, value: number): Effect;
  29427. /**
  29428. * Sets an int array on a uniform variable.
  29429. * @param uniformName Name of the variable.
  29430. * @param array array to be set.
  29431. * @returns this effect.
  29432. */
  29433. setIntArray(uniformName: string, array: Int32Array): Effect;
  29434. /**
  29435. * Sets an int array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  29436. * @param uniformName Name of the variable.
  29437. * @param array array to be set.
  29438. * @returns this effect.
  29439. */
  29440. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29441. /**
  29442. * Sets an int array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  29443. * @param uniformName Name of the variable.
  29444. * @param array array to be set.
  29445. * @returns this effect.
  29446. */
  29447. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29448. /**
  29449. * Sets an int array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  29450. * @param uniformName Name of the variable.
  29451. * @param array array to be set.
  29452. * @returns this effect.
  29453. */
  29454. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29455. /**
  29456. * Sets an float array on a uniform variable.
  29457. * @param uniformName Name of the variable.
  29458. * @param array array to be set.
  29459. * @returns this effect.
  29460. */
  29461. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29462. /**
  29463. * Sets an float array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  29464. * @param uniformName Name of the variable.
  29465. * @param array array to be set.
  29466. * @returns this effect.
  29467. */
  29468. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29469. /**
  29470. * Sets an float array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  29471. * @param uniformName Name of the variable.
  29472. * @param array array to be set.
  29473. * @returns this effect.
  29474. */
  29475. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29476. /**
  29477. * Sets an float array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  29478. * @param uniformName Name of the variable.
  29479. * @param array array to be set.
  29480. * @returns this effect.
  29481. */
  29482. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29483. /**
  29484. * Sets an array on a uniform variable.
  29485. * @param uniformName Name of the variable.
  29486. * @param array array to be set.
  29487. * @returns this effect.
  29488. */
  29489. setArray(uniformName: string, array: number[]): Effect;
  29490. /**
  29491. * Sets an array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  29492. * @param uniformName Name of the variable.
  29493. * @param array array to be set.
  29494. * @returns this effect.
  29495. */
  29496. setArray2(uniformName: string, array: number[]): Effect;
  29497. /**
  29498. * Sets an array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  29499. * @param uniformName Name of the variable.
  29500. * @param array array to be set.
  29501. * @returns this effect.
  29502. */
  29503. setArray3(uniformName: string, array: number[]): Effect;
  29504. /**
  29505. * Sets an array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  29506. * @param uniformName Name of the variable.
  29507. * @param array array to be set.
  29508. * @returns this effect.
  29509. */
  29510. setArray4(uniformName: string, array: number[]): Effect;
  29511. /**
  29512. * Sets matrices on a uniform variable.
  29513. * @param uniformName Name of the variable.
  29514. * @param matrices matrices to be set.
  29515. * @returns this effect.
  29516. */
  29517. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29518. /**
  29519. * Sets matrix on a uniform variable.
  29520. * @param uniformName Name of the variable.
  29521. * @param matrix matrix to be set.
  29522. * @returns this effect.
  29523. */
  29524. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  29525. /**
  29526. * Sets a 3x3 matrix on a uniform variable. (Speicified as [1,2,3,4,5,6,7,8,9] will result in [1,2,3][4,5,6][7,8,9] matrix)
  29527. * @param uniformName Name of the variable.
  29528. * @param matrix matrix to be set.
  29529. * @returns this effect.
  29530. */
  29531. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29532. /**
  29533. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29534. * @param uniformName Name of the variable.
  29535. * @param matrix matrix to be set.
  29536. * @returns this effect.
  29537. */
  29538. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29539. /**
  29540. * Sets a float on a uniform variable.
  29541. * @param uniformName Name of the variable.
  29542. * @param value value to be set.
  29543. * @returns this effect.
  29544. */
  29545. setFloat(uniformName: string, value: number): Effect;
  29546. /**
  29547. * Sets a boolean on a uniform variable.
  29548. * @param uniformName Name of the variable.
  29549. * @param bool value to be set.
  29550. * @returns this effect.
  29551. */
  29552. setBool(uniformName: string, bool: boolean): Effect;
  29553. /**
  29554. * Sets a Vector2 on a uniform variable.
  29555. * @param uniformName Name of the variable.
  29556. * @param vector2 vector2 to be set.
  29557. * @returns this effect.
  29558. */
  29559. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  29560. /**
  29561. * Sets a float2 on a uniform variable.
  29562. * @param uniformName Name of the variable.
  29563. * @param x First float in float2.
  29564. * @param y Second float in float2.
  29565. * @returns this effect.
  29566. */
  29567. setFloat2(uniformName: string, x: number, y: number): Effect;
  29568. /**
  29569. * Sets a Vector3 on a uniform variable.
  29570. * @param uniformName Name of the variable.
  29571. * @param vector3 Value to be set.
  29572. * @returns this effect.
  29573. */
  29574. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  29575. /**
  29576. * Sets a float3 on a uniform variable.
  29577. * @param uniformName Name of the variable.
  29578. * @param x First float in float3.
  29579. * @param y Second float in float3.
  29580. * @param z Third float in float3.
  29581. * @returns this effect.
  29582. */
  29583. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29584. /**
  29585. * Sets a Vector4 on a uniform variable.
  29586. * @param uniformName Name of the variable.
  29587. * @param vector4 Value to be set.
  29588. * @returns this effect.
  29589. */
  29590. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  29591. /**
  29592. * Sets a float4 on a uniform variable.
  29593. * @param uniformName Name of the variable.
  29594. * @param x First float in float4.
  29595. * @param y Second float in float4.
  29596. * @param z Third float in float4.
  29597. * @param w Fourth float in float4.
  29598. * @returns this effect.
  29599. */
  29600. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29601. /**
  29602. * Sets a Color3 on a uniform variable.
  29603. * @param uniformName Name of the variable.
  29604. * @param color3 Value to be set.
  29605. * @returns this effect.
  29606. */
  29607. setColor3(uniformName: string, color3: IColor3Like): Effect;
  29608. /**
  29609. * Sets a Color4 on a uniform variable.
  29610. * @param uniformName Name of the variable.
  29611. * @param color3 Value to be set.
  29612. * @param alpha Alpha value to be set.
  29613. * @returns this effect.
  29614. */
  29615. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  29616. /**
  29617. * Sets a Color4 on a uniform variable
  29618. * @param uniformName defines the name of the variable
  29619. * @param color4 defines the value to be set
  29620. * @returns this effect.
  29621. */
  29622. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  29623. /** Release all associated resources */
  29624. dispose(): void;
  29625. /**
  29626. * This function will add a new shader to the shader store
  29627. * @param name the name of the shader
  29628. * @param pixelShader optional pixel shader content
  29629. * @param vertexShader optional vertex shader content
  29630. */
  29631. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29632. /**
  29633. * Store of each shader (The can be looked up using effect.key)
  29634. */
  29635. static ShadersStore: {
  29636. [key: string]: string;
  29637. };
  29638. /**
  29639. * Store of each included file for a shader (The can be looked up using effect.key)
  29640. */
  29641. static IncludesShadersStore: {
  29642. [key: string]: string;
  29643. };
  29644. /**
  29645. * Resets the cache of effects.
  29646. */
  29647. static ResetCache(): void;
  29648. }
  29649. }
  29650. declare module "babylonjs/Materials/uniformBuffer" {
  29651. import { Nullable, FloatArray } from "babylonjs/types";
  29652. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  29653. import { Engine } from "babylonjs/Engines/engine";
  29654. import { Effect } from "babylonjs/Materials/effect";
  29655. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29656. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29657. import { Color3 } from "babylonjs/Maths/math.color";
  29658. /**
  29659. * Uniform buffer objects.
  29660. *
  29661. * Handles blocks of uniform on the GPU.
  29662. *
  29663. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  29664. *
  29665. * For more information, please refer to :
  29666. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  29667. */
  29668. export class UniformBuffer {
  29669. private _engine;
  29670. private _buffer;
  29671. private _data;
  29672. private _bufferData;
  29673. private _dynamic?;
  29674. private _uniformLocations;
  29675. private _uniformSizes;
  29676. private _uniformLocationPointer;
  29677. private _needSync;
  29678. private _noUBO;
  29679. private _currentEffect;
  29680. private static _MAX_UNIFORM_SIZE;
  29681. private static _tempBuffer;
  29682. /**
  29683. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  29684. * This is dynamic to allow compat with webgl 1 and 2.
  29685. * You will need to pass the name of the uniform as well as the value.
  29686. */
  29687. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  29688. /**
  29689. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  29690. * This is dynamic to allow compat with webgl 1 and 2.
  29691. * You will need to pass the name of the uniform as well as the value.
  29692. */
  29693. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  29694. /**
  29695. * Lambda to Update a single float in a uniform buffer.
  29696. * This is dynamic to allow compat with webgl 1 and 2.
  29697. * You will need to pass the name of the uniform as well as the value.
  29698. */
  29699. updateFloat: (name: string, x: number) => void;
  29700. /**
  29701. * Lambda to Update a vec2 of float in a uniform buffer.
  29702. * This is dynamic to allow compat with webgl 1 and 2.
  29703. * You will need to pass the name of the uniform as well as the value.
  29704. */
  29705. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  29706. /**
  29707. * Lambda to Update a vec3 of float in a uniform buffer.
  29708. * This is dynamic to allow compat with webgl 1 and 2.
  29709. * You will need to pass the name of the uniform as well as the value.
  29710. */
  29711. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  29712. /**
  29713. * Lambda to Update a vec4 of float in a uniform buffer.
  29714. * This is dynamic to allow compat with webgl 1 and 2.
  29715. * You will need to pass the name of the uniform as well as the value.
  29716. */
  29717. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  29718. /**
  29719. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  29720. * This is dynamic to allow compat with webgl 1 and 2.
  29721. * You will need to pass the name of the uniform as well as the value.
  29722. */
  29723. updateMatrix: (name: string, mat: Matrix) => void;
  29724. /**
  29725. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  29726. * This is dynamic to allow compat with webgl 1 and 2.
  29727. * You will need to pass the name of the uniform as well as the value.
  29728. */
  29729. updateVector3: (name: string, vector: Vector3) => void;
  29730. /**
  29731. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  29732. * This is dynamic to allow compat with webgl 1 and 2.
  29733. * You will need to pass the name of the uniform as well as the value.
  29734. */
  29735. updateVector4: (name: string, vector: Vector4) => void;
  29736. /**
  29737. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  29738. * This is dynamic to allow compat with webgl 1 and 2.
  29739. * You will need to pass the name of the uniform as well as the value.
  29740. */
  29741. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  29742. /**
  29743. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  29744. * This is dynamic to allow compat with webgl 1 and 2.
  29745. * You will need to pass the name of the uniform as well as the value.
  29746. */
  29747. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  29748. /**
  29749. * Instantiates a new Uniform buffer objects.
  29750. *
  29751. * Handles blocks of uniform on the GPU.
  29752. *
  29753. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  29754. *
  29755. * For more information, please refer to :
  29756. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  29757. * @param engine Define the engine the buffer is associated with
  29758. * @param data Define the data contained in the buffer
  29759. * @param dynamic Define if the buffer is updatable
  29760. */
  29761. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  29762. /**
  29763. * Indicates if the buffer is using the WebGL2 UBO implementation,
  29764. * or just falling back on setUniformXXX calls.
  29765. */
  29766. readonly useUbo: boolean;
  29767. /**
  29768. * Indicates if the WebGL underlying uniform buffer is in sync
  29769. * with the javascript cache data.
  29770. */
  29771. readonly isSync: boolean;
  29772. /**
  29773. * Indicates if the WebGL underlying uniform buffer is dynamic.
  29774. * Also, a dynamic UniformBuffer will disable cache verification and always
  29775. * update the underlying WebGL uniform buffer to the GPU.
  29776. * @returns if Dynamic, otherwise false
  29777. */
  29778. isDynamic(): boolean;
  29779. /**
  29780. * The data cache on JS side.
  29781. * @returns the underlying data as a float array
  29782. */
  29783. getData(): Float32Array;
  29784. /**
  29785. * The underlying WebGL Uniform buffer.
  29786. * @returns the webgl buffer
  29787. */
  29788. getBuffer(): Nullable<DataBuffer>;
  29789. /**
  29790. * std140 layout specifies how to align data within an UBO structure.
  29791. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  29792. * for specs.
  29793. */
  29794. private _fillAlignment;
  29795. /**
  29796. * Adds an uniform in the buffer.
  29797. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  29798. * for the layout to be correct !
  29799. * @param name Name of the uniform, as used in the uniform block in the shader.
  29800. * @param size Data size, or data directly.
  29801. */
  29802. addUniform(name: string, size: number | number[]): void;
  29803. /**
  29804. * Adds a Matrix 4x4 to the uniform buffer.
  29805. * @param name Name of the uniform, as used in the uniform block in the shader.
  29806. * @param mat A 4x4 matrix.
  29807. */
  29808. addMatrix(name: string, mat: Matrix): void;
  29809. /**
  29810. * Adds a vec2 to the uniform buffer.
  29811. * @param name Name of the uniform, as used in the uniform block in the shader.
  29812. * @param x Define the x component value of the vec2
  29813. * @param y Define the y component value of the vec2
  29814. */
  29815. addFloat2(name: string, x: number, y: number): void;
  29816. /**
  29817. * Adds a vec3 to the uniform buffer.
  29818. * @param name Name of the uniform, as used in the uniform block in the shader.
  29819. * @param x Define the x component value of the vec3
  29820. * @param y Define the y component value of the vec3
  29821. * @param z Define the z component value of the vec3
  29822. */
  29823. addFloat3(name: string, x: number, y: number, z: number): void;
  29824. /**
  29825. * Adds a vec3 to the uniform buffer.
  29826. * @param name Name of the uniform, as used in the uniform block in the shader.
  29827. * @param color Define the vec3 from a Color
  29828. */
  29829. addColor3(name: string, color: Color3): void;
  29830. /**
  29831. * Adds a vec4 to the uniform buffer.
  29832. * @param name Name of the uniform, as used in the uniform block in the shader.
  29833. * @param color Define the rgb components from a Color
  29834. * @param alpha Define the a component of the vec4
  29835. */
  29836. addColor4(name: string, color: Color3, alpha: number): void;
  29837. /**
  29838. * Adds a vec3 to the uniform buffer.
  29839. * @param name Name of the uniform, as used in the uniform block in the shader.
  29840. * @param vector Define the vec3 components from a Vector
  29841. */
  29842. addVector3(name: string, vector: Vector3): void;
  29843. /**
  29844. * Adds a Matrix 3x3 to the uniform buffer.
  29845. * @param name Name of the uniform, as used in the uniform block in the shader.
  29846. */
  29847. addMatrix3x3(name: string): void;
  29848. /**
  29849. * Adds a Matrix 2x2 to the uniform buffer.
  29850. * @param name Name of the uniform, as used in the uniform block in the shader.
  29851. */
  29852. addMatrix2x2(name: string): void;
  29853. /**
  29854. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  29855. */
  29856. create(): void;
  29857. /** @hidden */
  29858. _rebuild(): void;
  29859. /**
  29860. * Updates the WebGL Uniform Buffer on the GPU.
  29861. * If the `dynamic` flag is set to true, no cache comparison is done.
  29862. * Otherwise, the buffer will be updated only if the cache differs.
  29863. */
  29864. update(): void;
  29865. /**
  29866. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  29867. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  29868. * @param data Define the flattened data
  29869. * @param size Define the size of the data.
  29870. */
  29871. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  29872. private _valueCache;
  29873. private _cacheMatrix;
  29874. private _updateMatrix3x3ForUniform;
  29875. private _updateMatrix3x3ForEffect;
  29876. private _updateMatrix2x2ForEffect;
  29877. private _updateMatrix2x2ForUniform;
  29878. private _updateFloatForEffect;
  29879. private _updateFloatForUniform;
  29880. private _updateFloat2ForEffect;
  29881. private _updateFloat2ForUniform;
  29882. private _updateFloat3ForEffect;
  29883. private _updateFloat3ForUniform;
  29884. private _updateFloat4ForEffect;
  29885. private _updateFloat4ForUniform;
  29886. private _updateMatrixForEffect;
  29887. private _updateMatrixForUniform;
  29888. private _updateVector3ForEffect;
  29889. private _updateVector3ForUniform;
  29890. private _updateVector4ForEffect;
  29891. private _updateVector4ForUniform;
  29892. private _updateColor3ForEffect;
  29893. private _updateColor3ForUniform;
  29894. private _updateColor4ForEffect;
  29895. private _updateColor4ForUniform;
  29896. /**
  29897. * Sets a sampler uniform on the effect.
  29898. * @param name Define the name of the sampler.
  29899. * @param texture Define the texture to set in the sampler
  29900. */
  29901. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  29902. /**
  29903. * Directly updates the value of the uniform in the cache AND on the GPU.
  29904. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  29905. * @param data Define the flattened data
  29906. */
  29907. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  29908. /**
  29909. * Binds this uniform buffer to an effect.
  29910. * @param effect Define the effect to bind the buffer to
  29911. * @param name Name of the uniform block in the shader.
  29912. */
  29913. bindToEffect(effect: Effect, name: string): void;
  29914. /**
  29915. * Disposes the uniform buffer.
  29916. */
  29917. dispose(): void;
  29918. }
  29919. }
  29920. declare module "babylonjs/Audio/analyser" {
  29921. import { Scene } from "babylonjs/scene";
  29922. /**
  29923. * Class used to work with sound analyzer using fast fourier transform (FFT)
  29924. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29925. */
  29926. export class Analyser {
  29927. /**
  29928. * Gets or sets the smoothing
  29929. * @ignorenaming
  29930. */
  29931. SMOOTHING: number;
  29932. /**
  29933. * Gets or sets the FFT table size
  29934. * @ignorenaming
  29935. */
  29936. FFT_SIZE: number;
  29937. /**
  29938. * Gets or sets the bar graph amplitude
  29939. * @ignorenaming
  29940. */
  29941. BARGRAPHAMPLITUDE: number;
  29942. /**
  29943. * Gets or sets the position of the debug canvas
  29944. * @ignorenaming
  29945. */
  29946. DEBUGCANVASPOS: {
  29947. x: number;
  29948. y: number;
  29949. };
  29950. /**
  29951. * Gets or sets the debug canvas size
  29952. * @ignorenaming
  29953. */
  29954. DEBUGCANVASSIZE: {
  29955. width: number;
  29956. height: number;
  29957. };
  29958. private _byteFreqs;
  29959. private _byteTime;
  29960. private _floatFreqs;
  29961. private _webAudioAnalyser;
  29962. private _debugCanvas;
  29963. private _debugCanvasContext;
  29964. private _scene;
  29965. private _registerFunc;
  29966. private _audioEngine;
  29967. /**
  29968. * Creates a new analyser
  29969. * @param scene defines hosting scene
  29970. */
  29971. constructor(scene: Scene);
  29972. /**
  29973. * Get the number of data values you will have to play with for the visualization
  29974. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  29975. * @returns a number
  29976. */
  29977. getFrequencyBinCount(): number;
  29978. /**
  29979. * Gets the current frequency data as a byte array
  29980. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29981. * @returns a Uint8Array
  29982. */
  29983. getByteFrequencyData(): Uint8Array;
  29984. /**
  29985. * Gets the current waveform as a byte array
  29986. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  29987. * @returns a Uint8Array
  29988. */
  29989. getByteTimeDomainData(): Uint8Array;
  29990. /**
  29991. * Gets the current frequency data as a float array
  29992. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29993. * @returns a Float32Array
  29994. */
  29995. getFloatFrequencyData(): Float32Array;
  29996. /**
  29997. * Renders the debug canvas
  29998. */
  29999. drawDebugCanvas(): void;
  30000. /**
  30001. * Stops rendering the debug canvas and removes it
  30002. */
  30003. stopDebugCanvas(): void;
  30004. /**
  30005. * Connects two audio nodes
  30006. * @param inputAudioNode defines first node to connect
  30007. * @param outputAudioNode defines second node to connect
  30008. */
  30009. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  30010. /**
  30011. * Releases all associated resources
  30012. */
  30013. dispose(): void;
  30014. }
  30015. }
  30016. declare module "babylonjs/Audio/audioEngine" {
  30017. import { IDisposable } from "babylonjs/scene";
  30018. import { Analyser } from "babylonjs/Audio/analyser";
  30019. import { Nullable } from "babylonjs/types";
  30020. import { Observable } from "babylonjs/Misc/observable";
  30021. /**
  30022. * This represents an audio engine and it is responsible
  30023. * to play, synchronize and analyse sounds throughout the application.
  30024. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30025. */
  30026. export interface IAudioEngine extends IDisposable {
  30027. /**
  30028. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  30029. */
  30030. readonly canUseWebAudio: boolean;
  30031. /**
  30032. * Gets the current AudioContext if available.
  30033. */
  30034. readonly audioContext: Nullable<AudioContext>;
  30035. /**
  30036. * The master gain node defines the global audio volume of your audio engine.
  30037. */
  30038. readonly masterGain: GainNode;
  30039. /**
  30040. * Gets whether or not mp3 are supported by your browser.
  30041. */
  30042. readonly isMP3supported: boolean;
  30043. /**
  30044. * Gets whether or not ogg are supported by your browser.
  30045. */
  30046. readonly isOGGsupported: boolean;
  30047. /**
  30048. * Defines if Babylon should emit a warning if WebAudio is not supported.
  30049. * @ignoreNaming
  30050. */
  30051. WarnedWebAudioUnsupported: boolean;
  30052. /**
  30053. * Defines if the audio engine relies on a custom unlocked button.
  30054. * In this case, the embedded button will not be displayed.
  30055. */
  30056. useCustomUnlockedButton: boolean;
  30057. /**
  30058. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  30059. */
  30060. readonly unlocked: boolean;
  30061. /**
  30062. * Event raised when audio has been unlocked on the browser.
  30063. */
  30064. onAudioUnlockedObservable: Observable<AudioEngine>;
  30065. /**
  30066. * Event raised when audio has been locked on the browser.
  30067. */
  30068. onAudioLockedObservable: Observable<AudioEngine>;
  30069. /**
  30070. * Flags the audio engine in Locked state.
  30071. * This happens due to new browser policies preventing audio to autoplay.
  30072. */
  30073. lock(): void;
  30074. /**
  30075. * Unlocks the audio engine once a user action has been done on the dom.
  30076. * This is helpful to resume play once browser policies have been satisfied.
  30077. */
  30078. unlock(): void;
  30079. }
  30080. /**
  30081. * This represents the default audio engine used in babylon.
  30082. * It is responsible to play, synchronize and analyse sounds throughout the application.
  30083. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30084. */
  30085. export class AudioEngine implements IAudioEngine {
  30086. private _audioContext;
  30087. private _audioContextInitialized;
  30088. private _muteButton;
  30089. private _hostElement;
  30090. /**
  30091. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  30092. */
  30093. canUseWebAudio: boolean;
  30094. /**
  30095. * The master gain node defines the global audio volume of your audio engine.
  30096. */
  30097. masterGain: GainNode;
  30098. /**
  30099. * Defines if Babylon should emit a warning if WebAudio is not supported.
  30100. * @ignoreNaming
  30101. */
  30102. WarnedWebAudioUnsupported: boolean;
  30103. /**
  30104. * Gets whether or not mp3 are supported by your browser.
  30105. */
  30106. isMP3supported: boolean;
  30107. /**
  30108. * Gets whether or not ogg are supported by your browser.
  30109. */
  30110. isOGGsupported: boolean;
  30111. /**
  30112. * Gets whether audio has been unlocked on the device.
  30113. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  30114. * a user interaction has happened.
  30115. */
  30116. unlocked: boolean;
  30117. /**
  30118. * Defines if the audio engine relies on a custom unlocked button.
  30119. * In this case, the embedded button will not be displayed.
  30120. */
  30121. useCustomUnlockedButton: boolean;
  30122. /**
  30123. * Event raised when audio has been unlocked on the browser.
  30124. */
  30125. onAudioUnlockedObservable: Observable<AudioEngine>;
  30126. /**
  30127. * Event raised when audio has been locked on the browser.
  30128. */
  30129. onAudioLockedObservable: Observable<AudioEngine>;
  30130. /**
  30131. * Gets the current AudioContext if available.
  30132. */
  30133. readonly audioContext: Nullable<AudioContext>;
  30134. private _connectedAnalyser;
  30135. /**
  30136. * Instantiates a new audio engine.
  30137. *
  30138. * There should be only one per page as some browsers restrict the number
  30139. * of audio contexts you can create.
  30140. * @param hostElement defines the host element where to display the mute icon if necessary
  30141. */
  30142. constructor(hostElement?: Nullable<HTMLElement>);
  30143. /**
  30144. * Flags the audio engine in Locked state.
  30145. * This happens due to new browser policies preventing audio to autoplay.
  30146. */
  30147. lock(): void;
  30148. /**
  30149. * Unlocks the audio engine once a user action has been done on the dom.
  30150. * This is helpful to resume play once browser policies have been satisfied.
  30151. */
  30152. unlock(): void;
  30153. private _resumeAudioContext;
  30154. private _initializeAudioContext;
  30155. private _tryToRun;
  30156. private _triggerRunningState;
  30157. private _triggerSuspendedState;
  30158. private _displayMuteButton;
  30159. private _moveButtonToTopLeft;
  30160. private _onResize;
  30161. private _hideMuteButton;
  30162. /**
  30163. * Destroy and release the resources associated with the audio ccontext.
  30164. */
  30165. dispose(): void;
  30166. /**
  30167. * Gets the global volume sets on the master gain.
  30168. * @returns the global volume if set or -1 otherwise
  30169. */
  30170. getGlobalVolume(): number;
  30171. /**
  30172. * Sets the global volume of your experience (sets on the master gain).
  30173. * @param newVolume Defines the new global volume of the application
  30174. */
  30175. setGlobalVolume(newVolume: number): void;
  30176. /**
  30177. * Connect the audio engine to an audio analyser allowing some amazing
  30178. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  30179. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  30180. * @param analyser The analyser to connect to the engine
  30181. */
  30182. connectToAnalyser(analyser: Analyser): void;
  30183. }
  30184. }
  30185. declare module "babylonjs/Loading/loadingScreen" {
  30186. /**
  30187. * Interface used to present a loading screen while loading a scene
  30188. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30189. */
  30190. export interface ILoadingScreen {
  30191. /**
  30192. * Function called to display the loading screen
  30193. */
  30194. displayLoadingUI: () => void;
  30195. /**
  30196. * Function called to hide the loading screen
  30197. */
  30198. hideLoadingUI: () => void;
  30199. /**
  30200. * Gets or sets the color to use for the background
  30201. */
  30202. loadingUIBackgroundColor: string;
  30203. /**
  30204. * Gets or sets the text to display while loading
  30205. */
  30206. loadingUIText: string;
  30207. }
  30208. /**
  30209. * Class used for the default loading screen
  30210. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30211. */
  30212. export class DefaultLoadingScreen implements ILoadingScreen {
  30213. private _renderingCanvas;
  30214. private _loadingText;
  30215. private _loadingDivBackgroundColor;
  30216. private _loadingDiv;
  30217. private _loadingTextDiv;
  30218. /** Gets or sets the logo url to use for the default loading screen */
  30219. static DefaultLogoUrl: string;
  30220. /** Gets or sets the spinner url to use for the default loading screen */
  30221. static DefaultSpinnerUrl: string;
  30222. /**
  30223. * Creates a new default loading screen
  30224. * @param _renderingCanvas defines the canvas used to render the scene
  30225. * @param _loadingText defines the default text to display
  30226. * @param _loadingDivBackgroundColor defines the default background color
  30227. */
  30228. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  30229. /**
  30230. * Function called to display the loading screen
  30231. */
  30232. displayLoadingUI(): void;
  30233. /**
  30234. * Function called to hide the loading screen
  30235. */
  30236. hideLoadingUI(): void;
  30237. /**
  30238. * Gets or sets the text to display while loading
  30239. */
  30240. loadingUIText: string;
  30241. /**
  30242. * Gets or sets the color to use for the background
  30243. */
  30244. loadingUIBackgroundColor: string;
  30245. private _resizeLoadingUI;
  30246. }
  30247. }
  30248. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  30249. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30250. import { Engine } from "babylonjs/Engines/engine";
  30251. import { Nullable } from "babylonjs/types";
  30252. /** @hidden */
  30253. export class WebGLPipelineContext implements IPipelineContext {
  30254. engine: Engine;
  30255. program: Nullable<WebGLProgram>;
  30256. context?: WebGLRenderingContext;
  30257. vertexShader?: WebGLShader;
  30258. fragmentShader?: WebGLShader;
  30259. isParallelCompiled: boolean;
  30260. onCompiled?: () => void;
  30261. transformFeedback?: WebGLTransformFeedback | null;
  30262. readonly isAsync: boolean;
  30263. readonly isReady: boolean;
  30264. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  30265. }
  30266. }
  30267. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  30268. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30269. /** @hidden */
  30270. export class WebGLDataBuffer extends DataBuffer {
  30271. private _buffer;
  30272. constructor(resource: WebGLBuffer);
  30273. readonly underlyingResource: any;
  30274. }
  30275. }
  30276. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  30277. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30278. /** @hidden */
  30279. export class WebGL2ShaderProcessor implements IShaderProcessor {
  30280. attributeProcessor(attribute: string): string;
  30281. varyingProcessor(varying: string, isFragment: boolean): string;
  30282. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  30283. }
  30284. }
  30285. declare module "babylonjs/Misc/perfCounter" {
  30286. /**
  30287. * This class is used to track a performance counter which is number based.
  30288. * The user has access to many properties which give statistics of different nature.
  30289. *
  30290. * The implementer can track two kinds of Performance Counter: time and count.
  30291. * For time you can optionally call fetchNewFrame() to notify the start of a new frame to monitor, then call beginMonitoring() to start and endMonitoring() to record the lapsed time. endMonitoring takes a newFrame parameter for you to specify if the monitored time should be set for a new frame or accumulated to the current frame being monitored.
  30292. * For count you first have to call fetchNewFrame() to notify the start of a new frame to monitor, then call addCount() how many time required to increment the count value you monitor.
  30293. */
  30294. export class PerfCounter {
  30295. /**
  30296. * Gets or sets a global boolean to turn on and off all the counters
  30297. */
  30298. static Enabled: boolean;
  30299. /**
  30300. * Returns the smallest value ever
  30301. */
  30302. readonly min: number;
  30303. /**
  30304. * Returns the biggest value ever
  30305. */
  30306. readonly max: number;
  30307. /**
  30308. * Returns the average value since the performance counter is running
  30309. */
  30310. readonly average: number;
  30311. /**
  30312. * Returns the average value of the last second the counter was monitored
  30313. */
  30314. readonly lastSecAverage: number;
  30315. /**
  30316. * Returns the current value
  30317. */
  30318. readonly current: number;
  30319. /**
  30320. * Gets the accumulated total
  30321. */
  30322. readonly total: number;
  30323. /**
  30324. * Gets the total value count
  30325. */
  30326. readonly count: number;
  30327. /**
  30328. * Creates a new counter
  30329. */
  30330. constructor();
  30331. /**
  30332. * Call this method to start monitoring a new frame.
  30333. * This scenario is typically used when you accumulate monitoring time many times for a single frame, you call this method at the start of the frame, then beginMonitoring to start recording and endMonitoring(false) to accumulated the recorded time to the PerfCounter or addCount() to accumulate a monitored count.
  30334. */
  30335. fetchNewFrame(): void;
  30336. /**
  30337. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  30338. * @param newCount the count value to add to the monitored count
  30339. * @param fetchResult true when it's the last time in the frame you add to the counter and you wish to update the statistics properties (min/max/average), false if you only want to update statistics.
  30340. */
  30341. addCount(newCount: number, fetchResult: boolean): void;
  30342. /**
  30343. * Start monitoring this performance counter
  30344. */
  30345. beginMonitoring(): void;
  30346. /**
  30347. * Compute the time lapsed since the previous beginMonitoring() call.
  30348. * @param newFrame true by default to fetch the result and monitor a new frame, if false the time monitored will be added to the current frame counter
  30349. */
  30350. endMonitoring(newFrame?: boolean): void;
  30351. private _fetchResult;
  30352. private _startMonitoringTime;
  30353. private _min;
  30354. private _max;
  30355. private _average;
  30356. private _current;
  30357. private _totalValueCount;
  30358. private _totalAccumulated;
  30359. private _lastSecAverage;
  30360. private _lastSecAccumulated;
  30361. private _lastSecTime;
  30362. private _lastSecValueCount;
  30363. }
  30364. }
  30365. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  30366. /**
  30367. * Interface for any object that can request an animation frame
  30368. */
  30369. export interface ICustomAnimationFrameRequester {
  30370. /**
  30371. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30372. */
  30373. renderFunction?: Function;
  30374. /**
  30375. * Called to request the next frame to render to
  30376. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30377. */
  30378. requestAnimationFrame: Function;
  30379. /**
  30380. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30381. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30382. */
  30383. requestID?: number;
  30384. }
  30385. }
  30386. declare module "babylonjs/Materials/Textures/videoTexture" {
  30387. import { Observable } from "babylonjs/Misc/observable";
  30388. import { Nullable } from "babylonjs/types";
  30389. import { Scene } from "babylonjs/scene";
  30390. import { Texture } from "babylonjs/Materials/Textures/texture";
  30391. /**
  30392. * Settings for finer control over video usage
  30393. */
  30394. export interface VideoTextureSettings {
  30395. /**
  30396. * Applies `autoplay` to video, if specified
  30397. */
  30398. autoPlay?: boolean;
  30399. /**
  30400. * Applies `loop` to video, if specified
  30401. */
  30402. loop?: boolean;
  30403. /**
  30404. * Automatically updates internal texture from video at every frame in the render loop
  30405. */
  30406. autoUpdateTexture: boolean;
  30407. /**
  30408. * Image src displayed during the video loading or until the user interacts with the video.
  30409. */
  30410. poster?: string;
  30411. }
  30412. /**
  30413. * If you want to display a video in your scene, this is the special texture for that.
  30414. * This special texture works similar to other textures, with the exception of a few parameters.
  30415. * @see https://doc.babylonjs.com/how_to/video_texture
  30416. */
  30417. export class VideoTexture extends Texture {
  30418. /**
  30419. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  30420. */
  30421. readonly autoUpdateTexture: boolean;
  30422. /**
  30423. * The video instance used by the texture internally
  30424. */
  30425. readonly video: HTMLVideoElement;
  30426. private _onUserActionRequestedObservable;
  30427. /**
  30428. * Event triggerd when a dom action is required by the user to play the video.
  30429. * This happens due to recent changes in browser policies preventing video to auto start.
  30430. */
  30431. readonly onUserActionRequestedObservable: Observable<Texture>;
  30432. private _generateMipMaps;
  30433. private _engine;
  30434. private _stillImageCaptured;
  30435. private _displayingPosterTexture;
  30436. private _settings;
  30437. private _createInternalTextureOnEvent;
  30438. private _frameId;
  30439. /**
  30440. * Creates a video texture.
  30441. * If you want to display a video in your scene, this is the special texture for that.
  30442. * This special texture works similar to other textures, with the exception of a few parameters.
  30443. * @see https://doc.babylonjs.com/how_to/video_texture
  30444. * @param name optional name, will detect from video source, if not defined
  30445. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  30446. * @param scene is obviously the current scene.
  30447. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  30448. * @param invertY is false by default but can be used to invert video on Y axis
  30449. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  30450. * @param settings allows finer control over video usage
  30451. */
  30452. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  30453. private _getName;
  30454. private _getVideo;
  30455. private _createInternalTexture;
  30456. private reset;
  30457. /**
  30458. * @hidden Internal method to initiate `update`.
  30459. */
  30460. _rebuild(): void;
  30461. /**
  30462. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  30463. */
  30464. update(): void;
  30465. /**
  30466. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  30467. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  30468. */
  30469. updateTexture(isVisible: boolean): void;
  30470. protected _updateInternalTexture: () => void;
  30471. /**
  30472. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  30473. * @param url New url.
  30474. */
  30475. updateURL(url: string): void;
  30476. /**
  30477. * Dispose the texture and release its associated resources.
  30478. */
  30479. dispose(): void;
  30480. /**
  30481. * Creates a video texture straight from a stream.
  30482. * @param scene Define the scene the texture should be created in
  30483. * @param stream Define the stream the texture should be created from
  30484. * @returns The created video texture as a promise
  30485. */
  30486. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  30487. /**
  30488. * Creates a video texture straight from your WebCam video feed.
  30489. * @param scene Define the scene the texture should be created in
  30490. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30491. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30492. * @returns The created video texture as a promise
  30493. */
  30494. static CreateFromWebCamAsync(scene: Scene, constraints: {
  30495. minWidth: number;
  30496. maxWidth: number;
  30497. minHeight: number;
  30498. maxHeight: number;
  30499. deviceId: string;
  30500. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  30501. /**
  30502. * Creates a video texture straight from your WebCam video feed.
  30503. * @param scene Define the scene the texture should be created in
  30504. * @param onReady Define a callback to triggered once the texture will be ready
  30505. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30506. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30507. */
  30508. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  30509. minWidth: number;
  30510. maxWidth: number;
  30511. minHeight: number;
  30512. maxHeight: number;
  30513. deviceId: string;
  30514. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  30515. }
  30516. }
  30517. declare module "babylonjs/Engines/engine" {
  30518. import { Observable } from "babylonjs/Misc/observable";
  30519. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  30520. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  30521. import { Scene } from "babylonjs/scene";
  30522. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  30523. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  30524. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  30525. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  30526. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30527. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30528. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  30529. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  30530. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  30531. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  30532. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  30533. import { WebRequest } from "babylonjs/Misc/webRequest";
  30534. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30535. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30536. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30537. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  30538. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  30539. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  30540. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  30541. import { Material } from "babylonjs/Materials/material";
  30542. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30543. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30544. /**
  30545. * Defines the interface used by objects containing a viewport (like a camera)
  30546. */
  30547. interface IViewportOwnerLike {
  30548. /**
  30549. * Gets or sets the viewport
  30550. */
  30551. viewport: IViewportLike;
  30552. }
  30553. /**
  30554. * Interface for attribute information associated with buffer instanciation
  30555. */
  30556. export class InstancingAttributeInfo {
  30557. /**
  30558. * Index/offset of the attribute in the vertex shader
  30559. */
  30560. index: number;
  30561. /**
  30562. * size of the attribute, 1, 2, 3 or 4
  30563. */
  30564. attributeSize: number;
  30565. /**
  30566. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  30567. * default is FLOAT
  30568. */
  30569. attribyteType: number;
  30570. /**
  30571. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  30572. */
  30573. normalized: boolean;
  30574. /**
  30575. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  30576. */
  30577. offset: number;
  30578. /**
  30579. * Name of the GLSL attribute, for debugging purpose only
  30580. */
  30581. attributeName: string;
  30582. }
  30583. /**
  30584. * Define options used to create a depth texture
  30585. */
  30586. export class DepthTextureCreationOptions {
  30587. /** Specifies whether or not a stencil should be allocated in the texture */
  30588. generateStencil?: boolean;
  30589. /** Specifies whether or not bilinear filtering is enable on the texture */
  30590. bilinearFiltering?: boolean;
  30591. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  30592. comparisonFunction?: number;
  30593. /** Specifies if the created texture is a cube texture */
  30594. isCube?: boolean;
  30595. }
  30596. /**
  30597. * Class used to describe the capabilities of the engine relatively to the current browser
  30598. */
  30599. export class EngineCapabilities {
  30600. /** Maximum textures units per fragment shader */
  30601. maxTexturesImageUnits: number;
  30602. /** Maximum texture units per vertex shader */
  30603. maxVertexTextureImageUnits: number;
  30604. /** Maximum textures units in the entire pipeline */
  30605. maxCombinedTexturesImageUnits: number;
  30606. /** Maximum texture size */
  30607. maxTextureSize: number;
  30608. /** Maximum cube texture size */
  30609. maxCubemapTextureSize: number;
  30610. /** Maximum render texture size */
  30611. maxRenderTextureSize: number;
  30612. /** Maximum number of vertex attributes */
  30613. maxVertexAttribs: number;
  30614. /** Maximum number of varyings */
  30615. maxVaryingVectors: number;
  30616. /** Maximum number of uniforms per vertex shader */
  30617. maxVertexUniformVectors: number;
  30618. /** Maximum number of uniforms per fragment shader */
  30619. maxFragmentUniformVectors: number;
  30620. /** Defines if standard derivates (dx/dy) are supported */
  30621. standardDerivatives: boolean;
  30622. /** Defines if s3tc texture compression is supported */
  30623. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  30624. /** Defines if pvrtc texture compression is supported */
  30625. pvrtc: any;
  30626. /** Defines if etc1 texture compression is supported */
  30627. etc1: any;
  30628. /** Defines if etc2 texture compression is supported */
  30629. etc2: any;
  30630. /** Defines if astc texture compression is supported */
  30631. astc: any;
  30632. /** Defines if float textures are supported */
  30633. textureFloat: boolean;
  30634. /** Defines if vertex array objects are supported */
  30635. vertexArrayObject: boolean;
  30636. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30637. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  30638. /** Gets the maximum level of anisotropy supported */
  30639. maxAnisotropy: number;
  30640. /** Defines if instancing is supported */
  30641. instancedArrays: boolean;
  30642. /** Defines if 32 bits indices are supported */
  30643. uintIndices: boolean;
  30644. /** Defines if high precision shaders are supported */
  30645. highPrecisionShaderSupported: boolean;
  30646. /** Defines if depth reading in the fragment shader is supported */
  30647. fragmentDepthSupported: boolean;
  30648. /** Defines if float texture linear filtering is supported*/
  30649. textureFloatLinearFiltering: boolean;
  30650. /** Defines if rendering to float textures is supported */
  30651. textureFloatRender: boolean;
  30652. /** Defines if half float textures are supported*/
  30653. textureHalfFloat: boolean;
  30654. /** Defines if half float texture linear filtering is supported*/
  30655. textureHalfFloatLinearFiltering: boolean;
  30656. /** Defines if rendering to half float textures is supported */
  30657. textureHalfFloatRender: boolean;
  30658. /** Defines if textureLOD shader command is supported */
  30659. textureLOD: boolean;
  30660. /** Defines if draw buffers extension is supported */
  30661. drawBuffersExtension: boolean;
  30662. /** Defines if depth textures are supported */
  30663. depthTextureExtension: boolean;
  30664. /** Defines if float color buffer are supported */
  30665. colorBufferFloat: boolean;
  30666. /** Gets disjoint timer query extension (null if not supported) */
  30667. timerQuery: EXT_disjoint_timer_query;
  30668. /** Defines if timestamp can be used with timer query */
  30669. canUseTimestampForTimerQuery: boolean;
  30670. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30671. multiview: any;
  30672. /** Function used to let the system compiles shaders in background */
  30673. parallelShaderCompile: {
  30674. COMPLETION_STATUS_KHR: number;
  30675. };
  30676. /** Max number of texture samples for MSAA */
  30677. maxMSAASamples: number;
  30678. }
  30679. /** Interface defining initialization parameters for Engine class */
  30680. export interface EngineOptions extends WebGLContextAttributes {
  30681. /**
  30682. * Defines if the engine should no exceed a specified device ratio
  30683. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  30684. */
  30685. limitDeviceRatio?: number;
  30686. /**
  30687. * Defines if webvr should be enabled automatically
  30688. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30689. */
  30690. autoEnableWebVR?: boolean;
  30691. /**
  30692. * Defines if webgl2 should be turned off even if supported
  30693. * @see http://doc.babylonjs.com/features/webgl2
  30694. */
  30695. disableWebGL2Support?: boolean;
  30696. /**
  30697. * Defines if webaudio should be initialized as well
  30698. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30699. */
  30700. audioEngine?: boolean;
  30701. /**
  30702. * Defines if animations should run using a deterministic lock step
  30703. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30704. */
  30705. deterministicLockstep?: boolean;
  30706. /** Defines the maximum steps to use with deterministic lock step mode */
  30707. lockstepMaxSteps?: number;
  30708. /**
  30709. * Defines that engine should ignore context lost events
  30710. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30711. */
  30712. doNotHandleContextLost?: boolean;
  30713. /**
  30714. * Defines that engine should ignore modifying touch action attribute and style
  30715. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30716. */
  30717. doNotHandleTouchAction?: boolean;
  30718. /**
  30719. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30720. */
  30721. useHighPrecisionFloats?: boolean;
  30722. }
  30723. /**
  30724. * Defines the interface used by display changed events
  30725. */
  30726. export interface IDisplayChangedEventArgs {
  30727. /** Gets the vrDisplay object (if any) */
  30728. vrDisplay: Nullable<any>;
  30729. /** Gets a boolean indicating if webVR is supported */
  30730. vrSupported: boolean;
  30731. }
  30732. /**
  30733. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  30734. */
  30735. export class Engine {
  30736. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30737. static ExceptionList: ({
  30738. key: string;
  30739. capture: string;
  30740. captureConstraint: number;
  30741. targets: string[];
  30742. } | {
  30743. key: string;
  30744. capture: null;
  30745. captureConstraint: null;
  30746. targets: string[];
  30747. })[];
  30748. /** Gets the list of created engines */
  30749. static readonly Instances: Engine[];
  30750. /**
  30751. * Gets the latest created engine
  30752. */
  30753. static readonly LastCreatedEngine: Nullable<Engine>;
  30754. /**
  30755. * Gets the latest created scene
  30756. */
  30757. static readonly LastCreatedScene: Nullable<Scene>;
  30758. /**
  30759. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  30760. * @param flag defines which part of the materials must be marked as dirty
  30761. * @param predicate defines a predicate used to filter which materials should be affected
  30762. */
  30763. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  30764. /** @hidden */
  30765. static _TextureLoaders: IInternalTextureLoader[];
  30766. /** Defines that alpha blending is disabled */
  30767. static readonly ALPHA_DISABLE: number;
  30768. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  30769. static readonly ALPHA_ADD: number;
  30770. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  30771. static readonly ALPHA_COMBINE: number;
  30772. /** Defines that alpha blending to DEST - SRC * DEST */
  30773. static readonly ALPHA_SUBTRACT: number;
  30774. /** Defines that alpha blending to SRC * DEST */
  30775. static readonly ALPHA_MULTIPLY: number;
  30776. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  30777. static readonly ALPHA_MAXIMIZED: number;
  30778. /** Defines that alpha blending to SRC + DEST */
  30779. static readonly ALPHA_ONEONE: number;
  30780. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  30781. static readonly ALPHA_PREMULTIPLIED: number;
  30782. /**
  30783. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  30784. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  30785. */
  30786. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  30787. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  30788. static readonly ALPHA_INTERPOLATE: number;
  30789. /**
  30790. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  30791. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  30792. */
  30793. static readonly ALPHA_SCREENMODE: number;
  30794. /** Defines that the ressource is not delayed*/
  30795. static readonly DELAYLOADSTATE_NONE: number;
  30796. /** Defines that the ressource was successfully delay loaded */
  30797. static readonly DELAYLOADSTATE_LOADED: number;
  30798. /** Defines that the ressource is currently delay loading */
  30799. static readonly DELAYLOADSTATE_LOADING: number;
  30800. /** Defines that the ressource is delayed and has not started loading */
  30801. static readonly DELAYLOADSTATE_NOTLOADED: number;
  30802. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  30803. static readonly NEVER: number;
  30804. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  30805. static readonly ALWAYS: number;
  30806. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  30807. static readonly LESS: number;
  30808. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  30809. static readonly EQUAL: number;
  30810. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  30811. static readonly LEQUAL: number;
  30812. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  30813. static readonly GREATER: number;
  30814. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  30815. static readonly GEQUAL: number;
  30816. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  30817. static readonly NOTEQUAL: number;
  30818. /** Passed to stencilOperation to specify that stencil value must be kept */
  30819. static readonly KEEP: number;
  30820. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30821. static readonly REPLACE: number;
  30822. /** Passed to stencilOperation to specify that stencil value must be incremented */
  30823. static readonly INCR: number;
  30824. /** Passed to stencilOperation to specify that stencil value must be decremented */
  30825. static readonly DECR: number;
  30826. /** Passed to stencilOperation to specify that stencil value must be inverted */
  30827. static readonly INVERT: number;
  30828. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  30829. static readonly INCR_WRAP: number;
  30830. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  30831. static readonly DECR_WRAP: number;
  30832. /** Texture is not repeating outside of 0..1 UVs */
  30833. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  30834. /** Texture is repeating outside of 0..1 UVs */
  30835. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  30836. /** Texture is repeating and mirrored */
  30837. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  30838. /** ALPHA */
  30839. static readonly TEXTUREFORMAT_ALPHA: number;
  30840. /** LUMINANCE */
  30841. static readonly TEXTUREFORMAT_LUMINANCE: number;
  30842. /** LUMINANCE_ALPHA */
  30843. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  30844. /** RGB */
  30845. static readonly TEXTUREFORMAT_RGB: number;
  30846. /** RGBA */
  30847. static readonly TEXTUREFORMAT_RGBA: number;
  30848. /** RED */
  30849. static readonly TEXTUREFORMAT_RED: number;
  30850. /** RED (2nd reference) */
  30851. static readonly TEXTUREFORMAT_R: number;
  30852. /** RG */
  30853. static readonly TEXTUREFORMAT_RG: number;
  30854. /** RED_INTEGER */
  30855. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  30856. /** RED_INTEGER (2nd reference) */
  30857. static readonly TEXTUREFORMAT_R_INTEGER: number;
  30858. /** RG_INTEGER */
  30859. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  30860. /** RGB_INTEGER */
  30861. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  30862. /** RGBA_INTEGER */
  30863. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  30864. /** UNSIGNED_BYTE */
  30865. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  30866. /** UNSIGNED_BYTE (2nd reference) */
  30867. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  30868. /** FLOAT */
  30869. static readonly TEXTURETYPE_FLOAT: number;
  30870. /** HALF_FLOAT */
  30871. static readonly TEXTURETYPE_HALF_FLOAT: number;
  30872. /** BYTE */
  30873. static readonly TEXTURETYPE_BYTE: number;
  30874. /** SHORT */
  30875. static readonly TEXTURETYPE_SHORT: number;
  30876. /** UNSIGNED_SHORT */
  30877. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  30878. /** INT */
  30879. static readonly TEXTURETYPE_INT: number;
  30880. /** UNSIGNED_INT */
  30881. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  30882. /** UNSIGNED_SHORT_4_4_4_4 */
  30883. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  30884. /** UNSIGNED_SHORT_5_5_5_1 */
  30885. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  30886. /** UNSIGNED_SHORT_5_6_5 */
  30887. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  30888. /** UNSIGNED_INT_2_10_10_10_REV */
  30889. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  30890. /** UNSIGNED_INT_24_8 */
  30891. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  30892. /** UNSIGNED_INT_10F_11F_11F_REV */
  30893. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  30894. /** UNSIGNED_INT_5_9_9_9_REV */
  30895. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  30896. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  30897. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  30898. /** nearest is mag = nearest and min = nearest and mip = linear */
  30899. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  30900. /** Bilinear is mag = linear and min = linear and mip = nearest */
  30901. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  30902. /** Trilinear is mag = linear and min = linear and mip = linear */
  30903. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  30904. /** nearest is mag = nearest and min = nearest and mip = linear */
  30905. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  30906. /** Bilinear is mag = linear and min = linear and mip = nearest */
  30907. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  30908. /** Trilinear is mag = linear and min = linear and mip = linear */
  30909. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  30910. /** mag = nearest and min = nearest and mip = nearest */
  30911. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  30912. /** mag = nearest and min = linear and mip = nearest */
  30913. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  30914. /** mag = nearest and min = linear and mip = linear */
  30915. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  30916. /** mag = nearest and min = linear and mip = none */
  30917. static readonly TEXTURE_NEAREST_LINEAR: number;
  30918. /** mag = nearest and min = nearest and mip = none */
  30919. static readonly TEXTURE_NEAREST_NEAREST: number;
  30920. /** mag = linear and min = nearest and mip = nearest */
  30921. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  30922. /** mag = linear and min = nearest and mip = linear */
  30923. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  30924. /** mag = linear and min = linear and mip = none */
  30925. static readonly TEXTURE_LINEAR_LINEAR: number;
  30926. /** mag = linear and min = nearest and mip = none */
  30927. static readonly TEXTURE_LINEAR_NEAREST: number;
  30928. /** Explicit coordinates mode */
  30929. static readonly TEXTURE_EXPLICIT_MODE: number;
  30930. /** Spherical coordinates mode */
  30931. static readonly TEXTURE_SPHERICAL_MODE: number;
  30932. /** Planar coordinates mode */
  30933. static readonly TEXTURE_PLANAR_MODE: number;
  30934. /** Cubic coordinates mode */
  30935. static readonly TEXTURE_CUBIC_MODE: number;
  30936. /** Projection coordinates mode */
  30937. static readonly TEXTURE_PROJECTION_MODE: number;
  30938. /** Skybox coordinates mode */
  30939. static readonly TEXTURE_SKYBOX_MODE: number;
  30940. /** Inverse Cubic coordinates mode */
  30941. static readonly TEXTURE_INVCUBIC_MODE: number;
  30942. /** Equirectangular coordinates mode */
  30943. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  30944. /** Equirectangular Fixed coordinates mode */
  30945. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  30946. /** Equirectangular Fixed Mirrored coordinates mode */
  30947. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  30948. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  30949. static readonly SCALEMODE_FLOOR: number;
  30950. /** Defines that texture rescaling will look for the nearest power of 2 size */
  30951. static readonly SCALEMODE_NEAREST: number;
  30952. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  30953. static readonly SCALEMODE_CEILING: number;
  30954. /**
  30955. * Returns the current npm package of the sdk
  30956. */
  30957. static readonly NpmPackage: string;
  30958. /**
  30959. * Returns the current version of the framework
  30960. */
  30961. static readonly Version: string;
  30962. /**
  30963. * Returns a string describing the current engine
  30964. */
  30965. readonly description: string;
  30966. /**
  30967. * Gets or sets the epsilon value used by collision engine
  30968. */
  30969. static CollisionsEpsilon: number;
  30970. /**
  30971. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30972. */
  30973. static ShadersRepository: string;
  30974. /**
  30975. * Method called to create the default loading screen.
  30976. * This can be overriden in your own app.
  30977. * @param canvas The rendering canvas element
  30978. * @returns The loading screen
  30979. */
  30980. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  30981. /**
  30982. * Method called to create the default rescale post process on each engine.
  30983. */
  30984. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  30985. /** @hidden */
  30986. _shaderProcessor: IShaderProcessor;
  30987. /**
  30988. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30989. */
  30990. forcePOTTextures: boolean;
  30991. /**
  30992. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30993. */
  30994. isFullscreen: boolean;
  30995. /**
  30996. * Gets a boolean indicating if the pointer is currently locked
  30997. */
  30998. isPointerLock: boolean;
  30999. /**
  31000. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  31001. */
  31002. cullBackFaces: boolean;
  31003. /**
  31004. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  31005. */
  31006. renderEvenInBackground: boolean;
  31007. /**
  31008. * Gets or sets a boolean indicating that cache can be kept between frames
  31009. */
  31010. preventCacheWipeBetweenFrames: boolean;
  31011. /**
  31012. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  31013. **/
  31014. enableOfflineSupport: boolean;
  31015. /**
  31016. * Gets or sets a boolean to enable/disable checking manifest if IndexedDB support is enabled (js will always consider the database is up to date)
  31017. **/
  31018. disableManifestCheck: boolean;
  31019. /**
  31020. * Gets the list of created scenes
  31021. */
  31022. scenes: Scene[];
  31023. /**
  31024. * Event raised when a new scene is created
  31025. */
  31026. onNewSceneAddedObservable: Observable<Scene>;
  31027. /**
  31028. * Gets the list of created postprocesses
  31029. */
  31030. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  31031. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  31032. validateShaderPrograms: boolean;
  31033. /**
  31034. * Observable event triggered each time the rendering canvas is resized
  31035. */
  31036. onResizeObservable: Observable<Engine>;
  31037. /**
  31038. * Observable event triggered each time the canvas loses focus
  31039. */
  31040. onCanvasBlurObservable: Observable<Engine>;
  31041. /**
  31042. * Observable event triggered each time the canvas gains focus
  31043. */
  31044. onCanvasFocusObservable: Observable<Engine>;
  31045. /**
  31046. * Observable event triggered each time the canvas receives pointerout event
  31047. */
  31048. onCanvasPointerOutObservable: Observable<PointerEvent>;
  31049. /**
  31050. * Observable event triggered before each texture is initialized
  31051. */
  31052. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  31053. /**
  31054. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31055. */
  31056. disableUniformBuffers: boolean;
  31057. /** @hidden */
  31058. _uniformBuffers: UniformBuffer[];
  31059. /**
  31060. * Gets a boolean indicating that the engine supports uniform buffers
  31061. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31062. */
  31063. readonly supportsUniformBuffers: boolean;
  31064. /**
  31065. * Observable raised when the engine begins a new frame
  31066. */
  31067. onBeginFrameObservable: Observable<Engine>;
  31068. /**
  31069. * If set, will be used to request the next animation frame for the render loop
  31070. */
  31071. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  31072. /**
  31073. * Observable raised when the engine ends the current frame
  31074. */
  31075. onEndFrameObservable: Observable<Engine>;
  31076. /**
  31077. * Observable raised when the engine is about to compile a shader
  31078. */
  31079. onBeforeShaderCompilationObservable: Observable<Engine>;
  31080. /**
  31081. * Observable raised when the engine has jsut compiled a shader
  31082. */
  31083. onAfterShaderCompilationObservable: Observable<Engine>;
  31084. /** @hidden */
  31085. _gl: WebGLRenderingContext;
  31086. private _renderingCanvas;
  31087. private _windowIsBackground;
  31088. protected _webGLVersion: number;
  31089. protected _highPrecisionShadersAllowed: boolean;
  31090. /** @hidden */
  31091. readonly _shouldUseHighPrecisionShader: boolean;
  31092. /**
  31093. * Gets a boolean indicating that only power of 2 textures are supported
  31094. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31095. */
  31096. readonly needPOTTextures: boolean;
  31097. /** @hidden */
  31098. _badOS: boolean;
  31099. /** @hidden */
  31100. _badDesktopOS: boolean;
  31101. /**
  31102. * Gets the audio engine
  31103. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31104. * @ignorenaming
  31105. */
  31106. static audioEngine: IAudioEngine;
  31107. /**
  31108. * Default AudioEngine factory responsible of creating the Audio Engine.
  31109. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  31110. */
  31111. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  31112. /**
  31113. * Default offline support factory responsible of creating a tool used to store data locally.
  31114. * By default, this will create a Database object if the workload has been embedded.
  31115. */
  31116. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  31117. private _onFocus;
  31118. private _onBlur;
  31119. private _onCanvasPointerOut;
  31120. private _onCanvasBlur;
  31121. private _onCanvasFocus;
  31122. private _onFullscreenChange;
  31123. private _onPointerLockChange;
  31124. private _hardwareScalingLevel;
  31125. /** @hidden */
  31126. _caps: EngineCapabilities;
  31127. private _pointerLockRequested;
  31128. private _isStencilEnable;
  31129. protected _colorWrite: boolean;
  31130. private _loadingScreen;
  31131. /** @hidden */
  31132. _drawCalls: PerfCounter;
  31133. private _glVersion;
  31134. private _glRenderer;
  31135. private _glVendor;
  31136. private _videoTextureSupported;
  31137. private _renderingQueueLaunched;
  31138. private _activeRenderLoops;
  31139. private _deterministicLockstep;
  31140. private _lockstepMaxSteps;
  31141. /**
  31142. * Observable signaled when a context lost event is raised
  31143. */
  31144. onContextLostObservable: Observable<Engine>;
  31145. /**
  31146. * Observable signaled when a context restored event is raised
  31147. */
  31148. onContextRestoredObservable: Observable<Engine>;
  31149. private _onContextLost;
  31150. private _onContextRestored;
  31151. private _contextWasLost;
  31152. /** @hidden */
  31153. _doNotHandleContextLost: boolean;
  31154. /**
  31155. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31156. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31157. */
  31158. doNotHandleContextLost: boolean;
  31159. private _performanceMonitor;
  31160. private _fps;
  31161. private _deltaTime;
  31162. /**
  31163. * Turn this value on if you want to pause FPS computation when in background
  31164. */
  31165. disablePerformanceMonitorInBackground: boolean;
  31166. /**
  31167. * Gets the performance monitor attached to this engine
  31168. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  31169. */
  31170. readonly performanceMonitor: PerformanceMonitor;
  31171. /**
  31172. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31173. */
  31174. disableVertexArrayObjects: boolean;
  31175. /** @hidden */
  31176. protected _depthCullingState: _DepthCullingState;
  31177. /** @hidden */
  31178. protected _stencilState: _StencilState;
  31179. /** @hidden */
  31180. protected _alphaState: _AlphaState;
  31181. /** @hidden */
  31182. protected _alphaMode: number;
  31183. /** @hidden */
  31184. _internalTexturesCache: InternalTexture[];
  31185. /** @hidden */
  31186. protected _activeChannel: number;
  31187. private _currentTextureChannel;
  31188. /** @hidden */
  31189. protected _boundTexturesCache: {
  31190. [key: string]: Nullable<InternalTexture>;
  31191. };
  31192. /** @hidden */
  31193. protected _currentEffect: Nullable<Effect>;
  31194. /** @hidden */
  31195. protected _currentProgram: Nullable<WebGLProgram>;
  31196. private _compiledEffects;
  31197. private _vertexAttribArraysEnabled;
  31198. /** @hidden */
  31199. protected _cachedViewport: Nullable<IViewportLike>;
  31200. private _cachedVertexArrayObject;
  31201. /** @hidden */
  31202. protected _cachedVertexBuffers: any;
  31203. /** @hidden */
  31204. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31205. /** @hidden */
  31206. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31207. /** @hidden */
  31208. _currentRenderTarget: Nullable<InternalTexture>;
  31209. private _uintIndicesCurrentlySet;
  31210. private _currentBoundBuffer;
  31211. /** @hidden */
  31212. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31213. private _currentBufferPointers;
  31214. private _currentInstanceLocations;
  31215. private _currentInstanceBuffers;
  31216. private _textureUnits;
  31217. /** @hidden */
  31218. _workingCanvas: Nullable<HTMLCanvasElement>;
  31219. /** @hidden */
  31220. _workingContext: Nullable<CanvasRenderingContext2D>;
  31221. private _rescalePostProcess;
  31222. private _dummyFramebuffer;
  31223. private _externalData;
  31224. /** @hidden */
  31225. _bindedRenderFunction: any;
  31226. private _vaoRecordInProgress;
  31227. private _mustWipeVertexAttributes;
  31228. private _emptyTexture;
  31229. private _emptyCubeTexture;
  31230. private _emptyTexture3D;
  31231. /** @hidden */
  31232. _frameHandler: number;
  31233. private _nextFreeTextureSlots;
  31234. private _maxSimultaneousTextures;
  31235. private _activeRequests;
  31236. private _texturesSupported;
  31237. /** @hidden */
  31238. _textureFormatInUse: Nullable<string>;
  31239. /**
  31240. * Gets the list of texture formats supported
  31241. */
  31242. readonly texturesSupported: Array<string>;
  31243. /**
  31244. * Gets the list of texture formats in use
  31245. */
  31246. readonly textureFormatInUse: Nullable<string>;
  31247. /**
  31248. * Gets the current viewport
  31249. */
  31250. readonly currentViewport: Nullable<IViewportLike>;
  31251. /**
  31252. * Gets the default empty texture
  31253. */
  31254. readonly emptyTexture: InternalTexture;
  31255. /**
  31256. * Gets the default empty 3D texture
  31257. */
  31258. readonly emptyTexture3D: InternalTexture;
  31259. /**
  31260. * Gets the default empty cube texture
  31261. */
  31262. readonly emptyCubeTexture: InternalTexture;
  31263. /**
  31264. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31265. */
  31266. readonly premultipliedAlpha: boolean;
  31267. /**
  31268. * Creates a new engine
  31269. * @param canvasOrContext defines the canvas or WebGL context to use for rendering. If you provide a WebGL context, Babylon.js will not hook events on the canvas (like pointers, keyboards, etc...) so no event observables will be available. This is mostly used when Babylon.js is used as a plugin on a system which alreay used the WebGL context
  31270. * @param antialias defines enable antialiasing (default: false)
  31271. * @param options defines further options to be sent to the getContext() function
  31272. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31273. */
  31274. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31275. /**
  31276. * Initializes a webVR display and starts listening to display change events
  31277. * The onVRDisplayChangedObservable will be notified upon these changes
  31278. * @returns The onVRDisplayChangedObservable
  31279. */
  31280. initWebVR(): Observable<IDisplayChangedEventArgs>;
  31281. /** @hidden */
  31282. _prepareVRComponent(): void;
  31283. /** @hidden */
  31284. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  31285. /** @hidden */
  31286. _submitVRFrame(): void;
  31287. /**
  31288. * Call this function to leave webVR mode
  31289. * Will do nothing if webVR is not supported or if there is no webVR device
  31290. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31291. */
  31292. disableVR(): void;
  31293. /**
  31294. * Gets a boolean indicating that the system is in VR mode and is presenting
  31295. * @returns true if VR mode is engaged
  31296. */
  31297. isVRPresenting(): boolean;
  31298. /** @hidden */
  31299. _requestVRFrame(): void;
  31300. private _disableTouchAction;
  31301. private _rebuildInternalTextures;
  31302. private _rebuildEffects;
  31303. /**
  31304. * Gets a boolean indicating if all created effects are ready
  31305. * @returns true if all effects are ready
  31306. */
  31307. areAllEffectsReady(): boolean;
  31308. private _rebuildBuffers;
  31309. private _initGLContext;
  31310. /**
  31311. * Gets version of the current webGL context
  31312. */
  31313. readonly webGLVersion: number;
  31314. /**
  31315. * Gets a string idenfifying the name of the class
  31316. * @returns "Engine" string
  31317. */
  31318. getClassName(): string;
  31319. /**
  31320. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31321. */
  31322. readonly isStencilEnable: boolean;
  31323. /** @hidden */
  31324. _prepareWorkingCanvas(): void;
  31325. /**
  31326. * Reset the texture cache to empty state
  31327. */
  31328. resetTextureCache(): void;
  31329. /**
  31330. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  31331. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31332. * @returns true if engine is in deterministic lock step mode
  31333. */
  31334. isDeterministicLockStep(): boolean;
  31335. /**
  31336. * Gets the max steps when engine is running in deterministic lock step
  31337. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31338. * @returns the max steps
  31339. */
  31340. getLockstepMaxSteps(): number;
  31341. /**
  31342. * Gets an object containing information about the current webGL context
  31343. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31344. */
  31345. getGlInfo(): {
  31346. vendor: string;
  31347. renderer: string;
  31348. version: string;
  31349. };
  31350. /**
  31351. * Gets current aspect ratio
  31352. * @param viewportOwner defines the camera to use to get the aspect ratio
  31353. * @param useScreen defines if screen size must be used (or the current render target if any)
  31354. * @returns a number defining the aspect ratio
  31355. */
  31356. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  31357. /**
  31358. * Gets current screen aspect ratio
  31359. * @returns a number defining the aspect ratio
  31360. */
  31361. getScreenAspectRatio(): number;
  31362. /**
  31363. * Gets the current render width
  31364. * @param useScreen defines if screen size must be used (or the current render target if any)
  31365. * @returns a number defining the current render width
  31366. */
  31367. getRenderWidth(useScreen?: boolean): number;
  31368. /**
  31369. * Gets the current render height
  31370. * @param useScreen defines if screen size must be used (or the current render target if any)
  31371. * @returns a number defining the current render height
  31372. */
  31373. getRenderHeight(useScreen?: boolean): number;
  31374. /**
  31375. * Gets the HTML canvas attached with the current webGL context
  31376. * @returns a HTML canvas
  31377. */
  31378. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31379. /**
  31380. * Gets host window
  31381. * @returns the host window object
  31382. */
  31383. getHostWindow(): Window;
  31384. /**
  31385. * Gets host document
  31386. * @returns the host document object
  31387. */
  31388. getHostDocument(): Document;
  31389. /**
  31390. * Gets the client rect of the HTML canvas attached with the current webGL context
  31391. * @returns a client rectanglee
  31392. */
  31393. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  31394. /**
  31395. * Defines the hardware scaling level.
  31396. * By default the hardware scaling level is computed from the window device ratio.
  31397. * if level = 1 then the engine will render at the exact resolution of the canvas. If level = 0.5 then the engine will render at twice the size of the canvas.
  31398. * @param level defines the level to use
  31399. */
  31400. setHardwareScalingLevel(level: number): void;
  31401. /**
  31402. * Gets the current hardware scaling level.
  31403. * By default the hardware scaling level is computed from the window device ratio.
  31404. * if level = 1 then the engine will render at the exact resolution of the canvas. If level = 0.5 then the engine will render at twice the size of the canvas.
  31405. * @returns a number indicating the current hardware scaling level
  31406. */
  31407. getHardwareScalingLevel(): number;
  31408. /**
  31409. * Gets the list of loaded textures
  31410. * @returns an array containing all loaded textures
  31411. */
  31412. getLoadedTexturesCache(): InternalTexture[];
  31413. /**
  31414. * Gets the object containing all engine capabilities
  31415. * @returns the EngineCapabilities object
  31416. */
  31417. getCaps(): EngineCapabilities;
  31418. /**
  31419. * Gets the current depth function
  31420. * @returns a number defining the depth function
  31421. */
  31422. getDepthFunction(): Nullable<number>;
  31423. /**
  31424. * Sets the current depth function
  31425. * @param depthFunc defines the function to use
  31426. */
  31427. setDepthFunction(depthFunc: number): void;
  31428. /**
  31429. * Sets the current depth function to GREATER
  31430. */
  31431. setDepthFunctionToGreater(): void;
  31432. /**
  31433. * Sets the current depth function to GEQUAL
  31434. */
  31435. setDepthFunctionToGreaterOrEqual(): void;
  31436. /**
  31437. * Sets the current depth function to LESS
  31438. */
  31439. setDepthFunctionToLess(): void;
  31440. private _cachedStencilBuffer;
  31441. private _cachedStencilFunction;
  31442. private _cachedStencilMask;
  31443. private _cachedStencilOperationPass;
  31444. private _cachedStencilOperationFail;
  31445. private _cachedStencilOperationDepthFail;
  31446. private _cachedStencilReference;
  31447. /**
  31448. * Caches the the state of the stencil buffer
  31449. */
  31450. cacheStencilState(): void;
  31451. /**
  31452. * Restores the state of the stencil buffer
  31453. */
  31454. restoreStencilState(): void;
  31455. /**
  31456. * Sets the current depth function to LEQUAL
  31457. */
  31458. setDepthFunctionToLessOrEqual(): void;
  31459. /**
  31460. * Gets a boolean indicating if stencil buffer is enabled
  31461. * @returns the current stencil buffer state
  31462. */
  31463. getStencilBuffer(): boolean;
  31464. /**
  31465. * Enable or disable the stencil buffer
  31466. * @param enable defines if the stencil buffer must be enabled or disabled
  31467. */
  31468. setStencilBuffer(enable: boolean): void;
  31469. /**
  31470. * Gets the current stencil mask
  31471. * @returns a number defining the new stencil mask to use
  31472. */
  31473. getStencilMask(): number;
  31474. /**
  31475. * Sets the current stencil mask
  31476. * @param mask defines the new stencil mask to use
  31477. */
  31478. setStencilMask(mask: number): void;
  31479. /**
  31480. * Gets the current stencil function
  31481. * @returns a number defining the stencil function to use
  31482. */
  31483. getStencilFunction(): number;
  31484. /**
  31485. * Gets the current stencil reference value
  31486. * @returns a number defining the stencil reference value to use
  31487. */
  31488. getStencilFunctionReference(): number;
  31489. /**
  31490. * Gets the current stencil mask
  31491. * @returns a number defining the stencil mask to use
  31492. */
  31493. getStencilFunctionMask(): number;
  31494. /**
  31495. * Sets the current stencil function
  31496. * @param stencilFunc defines the new stencil function to use
  31497. */
  31498. setStencilFunction(stencilFunc: number): void;
  31499. /**
  31500. * Sets the current stencil reference
  31501. * @param reference defines the new stencil reference to use
  31502. */
  31503. setStencilFunctionReference(reference: number): void;
  31504. /**
  31505. * Sets the current stencil mask
  31506. * @param mask defines the new stencil mask to use
  31507. */
  31508. setStencilFunctionMask(mask: number): void;
  31509. /**
  31510. * Gets the current stencil operation when stencil fails
  31511. * @returns a number defining stencil operation to use when stencil fails
  31512. */
  31513. getStencilOperationFail(): number;
  31514. /**
  31515. * Gets the current stencil operation when depth fails
  31516. * @returns a number defining stencil operation to use when depth fails
  31517. */
  31518. getStencilOperationDepthFail(): number;
  31519. /**
  31520. * Gets the current stencil operation when stencil passes
  31521. * @returns a number defining stencil operation to use when stencil passes
  31522. */
  31523. getStencilOperationPass(): number;
  31524. /**
  31525. * Sets the stencil operation to use when stencil fails
  31526. * @param operation defines the stencil operation to use when stencil fails
  31527. */
  31528. setStencilOperationFail(operation: number): void;
  31529. /**
  31530. * Sets the stencil operation to use when depth fails
  31531. * @param operation defines the stencil operation to use when depth fails
  31532. */
  31533. setStencilOperationDepthFail(operation: number): void;
  31534. /**
  31535. * Sets the stencil operation to use when stencil passes
  31536. * @param operation defines the stencil operation to use when stencil passes
  31537. */
  31538. setStencilOperationPass(operation: number): void;
  31539. /**
  31540. * Sets a boolean indicating if the dithering state is enabled or disabled
  31541. * @param value defines the dithering state
  31542. */
  31543. setDitheringState(value: boolean): void;
  31544. /**
  31545. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  31546. * @param value defines the rasterizer state
  31547. */
  31548. setRasterizerState(value: boolean): void;
  31549. /**
  31550. * stop executing a render loop function and remove it from the execution array
  31551. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31552. */
  31553. stopRenderLoop(renderFunction?: () => void): void;
  31554. /** @hidden */
  31555. _renderLoop(): void;
  31556. /**
  31557. * Can be used to override the current requestAnimationFrame requester.
  31558. * @hidden
  31559. */
  31560. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  31561. /**
  31562. * Register and execute a render loop. The engine can have more than one render function
  31563. * @param renderFunction defines the function to continuously execute
  31564. */
  31565. runRenderLoop(renderFunction: () => void): void;
  31566. /**
  31567. * Toggle full screen mode
  31568. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31569. */
  31570. switchFullscreen(requestPointerLock: boolean): void;
  31571. /**
  31572. * Enters full screen mode
  31573. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31574. */
  31575. enterFullscreen(requestPointerLock: boolean): void;
  31576. /**
  31577. * Exits full screen mode
  31578. */
  31579. exitFullscreen(): void;
  31580. /**
  31581. * Enters Pointerlock mode
  31582. */
  31583. enterPointerlock(): void;
  31584. /**
  31585. * Exits Pointerlock mode
  31586. */
  31587. exitPointerlock(): void;
  31588. /**
  31589. * Clear the current render buffer or the current render target (if any is set up)
  31590. * @param color defines the color to use
  31591. * @param backBuffer defines if the back buffer must be cleared
  31592. * @param depth defines if the depth buffer must be cleared
  31593. * @param stencil defines if the stencil buffer must be cleared
  31594. */
  31595. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31596. /**
  31597. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  31598. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31599. * @param y defines the y-coordinate of the corner of the clear rectangle
  31600. * @param width defines the width of the clear rectangle
  31601. * @param height defines the height of the clear rectangle
  31602. * @param clearColor defines the clear color
  31603. */
  31604. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  31605. /**
  31606. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  31607. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31608. * @param y defines the y-coordinate of the corner of the clear rectangle
  31609. * @param width defines the width of the clear rectangle
  31610. * @param height defines the height of the clear rectangle
  31611. */
  31612. enableScissor(x: number, y: number, width: number, height: number): void;
  31613. /**
  31614. * Disable previously set scissor test rectangle
  31615. */
  31616. disableScissor(): void;
  31617. private _viewportCached;
  31618. /** @hidden */
  31619. _viewport(x: number, y: number, width: number, height: number): void;
  31620. /**
  31621. * Set the WebGL's viewport
  31622. * @param viewport defines the viewport element to be used
  31623. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31624. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31625. */
  31626. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31627. /**
  31628. * Directly set the WebGL Viewport
  31629. * @param x defines the x coordinate of the viewport (in screen space)
  31630. * @param y defines the y coordinate of the viewport (in screen space)
  31631. * @param width defines the width of the viewport (in screen space)
  31632. * @param height defines the height of the viewport (in screen space)
  31633. * @return the current viewport Object (if any) that is being replaced by this call. You can restore this viewport later on to go back to the original state
  31634. */
  31635. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  31636. /**
  31637. * Begin a new frame
  31638. */
  31639. beginFrame(): void;
  31640. /**
  31641. * Enf the current frame
  31642. */
  31643. endFrame(): void;
  31644. /**
  31645. * Resize the view according to the canvas' size
  31646. */
  31647. resize(): void;
  31648. /**
  31649. * Force a specific size of the canvas
  31650. * @param width defines the new canvas' width
  31651. * @param height defines the new canvas' height
  31652. */
  31653. setSize(width: number, height: number): void;
  31654. /**
  31655. * Binds the frame buffer to the specified texture.
  31656. * @param texture The texture to render to or null for the default canvas
  31657. * @param faceIndex The face of the texture to render to in case of cube texture
  31658. * @param requiredWidth The width of the target to render to
  31659. * @param requiredHeight The height of the target to render to
  31660. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31661. * @param depthStencilTexture The depth stencil texture to use to render
  31662. * @param lodLevel defines le lod level to bind to the frame buffer
  31663. */
  31664. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  31665. /** @hidden */
  31666. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31667. /**
  31668. * Unbind the current render target texture from the webGL context
  31669. * @param texture defines the render target texture to unbind
  31670. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31671. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31672. */
  31673. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31674. /**
  31675. * Force the mipmap generation for the given render target texture
  31676. * @param texture defines the render target texture to use
  31677. */
  31678. generateMipMapsForCubemap(texture: InternalTexture): void;
  31679. /**
  31680. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31681. */
  31682. flushFramebuffer(): void;
  31683. /**
  31684. * Unbind the current render target and bind the default framebuffer
  31685. */
  31686. restoreDefaultFramebuffer(): void;
  31687. /**
  31688. * Create an uniform buffer
  31689. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31690. * @param elements defines the content of the uniform buffer
  31691. * @returns the webGL uniform buffer
  31692. */
  31693. createUniformBuffer(elements: FloatArray): DataBuffer;
  31694. /**
  31695. * Create a dynamic uniform buffer
  31696. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31697. * @param elements defines the content of the uniform buffer
  31698. * @returns the webGL uniform buffer
  31699. */
  31700. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  31701. /**
  31702. * Update an existing uniform buffer
  31703. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31704. * @param uniformBuffer defines the target uniform buffer
  31705. * @param elements defines the content to update
  31706. * @param offset defines the offset in the uniform buffer where update should start
  31707. * @param count defines the size of the data to update
  31708. */
  31709. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  31710. private _resetVertexBufferBinding;
  31711. /**
  31712. * Creates a vertex buffer
  31713. * @param data the data for the vertex buffer
  31714. * @returns the new WebGL static buffer
  31715. */
  31716. createVertexBuffer(data: DataArray): DataBuffer;
  31717. /**
  31718. * Creates a dynamic vertex buffer
  31719. * @param data the data for the dynamic vertex buffer
  31720. * @returns the new WebGL dynamic buffer
  31721. */
  31722. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31723. /**
  31724. * Update a dynamic index buffer
  31725. * @param indexBuffer defines the target index buffer
  31726. * @param indices defines the data to update
  31727. * @param offset defines the offset in the target index buffer where update should start
  31728. */
  31729. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  31730. /**
  31731. * Updates a dynamic vertex buffer.
  31732. * @param vertexBuffer the vertex buffer to update
  31733. * @param data the data used to update the vertex buffer
  31734. * @param byteOffset the byte offset of the data
  31735. * @param byteLength the byte length of the data
  31736. */
  31737. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  31738. private _resetIndexBufferBinding;
  31739. /**
  31740. * Creates a new index buffer
  31741. * @param indices defines the content of the index buffer
  31742. * @param updatable defines if the index buffer must be updatable
  31743. * @returns a new webGL buffer
  31744. */
  31745. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31746. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  31747. /**
  31748. * Bind a webGL buffer to the webGL context
  31749. * @param buffer defines the buffer to bind
  31750. */
  31751. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31752. /**
  31753. * Bind an uniform buffer to the current webGL context
  31754. * @param buffer defines the buffer to bind
  31755. */
  31756. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  31757. /**
  31758. * Bind a buffer to the current webGL context at a given location
  31759. * @param buffer defines the buffer to bind
  31760. * @param location defines the index where to bind the buffer
  31761. */
  31762. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  31763. /**
  31764. * Bind a specific block at a given index in a specific shader program
  31765. * @param pipelineContext defines the pipeline context to use
  31766. * @param blockName defines the block name
  31767. * @param index defines the index where to bind the block
  31768. */
  31769. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  31770. private bindIndexBuffer;
  31771. private bindBuffer;
  31772. /**
  31773. * update the bound buffer with the given data
  31774. * @param data defines the data to update
  31775. */
  31776. updateArrayBuffer(data: Float32Array): void;
  31777. private _vertexAttribPointer;
  31778. private _bindIndexBufferWithCache;
  31779. private _bindVertexBuffersAttributes;
  31780. /**
  31781. * Records a vertex array object
  31782. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31783. * @param vertexBuffers defines the list of vertex buffers to store
  31784. * @param indexBuffer defines the index buffer to store
  31785. * @param effect defines the effect to store
  31786. * @returns the new vertex array object
  31787. */
  31788. recordVertexArrayObject(vertexBuffers: {
  31789. [key: string]: VertexBuffer;
  31790. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31791. /**
  31792. * Bind a specific vertex array object
  31793. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31794. * @param vertexArrayObject defines the vertex array object to bind
  31795. * @param indexBuffer defines the index buffer to bind
  31796. */
  31797. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31798. /**
  31799. * Bind webGl buffers directly to the webGL context
  31800. * @param vertexBuffer defines the vertex buffer to bind
  31801. * @param indexBuffer defines the index buffer to bind
  31802. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31803. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31804. * @param effect defines the effect associated with the vertex buffer
  31805. */
  31806. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31807. private _unbindVertexArrayObject;
  31808. /**
  31809. * Bind a list of vertex buffers to the webGL context
  31810. * @param vertexBuffers defines the list of vertex buffers to bind
  31811. * @param indexBuffer defines the index buffer to bind
  31812. * @param effect defines the effect associated with the vertex buffers
  31813. */
  31814. bindBuffers(vertexBuffers: {
  31815. [key: string]: Nullable<VertexBuffer>;
  31816. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31817. /**
  31818. * Unbind all instance attributes
  31819. */
  31820. unbindInstanceAttributes(): void;
  31821. /**
  31822. * Release and free the memory of a vertex array object
  31823. * @param vao defines the vertex array object to delete
  31824. */
  31825. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31826. /** @hidden */
  31827. _releaseBuffer(buffer: DataBuffer): boolean;
  31828. protected _deleteBuffer(buffer: DataBuffer): void;
  31829. /**
  31830. * Creates a webGL buffer to use with instanciation
  31831. * @param capacity defines the size of the buffer
  31832. * @returns the webGL buffer
  31833. */
  31834. createInstancesBuffer(capacity: number): DataBuffer;
  31835. /**
  31836. * Delete a webGL buffer used with instanciation
  31837. * @param buffer defines the webGL buffer to delete
  31838. */
  31839. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  31840. /**
  31841. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31842. * @param instancesBuffer defines the webGL buffer to update and bind
  31843. * @param data defines the data to store in the buffer
  31844. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31845. */
  31846. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31847. /**
  31848. * Apply all cached states (depth, culling, stencil and alpha)
  31849. */
  31850. applyStates(): void;
  31851. /**
  31852. * Send a draw order
  31853. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31854. * @param indexStart defines the starting index
  31855. * @param indexCount defines the number of index to draw
  31856. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31857. */
  31858. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31859. /**
  31860. * Draw a list of points
  31861. * @param verticesStart defines the index of first vertex to draw
  31862. * @param verticesCount defines the count of vertices to draw
  31863. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31864. */
  31865. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31866. /**
  31867. * Draw a list of unindexed primitives
  31868. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31869. * @param verticesStart defines the index of first vertex to draw
  31870. * @param verticesCount defines the count of vertices to draw
  31871. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31872. */
  31873. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31874. /**
  31875. * Draw a list of indexed primitives
  31876. * @param fillMode defines the primitive to use
  31877. * @param indexStart defines the starting index
  31878. * @param indexCount defines the number of index to draw
  31879. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31880. */
  31881. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  31882. /**
  31883. * Draw a list of unindexed primitives
  31884. * @param fillMode defines the primitive to use
  31885. * @param verticesStart defines the index of first vertex to draw
  31886. * @param verticesCount defines the count of vertices to draw
  31887. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31888. */
  31889. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31890. private _drawMode;
  31891. /** @hidden */
  31892. _releaseEffect(effect: Effect): void;
  31893. /** @hidden */
  31894. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31895. /**
  31896. * Create a new effect (used to store vertex/fragment shaders)
  31897. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31898. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  31899. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31900. * @param samplers defines an array of string used to represent textures
  31901. * @param defines defines the string containing the defines to use to compile the shaders
  31902. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31903. * @param onCompiled defines a function to call when the effect creation is successful
  31904. * @param onError defines a function to call when the effect creation has failed
  31905. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31906. * @returns the new Effect
  31907. */
  31908. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  31909. protected static _concatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  31910. private _compileShader;
  31911. private _compileRawShader;
  31912. /**
  31913. * Directly creates a webGL program
  31914. * @param pipelineContext defines the pipeline context to attach to
  31915. * @param vertexCode defines the vertex shader code to use
  31916. * @param fragmentCode defines the fragment shader code to use
  31917. * @param context defines the webGL context to use (if not set, the current one will be used)
  31918. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31919. * @returns the new webGL program
  31920. */
  31921. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31922. /**
  31923. * Creates a webGL program
  31924. * @param pipelineContext defines the pipeline context to attach to
  31925. * @param vertexCode defines the vertex shader code to use
  31926. * @param fragmentCode defines the fragment shader code to use
  31927. * @param defines defines the string containing the defines to use to compile the shaders
  31928. * @param context defines the webGL context to use (if not set, the current one will be used)
  31929. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31930. * @returns the new webGL program
  31931. */
  31932. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31933. /**
  31934. * Creates a new pipeline context
  31935. * @returns the new pipeline
  31936. */
  31937. createPipelineContext(): IPipelineContext;
  31938. private _createShaderProgram;
  31939. private _finalizePipelineContext;
  31940. /** @hidden */
  31941. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31942. /** @hidden */
  31943. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31944. /** @hidden */
  31945. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31946. /**
  31947. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31948. * @param pipelineContext defines the pipeline context to use
  31949. * @param uniformsNames defines the list of uniform names
  31950. * @returns an array of webGL uniform locations
  31951. */
  31952. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31953. /**
  31954. * Gets the lsit of active attributes for a given webGL program
  31955. * @param pipelineContext defines the pipeline context to use
  31956. * @param attributesNames defines the list of attribute names to get
  31957. * @returns an array of indices indicating the offset of each attribute
  31958. */
  31959. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31960. /**
  31961. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31962. * @param effect defines the effect to activate
  31963. */
  31964. enableEffect(effect: Nullable<Effect>): void;
  31965. /**
  31966. * Set the value of an uniform to an array of int32
  31967. * @param uniform defines the webGL uniform location where to store the value
  31968. * @param array defines the array of int32 to store
  31969. */
  31970. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31971. /**
  31972. * Set the value of an uniform to an array of int32 (stored as vec2)
  31973. * @param uniform defines the webGL uniform location where to store the value
  31974. * @param array defines the array of int32 to store
  31975. */
  31976. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31977. /**
  31978. * Set the value of an uniform to an array of int32 (stored as vec3)
  31979. * @param uniform defines the webGL uniform location where to store the value
  31980. * @param array defines the array of int32 to store
  31981. */
  31982. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31983. /**
  31984. * Set the value of an uniform to an array of int32 (stored as vec4)
  31985. * @param uniform defines the webGL uniform location where to store the value
  31986. * @param array defines the array of int32 to store
  31987. */
  31988. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31989. /**
  31990. * Set the value of an uniform to an array of float32
  31991. * @param uniform defines the webGL uniform location where to store the value
  31992. * @param array defines the array of float32 to store
  31993. */
  31994. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31995. /**
  31996. * Set the value of an uniform to an array of float32 (stored as vec2)
  31997. * @param uniform defines the webGL uniform location where to store the value
  31998. * @param array defines the array of float32 to store
  31999. */
  32000. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  32001. /**
  32002. * Set the value of an uniform to an array of float32 (stored as vec3)
  32003. * @param uniform defines the webGL uniform location where to store the value
  32004. * @param array defines the array of float32 to store
  32005. */
  32006. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  32007. /**
  32008. * Set the value of an uniform to an array of float32 (stored as vec4)
  32009. * @param uniform defines the webGL uniform location where to store the value
  32010. * @param array defines the array of float32 to store
  32011. */
  32012. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  32013. /**
  32014. * Set the value of an uniform to an array of number
  32015. * @param uniform defines the webGL uniform location where to store the value
  32016. * @param array defines the array of number to store
  32017. */
  32018. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  32019. /**
  32020. * Set the value of an uniform to an array of number (stored as vec2)
  32021. * @param uniform defines the webGL uniform location where to store the value
  32022. * @param array defines the array of number to store
  32023. */
  32024. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  32025. /**
  32026. * Set the value of an uniform to an array of number (stored as vec3)
  32027. * @param uniform defines the webGL uniform location where to store the value
  32028. * @param array defines the array of number to store
  32029. */
  32030. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  32031. /**
  32032. * Set the value of an uniform to an array of number (stored as vec4)
  32033. * @param uniform defines the webGL uniform location where to store the value
  32034. * @param array defines the array of number to store
  32035. */
  32036. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  32037. /**
  32038. * Set the value of an uniform to an array of float32 (stored as matrices)
  32039. * @param uniform defines the webGL uniform location where to store the value
  32040. * @param matrices defines the array of float32 to store
  32041. */
  32042. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  32043. /**
  32044. * Set the value of an uniform to a matrix (3x3)
  32045. * @param uniform defines the webGL uniform location where to store the value
  32046. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  32047. */
  32048. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32049. /**
  32050. * Set the value of an uniform to a matrix (2x2)
  32051. * @param uniform defines the webGL uniform location where to store the value
  32052. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  32053. */
  32054. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32055. /**
  32056. * Set the value of an uniform to a number (int)
  32057. * @param uniform defines the webGL uniform location where to store the value
  32058. * @param value defines the int number to store
  32059. */
  32060. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32061. /**
  32062. * Set the value of an uniform to a number (float)
  32063. * @param uniform defines the webGL uniform location where to store the value
  32064. * @param value defines the float number to store
  32065. */
  32066. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32067. /**
  32068. * Set the value of an uniform to a vec2
  32069. * @param uniform defines the webGL uniform location where to store the value
  32070. * @param x defines the 1st component of the value
  32071. * @param y defines the 2nd component of the value
  32072. */
  32073. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  32074. /**
  32075. * Set the value of an uniform to a vec3
  32076. * @param uniform defines the webGL uniform location where to store the value
  32077. * @param x defines the 1st component of the value
  32078. * @param y defines the 2nd component of the value
  32079. * @param z defines the 3rd component of the value
  32080. */
  32081. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  32082. /**
  32083. * Set the value of an uniform to a boolean
  32084. * @param uniform defines the webGL uniform location where to store the value
  32085. * @param bool defines the boolean to store
  32086. */
  32087. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  32088. /**
  32089. * Set the value of an uniform to a vec4
  32090. * @param uniform defines the webGL uniform location where to store the value
  32091. * @param x defines the 1st component of the value
  32092. * @param y defines the 2nd component of the value
  32093. * @param z defines the 3rd component of the value
  32094. * @param w defines the 4th component of the value
  32095. */
  32096. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  32097. /**
  32098. * Sets a Color4 on a uniform variable
  32099. * @param uniform defines the uniform location
  32100. * @param color4 defines the value to be set
  32101. */
  32102. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  32103. /**
  32104. * Set various states to the webGL context
  32105. * @param culling defines backface culling state
  32106. * @param zOffset defines the value to apply to zOffset (0 by default)
  32107. * @param force defines if states must be applied even if cache is up to date
  32108. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  32109. */
  32110. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  32111. /**
  32112. * Set the z offset to apply to current rendering
  32113. * @param value defines the offset to apply
  32114. */
  32115. setZOffset(value: number): void;
  32116. /**
  32117. * Gets the current value of the zOffset
  32118. * @returns the current zOffset state
  32119. */
  32120. getZOffset(): number;
  32121. /**
  32122. * Enable or disable depth buffering
  32123. * @param enable defines the state to set
  32124. */
  32125. setDepthBuffer(enable: boolean): void;
  32126. /**
  32127. * Gets a boolean indicating if depth writing is enabled
  32128. * @returns the current depth writing state
  32129. */
  32130. getDepthWrite(): boolean;
  32131. /**
  32132. * Enable or disable depth writing
  32133. * @param enable defines the state to set
  32134. */
  32135. setDepthWrite(enable: boolean): void;
  32136. /**
  32137. * Enable or disable color writing
  32138. * @param enable defines the state to set
  32139. */
  32140. setColorWrite(enable: boolean): void;
  32141. /**
  32142. * Gets a boolean indicating if color writing is enabled
  32143. * @returns the current color writing state
  32144. */
  32145. getColorWrite(): boolean;
  32146. /**
  32147. * Sets alpha constants used by some alpha blending modes
  32148. * @param r defines the red component
  32149. * @param g defines the green component
  32150. * @param b defines the blue component
  32151. * @param a defines the alpha component
  32152. */
  32153. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  32154. /**
  32155. * Sets the current alpha mode
  32156. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  32157. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  32158. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32159. */
  32160. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  32161. /**
  32162. * Gets the current alpha mode
  32163. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32164. * @returns the current alpha mode
  32165. */
  32166. getAlphaMode(): number;
  32167. /**
  32168. * Clears the list of texture accessible through engine.
  32169. * This can help preventing texture load conflict due to name collision.
  32170. */
  32171. clearInternalTexturesCache(): void;
  32172. /**
  32173. * Force the entire cache to be cleared
  32174. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32175. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32176. */
  32177. wipeCaches(bruteForce?: boolean): void;
  32178. /**
  32179. * Set the compressed texture format to use, based on the formats you have, and the formats
  32180. * supported by the hardware / browser.
  32181. *
  32182. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  32183. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  32184. * to API arguments needed to compressed textures. This puts the burden on the container
  32185. * generator to house the arcane code for determining these for current & future formats.
  32186. *
  32187. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  32188. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  32189. *
  32190. * Note: The result of this call is not taken into account when a texture is base64.
  32191. *
  32192. * @param formatsAvailable defines the list of those format families you have created
  32193. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  32194. *
  32195. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  32196. * @returns The extension selected.
  32197. */
  32198. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  32199. /** @hidden */
  32200. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32201. min: number;
  32202. mag: number;
  32203. };
  32204. /** @hidden */
  32205. _createTexture(): WebGLTexture;
  32206. /**
  32207. * Usually called from Texture.ts.
  32208. * Passed information to create a WebGLTexture
  32209. * @param urlArg defines a value which contains one of the following:
  32210. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32211. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32212. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32213. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32214. * @param invertY when true, image is flipped when loaded. You probably want true. Certain compressed textures may invert this if their default is inverted (eg. ktx)
  32215. * @param scene needed for loading to the correct scene
  32216. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32217. * @param onLoad optional callback to be called upon successful completion
  32218. * @param onError optional callback to be called upon failure
  32219. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), HTMLImageElement (image format), or a Blob
  32220. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32221. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32222. * @param forcedExtension defines the extension to use to pick the right loader
  32223. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  32224. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32225. */
  32226. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  32227. /**
  32228. * @hidden
  32229. * Rescales a texture
  32230. * @param source input texutre
  32231. * @param destination destination texture
  32232. * @param scene scene to use to render the resize
  32233. * @param internalFormat format to use when resizing
  32234. * @param onComplete callback to be called when resize has completed
  32235. */
  32236. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  32237. private _unpackFlipYCached;
  32238. /**
  32239. * In case you are sharing the context with other applications, it might
  32240. * be interested to not cache the unpack flip y state to ensure a consistent
  32241. * value would be set.
  32242. */
  32243. enableUnpackFlipYCached: boolean;
  32244. /** @hidden */
  32245. _unpackFlipY(value: boolean): void;
  32246. /** @hidden */
  32247. _getUnpackAlignement(): number;
  32248. /**
  32249. * Creates a dynamic texture
  32250. * @param width defines the width of the texture
  32251. * @param height defines the height of the texture
  32252. * @param generateMipMaps defines if the engine should generate the mip levels
  32253. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32254. * @returns the dynamic texture inside an InternalTexture
  32255. */
  32256. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  32257. /**
  32258. * Update the sampling mode of a given texture
  32259. * @param samplingMode defines the required sampling mode
  32260. * @param texture defines the texture to update
  32261. */
  32262. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  32263. /**
  32264. * Update the content of a dynamic texture
  32265. * @param texture defines the texture to update
  32266. * @param canvas defines the canvas containing the source
  32267. * @param invertY defines if data must be stored with Y axis inverted
  32268. * @param premulAlpha defines if alpha is stored as premultiplied
  32269. * @param format defines the format of the data
  32270. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  32271. */
  32272. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  32273. /**
  32274. * Update a video texture
  32275. * @param texture defines the texture to update
  32276. * @param video defines the video element to use
  32277. * @param invertY defines if data must be stored with Y axis inverted
  32278. */
  32279. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  32280. /**
  32281. * Updates a depth texture Comparison Mode and Function.
  32282. * If the comparison Function is equal to 0, the mode will be set to none.
  32283. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  32284. * @param texture The texture to set the comparison function for
  32285. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  32286. */
  32287. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  32288. /** @hidden */
  32289. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32290. width: number;
  32291. height: number;
  32292. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32293. /**
  32294. * Creates a depth stencil texture.
  32295. * This is only available in WebGL 2 or with the depth texture extension available.
  32296. * @param size The size of face edge in the texture.
  32297. * @param options The options defining the texture.
  32298. * @returns The texture
  32299. */
  32300. createDepthStencilTexture(size: number | {
  32301. width: number;
  32302. height: number;
  32303. }, options: DepthTextureCreationOptions): InternalTexture;
  32304. /**
  32305. * Creates a depth stencil texture.
  32306. * This is only available in WebGL 2 or with the depth texture extension available.
  32307. * @param size The size of face edge in the texture.
  32308. * @param options The options defining the texture.
  32309. * @returns The texture
  32310. */
  32311. private _createDepthStencilTexture;
  32312. /**
  32313. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  32314. * @param renderTarget The render target to set the frame buffer for
  32315. */
  32316. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  32317. /**
  32318. * Creates a new render target texture
  32319. * @param size defines the size of the texture
  32320. * @param options defines the options used to create the texture
  32321. * @returns a new render target texture stored in an InternalTexture
  32322. */
  32323. createRenderTargetTexture(size: number | {
  32324. width: number;
  32325. height: number;
  32326. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  32327. /** @hidden */
  32328. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32329. /**
  32330. * Updates the sample count of a render target texture
  32331. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  32332. * @param texture defines the texture to update
  32333. * @param samples defines the sample count to set
  32334. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  32335. */
  32336. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  32337. /** @hidden */
  32338. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32339. /** @hidden */
  32340. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32341. /** @hidden */
  32342. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32343. /** @hidden */
  32344. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  32345. /**
  32346. * @hidden
  32347. */
  32348. _setCubeMapTextureParams(loadMipmap: boolean): void;
  32349. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<Scene>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32350. private _prepareWebGLTexture;
  32351. /** @hidden */
  32352. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  32353. /** @hidden */
  32354. _releaseFramebufferObjects(texture: InternalTexture): void;
  32355. /** @hidden */
  32356. _releaseTexture(texture: InternalTexture): void;
  32357. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32358. protected _setProgram(program: WebGLProgram): void;
  32359. protected _boundUniforms: {
  32360. [key: number]: WebGLUniformLocation;
  32361. };
  32362. /**
  32363. * Binds an effect to the webGL context
  32364. * @param effect defines the effect to bind
  32365. */
  32366. bindSamplers(effect: Effect): void;
  32367. private _activateCurrentTexture;
  32368. /** @hidden */
  32369. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32370. /** @hidden */
  32371. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32372. /**
  32373. * Sets a texture to the webGL context from a postprocess
  32374. * @param channel defines the channel to use
  32375. * @param postProcess defines the source postprocess
  32376. */
  32377. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  32378. /**
  32379. * Binds the output of the passed in post process to the texture channel specified
  32380. * @param channel The channel the texture should be bound to
  32381. * @param postProcess The post process which's output should be bound
  32382. */
  32383. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  32384. /**
  32385. * Unbind all textures from the webGL context
  32386. */
  32387. unbindAllTextures(): void;
  32388. /**
  32389. * Sets a texture to the according uniform.
  32390. * @param channel The texture channel
  32391. * @param uniform The uniform to set
  32392. * @param texture The texture to apply
  32393. */
  32394. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32395. /**
  32396. * Sets a depth stencil texture from a render target to the according uniform.
  32397. * @param channel The texture channel
  32398. * @param uniform The uniform to set
  32399. * @param texture The render target texture containing the depth stencil texture to apply
  32400. */
  32401. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  32402. private _bindSamplerUniformToChannel;
  32403. private _getTextureWrapMode;
  32404. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32405. /**
  32406. * Sets an array of texture to the webGL context
  32407. * @param channel defines the channel where the texture array must be set
  32408. * @param uniform defines the associated uniform location
  32409. * @param textures defines the array of textures to bind
  32410. */
  32411. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32412. /** @hidden */
  32413. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  32414. private _setTextureParameterFloat;
  32415. private _setTextureParameterInteger;
  32416. /**
  32417. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32418. * @param x defines the x coordinate of the rectangle where pixels must be read
  32419. * @param y defines the y coordinate of the rectangle where pixels must be read
  32420. * @param width defines the width of the rectangle where pixels must be read
  32421. * @param height defines the height of the rectangle where pixels must be read
  32422. * @returns a Uint8Array containing RGBA colors
  32423. */
  32424. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  32425. /**
  32426. * Add an externaly attached data from its key.
  32427. * This method call will fail and return false, if such key already exists.
  32428. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  32429. * @param key the unique key that identifies the data
  32430. * @param data the data object to associate to the key for this Engine instance
  32431. * @return true if no such key were already present and the data was added successfully, false otherwise
  32432. */
  32433. addExternalData<T>(key: string, data: T): boolean;
  32434. /**
  32435. * Get an externaly attached data from its key
  32436. * @param key the unique key that identifies the data
  32437. * @return the associated data, if present (can be null), or undefined if not present
  32438. */
  32439. getExternalData<T>(key: string): T;
  32440. /**
  32441. * Get an externaly attached data from its key, create it using a factory if it's not already present
  32442. * @param key the unique key that identifies the data
  32443. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  32444. * @return the associated data, can be null if the factory returned null.
  32445. */
  32446. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  32447. /**
  32448. * Remove an externaly attached data from the Engine instance
  32449. * @param key the unique key that identifies the data
  32450. * @return true if the data was successfully removed, false if it doesn't exist
  32451. */
  32452. removeExternalData(key: string): boolean;
  32453. /**
  32454. * Unbind all vertex attributes from the webGL context
  32455. */
  32456. unbindAllAttributes(): void;
  32457. /**
  32458. * Force the engine to release all cached effects. This means that next effect compilation will have to be done completely even if a similar effect was already compiled
  32459. */
  32460. releaseEffects(): void;
  32461. /**
  32462. * Dispose and release all associated resources
  32463. */
  32464. dispose(): void;
  32465. /**
  32466. * Display the loading screen
  32467. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32468. */
  32469. displayLoadingUI(): void;
  32470. /**
  32471. * Hide the loading screen
  32472. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32473. */
  32474. hideLoadingUI(): void;
  32475. /**
  32476. * Gets the current loading screen object
  32477. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32478. */
  32479. /**
  32480. * Sets the current loading screen object
  32481. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32482. */
  32483. loadingScreen: ILoadingScreen;
  32484. /**
  32485. * Sets the current loading screen text
  32486. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32487. */
  32488. loadingUIText: string;
  32489. /**
  32490. * Sets the current loading screen background color
  32491. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32492. */
  32493. loadingUIBackgroundColor: string;
  32494. /**
  32495. * Attach a new callback raised when context lost event is fired
  32496. * @param callback defines the callback to call
  32497. */
  32498. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32499. /**
  32500. * Attach a new callback raised when context restored event is fired
  32501. * @param callback defines the callback to call
  32502. */
  32503. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32504. /**
  32505. * Gets the source code of the vertex shader associated with a specific webGL program
  32506. * @param program defines the program to use
  32507. * @returns a string containing the source code of the vertex shader associated with the program
  32508. */
  32509. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  32510. /**
  32511. * Gets the source code of the fragment shader associated with a specific webGL program
  32512. * @param program defines the program to use
  32513. * @returns a string containing the source code of the fragment shader associated with the program
  32514. */
  32515. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  32516. /**
  32517. * Get the current error code of the webGL context
  32518. * @returns the error code
  32519. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32520. */
  32521. getError(): number;
  32522. /**
  32523. * Gets the current framerate
  32524. * @returns a number representing the framerate
  32525. */
  32526. getFps(): number;
  32527. /**
  32528. * Gets the time spent between current and previous frame
  32529. * @returns a number representing the delta time in ms
  32530. */
  32531. getDeltaTime(): number;
  32532. private _measureFps;
  32533. /** @hidden */
  32534. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  32535. private _canRenderToFloatFramebuffer;
  32536. private _canRenderToHalfFloatFramebuffer;
  32537. private _canRenderToFramebuffer;
  32538. /** @hidden */
  32539. _getWebGLTextureType(type: number): number;
  32540. /** @hidden */
  32541. _getInternalFormat(format: number): number;
  32542. /** @hidden */
  32543. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32544. /** @hidden */
  32545. _getRGBAMultiSampleBufferFormat(type: number): number;
  32546. /** @hidden */
  32547. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  32548. /** @hidden */
  32549. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32550. /**
  32551. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32552. * @returns true if the engine can be created
  32553. * @ignorenaming
  32554. */
  32555. static isSupported(): boolean;
  32556. /**
  32557. * Find the next highest power of two.
  32558. * @param x Number to start search from.
  32559. * @return Next highest power of two.
  32560. */
  32561. static CeilingPOT(x: number): number;
  32562. /**
  32563. * Find the next lowest power of two.
  32564. * @param x Number to start search from.
  32565. * @return Next lowest power of two.
  32566. */
  32567. static FloorPOT(x: number): number;
  32568. /**
  32569. * Find the nearest power of two.
  32570. * @param x Number to start search from.
  32571. * @return Next nearest power of two.
  32572. */
  32573. static NearestPOT(x: number): number;
  32574. /**
  32575. * Get the closest exponent of two
  32576. * @param value defines the value to approximate
  32577. * @param max defines the maximum value to return
  32578. * @param mode defines how to define the closest value
  32579. * @returns closest exponent of two of the given value
  32580. */
  32581. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32582. /**
  32583. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32584. * @param func - the function to be called
  32585. * @param requester - the object that will request the next frame. Falls back to window.
  32586. * @returns frame number
  32587. */
  32588. static QueueNewFrame(func: () => void, requester?: any): number;
  32589. /**
  32590. * Ask the browser to promote the current element to pointerlock mode
  32591. * @param element defines the DOM element to promote
  32592. */
  32593. static _RequestPointerlock(element: HTMLElement): void;
  32594. /**
  32595. * Asks the browser to exit pointerlock mode
  32596. */
  32597. static _ExitPointerlock(): void;
  32598. /**
  32599. * Ask the browser to promote the current element to fullscreen rendering mode
  32600. * @param element defines the DOM element to promote
  32601. */
  32602. static _RequestFullscreen(element: HTMLElement): void;
  32603. /**
  32604. * Asks the browser to exit fullscreen mode
  32605. */
  32606. static _ExitFullscreen(): void;
  32607. }
  32608. }
  32609. declare module "babylonjs/Engines/engineStore" {
  32610. import { Nullable } from "babylonjs/types";
  32611. import { Engine } from "babylonjs/Engines/engine";
  32612. import { Scene } from "babylonjs/scene";
  32613. /**
  32614. * The engine store class is responsible to hold all the instances of Engine and Scene created
  32615. * during the life time of the application.
  32616. */
  32617. export class EngineStore {
  32618. /** Gets the list of created engines */
  32619. static Instances: import("babylonjs/Engines/engine").Engine[];
  32620. /** @hidden */
  32621. static _LastCreatedScene: Nullable<Scene>;
  32622. /**
  32623. * Gets the latest created engine
  32624. */
  32625. static readonly LastCreatedEngine: Nullable<Engine>;
  32626. /**
  32627. * Gets the latest created scene
  32628. */
  32629. static readonly LastCreatedScene: Nullable<Scene>;
  32630. /**
  32631. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32632. * @ignorenaming
  32633. */
  32634. static UseFallbackTexture: boolean;
  32635. /**
  32636. * Texture content used if a texture cannot loaded
  32637. * @ignorenaming
  32638. */
  32639. static FallbackTexture: string;
  32640. }
  32641. }
  32642. declare module "babylonjs/Misc/promise" {
  32643. /**
  32644. * Helper class that provides a small promise polyfill
  32645. */
  32646. export class PromisePolyfill {
  32647. /**
  32648. * Static function used to check if the polyfill is required
  32649. * If this is the case then the function will inject the polyfill to window.Promise
  32650. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  32651. */
  32652. static Apply(force?: boolean): void;
  32653. }
  32654. }
  32655. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  32656. /**
  32657. * Interface for screenshot methods with describe argument called `size` as object with options
  32658. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  32659. */
  32660. export interface IScreenshotSize {
  32661. /**
  32662. * number in pixels for canvas height
  32663. */
  32664. height?: number;
  32665. /**
  32666. * multiplier allowing render at a higher or lower resolution
  32667. * If value is defined then height and width will be ignored and taken from camera
  32668. */
  32669. precision?: number;
  32670. /**
  32671. * number in pixels for canvas width
  32672. */
  32673. width?: number;
  32674. }
  32675. }
  32676. declare module "babylonjs/Misc/tools" {
  32677. import { Nullable, float } from "babylonjs/types";
  32678. import { DomManagement } from "babylonjs/Misc/domManagement";
  32679. import { WebRequest } from "babylonjs/Misc/webRequest";
  32680. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  32681. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32682. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  32683. import { Camera } from "babylonjs/Cameras/camera";
  32684. import { Engine } from "babylonjs/Engines/engine";
  32685. interface IColor4Like {
  32686. r: float;
  32687. g: float;
  32688. b: float;
  32689. a: float;
  32690. }
  32691. /**
  32692. * Class containing a set of static utilities functions
  32693. */
  32694. export class Tools {
  32695. /**
  32696. * Gets or sets the base URL to use to load assets
  32697. */
  32698. static BaseUrl: string;
  32699. /**
  32700. * Enable/Disable Custom HTTP Request Headers globally.
  32701. * default = false
  32702. * @see CustomRequestHeaders
  32703. */
  32704. static UseCustomRequestHeaders: boolean;
  32705. /**
  32706. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  32707. * i.e. when loading files, where the server/service expects an Authorization header
  32708. */
  32709. static CustomRequestHeaders: {
  32710. [key: string]: string;
  32711. };
  32712. /**
  32713. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  32714. */
  32715. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  32716. /**
  32717. * Default behaviour for cors in the application.
  32718. * It can be a string if the expected behavior is identical in the entire app.
  32719. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  32720. */
  32721. static CorsBehavior: string | ((url: string | string[]) => string);
  32722. /**
  32723. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32724. * @ignorenaming
  32725. */
  32726. static UseFallbackTexture: boolean;
  32727. /**
  32728. * Use this object to register external classes like custom textures or material
  32729. * to allow the laoders to instantiate them
  32730. */
  32731. static RegisteredExternalClasses: {
  32732. [key: string]: Object;
  32733. };
  32734. /**
  32735. * Texture content used if a texture cannot loaded
  32736. * @ignorenaming
  32737. */
  32738. static fallbackTexture: string;
  32739. /**
  32740. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  32741. * @param u defines the coordinate on X axis
  32742. * @param v defines the coordinate on Y axis
  32743. * @param width defines the width of the source data
  32744. * @param height defines the height of the source data
  32745. * @param pixels defines the source byte array
  32746. * @param color defines the output color
  32747. */
  32748. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  32749. /**
  32750. * Interpolates between a and b via alpha
  32751. * @param a The lower value (returned when alpha = 0)
  32752. * @param b The upper value (returned when alpha = 1)
  32753. * @param alpha The interpolation-factor
  32754. * @return The mixed value
  32755. */
  32756. static Mix(a: number, b: number, alpha: number): number;
  32757. /**
  32758. * Tries to instantiate a new object from a given class name
  32759. * @param className defines the class name to instantiate
  32760. * @returns the new object or null if the system was not able to do the instantiation
  32761. */
  32762. static Instantiate(className: string): any;
  32763. /**
  32764. * Provides a slice function that will work even on IE
  32765. * @param data defines the array to slice
  32766. * @param start defines the start of the data (optional)
  32767. * @param end defines the end of the data (optional)
  32768. * @returns the new sliced array
  32769. */
  32770. static Slice<T>(data: T, start?: number, end?: number): T;
  32771. /**
  32772. * Polyfill for setImmediate
  32773. * @param action defines the action to execute after the current execution block
  32774. */
  32775. static SetImmediate(action: () => void): void;
  32776. /**
  32777. * Function indicating if a number is an exponent of 2
  32778. * @param value defines the value to test
  32779. * @returns true if the value is an exponent of 2
  32780. */
  32781. static IsExponentOfTwo(value: number): boolean;
  32782. private static _tmpFloatArray;
  32783. /**
  32784. * Returns the nearest 32-bit single precision float representation of a Number
  32785. * @param value A Number. If the parameter is of a different type, it will get converted
  32786. * to a number or to NaN if it cannot be converted
  32787. * @returns number
  32788. */
  32789. static FloatRound(value: number): number;
  32790. /**
  32791. * Extracts the filename from a path
  32792. * @param path defines the path to use
  32793. * @returns the filename
  32794. */
  32795. static GetFilename(path: string): string;
  32796. /**
  32797. * Extracts the "folder" part of a path (everything before the filename).
  32798. * @param uri The URI to extract the info from
  32799. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32800. * @returns The "folder" part of the path
  32801. */
  32802. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  32803. /**
  32804. * Extracts text content from a DOM element hierarchy
  32805. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  32806. */
  32807. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32808. /**
  32809. * Convert an angle in radians to degrees
  32810. * @param angle defines the angle to convert
  32811. * @returns the angle in degrees
  32812. */
  32813. static ToDegrees(angle: number): number;
  32814. /**
  32815. * Convert an angle in degrees to radians
  32816. * @param angle defines the angle to convert
  32817. * @returns the angle in radians
  32818. */
  32819. static ToRadians(angle: number): number;
  32820. /**
  32821. * Encode a buffer to a base64 string
  32822. * @param buffer defines the buffer to encode
  32823. * @returns the encoded string
  32824. */
  32825. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  32826. /**
  32827. * Returns an array if obj is not an array
  32828. * @param obj defines the object to evaluate as an array
  32829. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32830. * @returns either obj directly if obj is an array or a new array containing obj
  32831. */
  32832. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32833. /**
  32834. * Gets the pointer prefix to use
  32835. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32836. */
  32837. static GetPointerPrefix(): string;
  32838. /**
  32839. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32840. * @param url define the url we are trying
  32841. * @param element define the dom element where to configure the cors policy
  32842. */
  32843. static SetCorsBehavior(url: string | string[], element: {
  32844. crossOrigin: string | null;
  32845. }): void;
  32846. /**
  32847. * Removes unwanted characters from an url
  32848. * @param url defines the url to clean
  32849. * @returns the cleaned url
  32850. */
  32851. static CleanUrl(url: string): string;
  32852. /**
  32853. * Gets or sets a function used to pre-process url before using them to load assets
  32854. */
  32855. static PreprocessUrl: (url: string) => string;
  32856. /**
  32857. * Loads an image as an HTMLImageElement.
  32858. * @param input url string, ArrayBuffer, or Blob to load
  32859. * @param onLoad callback called when the image successfully loads
  32860. * @param onError callback called when the image fails to load
  32861. * @param offlineProvider offline provider for caching
  32862. * @returns the HTMLImageElement of the loaded image
  32863. */
  32864. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  32865. /**
  32866. * Loads a file
  32867. * @param url url string, ArrayBuffer, or Blob to load
  32868. * @param onSuccess callback called when the file successfully loads
  32869. * @param onProgress callback called while file is loading (if the server supports this mode)
  32870. * @param offlineProvider defines the offline provider for caching
  32871. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32872. * @param onError callback called when the file fails to load
  32873. * @returns a file request object
  32874. */
  32875. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  32876. /**
  32877. * Loads a file from a url
  32878. * @param url the file url to load
  32879. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  32880. */
  32881. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  32882. /**
  32883. * Load a script (identified by an url). When the url returns, the
  32884. * content of this file is added into a new script element, attached to the DOM (body element)
  32885. * @param scriptUrl defines the url of the script to laod
  32886. * @param onSuccess defines the callback called when the script is loaded
  32887. * @param onError defines the callback to call if an error occurs
  32888. * @param scriptId defines the id of the script element
  32889. */
  32890. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  32891. /**
  32892. * Load an asynchronous script (identified by an url). When the url returns, the
  32893. * content of this file is added into a new script element, attached to the DOM (body element)
  32894. * @param scriptUrl defines the url of the script to laod
  32895. * @param scriptId defines the id of the script element
  32896. * @returns a promise request object
  32897. */
  32898. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  32899. /**
  32900. * Loads a file from a blob
  32901. * @param fileToLoad defines the blob to use
  32902. * @param callback defines the callback to call when data is loaded
  32903. * @param progressCallback defines the callback to call during loading process
  32904. * @returns a file request object
  32905. */
  32906. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32907. /**
  32908. * Loads a file
  32909. * @param fileToLoad defines the file to load
  32910. * @param callback defines the callback to call when data is loaded
  32911. * @param progressCallBack defines the callback to call during loading process
  32912. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32913. * @returns a file request object
  32914. */
  32915. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  32916. /**
  32917. * Creates a data url from a given string content
  32918. * @param content defines the content to convert
  32919. * @returns the new data url link
  32920. */
  32921. static FileAsURL(content: string): string;
  32922. /**
  32923. * Format the given number to a specific decimal format
  32924. * @param value defines the number to format
  32925. * @param decimals defines the number of decimals to use
  32926. * @returns the formatted string
  32927. */
  32928. static Format(value: number, decimals?: number): string;
  32929. /**
  32930. * Tries to copy an object by duplicating every property
  32931. * @param source defines the source object
  32932. * @param destination defines the target object
  32933. * @param doNotCopyList defines a list of properties to avoid
  32934. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  32935. */
  32936. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  32937. /**
  32938. * Gets a boolean indicating if the given object has no own property
  32939. * @param obj defines the object to test
  32940. * @returns true if object has no own property
  32941. */
  32942. static IsEmpty(obj: any): boolean;
  32943. /**
  32944. * Function used to register events at window level
  32945. * @param windowElement defines the Window object to use
  32946. * @param events defines the events to register
  32947. */
  32948. static RegisterTopRootEvents(windowElement: Window, events: {
  32949. name: string;
  32950. handler: Nullable<(e: FocusEvent) => any>;
  32951. }[]): void;
  32952. /**
  32953. * Function used to unregister events from window level
  32954. * @param windowElement defines the Window object to use
  32955. * @param events defines the events to unregister
  32956. */
  32957. static UnregisterTopRootEvents(windowElement: Window, events: {
  32958. name: string;
  32959. handler: Nullable<(e: FocusEvent) => any>;
  32960. }[]): void;
  32961. /**
  32962. * @ignore
  32963. */
  32964. static _ScreenshotCanvas: HTMLCanvasElement;
  32965. /**
  32966. * Dumps the current bound framebuffer
  32967. * @param width defines the rendering width
  32968. * @param height defines the rendering height
  32969. * @param engine defines the hosting engine
  32970. * @param successCallback defines the callback triggered once the data are available
  32971. * @param mimeType defines the mime type of the result
  32972. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  32973. */
  32974. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32975. /**
  32976. * Converts the canvas data to blob.
  32977. * This acts as a polyfill for browsers not supporting the to blob function.
  32978. * @param canvas Defines the canvas to extract the data from
  32979. * @param successCallback Defines the callback triggered once the data are available
  32980. * @param mimeType Defines the mime type of the result
  32981. */
  32982. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32983. /**
  32984. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32985. * @param successCallback defines the callback triggered once the data are available
  32986. * @param mimeType defines the mime type of the result
  32987. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  32988. */
  32989. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32990. /**
  32991. * Downloads a blob in the browser
  32992. * @param blob defines the blob to download
  32993. * @param fileName defines the name of the downloaded file
  32994. */
  32995. static Download(blob: Blob, fileName: string): void;
  32996. /**
  32997. * Captures a screenshot of the current rendering
  32998. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32999. * @param engine defines the rendering engine
  33000. * @param camera defines the source camera
  33001. * @param size This parameter can be set to a single number or to an object with the
  33002. * following (optional) properties: precision, width, height. If a single number is passed,
  33003. * it will be used for both width and height. If an object is passed, the screenshot size
  33004. * will be derived from the parameters. The precision property is a multiplier allowing
  33005. * rendering at a higher or lower resolution
  33006. * @param successCallback defines the callback receives a single parameter which contains the
  33007. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33008. * src parameter of an <img> to display it
  33009. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33010. * Check your browser for supported MIME types
  33011. */
  33012. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  33013. /**
  33014. * Captures a screenshot of the current rendering
  33015. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33016. * @param engine defines the rendering engine
  33017. * @param camera defines the source camera
  33018. * @param size This parameter can be set to a single number or to an object with the
  33019. * following (optional) properties: precision, width, height. If a single number is passed,
  33020. * it will be used for both width and height. If an object is passed, the screenshot size
  33021. * will be derived from the parameters. The precision property is a multiplier allowing
  33022. * rendering at a higher or lower resolution
  33023. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33024. * Check your browser for supported MIME types
  33025. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33026. * to the src parameter of an <img> to display it
  33027. */
  33028. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  33029. /**
  33030. * Generates an image screenshot from the specified camera.
  33031. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33032. * @param engine The engine to use for rendering
  33033. * @param camera The camera to use for rendering
  33034. * @param size This parameter can be set to a single number or to an object with the
  33035. * following (optional) properties: precision, width, height. If a single number is passed,
  33036. * it will be used for both width and height. If an object is passed, the screenshot size
  33037. * will be derived from the parameters. The precision property is a multiplier allowing
  33038. * rendering at a higher or lower resolution
  33039. * @param successCallback The callback receives a single parameter which contains the
  33040. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33041. * src parameter of an <img> to display it
  33042. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33043. * Check your browser for supported MIME types
  33044. * @param samples Texture samples (default: 1)
  33045. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33046. * @param fileName A name for for the downloaded file.
  33047. */
  33048. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  33049. /**
  33050. * Generates an image screenshot from the specified camera.
  33051. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33052. * @param engine The engine to use for rendering
  33053. * @param camera The camera to use for rendering
  33054. * @param size This parameter can be set to a single number or to an object with the
  33055. * following (optional) properties: precision, width, height. If a single number is passed,
  33056. * it will be used for both width and height. If an object is passed, the screenshot size
  33057. * will be derived from the parameters. The precision property is a multiplier allowing
  33058. * rendering at a higher or lower resolution
  33059. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33060. * Check your browser for supported MIME types
  33061. * @param samples Texture samples (default: 1)
  33062. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33063. * @param fileName A name for for the downloaded file.
  33064. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33065. * to the src parameter of an <img> to display it
  33066. */
  33067. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  33068. /**
  33069. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  33070. * Be aware Math.random() could cause collisions, but:
  33071. * "All but 6 of the 128 bits of the ID are randomly generated, which means that for any two ids, there's a 1 in 2^^122 (or 5.3x10^^36) chance they'll collide"
  33072. * @returns a pseudo random id
  33073. */
  33074. static RandomId(): string;
  33075. /**
  33076. * Test if the given uri is a base64 string
  33077. * @param uri The uri to test
  33078. * @return True if the uri is a base64 string or false otherwise
  33079. */
  33080. static IsBase64(uri: string): boolean;
  33081. /**
  33082. * Decode the given base64 uri.
  33083. * @param uri The uri to decode
  33084. * @return The decoded base64 data.
  33085. */
  33086. static DecodeBase64(uri: string): ArrayBuffer;
  33087. /**
  33088. * Gets the absolute url.
  33089. * @param url the input url
  33090. * @return the absolute url
  33091. */
  33092. static GetAbsoluteUrl(url: string): string;
  33093. /**
  33094. * No log
  33095. */
  33096. static readonly NoneLogLevel: number;
  33097. /**
  33098. * Only message logs
  33099. */
  33100. static readonly MessageLogLevel: number;
  33101. /**
  33102. * Only warning logs
  33103. */
  33104. static readonly WarningLogLevel: number;
  33105. /**
  33106. * Only error logs
  33107. */
  33108. static readonly ErrorLogLevel: number;
  33109. /**
  33110. * All logs
  33111. */
  33112. static readonly AllLogLevel: number;
  33113. /**
  33114. * Gets a value indicating the number of loading errors
  33115. * @ignorenaming
  33116. */
  33117. static readonly errorsCount: number;
  33118. /**
  33119. * Callback called when a new log is added
  33120. */
  33121. static OnNewCacheEntry: (entry: string) => void;
  33122. /**
  33123. * Log a message to the console
  33124. * @param message defines the message to log
  33125. */
  33126. static Log(message: string): void;
  33127. /**
  33128. * Write a warning message to the console
  33129. * @param message defines the message to log
  33130. */
  33131. static Warn(message: string): void;
  33132. /**
  33133. * Write an error message to the console
  33134. * @param message defines the message to log
  33135. */
  33136. static Error(message: string): void;
  33137. /**
  33138. * Gets current log cache (list of logs)
  33139. */
  33140. static readonly LogCache: string;
  33141. /**
  33142. * Clears the log cache
  33143. */
  33144. static ClearLogCache(): void;
  33145. /**
  33146. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  33147. */
  33148. static LogLevels: number;
  33149. /**
  33150. * Checks if the window object exists
  33151. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  33152. */
  33153. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  33154. /**
  33155. * No performance log
  33156. */
  33157. static readonly PerformanceNoneLogLevel: number;
  33158. /**
  33159. * Use user marks to log performance
  33160. */
  33161. static readonly PerformanceUserMarkLogLevel: number;
  33162. /**
  33163. * Log performance to the console
  33164. */
  33165. static readonly PerformanceConsoleLogLevel: number;
  33166. private static _performance;
  33167. /**
  33168. * Sets the current performance log level
  33169. */
  33170. static PerformanceLogLevel: number;
  33171. private static _StartPerformanceCounterDisabled;
  33172. private static _EndPerformanceCounterDisabled;
  33173. private static _StartUserMark;
  33174. private static _EndUserMark;
  33175. private static _StartPerformanceConsole;
  33176. private static _EndPerformanceConsole;
  33177. /**
  33178. * Starts a performance counter
  33179. */
  33180. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33181. /**
  33182. * Ends a specific performance coutner
  33183. */
  33184. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33185. /**
  33186. * Gets either window.performance.now() if supported or Date.now() else
  33187. */
  33188. static readonly Now: number;
  33189. /**
  33190. * This method will return the name of the class used to create the instance of the given object.
  33191. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  33192. * @param object the object to get the class name from
  33193. * @param isType defines if the object is actually a type
  33194. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  33195. */
  33196. static GetClassName(object: any, isType?: boolean): string;
  33197. /**
  33198. * Gets the first element of an array satisfying a given predicate
  33199. * @param array defines the array to browse
  33200. * @param predicate defines the predicate to use
  33201. * @returns null if not found or the element
  33202. */
  33203. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  33204. /**
  33205. * This method will return the name of the full name of the class, including its owning module (if any).
  33206. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator or implementing a method getClassName():string (in which case the module won't be specified).
  33207. * @param object the object to get the class name from
  33208. * @param isType defines if the object is actually a type
  33209. * @return a string that can have two forms: "moduleName.className" if module was specified when the class' Name was registered or "className" if there was not module specified.
  33210. * @ignorenaming
  33211. */
  33212. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  33213. /**
  33214. * Returns a promise that resolves after the given amount of time.
  33215. * @param delay Number of milliseconds to delay
  33216. * @returns Promise that resolves after the given amount of time
  33217. */
  33218. static DelayAsync(delay: number): Promise<void>;
  33219. }
  33220. /**
  33221. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  33222. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  33223. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  33224. * @param name The name of the class, case should be preserved
  33225. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  33226. */
  33227. export function className(name: string, module?: string): (target: Object) => void;
  33228. /**
  33229. * An implementation of a loop for asynchronous functions.
  33230. */
  33231. export class AsyncLoop {
  33232. /**
  33233. * Defines the number of iterations for the loop
  33234. */
  33235. iterations: number;
  33236. /**
  33237. * Defines the current index of the loop.
  33238. */
  33239. index: number;
  33240. private _done;
  33241. private _fn;
  33242. private _successCallback;
  33243. /**
  33244. * Constructor.
  33245. * @param iterations the number of iterations.
  33246. * @param func the function to run each iteration
  33247. * @param successCallback the callback that will be called upon succesful execution
  33248. * @param offset starting offset.
  33249. */
  33250. constructor(
  33251. /**
  33252. * Defines the number of iterations for the loop
  33253. */
  33254. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  33255. /**
  33256. * Execute the next iteration. Must be called after the last iteration was finished.
  33257. */
  33258. executeNext(): void;
  33259. /**
  33260. * Break the loop and run the success callback.
  33261. */
  33262. breakLoop(): void;
  33263. /**
  33264. * Create and run an async loop.
  33265. * @param iterations the number of iterations.
  33266. * @param fn the function to run each iteration
  33267. * @param successCallback the callback that will be called upon succesful execution
  33268. * @param offset starting offset.
  33269. * @returns the created async loop object
  33270. */
  33271. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  33272. /**
  33273. * A for-loop that will run a given number of iterations synchronous and the rest async.
  33274. * @param iterations total number of iterations
  33275. * @param syncedIterations number of synchronous iterations in each async iteration.
  33276. * @param fn the function to call each iteration.
  33277. * @param callback a success call back that will be called when iterating stops.
  33278. * @param breakFunction a break condition (optional)
  33279. * @param timeout timeout settings for the setTimeout function. default - 0.
  33280. * @returns the created async loop object
  33281. */
  33282. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  33283. }
  33284. }
  33285. declare module "babylonjs/Collisions/collisionCoordinator" {
  33286. import { Nullable } from "babylonjs/types";
  33287. import { Scene } from "babylonjs/scene";
  33288. import { Vector3 } from "babylonjs/Maths/math.vector";
  33289. import { Collider } from "babylonjs/Collisions/collider";
  33290. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33291. /** @hidden */
  33292. export interface ICollisionCoordinator {
  33293. createCollider(): Collider;
  33294. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33295. init(scene: Scene): void;
  33296. }
  33297. /** @hidden */
  33298. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  33299. private _scene;
  33300. private _scaledPosition;
  33301. private _scaledVelocity;
  33302. private _finalPosition;
  33303. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33304. createCollider(): Collider;
  33305. init(scene: Scene): void;
  33306. private _collideWithWorld;
  33307. }
  33308. }
  33309. declare module "babylonjs/Inputs/scene.inputManager" {
  33310. import { Nullable } from "babylonjs/types";
  33311. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33312. import { Vector2 } from "babylonjs/Maths/math.vector";
  33313. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33314. import { Scene } from "babylonjs/scene";
  33315. /**
  33316. * Class used to manage all inputs for the scene.
  33317. */
  33318. export class InputManager {
  33319. /** The distance in pixel that you have to move to prevent some events */
  33320. static DragMovementThreshold: number;
  33321. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  33322. static LongPressDelay: number;
  33323. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  33324. static DoubleClickDelay: number;
  33325. /** If you need to check double click without raising a single click at first click, enable this flag */
  33326. static ExclusiveDoubleClickMode: boolean;
  33327. private _wheelEventName;
  33328. private _onPointerMove;
  33329. private _onPointerDown;
  33330. private _onPointerUp;
  33331. private _initClickEvent;
  33332. private _initActionManager;
  33333. private _delayedSimpleClick;
  33334. private _delayedSimpleClickTimeout;
  33335. private _previousDelayedSimpleClickTimeout;
  33336. private _meshPickProceed;
  33337. private _previousButtonPressed;
  33338. private _currentPickResult;
  33339. private _previousPickResult;
  33340. private _totalPointersPressed;
  33341. private _doubleClickOccured;
  33342. private _pointerOverMesh;
  33343. private _pickedDownMesh;
  33344. private _pickedUpMesh;
  33345. private _pointerX;
  33346. private _pointerY;
  33347. private _unTranslatedPointerX;
  33348. private _unTranslatedPointerY;
  33349. private _startingPointerPosition;
  33350. private _previousStartingPointerPosition;
  33351. private _startingPointerTime;
  33352. private _previousStartingPointerTime;
  33353. private _pointerCaptures;
  33354. private _onKeyDown;
  33355. private _onKeyUp;
  33356. private _onCanvasFocusObserver;
  33357. private _onCanvasBlurObserver;
  33358. private _scene;
  33359. /**
  33360. * Creates a new InputManager
  33361. * @param scene defines the hosting scene
  33362. */
  33363. constructor(scene: Scene);
  33364. /**
  33365. * Gets the mesh that is currently under the pointer
  33366. */
  33367. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33368. /**
  33369. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  33370. */
  33371. readonly unTranslatedPointer: Vector2;
  33372. /**
  33373. * Gets or sets the current on-screen X position of the pointer
  33374. */
  33375. pointerX: number;
  33376. /**
  33377. * Gets or sets the current on-screen Y position of the pointer
  33378. */
  33379. pointerY: number;
  33380. private _updatePointerPosition;
  33381. private _processPointerMove;
  33382. private _setRayOnPointerInfo;
  33383. private _checkPrePointerObservable;
  33384. /**
  33385. * Use this method to simulate a pointer move on a mesh
  33386. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33387. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33388. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33389. */
  33390. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33391. /**
  33392. * Use this method to simulate a pointer down on a mesh
  33393. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33394. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33395. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33396. */
  33397. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33398. private _processPointerDown;
  33399. /** @hidden */
  33400. _isPointerSwiping(): boolean;
  33401. /**
  33402. * Use this method to simulate a pointer up on a mesh
  33403. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33404. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33405. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33406. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33407. */
  33408. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  33409. private _processPointerUp;
  33410. /**
  33411. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33412. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33413. * @returns true if the pointer was captured
  33414. */
  33415. isPointerCaptured(pointerId?: number): boolean;
  33416. /**
  33417. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33418. * @param attachUp defines if you want to attach events to pointerup
  33419. * @param attachDown defines if you want to attach events to pointerdown
  33420. * @param attachMove defines if you want to attach events to pointermove
  33421. */
  33422. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33423. /**
  33424. * Detaches all event handlers
  33425. */
  33426. detachControl(): void;
  33427. /**
  33428. * Force the value of meshUnderPointer
  33429. * @param mesh defines the mesh to use
  33430. */
  33431. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33432. /**
  33433. * Gets the mesh under the pointer
  33434. * @returns a Mesh or null if no mesh is under the pointer
  33435. */
  33436. getPointerOverMesh(): Nullable<AbstractMesh>;
  33437. }
  33438. }
  33439. declare module "babylonjs/Misc/uniqueIdGenerator" {
  33440. /**
  33441. * Helper class used to generate session unique ID
  33442. */
  33443. export class UniqueIdGenerator {
  33444. private static _UniqueIdCounter;
  33445. /**
  33446. * Gets an unique (relatively to the current scene) Id
  33447. */
  33448. static readonly UniqueId: number;
  33449. }
  33450. }
  33451. declare module "babylonjs/Animations/animationGroup" {
  33452. import { Animatable } from "babylonjs/Animations/animatable";
  33453. import { Animation } from "babylonjs/Animations/animation";
  33454. import { Scene, IDisposable } from "babylonjs/scene";
  33455. import { Observable } from "babylonjs/Misc/observable";
  33456. import { Nullable } from "babylonjs/types";
  33457. import "babylonjs/Animations/animatable";
  33458. /**
  33459. * This class defines the direct association between an animation and a target
  33460. */
  33461. export class TargetedAnimation {
  33462. /**
  33463. * Animation to perform
  33464. */
  33465. animation: Animation;
  33466. /**
  33467. * Target to animate
  33468. */
  33469. target: any;
  33470. /**
  33471. * Serialize the object
  33472. * @returns the JSON object representing the current entity
  33473. */
  33474. serialize(): any;
  33475. }
  33476. /**
  33477. * Use this class to create coordinated animations on multiple targets
  33478. */
  33479. export class AnimationGroup implements IDisposable {
  33480. /** The name of the animation group */
  33481. name: string;
  33482. private _scene;
  33483. private _targetedAnimations;
  33484. private _animatables;
  33485. private _from;
  33486. private _to;
  33487. private _isStarted;
  33488. private _isPaused;
  33489. private _speedRatio;
  33490. private _loopAnimation;
  33491. /**
  33492. * Gets or sets the unique id of the node
  33493. */
  33494. uniqueId: number;
  33495. /**
  33496. * This observable will notify when one animation have ended
  33497. */
  33498. onAnimationEndObservable: Observable<TargetedAnimation>;
  33499. /**
  33500. * Observer raised when one animation loops
  33501. */
  33502. onAnimationLoopObservable: Observable<TargetedAnimation>;
  33503. /**
  33504. * This observable will notify when all animations have ended.
  33505. */
  33506. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  33507. /**
  33508. * This observable will notify when all animations have paused.
  33509. */
  33510. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  33511. /**
  33512. * This observable will notify when all animations are playing.
  33513. */
  33514. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  33515. /**
  33516. * Gets the first frame
  33517. */
  33518. readonly from: number;
  33519. /**
  33520. * Gets the last frame
  33521. */
  33522. readonly to: number;
  33523. /**
  33524. * Define if the animations are started
  33525. */
  33526. readonly isStarted: boolean;
  33527. /**
  33528. * Gets a value indicating that the current group is playing
  33529. */
  33530. readonly isPlaying: boolean;
  33531. /**
  33532. * Gets or sets the speed ratio to use for all animations
  33533. */
  33534. /**
  33535. * Gets or sets the speed ratio to use for all animations
  33536. */
  33537. speedRatio: number;
  33538. /**
  33539. * Gets or sets if all animations should loop or not
  33540. */
  33541. loopAnimation: boolean;
  33542. /**
  33543. * Gets the targeted animations for this animation group
  33544. */
  33545. readonly targetedAnimations: Array<TargetedAnimation>;
  33546. /**
  33547. * returning the list of animatables controlled by this animation group.
  33548. */
  33549. readonly animatables: Array<Animatable>;
  33550. /**
  33551. * Instantiates a new Animation Group.
  33552. * This helps managing several animations at once.
  33553. * @see http://doc.babylonjs.com/how_to/group
  33554. * @param name Defines the name of the group
  33555. * @param scene Defines the scene the group belongs to
  33556. */
  33557. constructor(
  33558. /** The name of the animation group */
  33559. name: string, scene?: Nullable<Scene>);
  33560. /**
  33561. * Add an animation (with its target) in the group
  33562. * @param animation defines the animation we want to add
  33563. * @param target defines the target of the animation
  33564. * @returns the TargetedAnimation object
  33565. */
  33566. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  33567. /**
  33568. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  33569. * It can add constant keys at begin or end
  33570. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  33571. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  33572. * @returns the animation group
  33573. */
  33574. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  33575. /**
  33576. * Start all animations on given targets
  33577. * @param loop defines if animations must loop
  33578. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  33579. * @param from defines the from key (optional)
  33580. * @param to defines the to key (optional)
  33581. * @returns the current animation group
  33582. */
  33583. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  33584. /**
  33585. * Pause all animations
  33586. * @returns the animation group
  33587. */
  33588. pause(): AnimationGroup;
  33589. /**
  33590. * Play all animations to initial state
  33591. * This function will start() the animations if they were not started or will restart() them if they were paused
  33592. * @param loop defines if animations must loop
  33593. * @returns the animation group
  33594. */
  33595. play(loop?: boolean): AnimationGroup;
  33596. /**
  33597. * Reset all animations to initial state
  33598. * @returns the animation group
  33599. */
  33600. reset(): AnimationGroup;
  33601. /**
  33602. * Restart animations from key 0
  33603. * @returns the animation group
  33604. */
  33605. restart(): AnimationGroup;
  33606. /**
  33607. * Stop all animations
  33608. * @returns the animation group
  33609. */
  33610. stop(): AnimationGroup;
  33611. /**
  33612. * Set animation weight for all animatables
  33613. * @param weight defines the weight to use
  33614. * @return the animationGroup
  33615. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33616. */
  33617. setWeightForAllAnimatables(weight: number): AnimationGroup;
  33618. /**
  33619. * Synchronize and normalize all animatables with a source animatable
  33620. * @param root defines the root animatable to synchronize with
  33621. * @return the animationGroup
  33622. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33623. */
  33624. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  33625. /**
  33626. * Goes to a specific frame in this animation group
  33627. * @param frame the frame number to go to
  33628. * @return the animationGroup
  33629. */
  33630. goToFrame(frame: number): AnimationGroup;
  33631. /**
  33632. * Dispose all associated resources
  33633. */
  33634. dispose(): void;
  33635. private _checkAnimationGroupEnded;
  33636. /**
  33637. * Clone the current animation group and returns a copy
  33638. * @param newName defines the name of the new group
  33639. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  33640. * @returns the new aniamtion group
  33641. */
  33642. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  33643. /**
  33644. * Serializes the animationGroup to an object
  33645. * @returns Serialized object
  33646. */
  33647. serialize(): any;
  33648. /**
  33649. * Returns a new AnimationGroup object parsed from the source provided.
  33650. * @param parsedAnimationGroup defines the source
  33651. * @param scene defines the scene that will receive the animationGroup
  33652. * @returns a new AnimationGroup
  33653. */
  33654. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  33655. /**
  33656. * Returns the string "AnimationGroup"
  33657. * @returns "AnimationGroup"
  33658. */
  33659. getClassName(): string;
  33660. /**
  33661. * Creates a detailled string about the object
  33662. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  33663. * @returns a string representing the object
  33664. */
  33665. toString(fullDetails?: boolean): string;
  33666. }
  33667. }
  33668. declare module "babylonjs/scene" {
  33669. import { Nullable } from "babylonjs/types";
  33670. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33671. import { Observable } from "babylonjs/Misc/observable";
  33672. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  33673. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  33674. import { Geometry } from "babylonjs/Meshes/geometry";
  33675. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33676. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33677. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33678. import { Mesh } from "babylonjs/Meshes/mesh";
  33679. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33680. import { Bone } from "babylonjs/Bones/bone";
  33681. import { Skeleton } from "babylonjs/Bones/skeleton";
  33682. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33683. import { Camera } from "babylonjs/Cameras/camera";
  33684. import { AbstractScene } from "babylonjs/abstractScene";
  33685. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33686. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33687. import { Material } from "babylonjs/Materials/material";
  33688. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  33689. import { Effect } from "babylonjs/Materials/effect";
  33690. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  33691. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33692. import { Light } from "babylonjs/Lights/light";
  33693. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33694. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  33695. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  33696. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  33697. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33698. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  33699. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33700. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  33701. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  33702. import { Engine } from "babylonjs/Engines/engine";
  33703. import { Node } from "babylonjs/node";
  33704. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  33705. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33706. import { WebRequest } from "babylonjs/Misc/webRequest";
  33707. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  33708. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  33709. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  33710. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  33711. import { Plane } from "babylonjs/Maths/math.plane";
  33712. import { Ray } from "babylonjs/Culling/ray";
  33713. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33714. import { Animation } from "babylonjs/Animations/animation";
  33715. import { Animatable } from "babylonjs/Animations/animatable";
  33716. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33717. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33718. import { Collider } from "babylonjs/Collisions/collider";
  33719. /**
  33720. * Define an interface for all classes that will hold resources
  33721. */
  33722. export interface IDisposable {
  33723. /**
  33724. * Releases all held resources
  33725. */
  33726. dispose(): void;
  33727. }
  33728. /** Interface defining initialization parameters for Scene class */
  33729. export interface SceneOptions {
  33730. /**
  33731. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  33732. * It will improve performance when the number of geometries becomes important.
  33733. */
  33734. useGeometryUniqueIdsMap?: boolean;
  33735. /**
  33736. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  33737. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33738. */
  33739. useMaterialMeshMap?: boolean;
  33740. /**
  33741. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  33742. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33743. */
  33744. useClonedMeshhMap?: boolean;
  33745. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  33746. virtual?: boolean;
  33747. }
  33748. /**
  33749. * Represents a scene to be rendered by the engine.
  33750. * @see http://doc.babylonjs.com/features/scene
  33751. */
  33752. export class Scene extends AbstractScene implements IAnimatable {
  33753. /** The fog is deactivated */
  33754. static readonly FOGMODE_NONE: number;
  33755. /** The fog density is following an exponential function */
  33756. static readonly FOGMODE_EXP: number;
  33757. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  33758. static readonly FOGMODE_EXP2: number;
  33759. /** The fog density is following a linear function. */
  33760. static readonly FOGMODE_LINEAR: number;
  33761. /**
  33762. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  33763. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33764. */
  33765. static MinDeltaTime: number;
  33766. /**
  33767. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  33768. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33769. */
  33770. static MaxDeltaTime: number;
  33771. /**
  33772. * Factory used to create the default material.
  33773. * @param name The name of the material to create
  33774. * @param scene The scene to create the material for
  33775. * @returns The default material
  33776. */
  33777. static DefaultMaterialFactory(scene: Scene): Material;
  33778. /**
  33779. * Factory used to create the a collision coordinator.
  33780. * @returns The collision coordinator
  33781. */
  33782. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  33783. /** @hidden */
  33784. _inputManager: InputManager;
  33785. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  33786. cameraToUseForPointers: Nullable<Camera>;
  33787. /** @hidden */
  33788. readonly _isScene: boolean;
  33789. /**
  33790. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  33791. */
  33792. autoClear: boolean;
  33793. /**
  33794. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  33795. */
  33796. autoClearDepthAndStencil: boolean;
  33797. /**
  33798. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  33799. */
  33800. clearColor: Color4;
  33801. /**
  33802. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  33803. */
  33804. ambientColor: Color3;
  33805. /**
  33806. * This is use to store the default BRDF lookup for PBR materials in your scene.
  33807. * It should only be one of the following (if not the default embedded one):
  33808. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  33809. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  33810. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  33811. * The material properties need to be setup according to the type of texture in use.
  33812. */
  33813. environmentBRDFTexture: BaseTexture;
  33814. /** @hidden */
  33815. protected _environmentTexture: Nullable<BaseTexture>;
  33816. /**
  33817. * Texture used in all pbr material as the reflection texture.
  33818. * As in the majority of the scene they are the same (exception for multi room and so on),
  33819. * this is easier to reference from here than from all the materials.
  33820. */
  33821. /**
  33822. * Texture used in all pbr material as the reflection texture.
  33823. * As in the majority of the scene they are the same (exception for multi room and so on),
  33824. * this is easier to set here than in all the materials.
  33825. */
  33826. environmentTexture: Nullable<BaseTexture>;
  33827. /** @hidden */
  33828. protected _environmentIntensity: number;
  33829. /**
  33830. * Intensity of the environment in all pbr material.
  33831. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33832. * As in the majority of the scene they are the same (exception for multi room and so on),
  33833. * this is easier to reference from here than from all the materials.
  33834. */
  33835. /**
  33836. * Intensity of the environment in all pbr material.
  33837. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33838. * As in the majority of the scene they are the same (exception for multi room and so on),
  33839. * this is easier to set here than in all the materials.
  33840. */
  33841. environmentIntensity: number;
  33842. /** @hidden */
  33843. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  33844. /**
  33845. * Default image processing configuration used either in the rendering
  33846. * Forward main pass or through the imageProcessingPostProcess if present.
  33847. * As in the majority of the scene they are the same (exception for multi camera),
  33848. * this is easier to reference from here than from all the materials and post process.
  33849. *
  33850. * No setter as we it is a shared configuration, you can set the values instead.
  33851. */
  33852. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  33853. private _forceWireframe;
  33854. /**
  33855. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  33856. */
  33857. forceWireframe: boolean;
  33858. private _forcePointsCloud;
  33859. /**
  33860. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  33861. */
  33862. forcePointsCloud: boolean;
  33863. /**
  33864. * Gets or sets the active clipplane 1
  33865. */
  33866. clipPlane: Nullable<Plane>;
  33867. /**
  33868. * Gets or sets the active clipplane 2
  33869. */
  33870. clipPlane2: Nullable<Plane>;
  33871. /**
  33872. * Gets or sets the active clipplane 3
  33873. */
  33874. clipPlane3: Nullable<Plane>;
  33875. /**
  33876. * Gets or sets the active clipplane 4
  33877. */
  33878. clipPlane4: Nullable<Plane>;
  33879. /**
  33880. * Gets or sets a boolean indicating if animations are enabled
  33881. */
  33882. animationsEnabled: boolean;
  33883. private _animationPropertiesOverride;
  33884. /**
  33885. * Gets or sets the animation properties override
  33886. */
  33887. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  33888. /**
  33889. * Gets or sets a boolean indicating if a constant deltatime has to be used
  33890. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  33891. */
  33892. useConstantAnimationDeltaTime: boolean;
  33893. /**
  33894. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  33895. * Please note that it requires to run a ray cast through the scene on every frame
  33896. */
  33897. constantlyUpdateMeshUnderPointer: boolean;
  33898. /**
  33899. * Defines the HTML cursor to use when hovering over interactive elements
  33900. */
  33901. hoverCursor: string;
  33902. /**
  33903. * Defines the HTML default cursor to use (empty by default)
  33904. */
  33905. defaultCursor: string;
  33906. /**
  33907. * This is used to call preventDefault() on pointer down
  33908. * in order to block unwanted artifacts like system double clicks
  33909. */
  33910. preventDefaultOnPointerDown: boolean;
  33911. /**
  33912. * This is used to call preventDefault() on pointer up
  33913. * in order to block unwanted artifacts like system double clicks
  33914. */
  33915. preventDefaultOnPointerUp: boolean;
  33916. /**
  33917. * Gets or sets user defined metadata
  33918. */
  33919. metadata: any;
  33920. /**
  33921. * For internal use only. Please do not use.
  33922. */
  33923. reservedDataStore: any;
  33924. /**
  33925. * Gets the name of the plugin used to load this scene (null by default)
  33926. */
  33927. loadingPluginName: string;
  33928. /**
  33929. * Use this array to add regular expressions used to disable offline support for specific urls
  33930. */
  33931. disableOfflineSupportExceptionRules: RegExp[];
  33932. /**
  33933. * An event triggered when the scene is disposed.
  33934. */
  33935. onDisposeObservable: Observable<Scene>;
  33936. private _onDisposeObserver;
  33937. /** Sets a function to be executed when this scene is disposed. */
  33938. onDispose: () => void;
  33939. /**
  33940. * An event triggered before rendering the scene (right after animations and physics)
  33941. */
  33942. onBeforeRenderObservable: Observable<Scene>;
  33943. private _onBeforeRenderObserver;
  33944. /** Sets a function to be executed before rendering this scene */
  33945. beforeRender: Nullable<() => void>;
  33946. /**
  33947. * An event triggered after rendering the scene
  33948. */
  33949. onAfterRenderObservable: Observable<Scene>;
  33950. /**
  33951. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  33952. */
  33953. onAfterRenderCameraObservable: Observable<Camera>;
  33954. private _onAfterRenderObserver;
  33955. /** Sets a function to be executed after rendering this scene */
  33956. afterRender: Nullable<() => void>;
  33957. /**
  33958. * An event triggered before animating the scene
  33959. */
  33960. onBeforeAnimationsObservable: Observable<Scene>;
  33961. /**
  33962. * An event triggered after animations processing
  33963. */
  33964. onAfterAnimationsObservable: Observable<Scene>;
  33965. /**
  33966. * An event triggered before draw calls are ready to be sent
  33967. */
  33968. onBeforeDrawPhaseObservable: Observable<Scene>;
  33969. /**
  33970. * An event triggered after draw calls have been sent
  33971. */
  33972. onAfterDrawPhaseObservable: Observable<Scene>;
  33973. /**
  33974. * An event triggered when the scene is ready
  33975. */
  33976. onReadyObservable: Observable<Scene>;
  33977. /**
  33978. * An event triggered before rendering a camera
  33979. */
  33980. onBeforeCameraRenderObservable: Observable<Camera>;
  33981. private _onBeforeCameraRenderObserver;
  33982. /** Sets a function to be executed before rendering a camera*/
  33983. beforeCameraRender: () => void;
  33984. /**
  33985. * An event triggered after rendering a camera
  33986. */
  33987. onAfterCameraRenderObservable: Observable<Camera>;
  33988. private _onAfterCameraRenderObserver;
  33989. /** Sets a function to be executed after rendering a camera*/
  33990. afterCameraRender: () => void;
  33991. /**
  33992. * An event triggered when active meshes evaluation is about to start
  33993. */
  33994. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  33995. /**
  33996. * An event triggered when active meshes evaluation is done
  33997. */
  33998. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  33999. /**
  34000. * An event triggered when particles rendering is about to start
  34001. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34002. */
  34003. onBeforeParticlesRenderingObservable: Observable<Scene>;
  34004. /**
  34005. * An event triggered when particles rendering is done
  34006. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34007. */
  34008. onAfterParticlesRenderingObservable: Observable<Scene>;
  34009. /**
  34010. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  34011. */
  34012. onDataLoadedObservable: Observable<Scene>;
  34013. /**
  34014. * An event triggered when a camera is created
  34015. */
  34016. onNewCameraAddedObservable: Observable<Camera>;
  34017. /**
  34018. * An event triggered when a camera is removed
  34019. */
  34020. onCameraRemovedObservable: Observable<Camera>;
  34021. /**
  34022. * An event triggered when a light is created
  34023. */
  34024. onNewLightAddedObservable: Observable<Light>;
  34025. /**
  34026. * An event triggered when a light is removed
  34027. */
  34028. onLightRemovedObservable: Observable<Light>;
  34029. /**
  34030. * An event triggered when a geometry is created
  34031. */
  34032. onNewGeometryAddedObservable: Observable<Geometry>;
  34033. /**
  34034. * An event triggered when a geometry is removed
  34035. */
  34036. onGeometryRemovedObservable: Observable<Geometry>;
  34037. /**
  34038. * An event triggered when a transform node is created
  34039. */
  34040. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  34041. /**
  34042. * An event triggered when a transform node is removed
  34043. */
  34044. onTransformNodeRemovedObservable: Observable<TransformNode>;
  34045. /**
  34046. * An event triggered when a mesh is created
  34047. */
  34048. onNewMeshAddedObservable: Observable<AbstractMesh>;
  34049. /**
  34050. * An event triggered when a mesh is removed
  34051. */
  34052. onMeshRemovedObservable: Observable<AbstractMesh>;
  34053. /**
  34054. * An event triggered when a skeleton is created
  34055. */
  34056. onNewSkeletonAddedObservable: Observable<Skeleton>;
  34057. /**
  34058. * An event triggered when a skeleton is removed
  34059. */
  34060. onSkeletonRemovedObservable: Observable<Skeleton>;
  34061. /**
  34062. * An event triggered when a material is created
  34063. */
  34064. onNewMaterialAddedObservable: Observable<Material>;
  34065. /**
  34066. * An event triggered when a material is removed
  34067. */
  34068. onMaterialRemovedObservable: Observable<Material>;
  34069. /**
  34070. * An event triggered when a texture is created
  34071. */
  34072. onNewTextureAddedObservable: Observable<BaseTexture>;
  34073. /**
  34074. * An event triggered when a texture is removed
  34075. */
  34076. onTextureRemovedObservable: Observable<BaseTexture>;
  34077. /**
  34078. * An event triggered when render targets are about to be rendered
  34079. * Can happen multiple times per frame.
  34080. */
  34081. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  34082. /**
  34083. * An event triggered when render targets were rendered.
  34084. * Can happen multiple times per frame.
  34085. */
  34086. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  34087. /**
  34088. * An event triggered before calculating deterministic simulation step
  34089. */
  34090. onBeforeStepObservable: Observable<Scene>;
  34091. /**
  34092. * An event triggered after calculating deterministic simulation step
  34093. */
  34094. onAfterStepObservable: Observable<Scene>;
  34095. /**
  34096. * An event triggered when the activeCamera property is updated
  34097. */
  34098. onActiveCameraChanged: Observable<Scene>;
  34099. /**
  34100. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  34101. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34102. * If you wish to register an Observer only for a given set of renderingGroup, use the mask with a combination of the renderingGroup index elevated to the power of two (1 for renderingGroup 0, 2 for renderingrOup1, 4 for 2 and 8 for 3)
  34103. */
  34104. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34105. /**
  34106. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  34107. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34108. * If you wish to register an Observer only for a given set of renderingGroup, use the mask with a combination of the renderingGroup index elevated to the power of two (1 for renderingGroup 0, 2 for renderingrOup1, 4 for 2 and 8 for 3)
  34109. */
  34110. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34111. /**
  34112. * This Observable will when a mesh has been imported into the scene.
  34113. */
  34114. onMeshImportedObservable: Observable<AbstractMesh>;
  34115. /**
  34116. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  34117. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  34118. */
  34119. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  34120. /** @hidden */
  34121. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  34122. /**
  34123. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  34124. */
  34125. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  34126. /**
  34127. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  34128. */
  34129. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  34130. /**
  34131. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  34132. */
  34133. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  34134. /** Callback called when a pointer move is detected */
  34135. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34136. /** Callback called when a pointer down is detected */
  34137. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34138. /** Callback called when a pointer up is detected */
  34139. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  34140. /** Callback called when a pointer pick is detected */
  34141. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  34142. /**
  34143. * This observable event is triggered when any ponter event is triggered. It is registered during Scene.attachControl() and it is called BEFORE the 3D engine process anything (mesh/sprite picking for instance).
  34144. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  34145. */
  34146. onPrePointerObservable: Observable<PointerInfoPre>;
  34147. /**
  34148. * Observable event triggered each time an input event is received from the rendering canvas
  34149. */
  34150. onPointerObservable: Observable<PointerInfo>;
  34151. /**
  34152. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  34153. */
  34154. readonly unTranslatedPointer: Vector2;
  34155. /**
  34156. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  34157. */
  34158. static DragMovementThreshold: number;
  34159. /**
  34160. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  34161. */
  34162. static LongPressDelay: number;
  34163. /**
  34164. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  34165. */
  34166. static DoubleClickDelay: number;
  34167. /** If you need to check double click without raising a single click at first click, enable this flag */
  34168. static ExclusiveDoubleClickMode: boolean;
  34169. /** @hidden */
  34170. _mirroredCameraPosition: Nullable<Vector3>;
  34171. /**
  34172. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  34173. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  34174. */
  34175. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  34176. /**
  34177. * Observable event triggered each time an keyboard event is received from the hosting window
  34178. */
  34179. onKeyboardObservable: Observable<KeyboardInfo>;
  34180. private _useRightHandedSystem;
  34181. /**
  34182. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  34183. */
  34184. useRightHandedSystem: boolean;
  34185. private _timeAccumulator;
  34186. private _currentStepId;
  34187. private _currentInternalStep;
  34188. /**
  34189. * Sets the step Id used by deterministic lock step
  34190. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34191. * @param newStepId defines the step Id
  34192. */
  34193. setStepId(newStepId: number): void;
  34194. /**
  34195. * Gets the step Id used by deterministic lock step
  34196. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34197. * @returns the step Id
  34198. */
  34199. getStepId(): number;
  34200. /**
  34201. * Gets the internal step used by deterministic lock step
  34202. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34203. * @returns the internal step
  34204. */
  34205. getInternalStep(): number;
  34206. private _fogEnabled;
  34207. /**
  34208. * Gets or sets a boolean indicating if fog is enabled on this scene
  34209. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34210. * (Default is true)
  34211. */
  34212. fogEnabled: boolean;
  34213. private _fogMode;
  34214. /**
  34215. * Gets or sets the fog mode to use
  34216. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34217. * | mode | value |
  34218. * | --- | --- |
  34219. * | FOGMODE_NONE | 0 |
  34220. * | FOGMODE_EXP | 1 |
  34221. * | FOGMODE_EXP2 | 2 |
  34222. * | FOGMODE_LINEAR | 3 |
  34223. */
  34224. fogMode: number;
  34225. /**
  34226. * Gets or sets the fog color to use
  34227. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34228. * (Default is Color3(0.2, 0.2, 0.3))
  34229. */
  34230. fogColor: Color3;
  34231. /**
  34232. * Gets or sets the fog density to use
  34233. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34234. * (Default is 0.1)
  34235. */
  34236. fogDensity: number;
  34237. /**
  34238. * Gets or sets the fog start distance to use
  34239. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34240. * (Default is 0)
  34241. */
  34242. fogStart: number;
  34243. /**
  34244. * Gets or sets the fog end distance to use
  34245. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34246. * (Default is 1000)
  34247. */
  34248. fogEnd: number;
  34249. private _shadowsEnabled;
  34250. /**
  34251. * Gets or sets a boolean indicating if shadows are enabled on this scene
  34252. */
  34253. shadowsEnabled: boolean;
  34254. private _lightsEnabled;
  34255. /**
  34256. * Gets or sets a boolean indicating if lights are enabled on this scene
  34257. */
  34258. lightsEnabled: boolean;
  34259. /** All of the active cameras added to this scene. */
  34260. activeCameras: Camera[];
  34261. /** @hidden */
  34262. _activeCamera: Nullable<Camera>;
  34263. /** Gets or sets the current active camera */
  34264. activeCamera: Nullable<Camera>;
  34265. private _defaultMaterial;
  34266. /** The default material used on meshes when no material is affected */
  34267. /** The default material used on meshes when no material is affected */
  34268. defaultMaterial: Material;
  34269. private _texturesEnabled;
  34270. /**
  34271. * Gets or sets a boolean indicating if textures are enabled on this scene
  34272. */
  34273. texturesEnabled: boolean;
  34274. /**
  34275. * Gets or sets a boolean indicating if particles are enabled on this scene
  34276. */
  34277. particlesEnabled: boolean;
  34278. /**
  34279. * Gets or sets a boolean indicating if sprites are enabled on this scene
  34280. */
  34281. spritesEnabled: boolean;
  34282. private _skeletonsEnabled;
  34283. /**
  34284. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  34285. */
  34286. skeletonsEnabled: boolean;
  34287. /**
  34288. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  34289. */
  34290. lensFlaresEnabled: boolean;
  34291. /**
  34292. * Gets or sets a boolean indicating if collisions are enabled on this scene
  34293. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34294. */
  34295. collisionsEnabled: boolean;
  34296. private _collisionCoordinator;
  34297. /** @hidden */
  34298. readonly collisionCoordinator: ICollisionCoordinator;
  34299. /**
  34300. * Defines the gravity applied to this scene (used only for collisions)
  34301. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34302. */
  34303. gravity: Vector3;
  34304. /**
  34305. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  34306. */
  34307. postProcessesEnabled: boolean;
  34308. /**
  34309. * The list of postprocesses added to the scene
  34310. */
  34311. postProcesses: PostProcess[];
  34312. /**
  34313. * Gets the current postprocess manager
  34314. */
  34315. postProcessManager: PostProcessManager;
  34316. /**
  34317. * Gets or sets a boolean indicating if render targets are enabled on this scene
  34318. */
  34319. renderTargetsEnabled: boolean;
  34320. /**
  34321. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  34322. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  34323. */
  34324. dumpNextRenderTargets: boolean;
  34325. /**
  34326. * The list of user defined render targets added to the scene
  34327. */
  34328. customRenderTargets: RenderTargetTexture[];
  34329. /**
  34330. * Defines if texture loading must be delayed
  34331. * If true, textures will only be loaded when they need to be rendered
  34332. */
  34333. useDelayedTextureLoading: boolean;
  34334. /**
  34335. * Gets the list of meshes imported to the scene through SceneLoader
  34336. */
  34337. importedMeshesFiles: String[];
  34338. /**
  34339. * Gets or sets a boolean indicating if probes are enabled on this scene
  34340. */
  34341. probesEnabled: boolean;
  34342. /**
  34343. * Gets or sets the current offline provider to use to store scene data
  34344. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  34345. */
  34346. offlineProvider: IOfflineProvider;
  34347. /**
  34348. * Gets or sets the action manager associated with the scene
  34349. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34350. */
  34351. actionManager: AbstractActionManager;
  34352. private _meshesForIntersections;
  34353. /**
  34354. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  34355. */
  34356. proceduralTexturesEnabled: boolean;
  34357. private _engine;
  34358. private _totalVertices;
  34359. /** @hidden */
  34360. _activeIndices: PerfCounter;
  34361. /** @hidden */
  34362. _activeParticles: PerfCounter;
  34363. /** @hidden */
  34364. _activeBones: PerfCounter;
  34365. private _animationRatio;
  34366. /** @hidden */
  34367. _animationTimeLast: number;
  34368. /** @hidden */
  34369. _animationTime: number;
  34370. /**
  34371. * Gets or sets a general scale for animation speed
  34372. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  34373. */
  34374. animationTimeScale: number;
  34375. /** @hidden */
  34376. _cachedMaterial: Nullable<Material>;
  34377. /** @hidden */
  34378. _cachedEffect: Nullable<Effect>;
  34379. /** @hidden */
  34380. _cachedVisibility: Nullable<number>;
  34381. private _renderId;
  34382. private _frameId;
  34383. private _executeWhenReadyTimeoutId;
  34384. private _intermediateRendering;
  34385. private _viewUpdateFlag;
  34386. private _projectionUpdateFlag;
  34387. /** @hidden */
  34388. _toBeDisposed: Nullable<IDisposable>[];
  34389. private _activeRequests;
  34390. /** @hidden */
  34391. _pendingData: any[];
  34392. private _isDisposed;
  34393. /**
  34394. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  34395. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  34396. */
  34397. dispatchAllSubMeshesOfActiveMeshes: boolean;
  34398. private _activeMeshes;
  34399. private _processedMaterials;
  34400. private _renderTargets;
  34401. /** @hidden */
  34402. _activeParticleSystems: SmartArray<IParticleSystem>;
  34403. private _activeSkeletons;
  34404. private _softwareSkinnedMeshes;
  34405. private _renderingManager;
  34406. /** @hidden */
  34407. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  34408. private _transformMatrix;
  34409. private _sceneUbo;
  34410. /** @hidden */
  34411. _viewMatrix: Matrix;
  34412. private _projectionMatrix;
  34413. /** @hidden */
  34414. _forcedViewPosition: Nullable<Vector3>;
  34415. /** @hidden */
  34416. _frustumPlanes: Plane[];
  34417. /**
  34418. * Gets the list of frustum planes (built from the active camera)
  34419. */
  34420. readonly frustumPlanes: Plane[];
  34421. /**
  34422. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  34423. * This is useful if there are more lights that the maximum simulteanous authorized
  34424. */
  34425. requireLightSorting: boolean;
  34426. /** @hidden */
  34427. readonly useMaterialMeshMap: boolean;
  34428. /** @hidden */
  34429. readonly useClonedMeshhMap: boolean;
  34430. private _externalData;
  34431. private _uid;
  34432. /**
  34433. * @hidden
  34434. * Backing store of defined scene components.
  34435. */
  34436. _components: ISceneComponent[];
  34437. /**
  34438. * @hidden
  34439. * Backing store of defined scene components.
  34440. */
  34441. _serializableComponents: ISceneSerializableComponent[];
  34442. /**
  34443. * List of components to register on the next registration step.
  34444. */
  34445. private _transientComponents;
  34446. /**
  34447. * Registers the transient components if needed.
  34448. */
  34449. private _registerTransientComponents;
  34450. /**
  34451. * @hidden
  34452. * Add a component to the scene.
  34453. * Note that the ccomponent could be registered on th next frame if this is called after
  34454. * the register component stage.
  34455. * @param component Defines the component to add to the scene
  34456. */
  34457. _addComponent(component: ISceneComponent): void;
  34458. /**
  34459. * @hidden
  34460. * Gets a component from the scene.
  34461. * @param name defines the name of the component to retrieve
  34462. * @returns the component or null if not present
  34463. */
  34464. _getComponent(name: string): Nullable<ISceneComponent>;
  34465. /**
  34466. * @hidden
  34467. * Defines the actions happening before camera updates.
  34468. */
  34469. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  34470. /**
  34471. * @hidden
  34472. * Defines the actions happening before clear the canvas.
  34473. */
  34474. _beforeClearStage: Stage<SimpleStageAction>;
  34475. /**
  34476. * @hidden
  34477. * Defines the actions when collecting render targets for the frame.
  34478. */
  34479. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34480. /**
  34481. * @hidden
  34482. * Defines the actions happening for one camera in the frame.
  34483. */
  34484. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34485. /**
  34486. * @hidden
  34487. * Defines the actions happening during the per mesh ready checks.
  34488. */
  34489. _isReadyForMeshStage: Stage<MeshStageAction>;
  34490. /**
  34491. * @hidden
  34492. * Defines the actions happening before evaluate active mesh checks.
  34493. */
  34494. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  34495. /**
  34496. * @hidden
  34497. * Defines the actions happening during the evaluate sub mesh checks.
  34498. */
  34499. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  34500. /**
  34501. * @hidden
  34502. * Defines the actions happening during the active mesh stage.
  34503. */
  34504. _activeMeshStage: Stage<ActiveMeshStageAction>;
  34505. /**
  34506. * @hidden
  34507. * Defines the actions happening during the per camera render target step.
  34508. */
  34509. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  34510. /**
  34511. * @hidden
  34512. * Defines the actions happening just before the active camera is drawing.
  34513. */
  34514. _beforeCameraDrawStage: Stage<CameraStageAction>;
  34515. /**
  34516. * @hidden
  34517. * Defines the actions happening just before a render target is drawing.
  34518. */
  34519. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34520. /**
  34521. * @hidden
  34522. * Defines the actions happening just before a rendering group is drawing.
  34523. */
  34524. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34525. /**
  34526. * @hidden
  34527. * Defines the actions happening just before a mesh is drawing.
  34528. */
  34529. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34530. /**
  34531. * @hidden
  34532. * Defines the actions happening just after a mesh has been drawn.
  34533. */
  34534. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34535. /**
  34536. * @hidden
  34537. * Defines the actions happening just after a rendering group has been drawn.
  34538. */
  34539. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34540. /**
  34541. * @hidden
  34542. * Defines the actions happening just after the active camera has been drawn.
  34543. */
  34544. _afterCameraDrawStage: Stage<CameraStageAction>;
  34545. /**
  34546. * @hidden
  34547. * Defines the actions happening just after a render target has been drawn.
  34548. */
  34549. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34550. /**
  34551. * @hidden
  34552. * Defines the actions happening just after rendering all cameras and computing intersections.
  34553. */
  34554. _afterRenderStage: Stage<SimpleStageAction>;
  34555. /**
  34556. * @hidden
  34557. * Defines the actions happening when a pointer move event happens.
  34558. */
  34559. _pointerMoveStage: Stage<PointerMoveStageAction>;
  34560. /**
  34561. * @hidden
  34562. * Defines the actions happening when a pointer down event happens.
  34563. */
  34564. _pointerDownStage: Stage<PointerUpDownStageAction>;
  34565. /**
  34566. * @hidden
  34567. * Defines the actions happening when a pointer up event happens.
  34568. */
  34569. _pointerUpStage: Stage<PointerUpDownStageAction>;
  34570. /**
  34571. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  34572. */
  34573. private geometriesByUniqueId;
  34574. /**
  34575. * Creates a new Scene
  34576. * @param engine defines the engine to use to render this scene
  34577. * @param options defines the scene options
  34578. */
  34579. constructor(engine: Engine, options?: SceneOptions);
  34580. /**
  34581. * Gets a string idenfifying the name of the class
  34582. * @returns "Scene" string
  34583. */
  34584. getClassName(): string;
  34585. private _defaultMeshCandidates;
  34586. /**
  34587. * @hidden
  34588. */
  34589. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  34590. private _defaultSubMeshCandidates;
  34591. /**
  34592. * @hidden
  34593. */
  34594. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  34595. /**
  34596. * Sets the default candidate providers for the scene.
  34597. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  34598. * and getCollidingSubMeshCandidates to their default function
  34599. */
  34600. setDefaultCandidateProviders(): void;
  34601. /**
  34602. * Gets the mesh that is currently under the pointer
  34603. */
  34604. readonly meshUnderPointer: Nullable<AbstractMesh>;
  34605. /**
  34606. * Gets or sets the current on-screen X position of the pointer
  34607. */
  34608. pointerX: number;
  34609. /**
  34610. * Gets or sets the current on-screen Y position of the pointer
  34611. */
  34612. pointerY: number;
  34613. /**
  34614. * Gets the cached material (ie. the latest rendered one)
  34615. * @returns the cached material
  34616. */
  34617. getCachedMaterial(): Nullable<Material>;
  34618. /**
  34619. * Gets the cached effect (ie. the latest rendered one)
  34620. * @returns the cached effect
  34621. */
  34622. getCachedEffect(): Nullable<Effect>;
  34623. /**
  34624. * Gets the cached visibility state (ie. the latest rendered one)
  34625. * @returns the cached visibility state
  34626. */
  34627. getCachedVisibility(): Nullable<number>;
  34628. /**
  34629. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  34630. * @param material defines the current material
  34631. * @param effect defines the current effect
  34632. * @param visibility defines the current visibility state
  34633. * @returns true if one parameter is not cached
  34634. */
  34635. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  34636. /**
  34637. * Gets the engine associated with the scene
  34638. * @returns an Engine
  34639. */
  34640. getEngine(): Engine;
  34641. /**
  34642. * Gets the total number of vertices rendered per frame
  34643. * @returns the total number of vertices rendered per frame
  34644. */
  34645. getTotalVertices(): number;
  34646. /**
  34647. * Gets the performance counter for total vertices
  34648. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34649. */
  34650. readonly totalVerticesPerfCounter: PerfCounter;
  34651. /**
  34652. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  34653. * @returns the total number of active indices rendered per frame
  34654. */
  34655. getActiveIndices(): number;
  34656. /**
  34657. * Gets the performance counter for active indices
  34658. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34659. */
  34660. readonly totalActiveIndicesPerfCounter: PerfCounter;
  34661. /**
  34662. * Gets the total number of active particles rendered per frame
  34663. * @returns the total number of active particles rendered per frame
  34664. */
  34665. getActiveParticles(): number;
  34666. /**
  34667. * Gets the performance counter for active particles
  34668. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34669. */
  34670. readonly activeParticlesPerfCounter: PerfCounter;
  34671. /**
  34672. * Gets the total number of active bones rendered per frame
  34673. * @returns the total number of active bones rendered per frame
  34674. */
  34675. getActiveBones(): number;
  34676. /**
  34677. * Gets the performance counter for active bones
  34678. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34679. */
  34680. readonly activeBonesPerfCounter: PerfCounter;
  34681. /**
  34682. * Gets the array of active meshes
  34683. * @returns an array of AbstractMesh
  34684. */
  34685. getActiveMeshes(): SmartArray<AbstractMesh>;
  34686. /**
  34687. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  34688. * @returns a number
  34689. */
  34690. getAnimationRatio(): number;
  34691. /**
  34692. * Gets an unique Id for the current render phase
  34693. * @returns a number
  34694. */
  34695. getRenderId(): number;
  34696. /**
  34697. * Gets an unique Id for the current frame
  34698. * @returns a number
  34699. */
  34700. getFrameId(): number;
  34701. /** Call this function if you want to manually increment the render Id*/
  34702. incrementRenderId(): void;
  34703. private _createUbo;
  34704. /**
  34705. * Use this method to simulate a pointer move on a mesh
  34706. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34707. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34708. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34709. * @returns the current scene
  34710. */
  34711. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34712. /**
  34713. * Use this method to simulate a pointer down on a mesh
  34714. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34715. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34716. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34717. * @returns the current scene
  34718. */
  34719. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34720. /**
  34721. * Use this method to simulate a pointer up on a mesh
  34722. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34723. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34724. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34725. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34726. * @returns the current scene
  34727. */
  34728. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  34729. /**
  34730. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34731. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34732. * @returns true if the pointer was captured
  34733. */
  34734. isPointerCaptured(pointerId?: number): boolean;
  34735. /**
  34736. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34737. * @param attachUp defines if you want to attach events to pointerup
  34738. * @param attachDown defines if you want to attach events to pointerdown
  34739. * @param attachMove defines if you want to attach events to pointermove
  34740. */
  34741. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34742. /** Detaches all event handlers*/
  34743. detachControl(): void;
  34744. /**
  34745. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  34746. * Delay loaded resources are not taking in account
  34747. * @return true if all required resources are ready
  34748. */
  34749. isReady(): boolean;
  34750. /** Resets all cached information relative to material (including effect and visibility) */
  34751. resetCachedMaterial(): void;
  34752. /**
  34753. * Registers a function to be called before every frame render
  34754. * @param func defines the function to register
  34755. */
  34756. registerBeforeRender(func: () => void): void;
  34757. /**
  34758. * Unregisters a function called before every frame render
  34759. * @param func defines the function to unregister
  34760. */
  34761. unregisterBeforeRender(func: () => void): void;
  34762. /**
  34763. * Registers a function to be called after every frame render
  34764. * @param func defines the function to register
  34765. */
  34766. registerAfterRender(func: () => void): void;
  34767. /**
  34768. * Unregisters a function called after every frame render
  34769. * @param func defines the function to unregister
  34770. */
  34771. unregisterAfterRender(func: () => void): void;
  34772. private _executeOnceBeforeRender;
  34773. /**
  34774. * The provided function will run before render once and will be disposed afterwards.
  34775. * A timeout delay can be provided so that the function will be executed in N ms.
  34776. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  34777. * @param func The function to be executed.
  34778. * @param timeout optional delay in ms
  34779. */
  34780. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  34781. /** @hidden */
  34782. _addPendingData(data: any): void;
  34783. /** @hidden */
  34784. _removePendingData(data: any): void;
  34785. /**
  34786. * Returns the number of items waiting to be loaded
  34787. * @returns the number of items waiting to be loaded
  34788. */
  34789. getWaitingItemsCount(): number;
  34790. /**
  34791. * Returns a boolean indicating if the scene is still loading data
  34792. */
  34793. readonly isLoading: boolean;
  34794. /**
  34795. * Registers a function to be executed when the scene is ready
  34796. * @param {Function} func - the function to be executed
  34797. */
  34798. executeWhenReady(func: () => void): void;
  34799. /**
  34800. * Returns a promise that resolves when the scene is ready
  34801. * @returns A promise that resolves when the scene is ready
  34802. */
  34803. whenReadyAsync(): Promise<void>;
  34804. /** @hidden */
  34805. _checkIsReady(): void;
  34806. /**
  34807. * Gets all animatable attached to the scene
  34808. */
  34809. readonly animatables: Animatable[];
  34810. /**
  34811. * Resets the last animation time frame.
  34812. * Useful to override when animations start running when loading a scene for the first time.
  34813. */
  34814. resetLastAnimationTimeFrame(): void;
  34815. /**
  34816. * Gets the current view matrix
  34817. * @returns a Matrix
  34818. */
  34819. getViewMatrix(): Matrix;
  34820. /**
  34821. * Gets the current projection matrix
  34822. * @returns a Matrix
  34823. */
  34824. getProjectionMatrix(): Matrix;
  34825. /**
  34826. * Gets the current transform matrix
  34827. * @returns a Matrix made of View * Projection
  34828. */
  34829. getTransformMatrix(): Matrix;
  34830. /**
  34831. * Sets the current transform matrix
  34832. * @param viewL defines the View matrix to use
  34833. * @param projectionL defines the Projection matrix to use
  34834. * @param viewR defines the right View matrix to use (if provided)
  34835. * @param projectionR defines the right Projection matrix to use (if provided)
  34836. */
  34837. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  34838. /**
  34839. * Gets the uniform buffer used to store scene data
  34840. * @returns a UniformBuffer
  34841. */
  34842. getSceneUniformBuffer(): UniformBuffer;
  34843. /**
  34844. * Gets an unique (relatively to the current scene) Id
  34845. * @returns an unique number for the scene
  34846. */
  34847. getUniqueId(): number;
  34848. /**
  34849. * Add a mesh to the list of scene's meshes
  34850. * @param newMesh defines the mesh to add
  34851. * @param recursive if all child meshes should also be added to the scene
  34852. */
  34853. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  34854. /**
  34855. * Remove a mesh for the list of scene's meshes
  34856. * @param toRemove defines the mesh to remove
  34857. * @param recursive if all child meshes should also be removed from the scene
  34858. * @returns the index where the mesh was in the mesh list
  34859. */
  34860. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  34861. /**
  34862. * Add a transform node to the list of scene's transform nodes
  34863. * @param newTransformNode defines the transform node to add
  34864. */
  34865. addTransformNode(newTransformNode: TransformNode): void;
  34866. /**
  34867. * Remove a transform node for the list of scene's transform nodes
  34868. * @param toRemove defines the transform node to remove
  34869. * @returns the index where the transform node was in the transform node list
  34870. */
  34871. removeTransformNode(toRemove: TransformNode): number;
  34872. /**
  34873. * Remove a skeleton for the list of scene's skeletons
  34874. * @param toRemove defines the skeleton to remove
  34875. * @returns the index where the skeleton was in the skeleton list
  34876. */
  34877. removeSkeleton(toRemove: Skeleton): number;
  34878. /**
  34879. * Remove a morph target for the list of scene's morph targets
  34880. * @param toRemove defines the morph target to remove
  34881. * @returns the index where the morph target was in the morph target list
  34882. */
  34883. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  34884. /**
  34885. * Remove a light for the list of scene's lights
  34886. * @param toRemove defines the light to remove
  34887. * @returns the index where the light was in the light list
  34888. */
  34889. removeLight(toRemove: Light): number;
  34890. /**
  34891. * Remove a camera for the list of scene's cameras
  34892. * @param toRemove defines the camera to remove
  34893. * @returns the index where the camera was in the camera list
  34894. */
  34895. removeCamera(toRemove: Camera): number;
  34896. /**
  34897. * Remove a particle system for the list of scene's particle systems
  34898. * @param toRemove defines the particle system to remove
  34899. * @returns the index where the particle system was in the particle system list
  34900. */
  34901. removeParticleSystem(toRemove: IParticleSystem): number;
  34902. /**
  34903. * Remove a animation for the list of scene's animations
  34904. * @param toRemove defines the animation to remove
  34905. * @returns the index where the animation was in the animation list
  34906. */
  34907. removeAnimation(toRemove: Animation): number;
  34908. /**
  34909. * Will stop the animation of the given target
  34910. * @param target - the target
  34911. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  34912. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  34913. */
  34914. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  34915. /**
  34916. * Removes the given animation group from this scene.
  34917. * @param toRemove The animation group to remove
  34918. * @returns The index of the removed animation group
  34919. */
  34920. removeAnimationGroup(toRemove: AnimationGroup): number;
  34921. /**
  34922. * Removes the given multi-material from this scene.
  34923. * @param toRemove The multi-material to remove
  34924. * @returns The index of the removed multi-material
  34925. */
  34926. removeMultiMaterial(toRemove: MultiMaterial): number;
  34927. /**
  34928. * Removes the given material from this scene.
  34929. * @param toRemove The material to remove
  34930. * @returns The index of the removed material
  34931. */
  34932. removeMaterial(toRemove: Material): number;
  34933. /**
  34934. * Removes the given action manager from this scene.
  34935. * @param toRemove The action manager to remove
  34936. * @returns The index of the removed action manager
  34937. */
  34938. removeActionManager(toRemove: AbstractActionManager): number;
  34939. /**
  34940. * Removes the given texture from this scene.
  34941. * @param toRemove The texture to remove
  34942. * @returns The index of the removed texture
  34943. */
  34944. removeTexture(toRemove: BaseTexture): number;
  34945. /**
  34946. * Adds the given light to this scene
  34947. * @param newLight The light to add
  34948. */
  34949. addLight(newLight: Light): void;
  34950. /**
  34951. * Sorts the list list based on light priorities
  34952. */
  34953. sortLightsByPriority(): void;
  34954. /**
  34955. * Adds the given camera to this scene
  34956. * @param newCamera The camera to add
  34957. */
  34958. addCamera(newCamera: Camera): void;
  34959. /**
  34960. * Adds the given skeleton to this scene
  34961. * @param newSkeleton The skeleton to add
  34962. */
  34963. addSkeleton(newSkeleton: Skeleton): void;
  34964. /**
  34965. * Adds the given particle system to this scene
  34966. * @param newParticleSystem The particle system to add
  34967. */
  34968. addParticleSystem(newParticleSystem: IParticleSystem): void;
  34969. /**
  34970. * Adds the given animation to this scene
  34971. * @param newAnimation The animation to add
  34972. */
  34973. addAnimation(newAnimation: Animation): void;
  34974. /**
  34975. * Adds the given animation group to this scene.
  34976. * @param newAnimationGroup The animation group to add
  34977. */
  34978. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  34979. /**
  34980. * Adds the given multi-material to this scene
  34981. * @param newMultiMaterial The multi-material to add
  34982. */
  34983. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  34984. /**
  34985. * Adds the given material to this scene
  34986. * @param newMaterial The material to add
  34987. */
  34988. addMaterial(newMaterial: Material): void;
  34989. /**
  34990. * Adds the given morph target to this scene
  34991. * @param newMorphTargetManager The morph target to add
  34992. */
  34993. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  34994. /**
  34995. * Adds the given geometry to this scene
  34996. * @param newGeometry The geometry to add
  34997. */
  34998. addGeometry(newGeometry: Geometry): void;
  34999. /**
  35000. * Adds the given action manager to this scene
  35001. * @param newActionManager The action manager to add
  35002. */
  35003. addActionManager(newActionManager: AbstractActionManager): void;
  35004. /**
  35005. * Adds the given texture to this scene.
  35006. * @param newTexture The texture to add
  35007. */
  35008. addTexture(newTexture: BaseTexture): void;
  35009. /**
  35010. * Switch active camera
  35011. * @param newCamera defines the new active camera
  35012. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  35013. */
  35014. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  35015. /**
  35016. * sets the active camera of the scene using its ID
  35017. * @param id defines the camera's ID
  35018. * @return the new active camera or null if none found.
  35019. */
  35020. setActiveCameraByID(id: string): Nullable<Camera>;
  35021. /**
  35022. * sets the active camera of the scene using its name
  35023. * @param name defines the camera's name
  35024. * @returns the new active camera or null if none found.
  35025. */
  35026. setActiveCameraByName(name: string): Nullable<Camera>;
  35027. /**
  35028. * get an animation group using its name
  35029. * @param name defines the material's name
  35030. * @return the animation group or null if none found.
  35031. */
  35032. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  35033. /**
  35034. * Get a material using its unique id
  35035. * @param uniqueId defines the material's unique id
  35036. * @return the material or null if none found.
  35037. */
  35038. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  35039. /**
  35040. * get a material using its id
  35041. * @param id defines the material's ID
  35042. * @return the material or null if none found.
  35043. */
  35044. getMaterialByID(id: string): Nullable<Material>;
  35045. /**
  35046. * Gets a the last added material using a given id
  35047. * @param id defines the material's ID
  35048. * @return the last material with the given id or null if none found.
  35049. */
  35050. getLastMaterialByID(id: string): Nullable<Material>;
  35051. /**
  35052. * Gets a material using its name
  35053. * @param name defines the material's name
  35054. * @return the material or null if none found.
  35055. */
  35056. getMaterialByName(name: string): Nullable<Material>;
  35057. /**
  35058. * Get a texture using its unique id
  35059. * @param uniqueId defines the texture's unique id
  35060. * @return the texture or null if none found.
  35061. */
  35062. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  35063. /**
  35064. * Gets a camera using its id
  35065. * @param id defines the id to look for
  35066. * @returns the camera or null if not found
  35067. */
  35068. getCameraByID(id: string): Nullable<Camera>;
  35069. /**
  35070. * Gets a camera using its unique id
  35071. * @param uniqueId defines the unique id to look for
  35072. * @returns the camera or null if not found
  35073. */
  35074. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  35075. /**
  35076. * Gets a camera using its name
  35077. * @param name defines the camera's name
  35078. * @return the camera or null if none found.
  35079. */
  35080. getCameraByName(name: string): Nullable<Camera>;
  35081. /**
  35082. * Gets a bone using its id
  35083. * @param id defines the bone's id
  35084. * @return the bone or null if not found
  35085. */
  35086. getBoneByID(id: string): Nullable<Bone>;
  35087. /**
  35088. * Gets a bone using its id
  35089. * @param name defines the bone's name
  35090. * @return the bone or null if not found
  35091. */
  35092. getBoneByName(name: string): Nullable<Bone>;
  35093. /**
  35094. * Gets a light node using its name
  35095. * @param name defines the the light's name
  35096. * @return the light or null if none found.
  35097. */
  35098. getLightByName(name: string): Nullable<Light>;
  35099. /**
  35100. * Gets a light node using its id
  35101. * @param id defines the light's id
  35102. * @return the light or null if none found.
  35103. */
  35104. getLightByID(id: string): Nullable<Light>;
  35105. /**
  35106. * Gets a light node using its scene-generated unique ID
  35107. * @param uniqueId defines the light's unique id
  35108. * @return the light or null if none found.
  35109. */
  35110. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  35111. /**
  35112. * Gets a particle system by id
  35113. * @param id defines the particle system id
  35114. * @return the corresponding system or null if none found
  35115. */
  35116. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  35117. /**
  35118. * Gets a geometry using its ID
  35119. * @param id defines the geometry's id
  35120. * @return the geometry or null if none found.
  35121. */
  35122. getGeometryByID(id: string): Nullable<Geometry>;
  35123. private _getGeometryByUniqueID;
  35124. /**
  35125. * Add a new geometry to this scene
  35126. * @param geometry defines the geometry to be added to the scene.
  35127. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  35128. * @return a boolean defining if the geometry was added or not
  35129. */
  35130. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  35131. /**
  35132. * Removes an existing geometry
  35133. * @param geometry defines the geometry to be removed from the scene
  35134. * @return a boolean defining if the geometry was removed or not
  35135. */
  35136. removeGeometry(geometry: Geometry): boolean;
  35137. /**
  35138. * Gets the list of geometries attached to the scene
  35139. * @returns an array of Geometry
  35140. */
  35141. getGeometries(): Geometry[];
  35142. /**
  35143. * Gets the first added mesh found of a given ID
  35144. * @param id defines the id to search for
  35145. * @return the mesh found or null if not found at all
  35146. */
  35147. getMeshByID(id: string): Nullable<AbstractMesh>;
  35148. /**
  35149. * Gets a list of meshes using their id
  35150. * @param id defines the id to search for
  35151. * @returns a list of meshes
  35152. */
  35153. getMeshesByID(id: string): Array<AbstractMesh>;
  35154. /**
  35155. * Gets the first added transform node found of a given ID
  35156. * @param id defines the id to search for
  35157. * @return the found transform node or null if not found at all.
  35158. */
  35159. getTransformNodeByID(id: string): Nullable<TransformNode>;
  35160. /**
  35161. * Gets a transform node with its auto-generated unique id
  35162. * @param uniqueId efines the unique id to search for
  35163. * @return the found transform node or null if not found at all.
  35164. */
  35165. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  35166. /**
  35167. * Gets a list of transform nodes using their id
  35168. * @param id defines the id to search for
  35169. * @returns a list of transform nodes
  35170. */
  35171. getTransformNodesByID(id: string): Array<TransformNode>;
  35172. /**
  35173. * Gets a mesh with its auto-generated unique id
  35174. * @param uniqueId defines the unique id to search for
  35175. * @return the found mesh or null if not found at all.
  35176. */
  35177. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  35178. /**
  35179. * Gets a the last added mesh using a given id
  35180. * @param id defines the id to search for
  35181. * @return the found mesh or null if not found at all.
  35182. */
  35183. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  35184. /**
  35185. * Gets a the last added node (Mesh, Camera, Light) using a given id
  35186. * @param id defines the id to search for
  35187. * @return the found node or null if not found at all
  35188. */
  35189. getLastEntryByID(id: string): Nullable<Node>;
  35190. /**
  35191. * Gets a node (Mesh, Camera, Light) using a given id
  35192. * @param id defines the id to search for
  35193. * @return the found node or null if not found at all
  35194. */
  35195. getNodeByID(id: string): Nullable<Node>;
  35196. /**
  35197. * Gets a node (Mesh, Camera, Light) using a given name
  35198. * @param name defines the name to search for
  35199. * @return the found node or null if not found at all.
  35200. */
  35201. getNodeByName(name: string): Nullable<Node>;
  35202. /**
  35203. * Gets a mesh using a given name
  35204. * @param name defines the name to search for
  35205. * @return the found mesh or null if not found at all.
  35206. */
  35207. getMeshByName(name: string): Nullable<AbstractMesh>;
  35208. /**
  35209. * Gets a transform node using a given name
  35210. * @param name defines the name to search for
  35211. * @return the found transform node or null if not found at all.
  35212. */
  35213. getTransformNodeByName(name: string): Nullable<TransformNode>;
  35214. /**
  35215. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  35216. * @param id defines the id to search for
  35217. * @return the found skeleton or null if not found at all.
  35218. */
  35219. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  35220. /**
  35221. * Gets a skeleton using a given auto generated unique id
  35222. * @param uniqueId defines the unique id to search for
  35223. * @return the found skeleton or null if not found at all.
  35224. */
  35225. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  35226. /**
  35227. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  35228. * @param id defines the id to search for
  35229. * @return the found skeleton or null if not found at all.
  35230. */
  35231. getSkeletonById(id: string): Nullable<Skeleton>;
  35232. /**
  35233. * Gets a skeleton using a given name
  35234. * @param name defines the name to search for
  35235. * @return the found skeleton or null if not found at all.
  35236. */
  35237. getSkeletonByName(name: string): Nullable<Skeleton>;
  35238. /**
  35239. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  35240. * @param id defines the id to search for
  35241. * @return the found morph target manager or null if not found at all.
  35242. */
  35243. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  35244. /**
  35245. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  35246. * @param id defines the id to search for
  35247. * @return the found morph target or null if not found at all.
  35248. */
  35249. getMorphTargetById(id: string): Nullable<MorphTarget>;
  35250. /**
  35251. * Gets a boolean indicating if the given mesh is active
  35252. * @param mesh defines the mesh to look for
  35253. * @returns true if the mesh is in the active list
  35254. */
  35255. isActiveMesh(mesh: AbstractMesh): boolean;
  35256. /**
  35257. * Return a unique id as a string which can serve as an identifier for the scene
  35258. */
  35259. readonly uid: string;
  35260. /**
  35261. * Add an externaly attached data from its key.
  35262. * This method call will fail and return false, if such key already exists.
  35263. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  35264. * @param key the unique key that identifies the data
  35265. * @param data the data object to associate to the key for this Engine instance
  35266. * @return true if no such key were already present and the data was added successfully, false otherwise
  35267. */
  35268. addExternalData<T>(key: string, data: T): boolean;
  35269. /**
  35270. * Get an externaly attached data from its key
  35271. * @param key the unique key that identifies the data
  35272. * @return the associated data, if present (can be null), or undefined if not present
  35273. */
  35274. getExternalData<T>(key: string): Nullable<T>;
  35275. /**
  35276. * Get an externaly attached data from its key, create it using a factory if it's not already present
  35277. * @param key the unique key that identifies the data
  35278. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  35279. * @return the associated data, can be null if the factory returned null.
  35280. */
  35281. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  35282. /**
  35283. * Remove an externaly attached data from the Engine instance
  35284. * @param key the unique key that identifies the data
  35285. * @return true if the data was successfully removed, false if it doesn't exist
  35286. */
  35287. removeExternalData(key: string): boolean;
  35288. private _evaluateSubMesh;
  35289. /**
  35290. * Clear the processed materials smart array preventing retention point in material dispose.
  35291. */
  35292. freeProcessedMaterials(): void;
  35293. private _preventFreeActiveMeshesAndRenderingGroups;
  35294. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  35295. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  35296. * when disposing several meshes in a row or a hierarchy of meshes.
  35297. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  35298. */
  35299. blockfreeActiveMeshesAndRenderingGroups: boolean;
  35300. /**
  35301. * Clear the active meshes smart array preventing retention point in mesh dispose.
  35302. */
  35303. freeActiveMeshes(): void;
  35304. /**
  35305. * Clear the info related to rendering groups preventing retention points during dispose.
  35306. */
  35307. freeRenderingGroups(): void;
  35308. /** @hidden */
  35309. _isInIntermediateRendering(): boolean;
  35310. /**
  35311. * Lambda returning the list of potentially active meshes.
  35312. */
  35313. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  35314. /**
  35315. * Lambda returning the list of potentially active sub meshes.
  35316. */
  35317. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  35318. /**
  35319. * Lambda returning the list of potentially intersecting sub meshes.
  35320. */
  35321. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  35322. /**
  35323. * Lambda returning the list of potentially colliding sub meshes.
  35324. */
  35325. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  35326. private _activeMeshesFrozen;
  35327. /**
  35328. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  35329. * @returns the current scene
  35330. */
  35331. freezeActiveMeshes(): Scene;
  35332. /**
  35333. * Use this function to restart evaluating active meshes on every frame
  35334. * @returns the current scene
  35335. */
  35336. unfreezeActiveMeshes(): Scene;
  35337. private _evaluateActiveMeshes;
  35338. private _activeMesh;
  35339. /**
  35340. * Update the transform matrix to update from the current active camera
  35341. * @param force defines a boolean used to force the update even if cache is up to date
  35342. */
  35343. updateTransformMatrix(force?: boolean): void;
  35344. private _bindFrameBuffer;
  35345. /** @hidden */
  35346. _allowPostProcessClearColor: boolean;
  35347. /** @hidden */
  35348. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  35349. private _processSubCameras;
  35350. private _checkIntersections;
  35351. /** @hidden */
  35352. _advancePhysicsEngineStep(step: number): void;
  35353. /**
  35354. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  35355. */
  35356. getDeterministicFrameTime: () => number;
  35357. /** @hidden */
  35358. _animate(): void;
  35359. /** Execute all animations (for a frame) */
  35360. animate(): void;
  35361. /**
  35362. * Render the scene
  35363. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  35364. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  35365. */
  35366. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  35367. /**
  35368. * Freeze all materials
  35369. * A frozen material will not be updatable but should be faster to render
  35370. */
  35371. freezeMaterials(): void;
  35372. /**
  35373. * Unfreeze all materials
  35374. * A frozen material will not be updatable but should be faster to render
  35375. */
  35376. unfreezeMaterials(): void;
  35377. /**
  35378. * Releases all held ressources
  35379. */
  35380. dispose(): void;
  35381. /**
  35382. * Gets if the scene is already disposed
  35383. */
  35384. readonly isDisposed: boolean;
  35385. /**
  35386. * Call this function to reduce memory footprint of the scene.
  35387. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  35388. */
  35389. clearCachedVertexData(): void;
  35390. /**
  35391. * This function will remove the local cached buffer data from texture.
  35392. * It will save memory but will prevent the texture from being rebuilt
  35393. */
  35394. cleanCachedTextureBuffer(): void;
  35395. /**
  35396. * Get the world extend vectors with an optional filter
  35397. *
  35398. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  35399. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  35400. */
  35401. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  35402. min: Vector3;
  35403. max: Vector3;
  35404. };
  35405. /**
  35406. * Creates a ray that can be used to pick in the scene
  35407. * @param x defines the x coordinate of the origin (on-screen)
  35408. * @param y defines the y coordinate of the origin (on-screen)
  35409. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35410. * @param camera defines the camera to use for the picking
  35411. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35412. * @returns a Ray
  35413. */
  35414. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  35415. /**
  35416. * Creates a ray that can be used to pick in the scene
  35417. * @param x defines the x coordinate of the origin (on-screen)
  35418. * @param y defines the y coordinate of the origin (on-screen)
  35419. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35420. * @param result defines the ray where to store the picking ray
  35421. * @param camera defines the camera to use for the picking
  35422. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35423. * @returns the current scene
  35424. */
  35425. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  35426. /**
  35427. * Creates a ray that can be used to pick in the scene
  35428. * @param x defines the x coordinate of the origin (on-screen)
  35429. * @param y defines the y coordinate of the origin (on-screen)
  35430. * @param camera defines the camera to use for the picking
  35431. * @returns a Ray
  35432. */
  35433. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  35434. /**
  35435. * Creates a ray that can be used to pick in the scene
  35436. * @param x defines the x coordinate of the origin (on-screen)
  35437. * @param y defines the y coordinate of the origin (on-screen)
  35438. * @param result defines the ray where to store the picking ray
  35439. * @param camera defines the camera to use for the picking
  35440. * @returns the current scene
  35441. */
  35442. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  35443. /** Launch a ray to try to pick a mesh in the scene
  35444. * @param x position on screen
  35445. * @param y position on screen
  35446. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  35447. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  35448. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35449. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35450. * @returns a PickingInfo
  35451. */
  35452. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35453. /** Use the given ray to pick a mesh in the scene
  35454. * @param ray The ray to use to pick meshes
  35455. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must have isPickable set to true
  35456. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  35457. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35458. * @returns a PickingInfo
  35459. */
  35460. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35461. /**
  35462. * Launch a ray to try to pick a mesh in the scene
  35463. * @param x X position on screen
  35464. * @param y Y position on screen
  35465. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  35466. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35467. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35468. * @returns an array of PickingInfo
  35469. */
  35470. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35471. /**
  35472. * Launch a ray to try to pick a mesh in the scene
  35473. * @param ray Ray to use
  35474. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  35475. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35476. * @returns an array of PickingInfo
  35477. */
  35478. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35479. /**
  35480. * Force the value of meshUnderPointer
  35481. * @param mesh defines the mesh to use
  35482. */
  35483. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35484. /**
  35485. * Gets the mesh under the pointer
  35486. * @returns a Mesh or null if no mesh is under the pointer
  35487. */
  35488. getPointerOverMesh(): Nullable<AbstractMesh>;
  35489. /** @hidden */
  35490. _rebuildGeometries(): void;
  35491. /** @hidden */
  35492. _rebuildTextures(): void;
  35493. private _getByTags;
  35494. /**
  35495. * Get a list of meshes by tags
  35496. * @param tagsQuery defines the tags query to use
  35497. * @param forEach defines a predicate used to filter results
  35498. * @returns an array of Mesh
  35499. */
  35500. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  35501. /**
  35502. * Get a list of cameras by tags
  35503. * @param tagsQuery defines the tags query to use
  35504. * @param forEach defines a predicate used to filter results
  35505. * @returns an array of Camera
  35506. */
  35507. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  35508. /**
  35509. * Get a list of lights by tags
  35510. * @param tagsQuery defines the tags query to use
  35511. * @param forEach defines a predicate used to filter results
  35512. * @returns an array of Light
  35513. */
  35514. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  35515. /**
  35516. * Get a list of materials by tags
  35517. * @param tagsQuery defines the tags query to use
  35518. * @param forEach defines a predicate used to filter results
  35519. * @returns an array of Material
  35520. */
  35521. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  35522. /**
  35523. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  35524. * This allowed control for front to back rendering or reversly depending of the special needs.
  35525. *
  35526. * @param renderingGroupId The rendering group id corresponding to its index
  35527. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  35528. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  35529. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  35530. */
  35531. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  35532. /**
  35533. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  35534. *
  35535. * @param renderingGroupId The rendering group id corresponding to its index
  35536. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  35537. * @param depth Automatically clears depth between groups if true and autoClear is true.
  35538. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  35539. */
  35540. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  35541. /**
  35542. * Gets the current auto clear configuration for one rendering group of the rendering
  35543. * manager.
  35544. * @param index the rendering group index to get the information for
  35545. * @returns The auto clear setup for the requested rendering group
  35546. */
  35547. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  35548. private _blockMaterialDirtyMechanism;
  35549. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  35550. blockMaterialDirtyMechanism: boolean;
  35551. /**
  35552. * Will flag all materials as dirty to trigger new shader compilation
  35553. * @param flag defines the flag used to specify which material part must be marked as dirty
  35554. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  35555. */
  35556. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  35557. /** @hidden */
  35558. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  35559. /** @hidden */
  35560. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35561. }
  35562. }
  35563. declare module "babylonjs/assetContainer" {
  35564. import { AbstractScene } from "babylonjs/abstractScene";
  35565. import { Scene } from "babylonjs/scene";
  35566. import { Mesh } from "babylonjs/Meshes/mesh";
  35567. /**
  35568. * Set of assets to keep when moving a scene into an asset container.
  35569. */
  35570. export class KeepAssets extends AbstractScene {
  35571. }
  35572. /**
  35573. * Container with a set of assets that can be added or removed from a scene.
  35574. */
  35575. export class AssetContainer extends AbstractScene {
  35576. /**
  35577. * The scene the AssetContainer belongs to.
  35578. */
  35579. scene: Scene;
  35580. /**
  35581. * Instantiates an AssetContainer.
  35582. * @param scene The scene the AssetContainer belongs to.
  35583. */
  35584. constructor(scene: Scene);
  35585. /**
  35586. * Adds all the assets from the container to the scene.
  35587. */
  35588. addAllToScene(): void;
  35589. /**
  35590. * Removes all the assets in the container from the scene
  35591. */
  35592. removeAllFromScene(): void;
  35593. /**
  35594. * Disposes all the assets in the container
  35595. */
  35596. dispose(): void;
  35597. private _moveAssets;
  35598. /**
  35599. * Removes all the assets contained in the scene and adds them to the container.
  35600. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  35601. */
  35602. moveAllFromScene(keepAssets?: KeepAssets): void;
  35603. /**
  35604. * Adds all meshes in the asset container to a root mesh that can be used to position all the contained meshes. The root mesh is then added to the front of the meshes in the assetContainer.
  35605. * @returns the root mesh
  35606. */
  35607. createRootMesh(): Mesh;
  35608. }
  35609. }
  35610. declare module "babylonjs/abstractScene" {
  35611. import { Scene } from "babylonjs/scene";
  35612. import { Nullable } from "babylonjs/types";
  35613. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35614. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35615. import { Geometry } from "babylonjs/Meshes/geometry";
  35616. import { Skeleton } from "babylonjs/Bones/skeleton";
  35617. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35618. import { AssetContainer } from "babylonjs/assetContainer";
  35619. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35620. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35621. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35622. import { Material } from "babylonjs/Materials/material";
  35623. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35624. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35625. import { Camera } from "babylonjs/Cameras/camera";
  35626. import { Light } from "babylonjs/Lights/light";
  35627. import { Node } from "babylonjs/node";
  35628. import { Animation } from "babylonjs/Animations/animation";
  35629. /**
  35630. * Defines how the parser contract is defined.
  35631. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  35632. */
  35633. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  35634. /**
  35635. * Defines how the individual parser contract is defined.
  35636. * These parser can parse an individual asset
  35637. */
  35638. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  35639. /**
  35640. * Base class of the scene acting as a container for the different elements composing a scene.
  35641. * This class is dynamically extended by the different components of the scene increasing
  35642. * flexibility and reducing coupling
  35643. */
  35644. export abstract class AbstractScene {
  35645. /**
  35646. * Stores the list of available parsers in the application.
  35647. */
  35648. private static _BabylonFileParsers;
  35649. /**
  35650. * Stores the list of available individual parsers in the application.
  35651. */
  35652. private static _IndividualBabylonFileParsers;
  35653. /**
  35654. * Adds a parser in the list of available ones
  35655. * @param name Defines the name of the parser
  35656. * @param parser Defines the parser to add
  35657. */
  35658. static AddParser(name: string, parser: BabylonFileParser): void;
  35659. /**
  35660. * Gets a general parser from the list of avaialble ones
  35661. * @param name Defines the name of the parser
  35662. * @returns the requested parser or null
  35663. */
  35664. static GetParser(name: string): Nullable<BabylonFileParser>;
  35665. /**
  35666. * Adds n individual parser in the list of available ones
  35667. * @param name Defines the name of the parser
  35668. * @param parser Defines the parser to add
  35669. */
  35670. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  35671. /**
  35672. * Gets an individual parser from the list of avaialble ones
  35673. * @param name Defines the name of the parser
  35674. * @returns the requested parser or null
  35675. */
  35676. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  35677. /**
  35678. * Parser json data and populate both a scene and its associated container object
  35679. * @param jsonData Defines the data to parse
  35680. * @param scene Defines the scene to parse the data for
  35681. * @param container Defines the container attached to the parsing sequence
  35682. * @param rootUrl Defines the root url of the data
  35683. */
  35684. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  35685. /**
  35686. * Gets the list of root nodes (ie. nodes with no parent)
  35687. */
  35688. rootNodes: Node[];
  35689. /** All of the cameras added to this scene
  35690. * @see http://doc.babylonjs.com/babylon101/cameras
  35691. */
  35692. cameras: Camera[];
  35693. /**
  35694. * All of the lights added to this scene
  35695. * @see http://doc.babylonjs.com/babylon101/lights
  35696. */
  35697. lights: Light[];
  35698. /**
  35699. * All of the (abstract) meshes added to this scene
  35700. */
  35701. meshes: AbstractMesh[];
  35702. /**
  35703. * The list of skeletons added to the scene
  35704. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35705. */
  35706. skeletons: Skeleton[];
  35707. /**
  35708. * All of the particle systems added to this scene
  35709. * @see http://doc.babylonjs.com/babylon101/particles
  35710. */
  35711. particleSystems: IParticleSystem[];
  35712. /**
  35713. * Gets a list of Animations associated with the scene
  35714. */
  35715. animations: Animation[];
  35716. /**
  35717. * All of the animation groups added to this scene
  35718. * @see http://doc.babylonjs.com/how_to/group
  35719. */
  35720. animationGroups: AnimationGroup[];
  35721. /**
  35722. * All of the multi-materials added to this scene
  35723. * @see http://doc.babylonjs.com/how_to/multi_materials
  35724. */
  35725. multiMaterials: MultiMaterial[];
  35726. /**
  35727. * All of the materials added to this scene
  35728. * In the context of a Scene, it is not supposed to be modified manually.
  35729. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  35730. * Note also that the order of the Material wihin the array is not significant and might change.
  35731. * @see http://doc.babylonjs.com/babylon101/materials
  35732. */
  35733. materials: Material[];
  35734. /**
  35735. * The list of morph target managers added to the scene
  35736. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  35737. */
  35738. morphTargetManagers: MorphTargetManager[];
  35739. /**
  35740. * The list of geometries used in the scene.
  35741. */
  35742. geometries: Geometry[];
  35743. /**
  35744. * All of the tranform nodes added to this scene
  35745. * In the context of a Scene, it is not supposed to be modified manually.
  35746. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  35747. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  35748. * @see http://doc.babylonjs.com/how_to/transformnode
  35749. */
  35750. transformNodes: TransformNode[];
  35751. /**
  35752. * ActionManagers available on the scene.
  35753. */
  35754. actionManagers: AbstractActionManager[];
  35755. /**
  35756. * Textures to keep.
  35757. */
  35758. textures: BaseTexture[];
  35759. /**
  35760. * Environment texture for the scene
  35761. */
  35762. environmentTexture: Nullable<BaseTexture>;
  35763. }
  35764. }
  35765. declare module "babylonjs/Audio/sound" {
  35766. import { Observable } from "babylonjs/Misc/observable";
  35767. import { Vector3 } from "babylonjs/Maths/math.vector";
  35768. import { Nullable } from "babylonjs/types";
  35769. import { Scene } from "babylonjs/scene";
  35770. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35771. /**
  35772. * Interface used to define options for Sound class
  35773. */
  35774. export interface ISoundOptions {
  35775. /**
  35776. * Does the sound autoplay once loaded.
  35777. */
  35778. autoplay?: boolean;
  35779. /**
  35780. * Does the sound loop after it finishes playing once.
  35781. */
  35782. loop?: boolean;
  35783. /**
  35784. * Sound's volume
  35785. */
  35786. volume?: number;
  35787. /**
  35788. * Is it a spatial sound?
  35789. */
  35790. spatialSound?: boolean;
  35791. /**
  35792. * Maximum distance to hear that sound
  35793. */
  35794. maxDistance?: number;
  35795. /**
  35796. * Uses user defined attenuation function
  35797. */
  35798. useCustomAttenuation?: boolean;
  35799. /**
  35800. * Define the roll off factor of spatial sounds.
  35801. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35802. */
  35803. rolloffFactor?: number;
  35804. /**
  35805. * Define the reference distance the sound should be heard perfectly.
  35806. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35807. */
  35808. refDistance?: number;
  35809. /**
  35810. * Define the distance attenuation model the sound will follow.
  35811. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35812. */
  35813. distanceModel?: string;
  35814. /**
  35815. * Defines the playback speed (1 by default)
  35816. */
  35817. playbackRate?: number;
  35818. /**
  35819. * Defines if the sound is from a streaming source
  35820. */
  35821. streaming?: boolean;
  35822. /**
  35823. * Defines an optional length (in seconds) inside the sound file
  35824. */
  35825. length?: number;
  35826. /**
  35827. * Defines an optional offset (in seconds) inside the sound file
  35828. */
  35829. offset?: number;
  35830. /**
  35831. * If true, URLs will not be required to state the audio file codec to use.
  35832. */
  35833. skipCodecCheck?: boolean;
  35834. }
  35835. /**
  35836. * Defines a sound that can be played in the application.
  35837. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  35838. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35839. */
  35840. export class Sound {
  35841. /**
  35842. * The name of the sound in the scene.
  35843. */
  35844. name: string;
  35845. /**
  35846. * Does the sound autoplay once loaded.
  35847. */
  35848. autoplay: boolean;
  35849. /**
  35850. * Does the sound loop after it finishes playing once.
  35851. */
  35852. loop: boolean;
  35853. /**
  35854. * Does the sound use a custom attenuation curve to simulate the falloff
  35855. * happening when the source gets further away from the camera.
  35856. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35857. */
  35858. useCustomAttenuation: boolean;
  35859. /**
  35860. * The sound track id this sound belongs to.
  35861. */
  35862. soundTrackId: number;
  35863. /**
  35864. * Is this sound currently played.
  35865. */
  35866. isPlaying: boolean;
  35867. /**
  35868. * Is this sound currently paused.
  35869. */
  35870. isPaused: boolean;
  35871. /**
  35872. * Does this sound enables spatial sound.
  35873. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35874. */
  35875. spatialSound: boolean;
  35876. /**
  35877. * Define the reference distance the sound should be heard perfectly.
  35878. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35879. */
  35880. refDistance: number;
  35881. /**
  35882. * Define the roll off factor of spatial sounds.
  35883. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35884. */
  35885. rolloffFactor: number;
  35886. /**
  35887. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  35888. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35889. */
  35890. maxDistance: number;
  35891. /**
  35892. * Define the distance attenuation model the sound will follow.
  35893. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35894. */
  35895. distanceModel: string;
  35896. /**
  35897. * @hidden
  35898. * Back Compat
  35899. **/
  35900. onended: () => any;
  35901. /**
  35902. * Observable event when the current playing sound finishes.
  35903. */
  35904. onEndedObservable: Observable<Sound>;
  35905. private _panningModel;
  35906. private _playbackRate;
  35907. private _streaming;
  35908. private _startTime;
  35909. private _startOffset;
  35910. private _position;
  35911. /** @hidden */
  35912. _positionInEmitterSpace: boolean;
  35913. private _localDirection;
  35914. private _volume;
  35915. private _isReadyToPlay;
  35916. private _isDirectional;
  35917. private _readyToPlayCallback;
  35918. private _audioBuffer;
  35919. private _soundSource;
  35920. private _streamingSource;
  35921. private _soundPanner;
  35922. private _soundGain;
  35923. private _inputAudioNode;
  35924. private _outputAudioNode;
  35925. private _coneInnerAngle;
  35926. private _coneOuterAngle;
  35927. private _coneOuterGain;
  35928. private _scene;
  35929. private _connectedTransformNode;
  35930. private _customAttenuationFunction;
  35931. private _registerFunc;
  35932. private _isOutputConnected;
  35933. private _htmlAudioElement;
  35934. private _urlType;
  35935. private _length?;
  35936. private _offset?;
  35937. /** @hidden */
  35938. static _SceneComponentInitialization: (scene: Scene) => void;
  35939. /**
  35940. * Create a sound and attach it to a scene
  35941. * @param name Name of your sound
  35942. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  35943. * @param scene defines the scene the sound belongs to
  35944. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  35945. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  35946. */
  35947. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  35948. /**
  35949. * Release the sound and its associated resources
  35950. */
  35951. dispose(): void;
  35952. /**
  35953. * Gets if the sounds is ready to be played or not.
  35954. * @returns true if ready, otherwise false
  35955. */
  35956. isReady(): boolean;
  35957. private _soundLoaded;
  35958. /**
  35959. * Sets the data of the sound from an audiobuffer
  35960. * @param audioBuffer The audioBuffer containing the data
  35961. */
  35962. setAudioBuffer(audioBuffer: AudioBuffer): void;
  35963. /**
  35964. * Updates the current sounds options such as maxdistance, loop...
  35965. * @param options A JSON object containing values named as the object properties
  35966. */
  35967. updateOptions(options: ISoundOptions): void;
  35968. private _createSpatialParameters;
  35969. private _updateSpatialParameters;
  35970. /**
  35971. * Switch the panning model to HRTF:
  35972. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35973. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35974. */
  35975. switchPanningModelToHRTF(): void;
  35976. /**
  35977. * Switch the panning model to Equal Power:
  35978. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35979. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35980. */
  35981. switchPanningModelToEqualPower(): void;
  35982. private _switchPanningModel;
  35983. /**
  35984. * Connect this sound to a sound track audio node like gain...
  35985. * @param soundTrackAudioNode the sound track audio node to connect to
  35986. */
  35987. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  35988. /**
  35989. * Transform this sound into a directional source
  35990. * @param coneInnerAngle Size of the inner cone in degree
  35991. * @param coneOuterAngle Size of the outer cone in degree
  35992. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  35993. */
  35994. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  35995. /**
  35996. * Gets or sets the inner angle for the directional cone.
  35997. */
  35998. /**
  35999. * Gets or sets the inner angle for the directional cone.
  36000. */
  36001. directionalConeInnerAngle: number;
  36002. /**
  36003. * Gets or sets the outer angle for the directional cone.
  36004. */
  36005. /**
  36006. * Gets or sets the outer angle for the directional cone.
  36007. */
  36008. directionalConeOuterAngle: number;
  36009. /**
  36010. * Sets the position of the emitter if spatial sound is enabled
  36011. * @param newPosition Defines the new posisiton
  36012. */
  36013. setPosition(newPosition: Vector3): void;
  36014. /**
  36015. * Sets the local direction of the emitter if spatial sound is enabled
  36016. * @param newLocalDirection Defines the new local direction
  36017. */
  36018. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  36019. private _updateDirection;
  36020. /** @hidden */
  36021. updateDistanceFromListener(): void;
  36022. /**
  36023. * Sets a new custom attenuation function for the sound.
  36024. * @param callback Defines the function used for the attenuation
  36025. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36026. */
  36027. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  36028. /**
  36029. * Play the sound
  36030. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  36031. * @param offset (optional) Start the sound at a specific time in seconds
  36032. * @param length (optional) Sound duration (in seconds)
  36033. */
  36034. play(time?: number, offset?: number, length?: number): void;
  36035. private _onended;
  36036. /**
  36037. * Stop the sound
  36038. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  36039. */
  36040. stop(time?: number): void;
  36041. /**
  36042. * Put the sound in pause
  36043. */
  36044. pause(): void;
  36045. /**
  36046. * Sets a dedicated volume for this sounds
  36047. * @param newVolume Define the new volume of the sound
  36048. * @param time Define time for gradual change to new volume
  36049. */
  36050. setVolume(newVolume: number, time?: number): void;
  36051. /**
  36052. * Set the sound play back rate
  36053. * @param newPlaybackRate Define the playback rate the sound should be played at
  36054. */
  36055. setPlaybackRate(newPlaybackRate: number): void;
  36056. /**
  36057. * Gets the volume of the sound.
  36058. * @returns the volume of the sound
  36059. */
  36060. getVolume(): number;
  36061. /**
  36062. * Attach the sound to a dedicated mesh
  36063. * @param transformNode The transform node to connect the sound with
  36064. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36065. */
  36066. attachToMesh(transformNode: TransformNode): void;
  36067. /**
  36068. * Detach the sound from the previously attached mesh
  36069. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36070. */
  36071. detachFromMesh(): void;
  36072. private _onRegisterAfterWorldMatrixUpdate;
  36073. /**
  36074. * Clone the current sound in the scene.
  36075. * @returns the new sound clone
  36076. */
  36077. clone(): Nullable<Sound>;
  36078. /**
  36079. * Gets the current underlying audio buffer containing the data
  36080. * @returns the audio buffer
  36081. */
  36082. getAudioBuffer(): Nullable<AudioBuffer>;
  36083. /**
  36084. * Serializes the Sound in a JSON representation
  36085. * @returns the JSON representation of the sound
  36086. */
  36087. serialize(): any;
  36088. /**
  36089. * Parse a JSON representation of a sound to innstantiate in a given scene
  36090. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  36091. * @param scene Define the scene the new parsed sound should be created in
  36092. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  36093. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  36094. * @returns the newly parsed sound
  36095. */
  36096. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  36097. }
  36098. }
  36099. declare module "babylonjs/Actions/directAudioActions" {
  36100. import { Action } from "babylonjs/Actions/action";
  36101. import { Condition } from "babylonjs/Actions/condition";
  36102. import { Sound } from "babylonjs/Audio/sound";
  36103. /**
  36104. * This defines an action helpful to play a defined sound on a triggered action.
  36105. */
  36106. export class PlaySoundAction extends Action {
  36107. private _sound;
  36108. /**
  36109. * Instantiate the action
  36110. * @param triggerOptions defines the trigger options
  36111. * @param sound defines the sound to play
  36112. * @param condition defines the trigger related conditions
  36113. */
  36114. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36115. /** @hidden */
  36116. _prepare(): void;
  36117. /**
  36118. * Execute the action and play the sound.
  36119. */
  36120. execute(): void;
  36121. /**
  36122. * Serializes the actions and its related information.
  36123. * @param parent defines the object to serialize in
  36124. * @returns the serialized object
  36125. */
  36126. serialize(parent: any): any;
  36127. }
  36128. /**
  36129. * This defines an action helpful to stop a defined sound on a triggered action.
  36130. */
  36131. export class StopSoundAction extends Action {
  36132. private _sound;
  36133. /**
  36134. * Instantiate the action
  36135. * @param triggerOptions defines the trigger options
  36136. * @param sound defines the sound to stop
  36137. * @param condition defines the trigger related conditions
  36138. */
  36139. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36140. /** @hidden */
  36141. _prepare(): void;
  36142. /**
  36143. * Execute the action and stop the sound.
  36144. */
  36145. execute(): void;
  36146. /**
  36147. * Serializes the actions and its related information.
  36148. * @param parent defines the object to serialize in
  36149. * @returns the serialized object
  36150. */
  36151. serialize(parent: any): any;
  36152. }
  36153. }
  36154. declare module "babylonjs/Actions/interpolateValueAction" {
  36155. import { Action } from "babylonjs/Actions/action";
  36156. import { Condition } from "babylonjs/Actions/condition";
  36157. import { Observable } from "babylonjs/Misc/observable";
  36158. /**
  36159. * This defines an action responsible to change the value of a property
  36160. * by interpolating between its current value and the newly set one once triggered.
  36161. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36162. */
  36163. export class InterpolateValueAction extends Action {
  36164. /**
  36165. * Defines the path of the property where the value should be interpolated
  36166. */
  36167. propertyPath: string;
  36168. /**
  36169. * Defines the target value at the end of the interpolation.
  36170. */
  36171. value: any;
  36172. /**
  36173. * Defines the time it will take for the property to interpolate to the value.
  36174. */
  36175. duration: number;
  36176. /**
  36177. * Defines if the other scene animations should be stopped when the action has been triggered
  36178. */
  36179. stopOtherAnimations?: boolean;
  36180. /**
  36181. * Defines a callback raised once the interpolation animation has been done.
  36182. */
  36183. onInterpolationDone?: () => void;
  36184. /**
  36185. * Observable triggered once the interpolation animation has been done.
  36186. */
  36187. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  36188. private _target;
  36189. private _effectiveTarget;
  36190. private _property;
  36191. /**
  36192. * Instantiate the action
  36193. * @param triggerOptions defines the trigger options
  36194. * @param target defines the object containing the value to interpolate
  36195. * @param propertyPath defines the path to the property in the target object
  36196. * @param value defines the target value at the end of the interpolation
  36197. * @param duration deines the time it will take for the property to interpolate to the value.
  36198. * @param condition defines the trigger related conditions
  36199. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  36200. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  36201. */
  36202. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  36203. /** @hidden */
  36204. _prepare(): void;
  36205. /**
  36206. * Execute the action starts the value interpolation.
  36207. */
  36208. execute(): void;
  36209. /**
  36210. * Serializes the actions and its related information.
  36211. * @param parent defines the object to serialize in
  36212. * @returns the serialized object
  36213. */
  36214. serialize(parent: any): any;
  36215. }
  36216. }
  36217. declare module "babylonjs/Actions/index" {
  36218. export * from "babylonjs/Actions/abstractActionManager";
  36219. export * from "babylonjs/Actions/action";
  36220. export * from "babylonjs/Actions/actionEvent";
  36221. export * from "babylonjs/Actions/actionManager";
  36222. export * from "babylonjs/Actions/condition";
  36223. export * from "babylonjs/Actions/directActions";
  36224. export * from "babylonjs/Actions/directAudioActions";
  36225. export * from "babylonjs/Actions/interpolateValueAction";
  36226. }
  36227. declare module "babylonjs/Animations/index" {
  36228. export * from "babylonjs/Animations/animatable";
  36229. export * from "babylonjs/Animations/animation";
  36230. export * from "babylonjs/Animations/animationGroup";
  36231. export * from "babylonjs/Animations/animationPropertiesOverride";
  36232. export * from "babylonjs/Animations/easing";
  36233. export * from "babylonjs/Animations/runtimeAnimation";
  36234. export * from "babylonjs/Animations/animationEvent";
  36235. export * from "babylonjs/Animations/animationGroup";
  36236. export * from "babylonjs/Animations/animationKey";
  36237. export * from "babylonjs/Animations/animationRange";
  36238. export * from "babylonjs/Animations/animatable.interface";
  36239. }
  36240. declare module "babylonjs/Audio/soundTrack" {
  36241. import { Sound } from "babylonjs/Audio/sound";
  36242. import { Analyser } from "babylonjs/Audio/analyser";
  36243. import { Scene } from "babylonjs/scene";
  36244. /**
  36245. * Options allowed during the creation of a sound track.
  36246. */
  36247. export interface ISoundTrackOptions {
  36248. /**
  36249. * The volume the sound track should take during creation
  36250. */
  36251. volume?: number;
  36252. /**
  36253. * Define if the sound track is the main sound track of the scene
  36254. */
  36255. mainTrack?: boolean;
  36256. }
  36257. /**
  36258. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  36259. * It will be also used in a future release to apply effects on a specific track.
  36260. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36261. */
  36262. export class SoundTrack {
  36263. /**
  36264. * The unique identifier of the sound track in the scene.
  36265. */
  36266. id: number;
  36267. /**
  36268. * The list of sounds included in the sound track.
  36269. */
  36270. soundCollection: Array<Sound>;
  36271. private _outputAudioNode;
  36272. private _scene;
  36273. private _isMainTrack;
  36274. private _connectedAnalyser;
  36275. private _options;
  36276. private _isInitialized;
  36277. /**
  36278. * Creates a new sound track.
  36279. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36280. * @param scene Define the scene the sound track belongs to
  36281. * @param options
  36282. */
  36283. constructor(scene: Scene, options?: ISoundTrackOptions);
  36284. private _initializeSoundTrackAudioGraph;
  36285. /**
  36286. * Release the sound track and its associated resources
  36287. */
  36288. dispose(): void;
  36289. /**
  36290. * Adds a sound to this sound track
  36291. * @param sound define the cound to add
  36292. * @ignoreNaming
  36293. */
  36294. AddSound(sound: Sound): void;
  36295. /**
  36296. * Removes a sound to this sound track
  36297. * @param sound define the cound to remove
  36298. * @ignoreNaming
  36299. */
  36300. RemoveSound(sound: Sound): void;
  36301. /**
  36302. * Set a global volume for the full sound track.
  36303. * @param newVolume Define the new volume of the sound track
  36304. */
  36305. setVolume(newVolume: number): void;
  36306. /**
  36307. * Switch the panning model to HRTF:
  36308. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36309. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36310. */
  36311. switchPanningModelToHRTF(): void;
  36312. /**
  36313. * Switch the panning model to Equal Power:
  36314. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36315. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36316. */
  36317. switchPanningModelToEqualPower(): void;
  36318. /**
  36319. * Connect the sound track to an audio analyser allowing some amazing
  36320. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36321. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36322. * @param analyser The analyser to connect to the engine
  36323. */
  36324. connectToAnalyser(analyser: Analyser): void;
  36325. }
  36326. }
  36327. declare module "babylonjs/Audio/audioSceneComponent" {
  36328. import { Sound } from "babylonjs/Audio/sound";
  36329. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  36330. import { Nullable } from "babylonjs/types";
  36331. import { Vector3 } from "babylonjs/Maths/math.vector";
  36332. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  36333. import { Scene } from "babylonjs/scene";
  36334. import { AbstractScene } from "babylonjs/abstractScene";
  36335. import "babylonjs/Audio/audioEngine";
  36336. module "babylonjs/abstractScene" {
  36337. interface AbstractScene {
  36338. /**
  36339. * The list of sounds used in the scene.
  36340. */
  36341. sounds: Nullable<Array<Sound>>;
  36342. }
  36343. }
  36344. module "babylonjs/scene" {
  36345. interface Scene {
  36346. /**
  36347. * @hidden
  36348. * Backing field
  36349. */
  36350. _mainSoundTrack: SoundTrack;
  36351. /**
  36352. * The main sound track played by the scene.
  36353. * It cotains your primary collection of sounds.
  36354. */
  36355. mainSoundTrack: SoundTrack;
  36356. /**
  36357. * The list of sound tracks added to the scene
  36358. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36359. */
  36360. soundTracks: Nullable<Array<SoundTrack>>;
  36361. /**
  36362. * Gets a sound using a given name
  36363. * @param name defines the name to search for
  36364. * @return the found sound or null if not found at all.
  36365. */
  36366. getSoundByName(name: string): Nullable<Sound>;
  36367. /**
  36368. * Gets or sets if audio support is enabled
  36369. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36370. */
  36371. audioEnabled: boolean;
  36372. /**
  36373. * Gets or sets if audio will be output to headphones
  36374. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36375. */
  36376. headphone: boolean;
  36377. /**
  36378. * Gets or sets custom audio listener position provider
  36379. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36380. */
  36381. audioListenerPositionProvider: Nullable<() => Vector3>;
  36382. }
  36383. }
  36384. /**
  36385. * Defines the sound scene component responsible to manage any sounds
  36386. * in a given scene.
  36387. */
  36388. export class AudioSceneComponent implements ISceneSerializableComponent {
  36389. /**
  36390. * The component name helpfull to identify the component in the list of scene components.
  36391. */
  36392. readonly name: string;
  36393. /**
  36394. * The scene the component belongs to.
  36395. */
  36396. scene: Scene;
  36397. private _audioEnabled;
  36398. /**
  36399. * Gets whether audio is enabled or not.
  36400. * Please use related enable/disable method to switch state.
  36401. */
  36402. readonly audioEnabled: boolean;
  36403. private _headphone;
  36404. /**
  36405. * Gets whether audio is outputing to headphone or not.
  36406. * Please use the according Switch methods to change output.
  36407. */
  36408. readonly headphone: boolean;
  36409. private _audioListenerPositionProvider;
  36410. /**
  36411. * Gets the current audio listener position provider
  36412. */
  36413. /**
  36414. * Sets a custom listener position for all sounds in the scene
  36415. * By default, this is the position of the first active camera
  36416. */
  36417. audioListenerPositionProvider: Nullable<() => Vector3>;
  36418. /**
  36419. * Creates a new instance of the component for the given scene
  36420. * @param scene Defines the scene to register the component in
  36421. */
  36422. constructor(scene: Scene);
  36423. /**
  36424. * Registers the component in a given scene
  36425. */
  36426. register(): void;
  36427. /**
  36428. * Rebuilds the elements related to this component in case of
  36429. * context lost for instance.
  36430. */
  36431. rebuild(): void;
  36432. /**
  36433. * Serializes the component data to the specified json object
  36434. * @param serializationObject The object to serialize to
  36435. */
  36436. serialize(serializationObject: any): void;
  36437. /**
  36438. * Adds all the elements from the container to the scene
  36439. * @param container the container holding the elements
  36440. */
  36441. addFromContainer(container: AbstractScene): void;
  36442. /**
  36443. * Removes all the elements in the container from the scene
  36444. * @param container contains the elements to remove
  36445. * @param dispose if the removed element should be disposed (default: false)
  36446. */
  36447. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  36448. /**
  36449. * Disposes the component and the associated ressources.
  36450. */
  36451. dispose(): void;
  36452. /**
  36453. * Disables audio in the associated scene.
  36454. */
  36455. disableAudio(): void;
  36456. /**
  36457. * Enables audio in the associated scene.
  36458. */
  36459. enableAudio(): void;
  36460. /**
  36461. * Switch audio to headphone output.
  36462. */
  36463. switchAudioModeForHeadphones(): void;
  36464. /**
  36465. * Switch audio to normal speakers.
  36466. */
  36467. switchAudioModeForNormalSpeakers(): void;
  36468. private _afterRender;
  36469. }
  36470. }
  36471. declare module "babylonjs/Audio/weightedsound" {
  36472. import { Sound } from "babylonjs/Audio/sound";
  36473. /**
  36474. * Wraps one or more Sound objects and selects one with random weight for playback.
  36475. */
  36476. export class WeightedSound {
  36477. /** When true a Sound will be selected and played when the current playing Sound completes. */
  36478. loop: boolean;
  36479. private _coneInnerAngle;
  36480. private _coneOuterAngle;
  36481. private _volume;
  36482. /** A Sound is currently playing. */
  36483. isPlaying: boolean;
  36484. /** A Sound is currently paused. */
  36485. isPaused: boolean;
  36486. private _sounds;
  36487. private _weights;
  36488. private _currentIndex?;
  36489. /**
  36490. * Creates a new WeightedSound from the list of sounds given.
  36491. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  36492. * @param sounds Array of Sounds that will be selected from.
  36493. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  36494. */
  36495. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  36496. /**
  36497. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  36498. */
  36499. /**
  36500. * The size of cone in degress for a directional sound in which there will be no attenuation.
  36501. */
  36502. directionalConeInnerAngle: number;
  36503. /**
  36504. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36505. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36506. */
  36507. /**
  36508. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36509. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36510. */
  36511. directionalConeOuterAngle: number;
  36512. /**
  36513. * Playback volume.
  36514. */
  36515. /**
  36516. * Playback volume.
  36517. */
  36518. volume: number;
  36519. private _onended;
  36520. /**
  36521. * Suspend playback
  36522. */
  36523. pause(): void;
  36524. /**
  36525. * Stop playback
  36526. */
  36527. stop(): void;
  36528. /**
  36529. * Start playback.
  36530. * @param startOffset Position the clip head at a specific time in seconds.
  36531. */
  36532. play(startOffset?: number): void;
  36533. }
  36534. }
  36535. declare module "babylonjs/Audio/index" {
  36536. export * from "babylonjs/Audio/analyser";
  36537. export * from "babylonjs/Audio/audioEngine";
  36538. export * from "babylonjs/Audio/audioSceneComponent";
  36539. export * from "babylonjs/Audio/sound";
  36540. export * from "babylonjs/Audio/soundTrack";
  36541. export * from "babylonjs/Audio/weightedsound";
  36542. }
  36543. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  36544. import { Behavior } from "babylonjs/Behaviors/behavior";
  36545. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36546. import { BackEase } from "babylonjs/Animations/easing";
  36547. /**
  36548. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  36549. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36550. */
  36551. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  36552. /**
  36553. * Gets the name of the behavior.
  36554. */
  36555. readonly name: string;
  36556. /**
  36557. * The easing function used by animations
  36558. */
  36559. static EasingFunction: BackEase;
  36560. /**
  36561. * The easing mode used by animations
  36562. */
  36563. static EasingMode: number;
  36564. /**
  36565. * The duration of the animation, in milliseconds
  36566. */
  36567. transitionDuration: number;
  36568. /**
  36569. * Length of the distance animated by the transition when lower radius is reached
  36570. */
  36571. lowerRadiusTransitionRange: number;
  36572. /**
  36573. * Length of the distance animated by the transition when upper radius is reached
  36574. */
  36575. upperRadiusTransitionRange: number;
  36576. private _autoTransitionRange;
  36577. /**
  36578. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36579. */
  36580. /**
  36581. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36582. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  36583. */
  36584. autoTransitionRange: boolean;
  36585. private _attachedCamera;
  36586. private _onAfterCheckInputsObserver;
  36587. private _onMeshTargetChangedObserver;
  36588. /**
  36589. * Initializes the behavior.
  36590. */
  36591. init(): void;
  36592. /**
  36593. * Attaches the behavior to its arc rotate camera.
  36594. * @param camera Defines the camera to attach the behavior to
  36595. */
  36596. attach(camera: ArcRotateCamera): void;
  36597. /**
  36598. * Detaches the behavior from its current arc rotate camera.
  36599. */
  36600. detach(): void;
  36601. private _radiusIsAnimating;
  36602. private _radiusBounceTransition;
  36603. private _animatables;
  36604. private _cachedWheelPrecision;
  36605. /**
  36606. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  36607. * @param radiusLimit The limit to check against.
  36608. * @return Bool to indicate if at limit.
  36609. */
  36610. private _isRadiusAtLimit;
  36611. /**
  36612. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  36613. * @param radiusDelta The delta by which to animate to. Can be negative.
  36614. */
  36615. private _applyBoundRadiusAnimation;
  36616. /**
  36617. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  36618. */
  36619. protected _clearAnimationLocks(): void;
  36620. /**
  36621. * Stops and removes all animations that have been applied to the camera
  36622. */
  36623. stopAllAnimations(): void;
  36624. }
  36625. }
  36626. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  36627. import { Behavior } from "babylonjs/Behaviors/behavior";
  36628. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36629. import { ExponentialEase } from "babylonjs/Animations/easing";
  36630. import { Nullable } from "babylonjs/types";
  36631. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36632. import { Vector3 } from "babylonjs/Maths/math.vector";
  36633. /**
  36634. * The framing behavior (FramingBehavior) is designed to automatically position an ArcRotateCamera when its target is set to a mesh. It is also useful if you want to prevent the camera to go under a virtual horizontal plane.
  36635. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36636. */
  36637. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  36638. /**
  36639. * Gets the name of the behavior.
  36640. */
  36641. readonly name: string;
  36642. private _mode;
  36643. private _radiusScale;
  36644. private _positionScale;
  36645. private _defaultElevation;
  36646. private _elevationReturnTime;
  36647. private _elevationReturnWaitTime;
  36648. private _zoomStopsAnimation;
  36649. private _framingTime;
  36650. /**
  36651. * The easing function used by animations
  36652. */
  36653. static EasingFunction: ExponentialEase;
  36654. /**
  36655. * The easing mode used by animations
  36656. */
  36657. static EasingMode: number;
  36658. /**
  36659. * Sets the current mode used by the behavior
  36660. */
  36661. /**
  36662. * Gets current mode used by the behavior.
  36663. */
  36664. mode: number;
  36665. /**
  36666. * Sets the scale applied to the radius (1 by default)
  36667. */
  36668. /**
  36669. * Gets the scale applied to the radius
  36670. */
  36671. radiusScale: number;
  36672. /**
  36673. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36674. */
  36675. /**
  36676. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36677. */
  36678. positionScale: number;
  36679. /**
  36680. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36681. * behaviour is triggered, in radians.
  36682. */
  36683. /**
  36684. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36685. * behaviour is triggered, in radians.
  36686. */
  36687. defaultElevation: number;
  36688. /**
  36689. * Sets the time (in milliseconds) taken to return to the default beta position.
  36690. * Negative value indicates camera should not return to default.
  36691. */
  36692. /**
  36693. * Gets the time (in milliseconds) taken to return to the default beta position.
  36694. * Negative value indicates camera should not return to default.
  36695. */
  36696. elevationReturnTime: number;
  36697. /**
  36698. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36699. */
  36700. /**
  36701. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36702. */
  36703. elevationReturnWaitTime: number;
  36704. /**
  36705. * Sets the flag that indicates if user zooming should stop animation.
  36706. */
  36707. /**
  36708. * Gets the flag that indicates if user zooming should stop animation.
  36709. */
  36710. zoomStopsAnimation: boolean;
  36711. /**
  36712. * Sets the transition time when framing the mesh, in milliseconds
  36713. */
  36714. /**
  36715. * Gets the transition time when framing the mesh, in milliseconds
  36716. */
  36717. framingTime: number;
  36718. /**
  36719. * Define if the behavior should automatically change the configured
  36720. * camera limits and sensibilities.
  36721. */
  36722. autoCorrectCameraLimitsAndSensibility: boolean;
  36723. private _onPrePointerObservableObserver;
  36724. private _onAfterCheckInputsObserver;
  36725. private _onMeshTargetChangedObserver;
  36726. private _attachedCamera;
  36727. private _isPointerDown;
  36728. private _lastInteractionTime;
  36729. /**
  36730. * Initializes the behavior.
  36731. */
  36732. init(): void;
  36733. /**
  36734. * Attaches the behavior to its arc rotate camera.
  36735. * @param camera Defines the camera to attach the behavior to
  36736. */
  36737. attach(camera: ArcRotateCamera): void;
  36738. /**
  36739. * Detaches the behavior from its current arc rotate camera.
  36740. */
  36741. detach(): void;
  36742. private _animatables;
  36743. private _betaIsAnimating;
  36744. private _betaTransition;
  36745. private _radiusTransition;
  36746. private _vectorTransition;
  36747. /**
  36748. * Targets the given mesh and updates zoom level accordingly.
  36749. * @param mesh The mesh to target.
  36750. * @param radius Optional. If a cached radius position already exists, overrides default.
  36751. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36752. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36753. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36754. */
  36755. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36756. /**
  36757. * Targets the given mesh with its children and updates zoom level accordingly.
  36758. * @param mesh The mesh to target.
  36759. * @param radius Optional. If a cached radius position already exists, overrides default.
  36760. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36761. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36762. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36763. */
  36764. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36765. /**
  36766. * Targets the given meshes with their children and updates zoom level accordingly.
  36767. * @param meshes The mesh to target.
  36768. * @param radius Optional. If a cached radius position already exists, overrides default.
  36769. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36770. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36771. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36772. */
  36773. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36774. /**
  36775. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  36776. * @param minimumWorld Determines the smaller position of the bounding box extend
  36777. * @param maximumWorld Determines the bigger position of the bounding box extend
  36778. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36779. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36780. */
  36781. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36782. /**
  36783. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  36784. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  36785. * frustum width.
  36786. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  36787. * to fully enclose the mesh in the viewing frustum.
  36788. */
  36789. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  36790. /**
  36791. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  36792. * is automatically returned to its default position (expected to be above ground plane).
  36793. */
  36794. private _maintainCameraAboveGround;
  36795. /**
  36796. * Returns the frustum slope based on the canvas ratio and camera FOV
  36797. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  36798. */
  36799. private _getFrustumSlope;
  36800. /**
  36801. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  36802. */
  36803. private _clearAnimationLocks;
  36804. /**
  36805. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36806. */
  36807. private _applyUserInteraction;
  36808. /**
  36809. * Stops and removes all animations that have been applied to the camera
  36810. */
  36811. stopAllAnimations(): void;
  36812. /**
  36813. * Gets a value indicating if the user is moving the camera
  36814. */
  36815. readonly isUserIsMoving: boolean;
  36816. /**
  36817. * The camera can move all the way towards the mesh.
  36818. */
  36819. static IgnoreBoundsSizeMode: number;
  36820. /**
  36821. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  36822. */
  36823. static FitFrustumSidesMode: number;
  36824. }
  36825. }
  36826. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  36827. import { Nullable } from "babylonjs/types";
  36828. import { Camera } from "babylonjs/Cameras/camera";
  36829. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36830. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36831. /**
  36832. * Base class for Camera Pointer Inputs.
  36833. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  36834. * for example usage.
  36835. */
  36836. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  36837. /**
  36838. * Defines the camera the input is attached to.
  36839. */
  36840. abstract camera: Camera;
  36841. /**
  36842. * Whether keyboard modifier keys are pressed at time of last mouse event.
  36843. */
  36844. protected _altKey: boolean;
  36845. protected _ctrlKey: boolean;
  36846. protected _metaKey: boolean;
  36847. protected _shiftKey: boolean;
  36848. /**
  36849. * Which mouse buttons were pressed at time of last mouse event.
  36850. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  36851. */
  36852. protected _buttonsPressed: number;
  36853. /**
  36854. * Defines the buttons associated with the input to handle camera move.
  36855. */
  36856. buttons: number[];
  36857. /**
  36858. * Attach the input controls to a specific dom element to get the input from.
  36859. * @param element Defines the element the controls should be listened from
  36860. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36861. */
  36862. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36863. /**
  36864. * Detach the current controls from the specified dom element.
  36865. * @param element Defines the element to stop listening the inputs from
  36866. */
  36867. detachControl(element: Nullable<HTMLElement>): void;
  36868. /**
  36869. * Gets the class name of the current input.
  36870. * @returns the class name
  36871. */
  36872. getClassName(): string;
  36873. /**
  36874. * Get the friendly name associated with the input class.
  36875. * @returns the input friendly name
  36876. */
  36877. getSimpleName(): string;
  36878. /**
  36879. * Called on pointer POINTERDOUBLETAP event.
  36880. * Override this method to provide functionality on POINTERDOUBLETAP event.
  36881. */
  36882. protected onDoubleTap(type: string): void;
  36883. /**
  36884. * Called on pointer POINTERMOVE event if only a single touch is active.
  36885. * Override this method to provide functionality.
  36886. */
  36887. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36888. /**
  36889. * Called on pointer POINTERMOVE event if multiple touches are active.
  36890. * Override this method to provide functionality.
  36891. */
  36892. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36893. /**
  36894. * Called on JS contextmenu event.
  36895. * Override this method to provide functionality.
  36896. */
  36897. protected onContextMenu(evt: PointerEvent): void;
  36898. /**
  36899. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36900. * press.
  36901. * Override this method to provide functionality.
  36902. */
  36903. protected onButtonDown(evt: PointerEvent): void;
  36904. /**
  36905. * Called each time a new POINTERUP event occurs. Ie, for each button
  36906. * release.
  36907. * Override this method to provide functionality.
  36908. */
  36909. protected onButtonUp(evt: PointerEvent): void;
  36910. /**
  36911. * Called when window becomes inactive.
  36912. * Override this method to provide functionality.
  36913. */
  36914. protected onLostFocus(): void;
  36915. private _pointerInput;
  36916. private _observer;
  36917. private _onLostFocus;
  36918. private pointA;
  36919. private pointB;
  36920. }
  36921. }
  36922. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  36923. import { Nullable } from "babylonjs/types";
  36924. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36925. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  36926. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36927. /**
  36928. * Manage the pointers inputs to control an arc rotate camera.
  36929. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36930. */
  36931. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  36932. /**
  36933. * Defines the camera the input is attached to.
  36934. */
  36935. camera: ArcRotateCamera;
  36936. /**
  36937. * Gets the class name of the current input.
  36938. * @returns the class name
  36939. */
  36940. getClassName(): string;
  36941. /**
  36942. * Defines the buttons associated with the input to handle camera move.
  36943. */
  36944. buttons: number[];
  36945. /**
  36946. * Defines the pointer angular sensibility along the X axis or how fast is
  36947. * the camera rotating.
  36948. */
  36949. angularSensibilityX: number;
  36950. /**
  36951. * Defines the pointer angular sensibility along the Y axis or how fast is
  36952. * the camera rotating.
  36953. */
  36954. angularSensibilityY: number;
  36955. /**
  36956. * Defines the pointer pinch precision or how fast is the camera zooming.
  36957. */
  36958. pinchPrecision: number;
  36959. /**
  36960. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36961. * from 0.
  36962. * It defines the percentage of current camera.radius to use as delta when
  36963. * pinch zoom is used.
  36964. */
  36965. pinchDeltaPercentage: number;
  36966. /**
  36967. * Defines the pointer panning sensibility or how fast is the camera moving.
  36968. */
  36969. panningSensibility: number;
  36970. /**
  36971. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  36972. */
  36973. multiTouchPanning: boolean;
  36974. /**
  36975. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  36976. * zoom (pinch) through multitouch.
  36977. */
  36978. multiTouchPanAndZoom: boolean;
  36979. /**
  36980. * Revers pinch action direction.
  36981. */
  36982. pinchInwards: boolean;
  36983. private _isPanClick;
  36984. private _twoFingerActivityCount;
  36985. private _isPinching;
  36986. /**
  36987. * Called on pointer POINTERMOVE event if only a single touch is active.
  36988. */
  36989. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36990. /**
  36991. * Called on pointer POINTERDOUBLETAP event.
  36992. */
  36993. protected onDoubleTap(type: string): void;
  36994. /**
  36995. * Called on pointer POINTERMOVE event if multiple touches are active.
  36996. */
  36997. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36998. /**
  36999. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37000. * press.
  37001. */
  37002. protected onButtonDown(evt: PointerEvent): void;
  37003. /**
  37004. * Called each time a new POINTERUP event occurs. Ie, for each button
  37005. * release.
  37006. */
  37007. protected onButtonUp(evt: PointerEvent): void;
  37008. /**
  37009. * Called when window becomes inactive.
  37010. */
  37011. protected onLostFocus(): void;
  37012. }
  37013. }
  37014. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  37015. import { Nullable } from "babylonjs/types";
  37016. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37017. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37018. /**
  37019. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  37020. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37021. */
  37022. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  37023. /**
  37024. * Defines the camera the input is attached to.
  37025. */
  37026. camera: ArcRotateCamera;
  37027. /**
  37028. * Defines the list of key codes associated with the up action (increase alpha)
  37029. */
  37030. keysUp: number[];
  37031. /**
  37032. * Defines the list of key codes associated with the down action (decrease alpha)
  37033. */
  37034. keysDown: number[];
  37035. /**
  37036. * Defines the list of key codes associated with the left action (increase beta)
  37037. */
  37038. keysLeft: number[];
  37039. /**
  37040. * Defines the list of key codes associated with the right action (decrease beta)
  37041. */
  37042. keysRight: number[];
  37043. /**
  37044. * Defines the list of key codes associated with the reset action.
  37045. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  37046. */
  37047. keysReset: number[];
  37048. /**
  37049. * Defines the panning sensibility of the inputs.
  37050. * (How fast is the camera paning)
  37051. */
  37052. panningSensibility: number;
  37053. /**
  37054. * Defines the zooming sensibility of the inputs.
  37055. * (How fast is the camera zooming)
  37056. */
  37057. zoomingSensibility: number;
  37058. /**
  37059. * Defines wether maintaining the alt key down switch the movement mode from
  37060. * orientation to zoom.
  37061. */
  37062. useAltToZoom: boolean;
  37063. /**
  37064. * Rotation speed of the camera
  37065. */
  37066. angularSpeed: number;
  37067. private _keys;
  37068. private _ctrlPressed;
  37069. private _altPressed;
  37070. private _onCanvasBlurObserver;
  37071. private _onKeyboardObserver;
  37072. private _engine;
  37073. private _scene;
  37074. /**
  37075. * Attach the input controls to a specific dom element to get the input from.
  37076. * @param element Defines the element the controls should be listened from
  37077. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37078. */
  37079. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37080. /**
  37081. * Detach the current controls from the specified dom element.
  37082. * @param element Defines the element to stop listening the inputs from
  37083. */
  37084. detachControl(element: Nullable<HTMLElement>): void;
  37085. /**
  37086. * Update the current camera state depending on the inputs that have been used this frame.
  37087. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37088. */
  37089. checkInputs(): void;
  37090. /**
  37091. * Gets the class name of the current intput.
  37092. * @returns the class name
  37093. */
  37094. getClassName(): string;
  37095. /**
  37096. * Get the friendly name associated with the input class.
  37097. * @returns the input friendly name
  37098. */
  37099. getSimpleName(): string;
  37100. }
  37101. }
  37102. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  37103. import { Nullable } from "babylonjs/types";
  37104. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37105. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37106. /**
  37107. * Manage the mouse wheel inputs to control an arc rotate camera.
  37108. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37109. */
  37110. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  37111. /**
  37112. * Defines the camera the input is attached to.
  37113. */
  37114. camera: ArcRotateCamera;
  37115. /**
  37116. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37117. */
  37118. wheelPrecision: number;
  37119. /**
  37120. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37121. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37122. */
  37123. wheelDeltaPercentage: number;
  37124. private _wheel;
  37125. private _observer;
  37126. private computeDeltaFromMouseWheelLegacyEvent;
  37127. /**
  37128. * Attach the input controls to a specific dom element to get the input from.
  37129. * @param element Defines the element the controls should be listened from
  37130. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37131. */
  37132. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37133. /**
  37134. * Detach the current controls from the specified dom element.
  37135. * @param element Defines the element to stop listening the inputs from
  37136. */
  37137. detachControl(element: Nullable<HTMLElement>): void;
  37138. /**
  37139. * Gets the class name of the current intput.
  37140. * @returns the class name
  37141. */
  37142. getClassName(): string;
  37143. /**
  37144. * Get the friendly name associated with the input class.
  37145. * @returns the input friendly name
  37146. */
  37147. getSimpleName(): string;
  37148. }
  37149. }
  37150. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37151. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37152. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37153. /**
  37154. * Default Inputs manager for the ArcRotateCamera.
  37155. * It groups all the default supported inputs for ease of use.
  37156. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37157. */
  37158. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  37159. /**
  37160. * Instantiates a new ArcRotateCameraInputsManager.
  37161. * @param camera Defines the camera the inputs belong to
  37162. */
  37163. constructor(camera: ArcRotateCamera);
  37164. /**
  37165. * Add mouse wheel input support to the input manager.
  37166. * @returns the current input manager
  37167. */
  37168. addMouseWheel(): ArcRotateCameraInputsManager;
  37169. /**
  37170. * Add pointers input support to the input manager.
  37171. * @returns the current input manager
  37172. */
  37173. addPointers(): ArcRotateCameraInputsManager;
  37174. /**
  37175. * Add keyboard input support to the input manager.
  37176. * @returns the current input manager
  37177. */
  37178. addKeyboard(): ArcRotateCameraInputsManager;
  37179. }
  37180. }
  37181. declare module "babylonjs/Cameras/arcRotateCamera" {
  37182. import { Observable } from "babylonjs/Misc/observable";
  37183. import { Nullable } from "babylonjs/types";
  37184. import { Scene } from "babylonjs/scene";
  37185. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  37186. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37187. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37188. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37189. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  37190. import { Camera } from "babylonjs/Cameras/camera";
  37191. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37192. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  37193. import { Collider } from "babylonjs/Collisions/collider";
  37194. /**
  37195. * This represents an orbital type of camera.
  37196. *
  37197. * This camera always points towards a given target position and can be rotated around that target with the target as the centre of rotation. It can be controlled with cursors and mouse, or with touch events.
  37198. * Think of this camera as one orbiting its target position, or more imaginatively as a spy satellite orbiting the earth. Its position relative to the target (earth) can be set by three parameters, alpha (radians) the longitudinal rotation, beta (radians) the latitudinal rotation and radius the distance from the target position.
  37199. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  37200. */
  37201. export class ArcRotateCamera extends TargetCamera {
  37202. /**
  37203. * Defines the rotation angle of the camera along the longitudinal axis.
  37204. */
  37205. alpha: number;
  37206. /**
  37207. * Defines the rotation angle of the camera along the latitudinal axis.
  37208. */
  37209. beta: number;
  37210. /**
  37211. * Defines the radius of the camera from it s target point.
  37212. */
  37213. radius: number;
  37214. protected _target: Vector3;
  37215. protected _targetHost: Nullable<AbstractMesh>;
  37216. /**
  37217. * Defines the target point of the camera.
  37218. * The camera looks towards it form the radius distance.
  37219. */
  37220. target: Vector3;
  37221. /**
  37222. * Define the current local position of the camera in the scene
  37223. */
  37224. position: Vector3;
  37225. protected _upVector: Vector3;
  37226. protected _upToYMatrix: Matrix;
  37227. protected _YToUpMatrix: Matrix;
  37228. /**
  37229. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  37230. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  37231. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  37232. */
  37233. upVector: Vector3;
  37234. /**
  37235. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  37236. */
  37237. setMatUp(): void;
  37238. /**
  37239. * Current inertia value on the longitudinal axis.
  37240. * The bigger this number the longer it will take for the camera to stop.
  37241. */
  37242. inertialAlphaOffset: number;
  37243. /**
  37244. * Current inertia value on the latitudinal axis.
  37245. * The bigger this number the longer it will take for the camera to stop.
  37246. */
  37247. inertialBetaOffset: number;
  37248. /**
  37249. * Current inertia value on the radius axis.
  37250. * The bigger this number the longer it will take for the camera to stop.
  37251. */
  37252. inertialRadiusOffset: number;
  37253. /**
  37254. * Minimum allowed angle on the longitudinal axis.
  37255. * This can help limiting how the Camera is able to move in the scene.
  37256. */
  37257. lowerAlphaLimit: Nullable<number>;
  37258. /**
  37259. * Maximum allowed angle on the longitudinal axis.
  37260. * This can help limiting how the Camera is able to move in the scene.
  37261. */
  37262. upperAlphaLimit: Nullable<number>;
  37263. /**
  37264. * Minimum allowed angle on the latitudinal axis.
  37265. * This can help limiting how the Camera is able to move in the scene.
  37266. */
  37267. lowerBetaLimit: number;
  37268. /**
  37269. * Maximum allowed angle on the latitudinal axis.
  37270. * This can help limiting how the Camera is able to move in the scene.
  37271. */
  37272. upperBetaLimit: number;
  37273. /**
  37274. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  37275. * This can help limiting how the Camera is able to move in the scene.
  37276. */
  37277. lowerRadiusLimit: Nullable<number>;
  37278. /**
  37279. * Maximum allowed distance of the camera to the target (The camera can not get further).
  37280. * This can help limiting how the Camera is able to move in the scene.
  37281. */
  37282. upperRadiusLimit: Nullable<number>;
  37283. /**
  37284. * Defines the current inertia value used during panning of the camera along the X axis.
  37285. */
  37286. inertialPanningX: number;
  37287. /**
  37288. * Defines the current inertia value used during panning of the camera along the Y axis.
  37289. */
  37290. inertialPanningY: number;
  37291. /**
  37292. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  37293. * Basically if your fingers moves away from more than this distance you will be considered
  37294. * in pinch mode.
  37295. */
  37296. pinchToPanMaxDistance: number;
  37297. /**
  37298. * Defines the maximum distance the camera can pan.
  37299. * This could help keeping the cammera always in your scene.
  37300. */
  37301. panningDistanceLimit: Nullable<number>;
  37302. /**
  37303. * Defines the target of the camera before paning.
  37304. */
  37305. panningOriginTarget: Vector3;
  37306. /**
  37307. * Defines the value of the inertia used during panning.
  37308. * 0 would mean stop inertia and one would mean no decelleration at all.
  37309. */
  37310. panningInertia: number;
  37311. /**
  37312. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  37313. */
  37314. angularSensibilityX: number;
  37315. /**
  37316. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  37317. */
  37318. angularSensibilityY: number;
  37319. /**
  37320. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  37321. */
  37322. pinchPrecision: number;
  37323. /**
  37324. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  37325. * It will be used instead of pinchDeltaPrecision if different from 0.
  37326. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37327. */
  37328. pinchDeltaPercentage: number;
  37329. /**
  37330. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  37331. */
  37332. panningSensibility: number;
  37333. /**
  37334. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  37335. */
  37336. keysUp: number[];
  37337. /**
  37338. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  37339. */
  37340. keysDown: number[];
  37341. /**
  37342. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  37343. */
  37344. keysLeft: number[];
  37345. /**
  37346. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  37347. */
  37348. keysRight: number[];
  37349. /**
  37350. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37351. */
  37352. wheelPrecision: number;
  37353. /**
  37354. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  37355. * It will be used instead of pinchDeltaPrecision if different from 0.
  37356. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37357. */
  37358. wheelDeltaPercentage: number;
  37359. /**
  37360. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  37361. */
  37362. zoomOnFactor: number;
  37363. /**
  37364. * Defines a screen offset for the camera position.
  37365. */
  37366. targetScreenOffset: Vector2;
  37367. /**
  37368. * Allows the camera to be completely reversed.
  37369. * If false the camera can not arrive upside down.
  37370. */
  37371. allowUpsideDown: boolean;
  37372. /**
  37373. * Define if double tap/click is used to restore the previously saved state of the camera.
  37374. */
  37375. useInputToRestoreState: boolean;
  37376. /** @hidden */
  37377. _viewMatrix: Matrix;
  37378. /** @hidden */
  37379. _useCtrlForPanning: boolean;
  37380. /** @hidden */
  37381. _panningMouseButton: number;
  37382. /**
  37383. * Defines the input associated to the camera.
  37384. */
  37385. inputs: ArcRotateCameraInputsManager;
  37386. /** @hidden */
  37387. _reset: () => void;
  37388. /**
  37389. * Defines the allowed panning axis.
  37390. */
  37391. panningAxis: Vector3;
  37392. protected _localDirection: Vector3;
  37393. protected _transformedDirection: Vector3;
  37394. private _bouncingBehavior;
  37395. /**
  37396. * Gets the bouncing behavior of the camera if it has been enabled.
  37397. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37398. */
  37399. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  37400. /**
  37401. * Defines if the bouncing behavior of the camera is enabled on the camera.
  37402. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37403. */
  37404. useBouncingBehavior: boolean;
  37405. private _framingBehavior;
  37406. /**
  37407. * Gets the framing behavior of the camera if it has been enabled.
  37408. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37409. */
  37410. readonly framingBehavior: Nullable<FramingBehavior>;
  37411. /**
  37412. * Defines if the framing behavior of the camera is enabled on the camera.
  37413. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37414. */
  37415. useFramingBehavior: boolean;
  37416. private _autoRotationBehavior;
  37417. /**
  37418. * Gets the auto rotation behavior of the camera if it has been enabled.
  37419. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37420. */
  37421. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  37422. /**
  37423. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  37424. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37425. */
  37426. useAutoRotationBehavior: boolean;
  37427. /**
  37428. * Observable triggered when the mesh target has been changed on the camera.
  37429. */
  37430. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  37431. /**
  37432. * Event raised when the camera is colliding with a mesh.
  37433. */
  37434. onCollide: (collidedMesh: AbstractMesh) => void;
  37435. /**
  37436. * Defines whether the camera should check collision with the objects oh the scene.
  37437. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  37438. */
  37439. checkCollisions: boolean;
  37440. /**
  37441. * Defines the collision radius of the camera.
  37442. * This simulates a sphere around the camera.
  37443. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37444. */
  37445. collisionRadius: Vector3;
  37446. protected _collider: Collider;
  37447. protected _previousPosition: Vector3;
  37448. protected _collisionVelocity: Vector3;
  37449. protected _newPosition: Vector3;
  37450. protected _previousAlpha: number;
  37451. protected _previousBeta: number;
  37452. protected _previousRadius: number;
  37453. protected _collisionTriggered: boolean;
  37454. protected _targetBoundingCenter: Nullable<Vector3>;
  37455. private _computationVector;
  37456. /**
  37457. * Instantiates a new ArcRotateCamera in a given scene
  37458. * @param name Defines the name of the camera
  37459. * @param alpha Defines the camera rotation along the logitudinal axis
  37460. * @param beta Defines the camera rotation along the latitudinal axis
  37461. * @param radius Defines the camera distance from its target
  37462. * @param target Defines the camera target
  37463. * @param scene Defines the scene the camera belongs to
  37464. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  37465. */
  37466. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37467. /** @hidden */
  37468. _initCache(): void;
  37469. /** @hidden */
  37470. _updateCache(ignoreParentClass?: boolean): void;
  37471. protected _getTargetPosition(): Vector3;
  37472. private _storedAlpha;
  37473. private _storedBeta;
  37474. private _storedRadius;
  37475. private _storedTarget;
  37476. private _storedTargetScreenOffset;
  37477. /**
  37478. * Stores the current state of the camera (alpha, beta, radius and target)
  37479. * @returns the camera itself
  37480. */
  37481. storeState(): Camera;
  37482. /**
  37483. * @hidden
  37484. * Restored camera state. You must call storeState() first
  37485. */
  37486. _restoreStateValues(): boolean;
  37487. /** @hidden */
  37488. _isSynchronizedViewMatrix(): boolean;
  37489. /**
  37490. * Attached controls to the current camera.
  37491. * @param element Defines the element the controls should be listened from
  37492. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37493. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  37494. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  37495. */
  37496. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  37497. /**
  37498. * Detach the current controls from the camera.
  37499. * The camera will stop reacting to inputs.
  37500. * @param element Defines the element to stop listening the inputs from
  37501. */
  37502. detachControl(element: HTMLElement): void;
  37503. /** @hidden */
  37504. _checkInputs(): void;
  37505. protected _checkLimits(): void;
  37506. /**
  37507. * Rebuilds angles (alpha, beta) and radius from the give position and target
  37508. */
  37509. rebuildAnglesAndRadius(): void;
  37510. /**
  37511. * Use a position to define the current camera related information like aplha, beta and radius
  37512. * @param position Defines the position to set the camera at
  37513. */
  37514. setPosition(position: Vector3): void;
  37515. /**
  37516. * Defines the target the camera should look at.
  37517. * This will automatically adapt alpha beta and radius to fit within the new target.
  37518. * @param target Defines the new target as a Vector or a mesh
  37519. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  37520. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  37521. */
  37522. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  37523. /** @hidden */
  37524. _getViewMatrix(): Matrix;
  37525. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  37526. /**
  37527. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  37528. * @param meshes Defines the mesh to zoom on
  37529. * @param doNotUpdateMaxZ Defines whether or not maxZ should be updated whilst zooming on the mesh (this can happen if the mesh is big and the maxradius pretty small for instance)
  37530. */
  37531. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  37532. /**
  37533. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  37534. * The target will be changed but the radius
  37535. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  37536. * @param doNotUpdateMaxZ Defines whether or not maxZ should be updated whilst zooming on the mesh (this can happen if the mesh is big and the maxradius pretty small for instance)
  37537. */
  37538. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  37539. min: Vector3;
  37540. max: Vector3;
  37541. distance: number;
  37542. }, doNotUpdateMaxZ?: boolean): void;
  37543. /**
  37544. * @override
  37545. * Override Camera.createRigCamera
  37546. */
  37547. createRigCamera(name: string, cameraIndex: number): Camera;
  37548. /**
  37549. * @hidden
  37550. * @override
  37551. * Override Camera._updateRigCameras
  37552. */
  37553. _updateRigCameras(): void;
  37554. /**
  37555. * Destroy the camera and release the current resources hold by it.
  37556. */
  37557. dispose(): void;
  37558. /**
  37559. * Gets the current object class name.
  37560. * @return the class name
  37561. */
  37562. getClassName(): string;
  37563. }
  37564. }
  37565. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  37566. import { Behavior } from "babylonjs/Behaviors/behavior";
  37567. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37568. /**
  37569. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  37570. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37571. */
  37572. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  37573. /**
  37574. * Gets the name of the behavior.
  37575. */
  37576. readonly name: string;
  37577. private _zoomStopsAnimation;
  37578. private _idleRotationSpeed;
  37579. private _idleRotationWaitTime;
  37580. private _idleRotationSpinupTime;
  37581. /**
  37582. * Sets the flag that indicates if user zooming should stop animation.
  37583. */
  37584. /**
  37585. * Gets the flag that indicates if user zooming should stop animation.
  37586. */
  37587. zoomStopsAnimation: boolean;
  37588. /**
  37589. * Sets the default speed at which the camera rotates around the model.
  37590. */
  37591. /**
  37592. * Gets the default speed at which the camera rotates around the model.
  37593. */
  37594. idleRotationSpeed: number;
  37595. /**
  37596. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  37597. */
  37598. /**
  37599. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  37600. */
  37601. idleRotationWaitTime: number;
  37602. /**
  37603. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37604. */
  37605. /**
  37606. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37607. */
  37608. idleRotationSpinupTime: number;
  37609. /**
  37610. * Gets a value indicating if the camera is currently rotating because of this behavior
  37611. */
  37612. readonly rotationInProgress: boolean;
  37613. private _onPrePointerObservableObserver;
  37614. private _onAfterCheckInputsObserver;
  37615. private _attachedCamera;
  37616. private _isPointerDown;
  37617. private _lastFrameTime;
  37618. private _lastInteractionTime;
  37619. private _cameraRotationSpeed;
  37620. /**
  37621. * Initializes the behavior.
  37622. */
  37623. init(): void;
  37624. /**
  37625. * Attaches the behavior to its arc rotate camera.
  37626. * @param camera Defines the camera to attach the behavior to
  37627. */
  37628. attach(camera: ArcRotateCamera): void;
  37629. /**
  37630. * Detaches the behavior from its current arc rotate camera.
  37631. */
  37632. detach(): void;
  37633. /**
  37634. * Returns true if user is scrolling.
  37635. * @return true if user is scrolling.
  37636. */
  37637. private _userIsZooming;
  37638. private _lastFrameRadius;
  37639. private _shouldAnimationStopForInteraction;
  37640. /**
  37641. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37642. */
  37643. private _applyUserInteraction;
  37644. private _userIsMoving;
  37645. }
  37646. }
  37647. declare module "babylonjs/Behaviors/Cameras/index" {
  37648. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37649. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37650. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  37651. }
  37652. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  37653. import { Mesh } from "babylonjs/Meshes/mesh";
  37654. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37655. import { Behavior } from "babylonjs/Behaviors/behavior";
  37656. /**
  37657. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  37658. */
  37659. export class AttachToBoxBehavior implements Behavior<Mesh> {
  37660. private ui;
  37661. /**
  37662. * The name of the behavior
  37663. */
  37664. name: string;
  37665. /**
  37666. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  37667. */
  37668. distanceAwayFromFace: number;
  37669. /**
  37670. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  37671. */
  37672. distanceAwayFromBottomOfFace: number;
  37673. private _faceVectors;
  37674. private _target;
  37675. private _scene;
  37676. private _onRenderObserver;
  37677. private _tmpMatrix;
  37678. private _tmpVector;
  37679. /**
  37680. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  37681. * @param ui The transform node that should be attched to the mesh
  37682. */
  37683. constructor(ui: TransformNode);
  37684. /**
  37685. * Initializes the behavior
  37686. */
  37687. init(): void;
  37688. private _closestFace;
  37689. private _zeroVector;
  37690. private _lookAtTmpMatrix;
  37691. private _lookAtToRef;
  37692. /**
  37693. * Attaches the AttachToBoxBehavior to the passed in mesh
  37694. * @param target The mesh that the specified node will be attached to
  37695. */
  37696. attach(target: Mesh): void;
  37697. /**
  37698. * Detaches the behavior from the mesh
  37699. */
  37700. detach(): void;
  37701. }
  37702. }
  37703. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  37704. import { Behavior } from "babylonjs/Behaviors/behavior";
  37705. import { Mesh } from "babylonjs/Meshes/mesh";
  37706. /**
  37707. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  37708. */
  37709. export class FadeInOutBehavior implements Behavior<Mesh> {
  37710. /**
  37711. * Time in milliseconds to delay before fading in (Default: 0)
  37712. */
  37713. delay: number;
  37714. /**
  37715. * Time in milliseconds for the mesh to fade in (Default: 300)
  37716. */
  37717. fadeInTime: number;
  37718. private _millisecondsPerFrame;
  37719. private _hovered;
  37720. private _hoverValue;
  37721. private _ownerNode;
  37722. /**
  37723. * Instatiates the FadeInOutBehavior
  37724. */
  37725. constructor();
  37726. /**
  37727. * The name of the behavior
  37728. */
  37729. readonly name: string;
  37730. /**
  37731. * Initializes the behavior
  37732. */
  37733. init(): void;
  37734. /**
  37735. * Attaches the fade behavior on the passed in mesh
  37736. * @param ownerNode The mesh that will be faded in/out once attached
  37737. */
  37738. attach(ownerNode: Mesh): void;
  37739. /**
  37740. * Detaches the behavior from the mesh
  37741. */
  37742. detach(): void;
  37743. /**
  37744. * Triggers the mesh to begin fading in or out
  37745. * @param value if the object should fade in or out (true to fade in)
  37746. */
  37747. fadeIn(value: boolean): void;
  37748. private _update;
  37749. private _setAllVisibility;
  37750. }
  37751. }
  37752. declare module "babylonjs/Misc/pivotTools" {
  37753. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37754. /**
  37755. * Class containing a set of static utilities functions for managing Pivots
  37756. * @hidden
  37757. */
  37758. export class PivotTools {
  37759. private static _PivotCached;
  37760. private static _OldPivotPoint;
  37761. private static _PivotTranslation;
  37762. private static _PivotTmpVector;
  37763. /** @hidden */
  37764. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  37765. /** @hidden */
  37766. static _RestorePivotPoint(mesh: AbstractMesh): void;
  37767. }
  37768. }
  37769. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  37770. import { Scene } from "babylonjs/scene";
  37771. import { Vector4 } from "babylonjs/Maths/math.vector";
  37772. import { Mesh } from "babylonjs/Meshes/mesh";
  37773. import { Nullable } from "babylonjs/types";
  37774. import { Plane } from "babylonjs/Maths/math.plane";
  37775. /**
  37776. * Class containing static functions to help procedurally build meshes
  37777. */
  37778. export class PlaneBuilder {
  37779. /**
  37780. * Creates a plane mesh
  37781. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  37782. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  37783. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  37784. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  37785. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  37786. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  37787. * @param name defines the name of the mesh
  37788. * @param options defines the options used to create the mesh
  37789. * @param scene defines the hosting scene
  37790. * @returns the plane mesh
  37791. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  37792. */
  37793. static CreatePlane(name: string, options: {
  37794. size?: number;
  37795. width?: number;
  37796. height?: number;
  37797. sideOrientation?: number;
  37798. frontUVs?: Vector4;
  37799. backUVs?: Vector4;
  37800. updatable?: boolean;
  37801. sourcePlane?: Plane;
  37802. }, scene?: Nullable<Scene>): Mesh;
  37803. }
  37804. }
  37805. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  37806. import { Behavior } from "babylonjs/Behaviors/behavior";
  37807. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37808. import { Observable } from "babylonjs/Misc/observable";
  37809. import { Vector3 } from "babylonjs/Maths/math.vector";
  37810. import { Ray } from "babylonjs/Culling/ray";
  37811. import "babylonjs/Meshes/Builders/planeBuilder";
  37812. /**
  37813. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  37814. */
  37815. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  37816. private static _AnyMouseID;
  37817. /**
  37818. * Abstract mesh the behavior is set on
  37819. */
  37820. attachedNode: AbstractMesh;
  37821. private _dragPlane;
  37822. private _scene;
  37823. private _pointerObserver;
  37824. private _beforeRenderObserver;
  37825. private static _planeScene;
  37826. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  37827. /**
  37828. * The maximum tolerated angle between the drag plane and dragging pointer rays to trigger pointer events. Set to 0 to allow any angle (default: 0)
  37829. */
  37830. maxDragAngle: number;
  37831. /**
  37832. * @hidden
  37833. */
  37834. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  37835. /**
  37836. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37837. */
  37838. currentDraggingPointerID: number;
  37839. /**
  37840. * The last position where the pointer hit the drag plane in world space
  37841. */
  37842. lastDragPosition: Vector3;
  37843. /**
  37844. * If the behavior is currently in a dragging state
  37845. */
  37846. dragging: boolean;
  37847. /**
  37848. * The distance towards the target drag position to move each frame. This can be useful to avoid jitter. Set this to 1 for no delay. (Default: 0.2)
  37849. */
  37850. dragDeltaRatio: number;
  37851. /**
  37852. * If the drag plane orientation should be updated during the dragging (Default: true)
  37853. */
  37854. updateDragPlane: boolean;
  37855. private _debugMode;
  37856. private _moving;
  37857. /**
  37858. * Fires each time the attached mesh is dragged with the pointer
  37859. * * delta between last drag position and current drag position in world space
  37860. * * dragDistance along the drag axis
  37861. * * dragPlaneNormal normal of the current drag plane used during the drag
  37862. * * dragPlanePoint in world space where the drag intersects the drag plane
  37863. */
  37864. onDragObservable: Observable<{
  37865. delta: Vector3;
  37866. dragPlanePoint: Vector3;
  37867. dragPlaneNormal: Vector3;
  37868. dragDistance: number;
  37869. pointerId: number;
  37870. }>;
  37871. /**
  37872. * Fires each time a drag begins (eg. mouse down on mesh)
  37873. */
  37874. onDragStartObservable: Observable<{
  37875. dragPlanePoint: Vector3;
  37876. pointerId: number;
  37877. }>;
  37878. /**
  37879. * Fires each time a drag ends (eg. mouse release after drag)
  37880. */
  37881. onDragEndObservable: Observable<{
  37882. dragPlanePoint: Vector3;
  37883. pointerId: number;
  37884. }>;
  37885. /**
  37886. * If the attached mesh should be moved when dragged
  37887. */
  37888. moveAttached: boolean;
  37889. /**
  37890. * If the drag behavior will react to drag events (Default: true)
  37891. */
  37892. enabled: boolean;
  37893. /**
  37894. * If pointer events should start and release the drag (Default: true)
  37895. */
  37896. startAndReleaseDragOnPointerEvents: boolean;
  37897. /**
  37898. * If camera controls should be detached during the drag
  37899. */
  37900. detachCameraControls: boolean;
  37901. /**
  37902. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  37903. */
  37904. useObjectOrienationForDragging: boolean;
  37905. private _options;
  37906. /**
  37907. * Creates a pointer drag behavior that can be attached to a mesh
  37908. * @param options The drag axis or normal of the plane that will be dragged across. If no options are specified the drag plane will always face the ray's origin (eg. camera)
  37909. */
  37910. constructor(options?: {
  37911. dragAxis?: Vector3;
  37912. dragPlaneNormal?: Vector3;
  37913. });
  37914. /**
  37915. * Predicate to determine if it is valid to move the object to a new position when it is moved
  37916. */
  37917. validateDrag: (targetPosition: Vector3) => boolean;
  37918. /**
  37919. * The name of the behavior
  37920. */
  37921. readonly name: string;
  37922. /**
  37923. * Initializes the behavior
  37924. */
  37925. init(): void;
  37926. private _tmpVector;
  37927. private _alternatePickedPoint;
  37928. private _worldDragAxis;
  37929. private _targetPosition;
  37930. private _attachedElement;
  37931. /**
  37932. * Attaches the drag behavior the passed in mesh
  37933. * @param ownerNode The mesh that will be dragged around once attached
  37934. * @param predicate Predicate to use for pick filtering
  37935. */
  37936. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  37937. /**
  37938. * Force relase the drag action by code.
  37939. */
  37940. releaseDrag(): void;
  37941. private _startDragRay;
  37942. private _lastPointerRay;
  37943. /**
  37944. * Simulates the start of a pointer drag event on the behavior
  37945. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  37946. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  37947. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  37948. */
  37949. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  37950. private _startDrag;
  37951. private _dragDelta;
  37952. private _moveDrag;
  37953. private _pickWithRayOnDragPlane;
  37954. private _pointA;
  37955. private _pointB;
  37956. private _pointC;
  37957. private _lineA;
  37958. private _lineB;
  37959. private _localAxis;
  37960. private _lookAt;
  37961. private _updateDragPlanePosition;
  37962. /**
  37963. * Detaches the behavior from the mesh
  37964. */
  37965. detach(): void;
  37966. }
  37967. }
  37968. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  37969. import { Mesh } from "babylonjs/Meshes/mesh";
  37970. import { Behavior } from "babylonjs/Behaviors/behavior";
  37971. /**
  37972. * A behavior that when attached to a mesh will allow the mesh to be scaled
  37973. */
  37974. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  37975. private _dragBehaviorA;
  37976. private _dragBehaviorB;
  37977. private _startDistance;
  37978. private _initialScale;
  37979. private _targetScale;
  37980. private _ownerNode;
  37981. private _sceneRenderObserver;
  37982. /**
  37983. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  37984. */
  37985. constructor();
  37986. /**
  37987. * The name of the behavior
  37988. */
  37989. readonly name: string;
  37990. /**
  37991. * Initializes the behavior
  37992. */
  37993. init(): void;
  37994. private _getCurrentDistance;
  37995. /**
  37996. * Attaches the scale behavior the passed in mesh
  37997. * @param ownerNode The mesh that will be scaled around once attached
  37998. */
  37999. attach(ownerNode: Mesh): void;
  38000. /**
  38001. * Detaches the behavior from the mesh
  38002. */
  38003. detach(): void;
  38004. }
  38005. }
  38006. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  38007. import { Behavior } from "babylonjs/Behaviors/behavior";
  38008. import { Mesh } from "babylonjs/Meshes/mesh";
  38009. import { Observable } from "babylonjs/Misc/observable";
  38010. /**
  38011. * A behavior that when attached to a mesh will allow the mesh to be dragged around based on directions and origin of the pointer's ray
  38012. */
  38013. export class SixDofDragBehavior implements Behavior<Mesh> {
  38014. private static _virtualScene;
  38015. private _ownerNode;
  38016. private _sceneRenderObserver;
  38017. private _scene;
  38018. private _targetPosition;
  38019. private _virtualOriginMesh;
  38020. private _virtualDragMesh;
  38021. private _pointerObserver;
  38022. private _moving;
  38023. private _startingOrientation;
  38024. /**
  38025. * How much faster the object should move when the controller is moving towards it. This is useful to bring objects that are far away from the user to them faster. Set this to 0 to avoid any speed increase. (Default: 3)
  38026. */
  38027. private zDragFactor;
  38028. /**
  38029. * If the object should rotate to face the drag origin
  38030. */
  38031. rotateDraggedObject: boolean;
  38032. /**
  38033. * If the behavior is currently in a dragging state
  38034. */
  38035. dragging: boolean;
  38036. /**
  38037. * The distance towards the target drag position to move each frame. This can be useful to avoid jitter. Set this to 1 for no delay. (Default: 0.2)
  38038. */
  38039. dragDeltaRatio: number;
  38040. /**
  38041. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38042. */
  38043. currentDraggingPointerID: number;
  38044. /**
  38045. * If camera controls should be detached during the drag
  38046. */
  38047. detachCameraControls: boolean;
  38048. /**
  38049. * Fires each time a drag starts
  38050. */
  38051. onDragStartObservable: Observable<{}>;
  38052. /**
  38053. * Fires each time a drag ends (eg. mouse release after drag)
  38054. */
  38055. onDragEndObservable: Observable<{}>;
  38056. /**
  38057. * Instantiates a behavior that when attached to a mesh will allow the mesh to be dragged around based on directions and origin of the pointer's ray
  38058. */
  38059. constructor();
  38060. /**
  38061. * The name of the behavior
  38062. */
  38063. readonly name: string;
  38064. /**
  38065. * Initializes the behavior
  38066. */
  38067. init(): void;
  38068. /**
  38069. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  38070. */
  38071. private readonly _pointerCamera;
  38072. /**
  38073. * Attaches the scale behavior the passed in mesh
  38074. * @param ownerNode The mesh that will be scaled around once attached
  38075. */
  38076. attach(ownerNode: Mesh): void;
  38077. /**
  38078. * Detaches the behavior from the mesh
  38079. */
  38080. detach(): void;
  38081. }
  38082. }
  38083. declare module "babylonjs/Behaviors/Meshes/index" {
  38084. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  38085. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  38086. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  38087. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  38088. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  38089. }
  38090. declare module "babylonjs/Behaviors/index" {
  38091. export * from "babylonjs/Behaviors/behavior";
  38092. export * from "babylonjs/Behaviors/Cameras/index";
  38093. export * from "babylonjs/Behaviors/Meshes/index";
  38094. }
  38095. declare module "babylonjs/Bones/boneIKController" {
  38096. import { Bone } from "babylonjs/Bones/bone";
  38097. import { Vector3 } from "babylonjs/Maths/math.vector";
  38098. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38099. import { Nullable } from "babylonjs/types";
  38100. /**
  38101. * Class used to apply inverse kinematics to bones
  38102. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  38103. */
  38104. export class BoneIKController {
  38105. private static _tmpVecs;
  38106. private static _tmpQuat;
  38107. private static _tmpMats;
  38108. /**
  38109. * Gets or sets the target mesh
  38110. */
  38111. targetMesh: AbstractMesh;
  38112. /** Gets or sets the mesh used as pole */
  38113. poleTargetMesh: AbstractMesh;
  38114. /**
  38115. * Gets or sets the bone used as pole
  38116. */
  38117. poleTargetBone: Nullable<Bone>;
  38118. /**
  38119. * Gets or sets the target position
  38120. */
  38121. targetPosition: Vector3;
  38122. /**
  38123. * Gets or sets the pole target position
  38124. */
  38125. poleTargetPosition: Vector3;
  38126. /**
  38127. * Gets or sets the pole target local offset
  38128. */
  38129. poleTargetLocalOffset: Vector3;
  38130. /**
  38131. * Gets or sets the pole angle
  38132. */
  38133. poleAngle: number;
  38134. /**
  38135. * Gets or sets the mesh associated with the controller
  38136. */
  38137. mesh: AbstractMesh;
  38138. /**
  38139. * The amount to slerp (spherical linear interpolation) to the target. Set this to a value between 0 and 1 (a value of 1 disables slerp)
  38140. */
  38141. slerpAmount: number;
  38142. private _bone1Quat;
  38143. private _bone1Mat;
  38144. private _bone2Ang;
  38145. private _bone1;
  38146. private _bone2;
  38147. private _bone1Length;
  38148. private _bone2Length;
  38149. private _maxAngle;
  38150. private _maxReach;
  38151. private _rightHandedSystem;
  38152. private _bendAxis;
  38153. private _slerping;
  38154. private _adjustRoll;
  38155. /**
  38156. * Gets or sets maximum allowed angle
  38157. */
  38158. maxAngle: number;
  38159. /**
  38160. * Creates a new BoneIKController
  38161. * @param mesh defines the mesh to control
  38162. * @param bone defines the bone to control
  38163. * @param options defines options to set up the controller
  38164. */
  38165. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  38166. targetMesh?: AbstractMesh;
  38167. poleTargetMesh?: AbstractMesh;
  38168. poleTargetBone?: Bone;
  38169. poleTargetLocalOffset?: Vector3;
  38170. poleAngle?: number;
  38171. bendAxis?: Vector3;
  38172. maxAngle?: number;
  38173. slerpAmount?: number;
  38174. });
  38175. private _setMaxAngle;
  38176. /**
  38177. * Force the controller to update the bones
  38178. */
  38179. update(): void;
  38180. }
  38181. }
  38182. declare module "babylonjs/Bones/boneLookController" {
  38183. import { Vector3 } from "babylonjs/Maths/math.vector";
  38184. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38185. import { Bone } from "babylonjs/Bones/bone";
  38186. import { Space } from "babylonjs/Maths/math.axis";
  38187. /**
  38188. * Class used to make a bone look toward a point in space
  38189. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  38190. */
  38191. export class BoneLookController {
  38192. private static _tmpVecs;
  38193. private static _tmpQuat;
  38194. private static _tmpMats;
  38195. /**
  38196. * The target Vector3 that the bone will look at
  38197. */
  38198. target: Vector3;
  38199. /**
  38200. * The mesh that the bone is attached to
  38201. */
  38202. mesh: AbstractMesh;
  38203. /**
  38204. * The bone that will be looking to the target
  38205. */
  38206. bone: Bone;
  38207. /**
  38208. * The up axis of the coordinate system that is used when the bone is rotated
  38209. */
  38210. upAxis: Vector3;
  38211. /**
  38212. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  38213. */
  38214. upAxisSpace: Space;
  38215. /**
  38216. * Used to make an adjustment to the yaw of the bone
  38217. */
  38218. adjustYaw: number;
  38219. /**
  38220. * Used to make an adjustment to the pitch of the bone
  38221. */
  38222. adjustPitch: number;
  38223. /**
  38224. * Used to make an adjustment to the roll of the bone
  38225. */
  38226. adjustRoll: number;
  38227. /**
  38228. * The amount to slerp (spherical linear interpolation) to the target. Set this to a value between 0 and 1 (a value of 1 disables slerp)
  38229. */
  38230. slerpAmount: number;
  38231. private _minYaw;
  38232. private _maxYaw;
  38233. private _minPitch;
  38234. private _maxPitch;
  38235. private _minYawSin;
  38236. private _minYawCos;
  38237. private _maxYawSin;
  38238. private _maxYawCos;
  38239. private _midYawConstraint;
  38240. private _minPitchTan;
  38241. private _maxPitchTan;
  38242. private _boneQuat;
  38243. private _slerping;
  38244. private _transformYawPitch;
  38245. private _transformYawPitchInv;
  38246. private _firstFrameSkipped;
  38247. private _yawRange;
  38248. private _fowardAxis;
  38249. /**
  38250. * Gets or sets the minimum yaw angle that the bone can look to
  38251. */
  38252. minYaw: number;
  38253. /**
  38254. * Gets or sets the maximum yaw angle that the bone can look to
  38255. */
  38256. maxYaw: number;
  38257. /**
  38258. * Gets or sets the minimum pitch angle that the bone can look to
  38259. */
  38260. minPitch: number;
  38261. /**
  38262. * Gets or sets the maximum pitch angle that the bone can look to
  38263. */
  38264. maxPitch: number;
  38265. /**
  38266. * Create a BoneLookController
  38267. * @param mesh the mesh that the bone belongs to
  38268. * @param bone the bone that will be looking to the target
  38269. * @param target the target Vector3 to look at
  38270. * @param options optional settings:
  38271. * * maxYaw: the maximum angle the bone will yaw to
  38272. * * minYaw: the minimum angle the bone will yaw to
  38273. * * maxPitch: the maximum angle the bone will pitch to
  38274. * * minPitch: the minimum angle the bone will yaw to
  38275. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  38276. * * upAxis: the up axis of the coordinate system
  38277. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  38278. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  38279. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  38280. * * adjustYaw: used to make an adjustment to the yaw of the bone
  38281. * * adjustPitch: used to make an adjustment to the pitch of the bone
  38282. * * adjustRoll: used to make an adjustment to the roll of the bone
  38283. **/
  38284. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  38285. maxYaw?: number;
  38286. minYaw?: number;
  38287. maxPitch?: number;
  38288. minPitch?: number;
  38289. slerpAmount?: number;
  38290. upAxis?: Vector3;
  38291. upAxisSpace?: Space;
  38292. yawAxis?: Vector3;
  38293. pitchAxis?: Vector3;
  38294. adjustYaw?: number;
  38295. adjustPitch?: number;
  38296. adjustRoll?: number;
  38297. });
  38298. /**
  38299. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  38300. */
  38301. update(): void;
  38302. private _getAngleDiff;
  38303. private _getAngleBetween;
  38304. private _isAngleBetween;
  38305. }
  38306. }
  38307. declare module "babylonjs/Bones/index" {
  38308. export * from "babylonjs/Bones/bone";
  38309. export * from "babylonjs/Bones/boneIKController";
  38310. export * from "babylonjs/Bones/boneLookController";
  38311. export * from "babylonjs/Bones/skeleton";
  38312. }
  38313. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  38314. import { Nullable } from "babylonjs/types";
  38315. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38316. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38317. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38318. /**
  38319. * Manage the gamepad inputs to control an arc rotate camera.
  38320. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38321. */
  38322. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  38323. /**
  38324. * Defines the camera the input is attached to.
  38325. */
  38326. camera: ArcRotateCamera;
  38327. /**
  38328. * Defines the gamepad the input is gathering event from.
  38329. */
  38330. gamepad: Nullable<Gamepad>;
  38331. /**
  38332. * Defines the gamepad rotation sensiblity.
  38333. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38334. */
  38335. gamepadRotationSensibility: number;
  38336. /**
  38337. * Defines the gamepad move sensiblity.
  38338. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38339. */
  38340. gamepadMoveSensibility: number;
  38341. private _onGamepadConnectedObserver;
  38342. private _onGamepadDisconnectedObserver;
  38343. /**
  38344. * Attach the input controls to a specific dom element to get the input from.
  38345. * @param element Defines the element the controls should be listened from
  38346. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38347. */
  38348. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38349. /**
  38350. * Detach the current controls from the specified dom element.
  38351. * @param element Defines the element to stop listening the inputs from
  38352. */
  38353. detachControl(element: Nullable<HTMLElement>): void;
  38354. /**
  38355. * Update the current camera state depending on the inputs that have been used this frame.
  38356. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38357. */
  38358. checkInputs(): void;
  38359. /**
  38360. * Gets the class name of the current intput.
  38361. * @returns the class name
  38362. */
  38363. getClassName(): string;
  38364. /**
  38365. * Get the friendly name associated with the input class.
  38366. * @returns the input friendly name
  38367. */
  38368. getSimpleName(): string;
  38369. }
  38370. }
  38371. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  38372. import { Nullable } from "babylonjs/types";
  38373. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38374. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38375. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  38376. interface ArcRotateCameraInputsManager {
  38377. /**
  38378. * Add orientation input support to the input manager.
  38379. * @returns the current input manager
  38380. */
  38381. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  38382. }
  38383. }
  38384. /**
  38385. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  38386. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38387. */
  38388. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  38389. /**
  38390. * Defines the camera the input is attached to.
  38391. */
  38392. camera: ArcRotateCamera;
  38393. /**
  38394. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  38395. */
  38396. alphaCorrection: number;
  38397. /**
  38398. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  38399. */
  38400. gammaCorrection: number;
  38401. private _alpha;
  38402. private _gamma;
  38403. private _dirty;
  38404. private _deviceOrientationHandler;
  38405. /**
  38406. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  38407. */
  38408. constructor();
  38409. /**
  38410. * Attach the input controls to a specific dom element to get the input from.
  38411. * @param element Defines the element the controls should be listened from
  38412. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38413. */
  38414. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38415. /** @hidden */
  38416. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  38417. /**
  38418. * Update the current camera state depending on the inputs that have been used this frame.
  38419. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38420. */
  38421. checkInputs(): void;
  38422. /**
  38423. * Detach the current controls from the specified dom element.
  38424. * @param element Defines the element to stop listening the inputs from
  38425. */
  38426. detachControl(element: Nullable<HTMLElement>): void;
  38427. /**
  38428. * Gets the class name of the current intput.
  38429. * @returns the class name
  38430. */
  38431. getClassName(): string;
  38432. /**
  38433. * Get the friendly name associated with the input class.
  38434. * @returns the input friendly name
  38435. */
  38436. getSimpleName(): string;
  38437. }
  38438. }
  38439. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  38440. import { Nullable } from "babylonjs/types";
  38441. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38442. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38443. /**
  38444. * Listen to mouse events to control the camera.
  38445. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38446. */
  38447. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  38448. /**
  38449. * Defines the camera the input is attached to.
  38450. */
  38451. camera: FlyCamera;
  38452. /**
  38453. * Defines if touch is enabled. (Default is true.)
  38454. */
  38455. touchEnabled: boolean;
  38456. /**
  38457. * Defines the buttons associated with the input to handle camera rotation.
  38458. */
  38459. buttons: number[];
  38460. /**
  38461. * Assign buttons for Yaw control.
  38462. */
  38463. buttonsYaw: number[];
  38464. /**
  38465. * Assign buttons for Pitch control.
  38466. */
  38467. buttonsPitch: number[];
  38468. /**
  38469. * Assign buttons for Roll control.
  38470. */
  38471. buttonsRoll: number[];
  38472. /**
  38473. * Detect if any button is being pressed while mouse is moved.
  38474. * -1 = Mouse locked.
  38475. * 0 = Left button.
  38476. * 1 = Middle Button.
  38477. * 2 = Right Button.
  38478. */
  38479. activeButton: number;
  38480. /**
  38481. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  38482. * Higher values reduce its sensitivity.
  38483. */
  38484. angularSensibility: number;
  38485. private _mousemoveCallback;
  38486. private _observer;
  38487. private _rollObserver;
  38488. private previousPosition;
  38489. private noPreventDefault;
  38490. private element;
  38491. /**
  38492. * Listen to mouse events to control the camera.
  38493. * @param touchEnabled Define if touch is enabled. (Default is true.)
  38494. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38495. */
  38496. constructor(touchEnabled?: boolean);
  38497. /**
  38498. * Attach the mouse control to the HTML DOM element.
  38499. * @param element Defines the element that listens to the input events.
  38500. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  38501. */
  38502. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38503. /**
  38504. * Detach the current controls from the specified dom element.
  38505. * @param element Defines the element to stop listening the inputs from
  38506. */
  38507. detachControl(element: Nullable<HTMLElement>): void;
  38508. /**
  38509. * Gets the class name of the current input.
  38510. * @returns the class name.
  38511. */
  38512. getClassName(): string;
  38513. /**
  38514. * Get the friendly name associated with the input class.
  38515. * @returns the input's friendly name.
  38516. */
  38517. getSimpleName(): string;
  38518. private _pointerInput;
  38519. private _onMouseMove;
  38520. /**
  38521. * Rotate camera by mouse offset.
  38522. */
  38523. private rotateCamera;
  38524. }
  38525. }
  38526. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  38527. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38528. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38529. /**
  38530. * Default Inputs manager for the FlyCamera.
  38531. * It groups all the default supported inputs for ease of use.
  38532. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38533. */
  38534. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  38535. /**
  38536. * Instantiates a new FlyCameraInputsManager.
  38537. * @param camera Defines the camera the inputs belong to.
  38538. */
  38539. constructor(camera: FlyCamera);
  38540. /**
  38541. * Add keyboard input support to the input manager.
  38542. * @returns the new FlyCameraKeyboardMoveInput().
  38543. */
  38544. addKeyboard(): FlyCameraInputsManager;
  38545. /**
  38546. * Add mouse input support to the input manager.
  38547. * @param touchEnabled Enable touch screen support.
  38548. * @returns the new FlyCameraMouseInput().
  38549. */
  38550. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  38551. }
  38552. }
  38553. declare module "babylonjs/Cameras/flyCamera" {
  38554. import { Scene } from "babylonjs/scene";
  38555. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  38556. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38557. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38558. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  38559. /**
  38560. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38561. * such as in a 3D Space Shooter or a Flight Simulator.
  38562. */
  38563. export class FlyCamera extends TargetCamera {
  38564. /**
  38565. * Define the collision ellipsoid of the camera.
  38566. * This is helpful for simulating a camera body, like a player's body.
  38567. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38568. */
  38569. ellipsoid: Vector3;
  38570. /**
  38571. * Define an offset for the position of the ellipsoid around the camera.
  38572. * This can be helpful if the camera is attached away from the player's body center,
  38573. * such as at its head.
  38574. */
  38575. ellipsoidOffset: Vector3;
  38576. /**
  38577. * Enable or disable collisions of the camera with the rest of the scene objects.
  38578. */
  38579. checkCollisions: boolean;
  38580. /**
  38581. * Enable or disable gravity on the camera.
  38582. */
  38583. applyGravity: boolean;
  38584. /**
  38585. * Define the current direction the camera is moving to.
  38586. */
  38587. cameraDirection: Vector3;
  38588. /**
  38589. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  38590. * This overrides and empties cameraRotation.
  38591. */
  38592. rotationQuaternion: Quaternion;
  38593. /**
  38594. * Track Roll to maintain the wanted Rolling when looking around.
  38595. */
  38596. _trackRoll: number;
  38597. /**
  38598. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  38599. */
  38600. rollCorrect: number;
  38601. /**
  38602. * Mimic a banked turn, Rolling the camera when Yawing.
  38603. * It's recommended to use rollCorrect = 10 for faster banking correction.
  38604. */
  38605. bankedTurn: boolean;
  38606. /**
  38607. * Limit in radians for how much Roll banking will add. (Default: 90°)
  38608. */
  38609. bankedTurnLimit: number;
  38610. /**
  38611. * Value of 0 disables the banked Roll.
  38612. * Value of 1 is equal to the Yaw angle in radians.
  38613. */
  38614. bankedTurnMultiplier: number;
  38615. /**
  38616. * The inputs manager loads all the input sources, such as keyboard and mouse.
  38617. */
  38618. inputs: FlyCameraInputsManager;
  38619. /**
  38620. * Gets the input sensibility for mouse input.
  38621. * Higher values reduce sensitivity.
  38622. */
  38623. /**
  38624. * Sets the input sensibility for a mouse input.
  38625. * Higher values reduce sensitivity.
  38626. */
  38627. angularSensibility: number;
  38628. /**
  38629. * Get the keys for camera movement forward.
  38630. */
  38631. /**
  38632. * Set the keys for camera movement forward.
  38633. */
  38634. keysForward: number[];
  38635. /**
  38636. * Get the keys for camera movement backward.
  38637. */
  38638. keysBackward: number[];
  38639. /**
  38640. * Get the keys for camera movement up.
  38641. */
  38642. /**
  38643. * Set the keys for camera movement up.
  38644. */
  38645. keysUp: number[];
  38646. /**
  38647. * Get the keys for camera movement down.
  38648. */
  38649. /**
  38650. * Set the keys for camera movement down.
  38651. */
  38652. keysDown: number[];
  38653. /**
  38654. * Get the keys for camera movement left.
  38655. */
  38656. /**
  38657. * Set the keys for camera movement left.
  38658. */
  38659. keysLeft: number[];
  38660. /**
  38661. * Set the keys for camera movement right.
  38662. */
  38663. /**
  38664. * Set the keys for camera movement right.
  38665. */
  38666. keysRight: number[];
  38667. /**
  38668. * Event raised when the camera collides with a mesh in the scene.
  38669. */
  38670. onCollide: (collidedMesh: AbstractMesh) => void;
  38671. private _collider;
  38672. private _needMoveForGravity;
  38673. private _oldPosition;
  38674. private _diffPosition;
  38675. private _newPosition;
  38676. /** @hidden */
  38677. _localDirection: Vector3;
  38678. /** @hidden */
  38679. _transformedDirection: Vector3;
  38680. /**
  38681. * Instantiates a FlyCamera.
  38682. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38683. * such as in a 3D Space Shooter or a Flight Simulator.
  38684. * @param name Define the name of the camera in the scene.
  38685. * @param position Define the starting position of the camera in the scene.
  38686. * @param scene Define the scene the camera belongs to.
  38687. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  38688. */
  38689. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38690. /**
  38691. * Attach a control to the HTML DOM element.
  38692. * @param element Defines the element that listens to the input events.
  38693. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  38694. */
  38695. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38696. /**
  38697. * Detach a control from the HTML DOM element.
  38698. * The camera will stop reacting to that input.
  38699. * @param element Defines the element that listens to the input events.
  38700. */
  38701. detachControl(element: HTMLElement): void;
  38702. private _collisionMask;
  38703. /**
  38704. * Get the mask that the camera ignores in collision events.
  38705. */
  38706. /**
  38707. * Set the mask that the camera ignores in collision events.
  38708. */
  38709. collisionMask: number;
  38710. /** @hidden */
  38711. _collideWithWorld(displacement: Vector3): void;
  38712. /** @hidden */
  38713. private _onCollisionPositionChange;
  38714. /** @hidden */
  38715. _checkInputs(): void;
  38716. /** @hidden */
  38717. _decideIfNeedsToMove(): boolean;
  38718. /** @hidden */
  38719. _updatePosition(): void;
  38720. /**
  38721. * Restore the Roll to its target value at the rate specified.
  38722. * @param rate - Higher means slower restoring.
  38723. * @hidden
  38724. */
  38725. restoreRoll(rate: number): void;
  38726. /**
  38727. * Destroy the camera and release the current resources held by it.
  38728. */
  38729. dispose(): void;
  38730. /**
  38731. * Get the current object class name.
  38732. * @returns the class name.
  38733. */
  38734. getClassName(): string;
  38735. }
  38736. }
  38737. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  38738. import { Nullable } from "babylonjs/types";
  38739. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38740. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38741. /**
  38742. * Listen to keyboard events to control the camera.
  38743. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38744. */
  38745. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  38746. /**
  38747. * Defines the camera the input is attached to.
  38748. */
  38749. camera: FlyCamera;
  38750. /**
  38751. * The list of keyboard keys used to control the forward move of the camera.
  38752. */
  38753. keysForward: number[];
  38754. /**
  38755. * The list of keyboard keys used to control the backward move of the camera.
  38756. */
  38757. keysBackward: number[];
  38758. /**
  38759. * The list of keyboard keys used to control the forward move of the camera.
  38760. */
  38761. keysUp: number[];
  38762. /**
  38763. * The list of keyboard keys used to control the backward move of the camera.
  38764. */
  38765. keysDown: number[];
  38766. /**
  38767. * The list of keyboard keys used to control the right strafe move of the camera.
  38768. */
  38769. keysRight: number[];
  38770. /**
  38771. * The list of keyboard keys used to control the left strafe move of the camera.
  38772. */
  38773. keysLeft: number[];
  38774. private _keys;
  38775. private _onCanvasBlurObserver;
  38776. private _onKeyboardObserver;
  38777. private _engine;
  38778. private _scene;
  38779. /**
  38780. * Attach the input controls to a specific dom element to get the input from.
  38781. * @param element Defines the element the controls should be listened from
  38782. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38783. */
  38784. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38785. /**
  38786. * Detach the current controls from the specified dom element.
  38787. * @param element Defines the element to stop listening the inputs from
  38788. */
  38789. detachControl(element: Nullable<HTMLElement>): void;
  38790. /**
  38791. * Gets the class name of the current intput.
  38792. * @returns the class name
  38793. */
  38794. getClassName(): string;
  38795. /** @hidden */
  38796. _onLostFocus(e: FocusEvent): void;
  38797. /**
  38798. * Get the friendly name associated with the input class.
  38799. * @returns the input friendly name
  38800. */
  38801. getSimpleName(): string;
  38802. /**
  38803. * Update the current camera state depending on the inputs that have been used this frame.
  38804. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38805. */
  38806. checkInputs(): void;
  38807. }
  38808. }
  38809. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  38810. import { Nullable } from "babylonjs/types";
  38811. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38812. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38813. /**
  38814. * Manage the mouse wheel inputs to control a follow camera.
  38815. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38816. */
  38817. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  38818. /**
  38819. * Defines the camera the input is attached to.
  38820. */
  38821. camera: FollowCamera;
  38822. /**
  38823. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  38824. */
  38825. axisControlRadius: boolean;
  38826. /**
  38827. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  38828. */
  38829. axisControlHeight: boolean;
  38830. /**
  38831. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  38832. */
  38833. axisControlRotation: boolean;
  38834. /**
  38835. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  38836. * relation to mouseWheel events.
  38837. */
  38838. wheelPrecision: number;
  38839. /**
  38840. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38841. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38842. */
  38843. wheelDeltaPercentage: number;
  38844. private _wheel;
  38845. private _observer;
  38846. /**
  38847. * Attach the input controls to a specific dom element to get the input from.
  38848. * @param element Defines the element the controls should be listened from
  38849. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38850. */
  38851. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38852. /**
  38853. * Detach the current controls from the specified dom element.
  38854. * @param element Defines the element to stop listening the inputs from
  38855. */
  38856. detachControl(element: Nullable<HTMLElement>): void;
  38857. /**
  38858. * Gets the class name of the current intput.
  38859. * @returns the class name
  38860. */
  38861. getClassName(): string;
  38862. /**
  38863. * Get the friendly name associated with the input class.
  38864. * @returns the input friendly name
  38865. */
  38866. getSimpleName(): string;
  38867. }
  38868. }
  38869. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  38870. import { Nullable } from "babylonjs/types";
  38871. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38872. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  38873. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  38874. /**
  38875. * Manage the pointers inputs to control an follow camera.
  38876. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38877. */
  38878. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  38879. /**
  38880. * Defines the camera the input is attached to.
  38881. */
  38882. camera: FollowCamera;
  38883. /**
  38884. * Gets the class name of the current input.
  38885. * @returns the class name
  38886. */
  38887. getClassName(): string;
  38888. /**
  38889. * Defines the pointer angular sensibility along the X axis or how fast is
  38890. * the camera rotating.
  38891. * A negative number will reverse the axis direction.
  38892. */
  38893. angularSensibilityX: number;
  38894. /**
  38895. * Defines the pointer angular sensibility along the Y axis or how fast is
  38896. * the camera rotating.
  38897. * A negative number will reverse the axis direction.
  38898. */
  38899. angularSensibilityY: number;
  38900. /**
  38901. * Defines the pointer pinch precision or how fast is the camera zooming.
  38902. * A negative number will reverse the axis direction.
  38903. */
  38904. pinchPrecision: number;
  38905. /**
  38906. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38907. * from 0.
  38908. * It defines the percentage of current camera.radius to use as delta when
  38909. * pinch zoom is used.
  38910. */
  38911. pinchDeltaPercentage: number;
  38912. /**
  38913. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  38914. */
  38915. axisXControlRadius: boolean;
  38916. /**
  38917. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  38918. */
  38919. axisXControlHeight: boolean;
  38920. /**
  38921. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  38922. */
  38923. axisXControlRotation: boolean;
  38924. /**
  38925. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  38926. */
  38927. axisYControlRadius: boolean;
  38928. /**
  38929. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  38930. */
  38931. axisYControlHeight: boolean;
  38932. /**
  38933. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  38934. */
  38935. axisYControlRotation: boolean;
  38936. /**
  38937. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  38938. */
  38939. axisPinchControlRadius: boolean;
  38940. /**
  38941. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  38942. */
  38943. axisPinchControlHeight: boolean;
  38944. /**
  38945. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  38946. */
  38947. axisPinchControlRotation: boolean;
  38948. /**
  38949. * Log error messages if basic misconfiguration has occurred.
  38950. */
  38951. warningEnable: boolean;
  38952. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38953. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38954. private _warningCounter;
  38955. private _warning;
  38956. }
  38957. }
  38958. declare module "babylonjs/Cameras/followCameraInputsManager" {
  38959. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38960. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38961. /**
  38962. * Default Inputs manager for the FollowCamera.
  38963. * It groups all the default supported inputs for ease of use.
  38964. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38965. */
  38966. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  38967. /**
  38968. * Instantiates a new FollowCameraInputsManager.
  38969. * @param camera Defines the camera the inputs belong to
  38970. */
  38971. constructor(camera: FollowCamera);
  38972. /**
  38973. * Add keyboard input support to the input manager.
  38974. * @returns the current input manager
  38975. */
  38976. addKeyboard(): FollowCameraInputsManager;
  38977. /**
  38978. * Add mouse wheel input support to the input manager.
  38979. * @returns the current input manager
  38980. */
  38981. addMouseWheel(): FollowCameraInputsManager;
  38982. /**
  38983. * Add pointers input support to the input manager.
  38984. * @returns the current input manager
  38985. */
  38986. addPointers(): FollowCameraInputsManager;
  38987. /**
  38988. * Add orientation input support to the input manager.
  38989. * @returns the current input manager
  38990. */
  38991. addVRDeviceOrientation(): FollowCameraInputsManager;
  38992. }
  38993. }
  38994. declare module "babylonjs/Cameras/followCamera" {
  38995. import { Nullable } from "babylonjs/types";
  38996. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38997. import { Scene } from "babylonjs/scene";
  38998. import { Vector3 } from "babylonjs/Maths/math.vector";
  38999. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39000. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  39001. /**
  39002. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  39003. * an arc rotate version arcFollowCamera are available.
  39004. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39005. */
  39006. export class FollowCamera extends TargetCamera {
  39007. /**
  39008. * Distance the follow camera should follow an object at
  39009. */
  39010. radius: number;
  39011. /**
  39012. * Minimum allowed distance of the camera to the axis of rotation
  39013. * (The camera can not get closer).
  39014. * This can help limiting how the Camera is able to move in the scene.
  39015. */
  39016. lowerRadiusLimit: Nullable<number>;
  39017. /**
  39018. * Maximum allowed distance of the camera to the axis of rotation
  39019. * (The camera can not get further).
  39020. * This can help limiting how the Camera is able to move in the scene.
  39021. */
  39022. upperRadiusLimit: Nullable<number>;
  39023. /**
  39024. * Define a rotation offset between the camera and the object it follows
  39025. */
  39026. rotationOffset: number;
  39027. /**
  39028. * Minimum allowed angle to camera position relative to target object.
  39029. * This can help limiting how the Camera is able to move in the scene.
  39030. */
  39031. lowerRotationOffsetLimit: Nullable<number>;
  39032. /**
  39033. * Maximum allowed angle to camera position relative to target object.
  39034. * This can help limiting how the Camera is able to move in the scene.
  39035. */
  39036. upperRotationOffsetLimit: Nullable<number>;
  39037. /**
  39038. * Define a height offset between the camera and the object it follows.
  39039. * It can help following an object from the top (like a car chaing a plane)
  39040. */
  39041. heightOffset: number;
  39042. /**
  39043. * Minimum allowed height of camera position relative to target object.
  39044. * This can help limiting how the Camera is able to move in the scene.
  39045. */
  39046. lowerHeightOffsetLimit: Nullable<number>;
  39047. /**
  39048. * Maximum allowed height of camera position relative to target object.
  39049. * This can help limiting how the Camera is able to move in the scene.
  39050. */
  39051. upperHeightOffsetLimit: Nullable<number>;
  39052. /**
  39053. * Define how fast the camera can accelerate to follow it s target.
  39054. */
  39055. cameraAcceleration: number;
  39056. /**
  39057. * Define the speed limit of the camera following an object.
  39058. */
  39059. maxCameraSpeed: number;
  39060. /**
  39061. * Define the target of the camera.
  39062. */
  39063. lockedTarget: Nullable<AbstractMesh>;
  39064. /**
  39065. * Defines the input associated with the camera.
  39066. */
  39067. inputs: FollowCameraInputsManager;
  39068. /**
  39069. * Instantiates the follow camera.
  39070. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39071. * @param name Define the name of the camera in the scene
  39072. * @param position Define the position of the camera
  39073. * @param scene Define the scene the camera belong to
  39074. * @param lockedTarget Define the target of the camera
  39075. */
  39076. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  39077. private _follow;
  39078. /**
  39079. * Attached controls to the current camera.
  39080. * @param element Defines the element the controls should be listened from
  39081. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39082. */
  39083. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39084. /**
  39085. * Detach the current controls from the camera.
  39086. * The camera will stop reacting to inputs.
  39087. * @param element Defines the element to stop listening the inputs from
  39088. */
  39089. detachControl(element: HTMLElement): void;
  39090. /** @hidden */
  39091. _checkInputs(): void;
  39092. private _checkLimits;
  39093. /**
  39094. * Gets the camera class name.
  39095. * @returns the class name
  39096. */
  39097. getClassName(): string;
  39098. }
  39099. /**
  39100. * Arc Rotate version of the follow camera.
  39101. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  39102. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39103. */
  39104. export class ArcFollowCamera extends TargetCamera {
  39105. /** The longitudinal angle of the camera */
  39106. alpha: number;
  39107. /** The latitudinal angle of the camera */
  39108. beta: number;
  39109. /** The radius of the camera from its target */
  39110. radius: number;
  39111. /** Define the camera target (the messh it should follow) */
  39112. target: Nullable<AbstractMesh>;
  39113. private _cartesianCoordinates;
  39114. /**
  39115. * Instantiates a new ArcFollowCamera
  39116. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39117. * @param name Define the name of the camera
  39118. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  39119. * @param beta Define the rotation angle of the camera around the elevation axis
  39120. * @param radius Define the radius of the camera from its target point
  39121. * @param target Define the target of the camera
  39122. * @param scene Define the scene the camera belongs to
  39123. */
  39124. constructor(name: string,
  39125. /** The longitudinal angle of the camera */
  39126. alpha: number,
  39127. /** The latitudinal angle of the camera */
  39128. beta: number,
  39129. /** The radius of the camera from its target */
  39130. radius: number,
  39131. /** Define the camera target (the messh it should follow) */
  39132. target: Nullable<AbstractMesh>, scene: Scene);
  39133. private _follow;
  39134. /** @hidden */
  39135. _checkInputs(): void;
  39136. /**
  39137. * Returns the class name of the object.
  39138. * It is mostly used internally for serialization purposes.
  39139. */
  39140. getClassName(): string;
  39141. }
  39142. }
  39143. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  39144. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39145. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39146. import { Nullable } from "babylonjs/types";
  39147. /**
  39148. * Manage the keyboard inputs to control the movement of a follow camera.
  39149. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39150. */
  39151. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  39152. /**
  39153. * Defines the camera the input is attached to.
  39154. */
  39155. camera: FollowCamera;
  39156. /**
  39157. * Defines the list of key codes associated with the up action (increase heightOffset)
  39158. */
  39159. keysHeightOffsetIncr: number[];
  39160. /**
  39161. * Defines the list of key codes associated with the down action (decrease heightOffset)
  39162. */
  39163. keysHeightOffsetDecr: number[];
  39164. /**
  39165. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  39166. */
  39167. keysHeightOffsetModifierAlt: boolean;
  39168. /**
  39169. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  39170. */
  39171. keysHeightOffsetModifierCtrl: boolean;
  39172. /**
  39173. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  39174. */
  39175. keysHeightOffsetModifierShift: boolean;
  39176. /**
  39177. * Defines the list of key codes associated with the left action (increase rotationOffset)
  39178. */
  39179. keysRotationOffsetIncr: number[];
  39180. /**
  39181. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  39182. */
  39183. keysRotationOffsetDecr: number[];
  39184. /**
  39185. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  39186. */
  39187. keysRotationOffsetModifierAlt: boolean;
  39188. /**
  39189. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  39190. */
  39191. keysRotationOffsetModifierCtrl: boolean;
  39192. /**
  39193. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  39194. */
  39195. keysRotationOffsetModifierShift: boolean;
  39196. /**
  39197. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  39198. */
  39199. keysRadiusIncr: number[];
  39200. /**
  39201. * Defines the list of key codes associated with the zoom-out action (increase radius)
  39202. */
  39203. keysRadiusDecr: number[];
  39204. /**
  39205. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  39206. */
  39207. keysRadiusModifierAlt: boolean;
  39208. /**
  39209. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  39210. */
  39211. keysRadiusModifierCtrl: boolean;
  39212. /**
  39213. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  39214. */
  39215. keysRadiusModifierShift: boolean;
  39216. /**
  39217. * Defines the rate of change of heightOffset.
  39218. */
  39219. heightSensibility: number;
  39220. /**
  39221. * Defines the rate of change of rotationOffset.
  39222. */
  39223. rotationSensibility: number;
  39224. /**
  39225. * Defines the rate of change of radius.
  39226. */
  39227. radiusSensibility: number;
  39228. private _keys;
  39229. private _ctrlPressed;
  39230. private _altPressed;
  39231. private _shiftPressed;
  39232. private _onCanvasBlurObserver;
  39233. private _onKeyboardObserver;
  39234. private _engine;
  39235. private _scene;
  39236. /**
  39237. * Attach the input controls to a specific dom element to get the input from.
  39238. * @param element Defines the element the controls should be listened from
  39239. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39240. */
  39241. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39242. /**
  39243. * Detach the current controls from the specified dom element.
  39244. * @param element Defines the element to stop listening the inputs from
  39245. */
  39246. detachControl(element: Nullable<HTMLElement>): void;
  39247. /**
  39248. * Update the current camera state depending on the inputs that have been used this frame.
  39249. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39250. */
  39251. checkInputs(): void;
  39252. /**
  39253. * Gets the class name of the current input.
  39254. * @returns the class name
  39255. */
  39256. getClassName(): string;
  39257. /**
  39258. * Get the friendly name associated with the input class.
  39259. * @returns the input friendly name
  39260. */
  39261. getSimpleName(): string;
  39262. /**
  39263. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39264. * allow modification of the heightOffset value.
  39265. */
  39266. private _modifierHeightOffset;
  39267. /**
  39268. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39269. * allow modification of the rotationOffset value.
  39270. */
  39271. private _modifierRotationOffset;
  39272. /**
  39273. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39274. * allow modification of the radius value.
  39275. */
  39276. private _modifierRadius;
  39277. }
  39278. }
  39279. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  39280. import { Nullable } from "babylonjs/types";
  39281. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39282. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39283. import { Observable } from "babylonjs/Misc/observable";
  39284. module "babylonjs/Cameras/freeCameraInputsManager" {
  39285. interface FreeCameraInputsManager {
  39286. /**
  39287. * @hidden
  39288. */
  39289. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  39290. /**
  39291. * Add orientation input support to the input manager.
  39292. * @returns the current input manager
  39293. */
  39294. addDeviceOrientation(): FreeCameraInputsManager;
  39295. }
  39296. }
  39297. /**
  39298. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  39299. * Screen rotation is taken into account.
  39300. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39301. */
  39302. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  39303. private _camera;
  39304. private _screenOrientationAngle;
  39305. private _constantTranform;
  39306. private _screenQuaternion;
  39307. private _alpha;
  39308. private _beta;
  39309. private _gamma;
  39310. /**
  39311. * Can be used to detect if a device orientation sensor is availible on a device
  39312. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  39313. * @returns a promise that will resolve on orientation change
  39314. */
  39315. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  39316. /**
  39317. * @hidden
  39318. */
  39319. _onDeviceOrientationChangedObservable: Observable<void>;
  39320. /**
  39321. * Instantiates a new input
  39322. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39323. */
  39324. constructor();
  39325. /**
  39326. * Define the camera controlled by the input.
  39327. */
  39328. camera: FreeCamera;
  39329. /**
  39330. * Attach the input controls to a specific dom element to get the input from.
  39331. * @param element Defines the element the controls should be listened from
  39332. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39333. */
  39334. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39335. private _orientationChanged;
  39336. private _deviceOrientation;
  39337. /**
  39338. * Detach the current controls from the specified dom element.
  39339. * @param element Defines the element to stop listening the inputs from
  39340. */
  39341. detachControl(element: Nullable<HTMLElement>): void;
  39342. /**
  39343. * Update the current camera state depending on the inputs that have been used this frame.
  39344. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39345. */
  39346. checkInputs(): void;
  39347. /**
  39348. * Gets the class name of the current intput.
  39349. * @returns the class name
  39350. */
  39351. getClassName(): string;
  39352. /**
  39353. * Get the friendly name associated with the input class.
  39354. * @returns the input friendly name
  39355. */
  39356. getSimpleName(): string;
  39357. }
  39358. }
  39359. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  39360. import { Nullable } from "babylonjs/types";
  39361. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39362. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39363. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39364. /**
  39365. * Manage the gamepad inputs to control a free camera.
  39366. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39367. */
  39368. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  39369. /**
  39370. * Define the camera the input is attached to.
  39371. */
  39372. camera: FreeCamera;
  39373. /**
  39374. * Define the Gamepad controlling the input
  39375. */
  39376. gamepad: Nullable<Gamepad>;
  39377. /**
  39378. * Defines the gamepad rotation sensiblity.
  39379. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39380. */
  39381. gamepadAngularSensibility: number;
  39382. /**
  39383. * Defines the gamepad move sensiblity.
  39384. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39385. */
  39386. gamepadMoveSensibility: number;
  39387. private _onGamepadConnectedObserver;
  39388. private _onGamepadDisconnectedObserver;
  39389. private _cameraTransform;
  39390. private _deltaTransform;
  39391. private _vector3;
  39392. private _vector2;
  39393. /**
  39394. * Attach the input controls to a specific dom element to get the input from.
  39395. * @param element Defines the element the controls should be listened from
  39396. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39397. */
  39398. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39399. /**
  39400. * Detach the current controls from the specified dom element.
  39401. * @param element Defines the element to stop listening the inputs from
  39402. */
  39403. detachControl(element: Nullable<HTMLElement>): void;
  39404. /**
  39405. * Update the current camera state depending on the inputs that have been used this frame.
  39406. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39407. */
  39408. checkInputs(): void;
  39409. /**
  39410. * Gets the class name of the current intput.
  39411. * @returns the class name
  39412. */
  39413. getClassName(): string;
  39414. /**
  39415. * Get the friendly name associated with the input class.
  39416. * @returns the input friendly name
  39417. */
  39418. getSimpleName(): string;
  39419. }
  39420. }
  39421. declare module "babylonjs/Misc/virtualJoystick" {
  39422. import { Nullable } from "babylonjs/types";
  39423. import { Vector3 } from "babylonjs/Maths/math.vector";
  39424. /**
  39425. * Defines the potential axis of a Joystick
  39426. */
  39427. export enum JoystickAxis {
  39428. /** X axis */
  39429. X = 0,
  39430. /** Y axis */
  39431. Y = 1,
  39432. /** Z axis */
  39433. Z = 2
  39434. }
  39435. /**
  39436. * Class used to define virtual joystick (used in touch mode)
  39437. */
  39438. export class VirtualJoystick {
  39439. /**
  39440. * Gets or sets a boolean indicating that left and right values must be inverted
  39441. */
  39442. reverseLeftRight: boolean;
  39443. /**
  39444. * Gets or sets a boolean indicating that up and down values must be inverted
  39445. */
  39446. reverseUpDown: boolean;
  39447. /**
  39448. * Gets the offset value for the position (ie. the change of the position value)
  39449. */
  39450. deltaPosition: Vector3;
  39451. /**
  39452. * Gets a boolean indicating if the virtual joystick was pressed
  39453. */
  39454. pressed: boolean;
  39455. /**
  39456. * Canvas the virtual joystick will render onto, default z-index of this is 5
  39457. */
  39458. static Canvas: Nullable<HTMLCanvasElement>;
  39459. private static _globalJoystickIndex;
  39460. private static vjCanvasContext;
  39461. private static vjCanvasWidth;
  39462. private static vjCanvasHeight;
  39463. private static halfWidth;
  39464. private _action;
  39465. private _axisTargetedByLeftAndRight;
  39466. private _axisTargetedByUpAndDown;
  39467. private _joystickSensibility;
  39468. private _inversedSensibility;
  39469. private _joystickPointerID;
  39470. private _joystickColor;
  39471. private _joystickPointerPos;
  39472. private _joystickPreviousPointerPos;
  39473. private _joystickPointerStartPos;
  39474. private _deltaJoystickVector;
  39475. private _leftJoystick;
  39476. private _touches;
  39477. private _onPointerDownHandlerRef;
  39478. private _onPointerMoveHandlerRef;
  39479. private _onPointerUpHandlerRef;
  39480. private _onResize;
  39481. /**
  39482. * Creates a new virtual joystick
  39483. * @param leftJoystick defines that the joystick is for left hand (false by default)
  39484. */
  39485. constructor(leftJoystick?: boolean);
  39486. /**
  39487. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  39488. * @param newJoystickSensibility defines the new sensibility
  39489. */
  39490. setJoystickSensibility(newJoystickSensibility: number): void;
  39491. private _onPointerDown;
  39492. private _onPointerMove;
  39493. private _onPointerUp;
  39494. /**
  39495. * Change the color of the virtual joystick
  39496. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  39497. */
  39498. setJoystickColor(newColor: string): void;
  39499. /**
  39500. * Defines a callback to call when the joystick is touched
  39501. * @param action defines the callback
  39502. */
  39503. setActionOnTouch(action: () => any): void;
  39504. /**
  39505. * Defines which axis you'd like to control for left & right
  39506. * @param axis defines the axis to use
  39507. */
  39508. setAxisForLeftRight(axis: JoystickAxis): void;
  39509. /**
  39510. * Defines which axis you'd like to control for up & down
  39511. * @param axis defines the axis to use
  39512. */
  39513. setAxisForUpDown(axis: JoystickAxis): void;
  39514. private _drawVirtualJoystick;
  39515. /**
  39516. * Release internal HTML canvas
  39517. */
  39518. releaseCanvas(): void;
  39519. }
  39520. }
  39521. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  39522. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  39523. import { Nullable } from "babylonjs/types";
  39524. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39525. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39526. module "babylonjs/Cameras/freeCameraInputsManager" {
  39527. interface FreeCameraInputsManager {
  39528. /**
  39529. * Add virtual joystick input support to the input manager.
  39530. * @returns the current input manager
  39531. */
  39532. addVirtualJoystick(): FreeCameraInputsManager;
  39533. }
  39534. }
  39535. /**
  39536. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  39537. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39538. */
  39539. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  39540. /**
  39541. * Defines the camera the input is attached to.
  39542. */
  39543. camera: FreeCamera;
  39544. private _leftjoystick;
  39545. private _rightjoystick;
  39546. /**
  39547. * Gets the left stick of the virtual joystick.
  39548. * @returns The virtual Joystick
  39549. */
  39550. getLeftJoystick(): VirtualJoystick;
  39551. /**
  39552. * Gets the right stick of the virtual joystick.
  39553. * @returns The virtual Joystick
  39554. */
  39555. getRightJoystick(): VirtualJoystick;
  39556. /**
  39557. * Update the current camera state depending on the inputs that have been used this frame.
  39558. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39559. */
  39560. checkInputs(): void;
  39561. /**
  39562. * Attach the input controls to a specific dom element to get the input from.
  39563. * @param element Defines the element the controls should be listened from
  39564. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39565. */
  39566. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39567. /**
  39568. * Detach the current controls from the specified dom element.
  39569. * @param element Defines the element to stop listening the inputs from
  39570. */
  39571. detachControl(element: Nullable<HTMLElement>): void;
  39572. /**
  39573. * Gets the class name of the current intput.
  39574. * @returns the class name
  39575. */
  39576. getClassName(): string;
  39577. /**
  39578. * Get the friendly name associated with the input class.
  39579. * @returns the input friendly name
  39580. */
  39581. getSimpleName(): string;
  39582. }
  39583. }
  39584. declare module "babylonjs/Cameras/Inputs/index" {
  39585. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  39586. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  39587. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  39588. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  39589. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39590. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  39591. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  39592. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  39593. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  39594. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  39595. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39596. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  39597. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  39598. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  39599. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  39600. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  39601. }
  39602. declare module "babylonjs/Cameras/touchCamera" {
  39603. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39604. import { Scene } from "babylonjs/scene";
  39605. import { Vector3 } from "babylonjs/Maths/math.vector";
  39606. /**
  39607. * This represents a FPS type of camera controlled by touch.
  39608. * This is like a universal camera minus the Gamepad controls.
  39609. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39610. */
  39611. export class TouchCamera extends FreeCamera {
  39612. /**
  39613. * Defines the touch sensibility for rotation.
  39614. * The higher the faster.
  39615. */
  39616. touchAngularSensibility: number;
  39617. /**
  39618. * Defines the touch sensibility for move.
  39619. * The higher the faster.
  39620. */
  39621. touchMoveSensibility: number;
  39622. /**
  39623. * Instantiates a new touch camera.
  39624. * This represents a FPS type of camera controlled by touch.
  39625. * This is like a universal camera minus the Gamepad controls.
  39626. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39627. * @param name Define the name of the camera in the scene
  39628. * @param position Define the start position of the camera in the scene
  39629. * @param scene Define the scene the camera belongs to
  39630. */
  39631. constructor(name: string, position: Vector3, scene: Scene);
  39632. /**
  39633. * Gets the current object class name.
  39634. * @return the class name
  39635. */
  39636. getClassName(): string;
  39637. /** @hidden */
  39638. _setupInputs(): void;
  39639. }
  39640. }
  39641. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  39642. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39643. import { Scene } from "babylonjs/scene";
  39644. import { Vector3 } from "babylonjs/Maths/math.vector";
  39645. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39646. import { Axis } from "babylonjs/Maths/math.axis";
  39647. /**
  39648. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  39649. * being tilted forward or back and left or right.
  39650. */
  39651. export class DeviceOrientationCamera extends FreeCamera {
  39652. private _initialQuaternion;
  39653. private _quaternionCache;
  39654. private _tmpDragQuaternion;
  39655. private _disablePointerInputWhenUsingDeviceOrientation;
  39656. /**
  39657. * Creates a new device orientation camera
  39658. * @param name The name of the camera
  39659. * @param position The start position camera
  39660. * @param scene The scene the camera belongs to
  39661. */
  39662. constructor(name: string, position: Vector3, scene: Scene);
  39663. /**
  39664. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  39665. */
  39666. disablePointerInputWhenUsingDeviceOrientation: boolean;
  39667. private _dragFactor;
  39668. /**
  39669. * Enabled turning on the y axis when the orientation sensor is active
  39670. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  39671. */
  39672. enableHorizontalDragging(dragFactor?: number): void;
  39673. /**
  39674. * Gets the current instance class name ("DeviceOrientationCamera").
  39675. * This helps avoiding instanceof at run time.
  39676. * @returns the class name
  39677. */
  39678. getClassName(): string;
  39679. /**
  39680. * @hidden
  39681. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  39682. */
  39683. _checkInputs(): void;
  39684. /**
  39685. * Reset the camera to its default orientation on the specified axis only.
  39686. * @param axis The axis to reset
  39687. */
  39688. resetToCurrentRotation(axis?: Axis): void;
  39689. }
  39690. }
  39691. declare module "babylonjs/Gamepads/xboxGamepad" {
  39692. import { Observable } from "babylonjs/Misc/observable";
  39693. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39694. /**
  39695. * Defines supported buttons for XBox360 compatible gamepads
  39696. */
  39697. export enum Xbox360Button {
  39698. /** A */
  39699. A = 0,
  39700. /** B */
  39701. B = 1,
  39702. /** X */
  39703. X = 2,
  39704. /** Y */
  39705. Y = 3,
  39706. /** Start */
  39707. Start = 4,
  39708. /** Back */
  39709. Back = 5,
  39710. /** Left button */
  39711. LB = 6,
  39712. /** Right button */
  39713. RB = 7,
  39714. /** Left stick */
  39715. LeftStick = 8,
  39716. /** Right stick */
  39717. RightStick = 9
  39718. }
  39719. /** Defines values for XBox360 DPad */
  39720. export enum Xbox360Dpad {
  39721. /** Up */
  39722. Up = 0,
  39723. /** Down */
  39724. Down = 1,
  39725. /** Left */
  39726. Left = 2,
  39727. /** Right */
  39728. Right = 3
  39729. }
  39730. /**
  39731. * Defines a XBox360 gamepad
  39732. */
  39733. export class Xbox360Pad extends Gamepad {
  39734. private _leftTrigger;
  39735. private _rightTrigger;
  39736. private _onlefttriggerchanged;
  39737. private _onrighttriggerchanged;
  39738. private _onbuttondown;
  39739. private _onbuttonup;
  39740. private _ondpaddown;
  39741. private _ondpadup;
  39742. /** Observable raised when a button is pressed */
  39743. onButtonDownObservable: Observable<Xbox360Button>;
  39744. /** Observable raised when a button is released */
  39745. onButtonUpObservable: Observable<Xbox360Button>;
  39746. /** Observable raised when a pad is pressed */
  39747. onPadDownObservable: Observable<Xbox360Dpad>;
  39748. /** Observable raised when a pad is released */
  39749. onPadUpObservable: Observable<Xbox360Dpad>;
  39750. private _buttonA;
  39751. private _buttonB;
  39752. private _buttonX;
  39753. private _buttonY;
  39754. private _buttonBack;
  39755. private _buttonStart;
  39756. private _buttonLB;
  39757. private _buttonRB;
  39758. private _buttonLeftStick;
  39759. private _buttonRightStick;
  39760. private _dPadUp;
  39761. private _dPadDown;
  39762. private _dPadLeft;
  39763. private _dPadRight;
  39764. private _isXboxOnePad;
  39765. /**
  39766. * Creates a new XBox360 gamepad object
  39767. * @param id defines the id of this gamepad
  39768. * @param index defines its index
  39769. * @param gamepad defines the internal HTML gamepad object
  39770. * @param xboxOne defines if it is a XBox One gamepad
  39771. */
  39772. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  39773. /**
  39774. * Defines the callback to call when left trigger is pressed
  39775. * @param callback defines the callback to use
  39776. */
  39777. onlefttriggerchanged(callback: (value: number) => void): void;
  39778. /**
  39779. * Defines the callback to call when right trigger is pressed
  39780. * @param callback defines the callback to use
  39781. */
  39782. onrighttriggerchanged(callback: (value: number) => void): void;
  39783. /**
  39784. * Gets the left trigger value
  39785. */
  39786. /**
  39787. * Sets the left trigger value
  39788. */
  39789. leftTrigger: number;
  39790. /**
  39791. * Gets the right trigger value
  39792. */
  39793. /**
  39794. * Sets the right trigger value
  39795. */
  39796. rightTrigger: number;
  39797. /**
  39798. * Defines the callback to call when a button is pressed
  39799. * @param callback defines the callback to use
  39800. */
  39801. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  39802. /**
  39803. * Defines the callback to call when a button is released
  39804. * @param callback defines the callback to use
  39805. */
  39806. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  39807. /**
  39808. * Defines the callback to call when a pad is pressed
  39809. * @param callback defines the callback to use
  39810. */
  39811. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  39812. /**
  39813. * Defines the callback to call when a pad is released
  39814. * @param callback defines the callback to use
  39815. */
  39816. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  39817. private _setButtonValue;
  39818. private _setDPadValue;
  39819. /**
  39820. * Gets the value of the `A` button
  39821. */
  39822. /**
  39823. * Sets the value of the `A` button
  39824. */
  39825. buttonA: number;
  39826. /**
  39827. * Gets the value of the `B` button
  39828. */
  39829. /**
  39830. * Sets the value of the `B` button
  39831. */
  39832. buttonB: number;
  39833. /**
  39834. * Gets the value of the `X` button
  39835. */
  39836. /**
  39837. * Sets the value of the `X` button
  39838. */
  39839. buttonX: number;
  39840. /**
  39841. * Gets the value of the `Y` button
  39842. */
  39843. /**
  39844. * Sets the value of the `Y` button
  39845. */
  39846. buttonY: number;
  39847. /**
  39848. * Gets the value of the `Start` button
  39849. */
  39850. /**
  39851. * Sets the value of the `Start` button
  39852. */
  39853. buttonStart: number;
  39854. /**
  39855. * Gets the value of the `Back` button
  39856. */
  39857. /**
  39858. * Sets the value of the `Back` button
  39859. */
  39860. buttonBack: number;
  39861. /**
  39862. * Gets the value of the `Left` button
  39863. */
  39864. /**
  39865. * Sets the value of the `Left` button
  39866. */
  39867. buttonLB: number;
  39868. /**
  39869. * Gets the value of the `Right` button
  39870. */
  39871. /**
  39872. * Sets the value of the `Right` button
  39873. */
  39874. buttonRB: number;
  39875. /**
  39876. * Gets the value of the Left joystick
  39877. */
  39878. /**
  39879. * Sets the value of the Left joystick
  39880. */
  39881. buttonLeftStick: number;
  39882. /**
  39883. * Gets the value of the Right joystick
  39884. */
  39885. /**
  39886. * Sets the value of the Right joystick
  39887. */
  39888. buttonRightStick: number;
  39889. /**
  39890. * Gets the value of D-pad up
  39891. */
  39892. /**
  39893. * Sets the value of D-pad up
  39894. */
  39895. dPadUp: number;
  39896. /**
  39897. * Gets the value of D-pad down
  39898. */
  39899. /**
  39900. * Sets the value of D-pad down
  39901. */
  39902. dPadDown: number;
  39903. /**
  39904. * Gets the value of D-pad left
  39905. */
  39906. /**
  39907. * Sets the value of D-pad left
  39908. */
  39909. dPadLeft: number;
  39910. /**
  39911. * Gets the value of D-pad right
  39912. */
  39913. /**
  39914. * Sets the value of D-pad right
  39915. */
  39916. dPadRight: number;
  39917. /**
  39918. * Force the gamepad to synchronize with device values
  39919. */
  39920. update(): void;
  39921. /**
  39922. * Disposes the gamepad
  39923. */
  39924. dispose(): void;
  39925. }
  39926. }
  39927. declare module "babylonjs/Gamepads/dualShockGamepad" {
  39928. import { Observable } from "babylonjs/Misc/observable";
  39929. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39930. /**
  39931. * Defines supported buttons for DualShock compatible gamepads
  39932. */
  39933. export enum DualShockButton {
  39934. /** Cross */
  39935. Cross = 0,
  39936. /** Circle */
  39937. Circle = 1,
  39938. /** Square */
  39939. Square = 2,
  39940. /** Triangle */
  39941. Triangle = 3,
  39942. /** Options */
  39943. Options = 4,
  39944. /** Share */
  39945. Share = 5,
  39946. /** L1 */
  39947. L1 = 6,
  39948. /** R1 */
  39949. R1 = 7,
  39950. /** Left stick */
  39951. LeftStick = 8,
  39952. /** Right stick */
  39953. RightStick = 9
  39954. }
  39955. /** Defines values for DualShock DPad */
  39956. export enum DualShockDpad {
  39957. /** Up */
  39958. Up = 0,
  39959. /** Down */
  39960. Down = 1,
  39961. /** Left */
  39962. Left = 2,
  39963. /** Right */
  39964. Right = 3
  39965. }
  39966. /**
  39967. * Defines a DualShock gamepad
  39968. */
  39969. export class DualShockPad extends Gamepad {
  39970. private _leftTrigger;
  39971. private _rightTrigger;
  39972. private _onlefttriggerchanged;
  39973. private _onrighttriggerchanged;
  39974. private _onbuttondown;
  39975. private _onbuttonup;
  39976. private _ondpaddown;
  39977. private _ondpadup;
  39978. /** Observable raised when a button is pressed */
  39979. onButtonDownObservable: Observable<DualShockButton>;
  39980. /** Observable raised when a button is released */
  39981. onButtonUpObservable: Observable<DualShockButton>;
  39982. /** Observable raised when a pad is pressed */
  39983. onPadDownObservable: Observable<DualShockDpad>;
  39984. /** Observable raised when a pad is released */
  39985. onPadUpObservable: Observable<DualShockDpad>;
  39986. private _buttonCross;
  39987. private _buttonCircle;
  39988. private _buttonSquare;
  39989. private _buttonTriangle;
  39990. private _buttonShare;
  39991. private _buttonOptions;
  39992. private _buttonL1;
  39993. private _buttonR1;
  39994. private _buttonLeftStick;
  39995. private _buttonRightStick;
  39996. private _dPadUp;
  39997. private _dPadDown;
  39998. private _dPadLeft;
  39999. private _dPadRight;
  40000. /**
  40001. * Creates a new DualShock gamepad object
  40002. * @param id defines the id of this gamepad
  40003. * @param index defines its index
  40004. * @param gamepad defines the internal HTML gamepad object
  40005. */
  40006. constructor(id: string, index: number, gamepad: any);
  40007. /**
  40008. * Defines the callback to call when left trigger is pressed
  40009. * @param callback defines the callback to use
  40010. */
  40011. onlefttriggerchanged(callback: (value: number) => void): void;
  40012. /**
  40013. * Defines the callback to call when right trigger is pressed
  40014. * @param callback defines the callback to use
  40015. */
  40016. onrighttriggerchanged(callback: (value: number) => void): void;
  40017. /**
  40018. * Gets the left trigger value
  40019. */
  40020. /**
  40021. * Sets the left trigger value
  40022. */
  40023. leftTrigger: number;
  40024. /**
  40025. * Gets the right trigger value
  40026. */
  40027. /**
  40028. * Sets the right trigger value
  40029. */
  40030. rightTrigger: number;
  40031. /**
  40032. * Defines the callback to call when a button is pressed
  40033. * @param callback defines the callback to use
  40034. */
  40035. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  40036. /**
  40037. * Defines the callback to call when a button is released
  40038. * @param callback defines the callback to use
  40039. */
  40040. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  40041. /**
  40042. * Defines the callback to call when a pad is pressed
  40043. * @param callback defines the callback to use
  40044. */
  40045. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  40046. /**
  40047. * Defines the callback to call when a pad is released
  40048. * @param callback defines the callback to use
  40049. */
  40050. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  40051. private _setButtonValue;
  40052. private _setDPadValue;
  40053. /**
  40054. * Gets the value of the `Cross` button
  40055. */
  40056. /**
  40057. * Sets the value of the `Cross` button
  40058. */
  40059. buttonCross: number;
  40060. /**
  40061. * Gets the value of the `Circle` button
  40062. */
  40063. /**
  40064. * Sets the value of the `Circle` button
  40065. */
  40066. buttonCircle: number;
  40067. /**
  40068. * Gets the value of the `Square` button
  40069. */
  40070. /**
  40071. * Sets the value of the `Square` button
  40072. */
  40073. buttonSquare: number;
  40074. /**
  40075. * Gets the value of the `Triangle` button
  40076. */
  40077. /**
  40078. * Sets the value of the `Triangle` button
  40079. */
  40080. buttonTriangle: number;
  40081. /**
  40082. * Gets the value of the `Options` button
  40083. */
  40084. /**
  40085. * Sets the value of the `Options` button
  40086. */
  40087. buttonOptions: number;
  40088. /**
  40089. * Gets the value of the `Share` button
  40090. */
  40091. /**
  40092. * Sets the value of the `Share` button
  40093. */
  40094. buttonShare: number;
  40095. /**
  40096. * Gets the value of the `L1` button
  40097. */
  40098. /**
  40099. * Sets the value of the `L1` button
  40100. */
  40101. buttonL1: number;
  40102. /**
  40103. * Gets the value of the `R1` button
  40104. */
  40105. /**
  40106. * Sets the value of the `R1` button
  40107. */
  40108. buttonR1: number;
  40109. /**
  40110. * Gets the value of the Left joystick
  40111. */
  40112. /**
  40113. * Sets the value of the Left joystick
  40114. */
  40115. buttonLeftStick: number;
  40116. /**
  40117. * Gets the value of the Right joystick
  40118. */
  40119. /**
  40120. * Sets the value of the Right joystick
  40121. */
  40122. buttonRightStick: number;
  40123. /**
  40124. * Gets the value of D-pad up
  40125. */
  40126. /**
  40127. * Sets the value of D-pad up
  40128. */
  40129. dPadUp: number;
  40130. /**
  40131. * Gets the value of D-pad down
  40132. */
  40133. /**
  40134. * Sets the value of D-pad down
  40135. */
  40136. dPadDown: number;
  40137. /**
  40138. * Gets the value of D-pad left
  40139. */
  40140. /**
  40141. * Sets the value of D-pad left
  40142. */
  40143. dPadLeft: number;
  40144. /**
  40145. * Gets the value of D-pad right
  40146. */
  40147. /**
  40148. * Sets the value of D-pad right
  40149. */
  40150. dPadRight: number;
  40151. /**
  40152. * Force the gamepad to synchronize with device values
  40153. */
  40154. update(): void;
  40155. /**
  40156. * Disposes the gamepad
  40157. */
  40158. dispose(): void;
  40159. }
  40160. }
  40161. declare module "babylonjs/Gamepads/gamepadManager" {
  40162. import { Observable } from "babylonjs/Misc/observable";
  40163. import { Nullable } from "babylonjs/types";
  40164. import { Scene } from "babylonjs/scene";
  40165. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40166. /**
  40167. * Manager for handling gamepads
  40168. */
  40169. export class GamepadManager {
  40170. private _scene?;
  40171. private _babylonGamepads;
  40172. private _oneGamepadConnected;
  40173. /** @hidden */
  40174. _isMonitoring: boolean;
  40175. private _gamepadEventSupported;
  40176. private _gamepadSupport;
  40177. /**
  40178. * observable to be triggered when the gamepad controller has been connected
  40179. */
  40180. onGamepadConnectedObservable: Observable<Gamepad>;
  40181. /**
  40182. * observable to be triggered when the gamepad controller has been disconnected
  40183. */
  40184. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40185. private _onGamepadConnectedEvent;
  40186. private _onGamepadDisconnectedEvent;
  40187. /**
  40188. * Initializes the gamepad manager
  40189. * @param _scene BabylonJS scene
  40190. */
  40191. constructor(_scene?: Scene | undefined);
  40192. /**
  40193. * The gamepads in the game pad manager
  40194. */
  40195. readonly gamepads: Gamepad[];
  40196. /**
  40197. * Get the gamepad controllers based on type
  40198. * @param type The type of gamepad controller
  40199. * @returns Nullable gamepad
  40200. */
  40201. getGamepadByType(type?: number): Nullable<Gamepad>;
  40202. /**
  40203. * Disposes the gamepad manager
  40204. */
  40205. dispose(): void;
  40206. private _addNewGamepad;
  40207. private _startMonitoringGamepads;
  40208. private _stopMonitoringGamepads;
  40209. /** @hidden */
  40210. _checkGamepadsStatus(): void;
  40211. private _updateGamepadObjects;
  40212. }
  40213. }
  40214. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40215. import { Nullable } from "babylonjs/types";
  40216. import { Scene } from "babylonjs/scene";
  40217. import { ISceneComponent } from "babylonjs/sceneComponent";
  40218. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40219. module "babylonjs/scene" {
  40220. interface Scene {
  40221. /** @hidden */
  40222. _gamepadManager: Nullable<GamepadManager>;
  40223. /**
  40224. * Gets the gamepad manager associated with the scene
  40225. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40226. */
  40227. gamepadManager: GamepadManager;
  40228. }
  40229. }
  40230. module "babylonjs/Cameras/freeCameraInputsManager" {
  40231. /**
  40232. * Interface representing a free camera inputs manager
  40233. */
  40234. interface FreeCameraInputsManager {
  40235. /**
  40236. * Adds gamepad input support to the FreeCameraInputsManager.
  40237. * @returns the FreeCameraInputsManager
  40238. */
  40239. addGamepad(): FreeCameraInputsManager;
  40240. }
  40241. }
  40242. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40243. /**
  40244. * Interface representing an arc rotate camera inputs manager
  40245. */
  40246. interface ArcRotateCameraInputsManager {
  40247. /**
  40248. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40249. * @returns the camera inputs manager
  40250. */
  40251. addGamepad(): ArcRotateCameraInputsManager;
  40252. }
  40253. }
  40254. /**
  40255. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40256. */
  40257. export class GamepadSystemSceneComponent implements ISceneComponent {
  40258. /**
  40259. * The component name helpfull to identify the component in the list of scene components.
  40260. */
  40261. readonly name: string;
  40262. /**
  40263. * The scene the component belongs to.
  40264. */
  40265. scene: Scene;
  40266. /**
  40267. * Creates a new instance of the component for the given scene
  40268. * @param scene Defines the scene to register the component in
  40269. */
  40270. constructor(scene: Scene);
  40271. /**
  40272. * Registers the component in a given scene
  40273. */
  40274. register(): void;
  40275. /**
  40276. * Rebuilds the elements related to this component in case of
  40277. * context lost for instance.
  40278. */
  40279. rebuild(): void;
  40280. /**
  40281. * Disposes the component and the associated ressources
  40282. */
  40283. dispose(): void;
  40284. private _beforeCameraUpdate;
  40285. }
  40286. }
  40287. declare module "babylonjs/Cameras/universalCamera" {
  40288. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  40289. import { Scene } from "babylonjs/scene";
  40290. import { Vector3 } from "babylonjs/Maths/math.vector";
  40291. import "babylonjs/Gamepads/gamepadSceneComponent";
  40292. /**
  40293. * The Universal Camera is the one to choose for first person shooter type games, and works with all the keyboard, mouse, touch and gamepads. This replaces the earlier Free Camera,
  40294. * which still works and will still be found in many Playgrounds.
  40295. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40296. */
  40297. export class UniversalCamera extends TouchCamera {
  40298. /**
  40299. * Defines the gamepad rotation sensiblity.
  40300. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40301. */
  40302. gamepadAngularSensibility: number;
  40303. /**
  40304. * Defines the gamepad move sensiblity.
  40305. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40306. */
  40307. gamepadMoveSensibility: number;
  40308. /**
  40309. * The Universal Camera is the one to choose for first person shooter type games, and works with all the keyboard, mouse, touch and gamepads. This replaces the earlier Free Camera,
  40310. * which still works and will still be found in many Playgrounds.
  40311. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40312. * @param name Define the name of the camera in the scene
  40313. * @param position Define the start position of the camera in the scene
  40314. * @param scene Define the scene the camera belongs to
  40315. */
  40316. constructor(name: string, position: Vector3, scene: Scene);
  40317. /**
  40318. * Gets the current object class name.
  40319. * @return the class name
  40320. */
  40321. getClassName(): string;
  40322. }
  40323. }
  40324. declare module "babylonjs/Cameras/gamepadCamera" {
  40325. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40326. import { Scene } from "babylonjs/scene";
  40327. import { Vector3 } from "babylonjs/Maths/math.vector";
  40328. /**
  40329. * This represents a FPS type of camera. This is only here for back compat purpose.
  40330. * Please use the UniversalCamera instead as both are identical.
  40331. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40332. */
  40333. export class GamepadCamera extends UniversalCamera {
  40334. /**
  40335. * Instantiates a new Gamepad Camera
  40336. * This represents a FPS type of camera. This is only here for back compat purpose.
  40337. * Please use the UniversalCamera instead as both are identical.
  40338. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40339. * @param name Define the name of the camera in the scene
  40340. * @param position Define the start position of the camera in the scene
  40341. * @param scene Define the scene the camera belongs to
  40342. */
  40343. constructor(name: string, position: Vector3, scene: Scene);
  40344. /**
  40345. * Gets the current object class name.
  40346. * @return the class name
  40347. */
  40348. getClassName(): string;
  40349. }
  40350. }
  40351. declare module "babylonjs/Shaders/pass.fragment" {
  40352. /** @hidden */
  40353. export var passPixelShader: {
  40354. name: string;
  40355. shader: string;
  40356. };
  40357. }
  40358. declare module "babylonjs/Shaders/passCube.fragment" {
  40359. /** @hidden */
  40360. export var passCubePixelShader: {
  40361. name: string;
  40362. shader: string;
  40363. };
  40364. }
  40365. declare module "babylonjs/PostProcesses/passPostProcess" {
  40366. import { Nullable } from "babylonjs/types";
  40367. import { Camera } from "babylonjs/Cameras/camera";
  40368. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40369. import { Engine } from "babylonjs/Engines/engine";
  40370. import "babylonjs/Shaders/pass.fragment";
  40371. import "babylonjs/Shaders/passCube.fragment";
  40372. /**
  40373. * PassPostProcess which produces an output the same as it's input
  40374. */
  40375. export class PassPostProcess extends PostProcess {
  40376. /**
  40377. * Creates the PassPostProcess
  40378. * @param name The name of the effect.
  40379. * @param options The required width/height ratio to downsize to before computing the render pass.
  40380. * @param camera The camera to apply the render pass to.
  40381. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40382. * @param engine The engine which the post process will be applied. (default: current engine)
  40383. * @param reusable If the post process can be reused on the same frame. (default: false)
  40384. * @param textureType The type of texture to be used when performing the post processing.
  40385. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  40386. */
  40387. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40388. }
  40389. /**
  40390. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  40391. */
  40392. export class PassCubePostProcess extends PostProcess {
  40393. private _face;
  40394. /**
  40395. * Gets or sets the cube face to display.
  40396. * * 0 is +X
  40397. * * 1 is -X
  40398. * * 2 is +Y
  40399. * * 3 is -Y
  40400. * * 4 is +Z
  40401. * * 5 is -Z
  40402. */
  40403. face: number;
  40404. /**
  40405. * Creates the PassCubePostProcess
  40406. * @param name The name of the effect.
  40407. * @param options The required width/height ratio to downsize to before computing the render pass.
  40408. * @param camera The camera to apply the render pass to.
  40409. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40410. * @param engine The engine which the post process will be applied. (default: current engine)
  40411. * @param reusable If the post process can be reused on the same frame. (default: false)
  40412. * @param textureType The type of texture to be used when performing the post processing.
  40413. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  40414. */
  40415. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40416. }
  40417. }
  40418. declare module "babylonjs/Shaders/anaglyph.fragment" {
  40419. /** @hidden */
  40420. export var anaglyphPixelShader: {
  40421. name: string;
  40422. shader: string;
  40423. };
  40424. }
  40425. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  40426. import { Engine } from "babylonjs/Engines/engine";
  40427. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40428. import { Camera } from "babylonjs/Cameras/camera";
  40429. import "babylonjs/Shaders/anaglyph.fragment";
  40430. /**
  40431. * Postprocess used to generate anaglyphic rendering
  40432. */
  40433. export class AnaglyphPostProcess extends PostProcess {
  40434. private _passedProcess;
  40435. /**
  40436. * Creates a new AnaglyphPostProcess
  40437. * @param name defines postprocess name
  40438. * @param options defines creation options or target ratio scale
  40439. * @param rigCameras defines cameras using this postprocess
  40440. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  40441. * @param engine defines hosting engine
  40442. * @param reusable defines if the postprocess will be reused multiple times per frame
  40443. */
  40444. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  40445. }
  40446. }
  40447. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  40448. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  40449. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40450. import { Scene } from "babylonjs/scene";
  40451. import { Vector3 } from "babylonjs/Maths/math.vector";
  40452. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40453. /**
  40454. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  40455. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40456. */
  40457. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  40458. /**
  40459. * Creates a new AnaglyphArcRotateCamera
  40460. * @param name defines camera name
  40461. * @param alpha defines alpha angle (in radians)
  40462. * @param beta defines beta angle (in radians)
  40463. * @param radius defines radius
  40464. * @param target defines camera target
  40465. * @param interaxialDistance defines distance between each color axis
  40466. * @param scene defines the hosting scene
  40467. */
  40468. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  40469. /**
  40470. * Gets camera class name
  40471. * @returns AnaglyphArcRotateCamera
  40472. */
  40473. getClassName(): string;
  40474. }
  40475. }
  40476. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  40477. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40478. import { Scene } from "babylonjs/scene";
  40479. import { Vector3 } from "babylonjs/Maths/math.vector";
  40480. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40481. /**
  40482. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  40483. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40484. */
  40485. export class AnaglyphFreeCamera extends FreeCamera {
  40486. /**
  40487. * Creates a new AnaglyphFreeCamera
  40488. * @param name defines camera name
  40489. * @param position defines initial position
  40490. * @param interaxialDistance defines distance between each color axis
  40491. * @param scene defines the hosting scene
  40492. */
  40493. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40494. /**
  40495. * Gets camera class name
  40496. * @returns AnaglyphFreeCamera
  40497. */
  40498. getClassName(): string;
  40499. }
  40500. }
  40501. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  40502. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40503. import { Scene } from "babylonjs/scene";
  40504. import { Vector3 } from "babylonjs/Maths/math.vector";
  40505. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40506. /**
  40507. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  40508. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40509. */
  40510. export class AnaglyphGamepadCamera extends GamepadCamera {
  40511. /**
  40512. * Creates a new AnaglyphGamepadCamera
  40513. * @param name defines camera name
  40514. * @param position defines initial position
  40515. * @param interaxialDistance defines distance between each color axis
  40516. * @param scene defines the hosting scene
  40517. */
  40518. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40519. /**
  40520. * Gets camera class name
  40521. * @returns AnaglyphGamepadCamera
  40522. */
  40523. getClassName(): string;
  40524. }
  40525. }
  40526. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  40527. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40528. import { Scene } from "babylonjs/scene";
  40529. import { Vector3 } from "babylonjs/Maths/math.vector";
  40530. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40531. /**
  40532. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  40533. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40534. */
  40535. export class AnaglyphUniversalCamera extends UniversalCamera {
  40536. /**
  40537. * Creates a new AnaglyphUniversalCamera
  40538. * @param name defines camera name
  40539. * @param position defines initial position
  40540. * @param interaxialDistance defines distance between each color axis
  40541. * @param scene defines the hosting scene
  40542. */
  40543. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40544. /**
  40545. * Gets camera class name
  40546. * @returns AnaglyphUniversalCamera
  40547. */
  40548. getClassName(): string;
  40549. }
  40550. }
  40551. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  40552. /** @hidden */
  40553. export var stereoscopicInterlacePixelShader: {
  40554. name: string;
  40555. shader: string;
  40556. };
  40557. }
  40558. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  40559. import { Camera } from "babylonjs/Cameras/camera";
  40560. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40561. import { Engine } from "babylonjs/Engines/engine";
  40562. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  40563. /**
  40564. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  40565. */
  40566. export class StereoscopicInterlacePostProcess extends PostProcess {
  40567. private _stepSize;
  40568. private _passedProcess;
  40569. /**
  40570. * Initializes a StereoscopicInterlacePostProcess
  40571. * @param name The name of the effect.
  40572. * @param rigCameras The rig cameras to be appled to the post process
  40573. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  40574. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40575. * @param engine The engine which the post process will be applied. (default: current engine)
  40576. * @param reusable If the post process can be reused on the same frame. (default: false)
  40577. */
  40578. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  40579. }
  40580. }
  40581. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  40582. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  40583. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40584. import { Scene } from "babylonjs/scene";
  40585. import { Vector3 } from "babylonjs/Maths/math.vector";
  40586. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40587. /**
  40588. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  40589. * @see http://doc.babylonjs.com/features/cameras
  40590. */
  40591. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  40592. /**
  40593. * Creates a new StereoscopicArcRotateCamera
  40594. * @param name defines camera name
  40595. * @param alpha defines alpha angle (in radians)
  40596. * @param beta defines beta angle (in radians)
  40597. * @param radius defines radius
  40598. * @param target defines camera target
  40599. * @param interaxialDistance defines distance between each color axis
  40600. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40601. * @param scene defines the hosting scene
  40602. */
  40603. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40604. /**
  40605. * Gets camera class name
  40606. * @returns StereoscopicArcRotateCamera
  40607. */
  40608. getClassName(): string;
  40609. }
  40610. }
  40611. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  40612. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40613. import { Scene } from "babylonjs/scene";
  40614. import { Vector3 } from "babylonjs/Maths/math.vector";
  40615. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40616. /**
  40617. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  40618. * @see http://doc.babylonjs.com/features/cameras
  40619. */
  40620. export class StereoscopicFreeCamera extends FreeCamera {
  40621. /**
  40622. * Creates a new StereoscopicFreeCamera
  40623. * @param name defines camera name
  40624. * @param position defines initial position
  40625. * @param interaxialDistance defines distance between each color axis
  40626. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40627. * @param scene defines the hosting scene
  40628. */
  40629. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40630. /**
  40631. * Gets camera class name
  40632. * @returns StereoscopicFreeCamera
  40633. */
  40634. getClassName(): string;
  40635. }
  40636. }
  40637. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  40638. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40639. import { Scene } from "babylonjs/scene";
  40640. import { Vector3 } from "babylonjs/Maths/math.vector";
  40641. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40642. /**
  40643. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  40644. * @see http://doc.babylonjs.com/features/cameras
  40645. */
  40646. export class StereoscopicGamepadCamera extends GamepadCamera {
  40647. /**
  40648. * Creates a new StereoscopicGamepadCamera
  40649. * @param name defines camera name
  40650. * @param position defines initial position
  40651. * @param interaxialDistance defines distance between each color axis
  40652. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40653. * @param scene defines the hosting scene
  40654. */
  40655. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40656. /**
  40657. * Gets camera class name
  40658. * @returns StereoscopicGamepadCamera
  40659. */
  40660. getClassName(): string;
  40661. }
  40662. }
  40663. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  40664. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40665. import { Scene } from "babylonjs/scene";
  40666. import { Vector3 } from "babylonjs/Maths/math.vector";
  40667. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40668. /**
  40669. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  40670. * @see http://doc.babylonjs.com/features/cameras
  40671. */
  40672. export class StereoscopicUniversalCamera extends UniversalCamera {
  40673. /**
  40674. * Creates a new StereoscopicUniversalCamera
  40675. * @param name defines camera name
  40676. * @param position defines initial position
  40677. * @param interaxialDistance defines distance between each color axis
  40678. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40679. * @param scene defines the hosting scene
  40680. */
  40681. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40682. /**
  40683. * Gets camera class name
  40684. * @returns StereoscopicUniversalCamera
  40685. */
  40686. getClassName(): string;
  40687. }
  40688. }
  40689. declare module "babylonjs/Cameras/Stereoscopic/index" {
  40690. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  40691. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  40692. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  40693. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  40694. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  40695. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  40696. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  40697. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  40698. }
  40699. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  40700. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40701. import { Scene } from "babylonjs/scene";
  40702. import { Vector3 } from "babylonjs/Maths/math.vector";
  40703. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  40704. /**
  40705. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  40706. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40707. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40708. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40709. */
  40710. export class VirtualJoysticksCamera extends FreeCamera {
  40711. /**
  40712. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  40713. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40714. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40715. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40716. * @param name Define the name of the camera in the scene
  40717. * @param position Define the start position of the camera in the scene
  40718. * @param scene Define the scene the camera belongs to
  40719. */
  40720. constructor(name: string, position: Vector3, scene: Scene);
  40721. /**
  40722. * Gets the current object class name.
  40723. * @return the class name
  40724. */
  40725. getClassName(): string;
  40726. }
  40727. }
  40728. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  40729. import { Matrix } from "babylonjs/Maths/math.vector";
  40730. /**
  40731. * This represents all the required metrics to create a VR camera.
  40732. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  40733. */
  40734. export class VRCameraMetrics {
  40735. /**
  40736. * Define the horizontal resolution off the screen.
  40737. */
  40738. hResolution: number;
  40739. /**
  40740. * Define the vertical resolution off the screen.
  40741. */
  40742. vResolution: number;
  40743. /**
  40744. * Define the horizontal screen size.
  40745. */
  40746. hScreenSize: number;
  40747. /**
  40748. * Define the vertical screen size.
  40749. */
  40750. vScreenSize: number;
  40751. /**
  40752. * Define the vertical screen center position.
  40753. */
  40754. vScreenCenter: number;
  40755. /**
  40756. * Define the distance of the eyes to the screen.
  40757. */
  40758. eyeToScreenDistance: number;
  40759. /**
  40760. * Define the distance between both lenses
  40761. */
  40762. lensSeparationDistance: number;
  40763. /**
  40764. * Define the distance between both viewer's eyes.
  40765. */
  40766. interpupillaryDistance: number;
  40767. /**
  40768. * Define the distortion factor of the VR postprocess.
  40769. * Please, touch with care.
  40770. */
  40771. distortionK: number[];
  40772. /**
  40773. * Define the chromatic aberration correction factors for the VR post process.
  40774. */
  40775. chromaAbCorrection: number[];
  40776. /**
  40777. * Define the scale factor of the post process.
  40778. * The smaller the better but the slower.
  40779. */
  40780. postProcessScaleFactor: number;
  40781. /**
  40782. * Define an offset for the lens center.
  40783. */
  40784. lensCenterOffset: number;
  40785. /**
  40786. * Define if the current vr camera should compensate the distortion of the lense or not.
  40787. */
  40788. compensateDistortion: boolean;
  40789. /**
  40790. * Defines if multiview should be enabled when rendering (Default: false)
  40791. */
  40792. multiviewEnabled: boolean;
  40793. /**
  40794. * Gets the rendering aspect ratio based on the provided resolutions.
  40795. */
  40796. readonly aspectRatio: number;
  40797. /**
  40798. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  40799. */
  40800. readonly aspectRatioFov: number;
  40801. /**
  40802. * @hidden
  40803. */
  40804. readonly leftHMatrix: Matrix;
  40805. /**
  40806. * @hidden
  40807. */
  40808. readonly rightHMatrix: Matrix;
  40809. /**
  40810. * @hidden
  40811. */
  40812. readonly leftPreViewMatrix: Matrix;
  40813. /**
  40814. * @hidden
  40815. */
  40816. readonly rightPreViewMatrix: Matrix;
  40817. /**
  40818. * Get the default VRMetrics based on the most generic setup.
  40819. * @returns the default vr metrics
  40820. */
  40821. static GetDefault(): VRCameraMetrics;
  40822. }
  40823. }
  40824. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  40825. /** @hidden */
  40826. export var vrDistortionCorrectionPixelShader: {
  40827. name: string;
  40828. shader: string;
  40829. };
  40830. }
  40831. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  40832. import { Camera } from "babylonjs/Cameras/camera";
  40833. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40834. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40835. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  40836. /**
  40837. * VRDistortionCorrectionPostProcess used for mobile VR
  40838. */
  40839. export class VRDistortionCorrectionPostProcess extends PostProcess {
  40840. private _isRightEye;
  40841. private _distortionFactors;
  40842. private _postProcessScaleFactor;
  40843. private _lensCenterOffset;
  40844. private _scaleIn;
  40845. private _scaleFactor;
  40846. private _lensCenter;
  40847. /**
  40848. * Initializes the VRDistortionCorrectionPostProcess
  40849. * @param name The name of the effect.
  40850. * @param camera The camera to apply the render pass to.
  40851. * @param isRightEye If this is for the right eye distortion
  40852. * @param vrMetrics All the required metrics for the VR camera
  40853. */
  40854. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  40855. }
  40856. }
  40857. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  40858. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  40859. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40860. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40861. import { Scene } from "babylonjs/scene";
  40862. import { Vector3 } from "babylonjs/Maths/math.vector";
  40863. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  40864. import "babylonjs/Cameras/RigModes/vrRigMode";
  40865. /**
  40866. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  40867. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40868. */
  40869. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  40870. /**
  40871. * Creates a new VRDeviceOrientationArcRotateCamera
  40872. * @param name defines camera name
  40873. * @param alpha defines the camera rotation along the logitudinal axis
  40874. * @param beta defines the camera rotation along the latitudinal axis
  40875. * @param radius defines the camera distance from its target
  40876. * @param target defines the camera target
  40877. * @param scene defines the scene the camera belongs to
  40878. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40879. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40880. */
  40881. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40882. /**
  40883. * Gets camera class name
  40884. * @returns VRDeviceOrientationArcRotateCamera
  40885. */
  40886. getClassName(): string;
  40887. }
  40888. }
  40889. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  40890. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  40891. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40892. import { Scene } from "babylonjs/scene";
  40893. import { Vector3 } from "babylonjs/Maths/math.vector";
  40894. import "babylonjs/Cameras/RigModes/vrRigMode";
  40895. /**
  40896. * Camera used to simulate VR rendering (based on FreeCamera)
  40897. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40898. */
  40899. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  40900. /**
  40901. * Creates a new VRDeviceOrientationFreeCamera
  40902. * @param name defines camera name
  40903. * @param position defines the start position of the camera
  40904. * @param scene defines the scene the camera belongs to
  40905. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40906. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40907. */
  40908. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40909. /**
  40910. * Gets camera class name
  40911. * @returns VRDeviceOrientationFreeCamera
  40912. */
  40913. getClassName(): string;
  40914. }
  40915. }
  40916. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  40917. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40918. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40919. import { Scene } from "babylonjs/scene";
  40920. import { Vector3 } from "babylonjs/Maths/math.vector";
  40921. import "babylonjs/Gamepads/gamepadSceneComponent";
  40922. /**
  40923. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  40924. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40925. */
  40926. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  40927. /**
  40928. * Creates a new VRDeviceOrientationGamepadCamera
  40929. * @param name defines camera name
  40930. * @param position defines the start position of the camera
  40931. * @param scene defines the scene the camera belongs to
  40932. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40933. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40934. */
  40935. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40936. /**
  40937. * Gets camera class name
  40938. * @returns VRDeviceOrientationGamepadCamera
  40939. */
  40940. getClassName(): string;
  40941. }
  40942. }
  40943. declare module "babylonjs/Materials/pushMaterial" {
  40944. import { Nullable } from "babylonjs/types";
  40945. import { Scene } from "babylonjs/scene";
  40946. import { Matrix } from "babylonjs/Maths/math.vector";
  40947. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40948. import { Mesh } from "babylonjs/Meshes/mesh";
  40949. import { Material } from "babylonjs/Materials/material";
  40950. import { Effect } from "babylonjs/Materials/effect";
  40951. /**
  40952. * Base class of materials working in push mode in babylon JS
  40953. * @hidden
  40954. */
  40955. export class PushMaterial extends Material {
  40956. protected _activeEffect: Effect;
  40957. protected _normalMatrix: Matrix;
  40958. /**
  40959. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  40960. * This means that the material can keep using a previous shader while a new one is being compiled.
  40961. * This is mostly used when shader parallel compilation is supported (true by default)
  40962. */
  40963. allowShaderHotSwapping: boolean;
  40964. constructor(name: string, scene: Scene);
  40965. getEffect(): Effect;
  40966. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  40967. /**
  40968. * Binds the given world matrix to the active effect
  40969. *
  40970. * @param world the matrix to bind
  40971. */
  40972. bindOnlyWorldMatrix(world: Matrix): void;
  40973. /**
  40974. * Binds the given normal matrix to the active effect
  40975. *
  40976. * @param normalMatrix the matrix to bind
  40977. */
  40978. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  40979. bind(world: Matrix, mesh?: Mesh): void;
  40980. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  40981. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  40982. }
  40983. }
  40984. declare module "babylonjs/Materials/materialFlags" {
  40985. /**
  40986. * This groups all the flags used to control the materials channel.
  40987. */
  40988. export class MaterialFlags {
  40989. private static _DiffuseTextureEnabled;
  40990. /**
  40991. * Are diffuse textures enabled in the application.
  40992. */
  40993. static DiffuseTextureEnabled: boolean;
  40994. private static _AmbientTextureEnabled;
  40995. /**
  40996. * Are ambient textures enabled in the application.
  40997. */
  40998. static AmbientTextureEnabled: boolean;
  40999. private static _OpacityTextureEnabled;
  41000. /**
  41001. * Are opacity textures enabled in the application.
  41002. */
  41003. static OpacityTextureEnabled: boolean;
  41004. private static _ReflectionTextureEnabled;
  41005. /**
  41006. * Are reflection textures enabled in the application.
  41007. */
  41008. static ReflectionTextureEnabled: boolean;
  41009. private static _EmissiveTextureEnabled;
  41010. /**
  41011. * Are emissive textures enabled in the application.
  41012. */
  41013. static EmissiveTextureEnabled: boolean;
  41014. private static _SpecularTextureEnabled;
  41015. /**
  41016. * Are specular textures enabled in the application.
  41017. */
  41018. static SpecularTextureEnabled: boolean;
  41019. private static _BumpTextureEnabled;
  41020. /**
  41021. * Are bump textures enabled in the application.
  41022. */
  41023. static BumpTextureEnabled: boolean;
  41024. private static _LightmapTextureEnabled;
  41025. /**
  41026. * Are lightmap textures enabled in the application.
  41027. */
  41028. static LightmapTextureEnabled: boolean;
  41029. private static _RefractionTextureEnabled;
  41030. /**
  41031. * Are refraction textures enabled in the application.
  41032. */
  41033. static RefractionTextureEnabled: boolean;
  41034. private static _ColorGradingTextureEnabled;
  41035. /**
  41036. * Are color grading textures enabled in the application.
  41037. */
  41038. static ColorGradingTextureEnabled: boolean;
  41039. private static _FresnelEnabled;
  41040. /**
  41041. * Are fresnels enabled in the application.
  41042. */
  41043. static FresnelEnabled: boolean;
  41044. private static _ClearCoatTextureEnabled;
  41045. /**
  41046. * Are clear coat textures enabled in the application.
  41047. */
  41048. static ClearCoatTextureEnabled: boolean;
  41049. private static _ClearCoatBumpTextureEnabled;
  41050. /**
  41051. * Are clear coat bump textures enabled in the application.
  41052. */
  41053. static ClearCoatBumpTextureEnabled: boolean;
  41054. private static _ClearCoatTintTextureEnabled;
  41055. /**
  41056. * Are clear coat tint textures enabled in the application.
  41057. */
  41058. static ClearCoatTintTextureEnabled: boolean;
  41059. private static _SheenTextureEnabled;
  41060. /**
  41061. * Are sheen textures enabled in the application.
  41062. */
  41063. static SheenTextureEnabled: boolean;
  41064. private static _AnisotropicTextureEnabled;
  41065. /**
  41066. * Are anisotropic textures enabled in the application.
  41067. */
  41068. static AnisotropicTextureEnabled: boolean;
  41069. private static _ThicknessTextureEnabled;
  41070. /**
  41071. * Are thickness textures enabled in the application.
  41072. */
  41073. static ThicknessTextureEnabled: boolean;
  41074. }
  41075. }
  41076. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  41077. /** @hidden */
  41078. export var defaultFragmentDeclaration: {
  41079. name: string;
  41080. shader: string;
  41081. };
  41082. }
  41083. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  41084. /** @hidden */
  41085. export var defaultUboDeclaration: {
  41086. name: string;
  41087. shader: string;
  41088. };
  41089. }
  41090. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  41091. /** @hidden */
  41092. export var lightFragmentDeclaration: {
  41093. name: string;
  41094. shader: string;
  41095. };
  41096. }
  41097. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  41098. /** @hidden */
  41099. export var lightUboDeclaration: {
  41100. name: string;
  41101. shader: string;
  41102. };
  41103. }
  41104. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  41105. /** @hidden */
  41106. export var lightsFragmentFunctions: {
  41107. name: string;
  41108. shader: string;
  41109. };
  41110. }
  41111. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  41112. /** @hidden */
  41113. export var shadowsFragmentFunctions: {
  41114. name: string;
  41115. shader: string;
  41116. };
  41117. }
  41118. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  41119. /** @hidden */
  41120. export var fresnelFunction: {
  41121. name: string;
  41122. shader: string;
  41123. };
  41124. }
  41125. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  41126. /** @hidden */
  41127. export var reflectionFunction: {
  41128. name: string;
  41129. shader: string;
  41130. };
  41131. }
  41132. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  41133. /** @hidden */
  41134. export var bumpFragmentFunctions: {
  41135. name: string;
  41136. shader: string;
  41137. };
  41138. }
  41139. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  41140. /** @hidden */
  41141. export var logDepthDeclaration: {
  41142. name: string;
  41143. shader: string;
  41144. };
  41145. }
  41146. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  41147. /** @hidden */
  41148. export var bumpFragment: {
  41149. name: string;
  41150. shader: string;
  41151. };
  41152. }
  41153. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  41154. /** @hidden */
  41155. export var depthPrePass: {
  41156. name: string;
  41157. shader: string;
  41158. };
  41159. }
  41160. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  41161. /** @hidden */
  41162. export var lightFragment: {
  41163. name: string;
  41164. shader: string;
  41165. };
  41166. }
  41167. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  41168. /** @hidden */
  41169. export var logDepthFragment: {
  41170. name: string;
  41171. shader: string;
  41172. };
  41173. }
  41174. declare module "babylonjs/Shaders/default.fragment" {
  41175. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  41176. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41177. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41178. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41179. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41180. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  41181. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  41182. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  41183. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  41184. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41185. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41186. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  41187. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  41188. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41189. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  41190. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  41191. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  41192. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  41193. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  41194. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  41195. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  41196. /** @hidden */
  41197. export var defaultPixelShader: {
  41198. name: string;
  41199. shader: string;
  41200. };
  41201. }
  41202. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  41203. /** @hidden */
  41204. export var defaultVertexDeclaration: {
  41205. name: string;
  41206. shader: string;
  41207. };
  41208. }
  41209. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  41210. /** @hidden */
  41211. export var bumpVertexDeclaration: {
  41212. name: string;
  41213. shader: string;
  41214. };
  41215. }
  41216. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  41217. /** @hidden */
  41218. export var bumpVertex: {
  41219. name: string;
  41220. shader: string;
  41221. };
  41222. }
  41223. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  41224. /** @hidden */
  41225. export var fogVertex: {
  41226. name: string;
  41227. shader: string;
  41228. };
  41229. }
  41230. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  41231. /** @hidden */
  41232. export var shadowsVertex: {
  41233. name: string;
  41234. shader: string;
  41235. };
  41236. }
  41237. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  41238. /** @hidden */
  41239. export var pointCloudVertex: {
  41240. name: string;
  41241. shader: string;
  41242. };
  41243. }
  41244. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  41245. /** @hidden */
  41246. export var logDepthVertex: {
  41247. name: string;
  41248. shader: string;
  41249. };
  41250. }
  41251. declare module "babylonjs/Shaders/default.vertex" {
  41252. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  41253. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41254. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41255. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  41256. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  41257. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  41258. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  41259. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  41260. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41261. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41262. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  41263. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  41264. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41265. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  41266. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  41267. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  41268. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  41269. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  41270. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  41271. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  41272. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  41273. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  41274. /** @hidden */
  41275. export var defaultVertexShader: {
  41276. name: string;
  41277. shader: string;
  41278. };
  41279. }
  41280. declare module "babylonjs/Materials/standardMaterial" {
  41281. import { SmartArray } from "babylonjs/Misc/smartArray";
  41282. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  41283. import { Nullable } from "babylonjs/types";
  41284. import { Scene } from "babylonjs/scene";
  41285. import { Matrix } from "babylonjs/Maths/math.vector";
  41286. import { Color3 } from "babylonjs/Maths/math.color";
  41287. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41288. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41289. import { Mesh } from "babylonjs/Meshes/mesh";
  41290. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  41291. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41292. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  41293. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  41294. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  41295. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41296. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41297. import "babylonjs/Shaders/default.fragment";
  41298. import "babylonjs/Shaders/default.vertex";
  41299. /** @hidden */
  41300. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  41301. MAINUV1: boolean;
  41302. MAINUV2: boolean;
  41303. DIFFUSE: boolean;
  41304. DIFFUSEDIRECTUV: number;
  41305. AMBIENT: boolean;
  41306. AMBIENTDIRECTUV: number;
  41307. OPACITY: boolean;
  41308. OPACITYDIRECTUV: number;
  41309. OPACITYRGB: boolean;
  41310. REFLECTION: boolean;
  41311. EMISSIVE: boolean;
  41312. EMISSIVEDIRECTUV: number;
  41313. SPECULAR: boolean;
  41314. SPECULARDIRECTUV: number;
  41315. BUMP: boolean;
  41316. BUMPDIRECTUV: number;
  41317. PARALLAX: boolean;
  41318. PARALLAXOCCLUSION: boolean;
  41319. SPECULAROVERALPHA: boolean;
  41320. CLIPPLANE: boolean;
  41321. CLIPPLANE2: boolean;
  41322. CLIPPLANE3: boolean;
  41323. CLIPPLANE4: boolean;
  41324. ALPHATEST: boolean;
  41325. DEPTHPREPASS: boolean;
  41326. ALPHAFROMDIFFUSE: boolean;
  41327. POINTSIZE: boolean;
  41328. FOG: boolean;
  41329. SPECULARTERM: boolean;
  41330. DIFFUSEFRESNEL: boolean;
  41331. OPACITYFRESNEL: boolean;
  41332. REFLECTIONFRESNEL: boolean;
  41333. REFRACTIONFRESNEL: boolean;
  41334. EMISSIVEFRESNEL: boolean;
  41335. FRESNEL: boolean;
  41336. NORMAL: boolean;
  41337. UV1: boolean;
  41338. UV2: boolean;
  41339. VERTEXCOLOR: boolean;
  41340. VERTEXALPHA: boolean;
  41341. NUM_BONE_INFLUENCERS: number;
  41342. BonesPerMesh: number;
  41343. BONETEXTURE: boolean;
  41344. INSTANCES: boolean;
  41345. GLOSSINESS: boolean;
  41346. ROUGHNESS: boolean;
  41347. EMISSIVEASILLUMINATION: boolean;
  41348. LINKEMISSIVEWITHDIFFUSE: boolean;
  41349. REFLECTIONFRESNELFROMSPECULAR: boolean;
  41350. LIGHTMAP: boolean;
  41351. LIGHTMAPDIRECTUV: number;
  41352. OBJECTSPACE_NORMALMAP: boolean;
  41353. USELIGHTMAPASSHADOWMAP: boolean;
  41354. REFLECTIONMAP_3D: boolean;
  41355. REFLECTIONMAP_SPHERICAL: boolean;
  41356. REFLECTIONMAP_PLANAR: boolean;
  41357. REFLECTIONMAP_CUBIC: boolean;
  41358. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  41359. REFLECTIONMAP_PROJECTION: boolean;
  41360. REFLECTIONMAP_SKYBOX: boolean;
  41361. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  41362. REFLECTIONMAP_EXPLICIT: boolean;
  41363. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  41364. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  41365. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  41366. INVERTCUBICMAP: boolean;
  41367. LOGARITHMICDEPTH: boolean;
  41368. REFRACTION: boolean;
  41369. REFRACTIONMAP_3D: boolean;
  41370. REFLECTIONOVERALPHA: boolean;
  41371. TWOSIDEDLIGHTING: boolean;
  41372. SHADOWFLOAT: boolean;
  41373. MORPHTARGETS: boolean;
  41374. MORPHTARGETS_NORMAL: boolean;
  41375. MORPHTARGETS_TANGENT: boolean;
  41376. MORPHTARGETS_UV: boolean;
  41377. NUM_MORPH_INFLUENCERS: number;
  41378. NONUNIFORMSCALING: boolean;
  41379. PREMULTIPLYALPHA: boolean;
  41380. IMAGEPROCESSING: boolean;
  41381. VIGNETTE: boolean;
  41382. VIGNETTEBLENDMODEMULTIPLY: boolean;
  41383. VIGNETTEBLENDMODEOPAQUE: boolean;
  41384. TONEMAPPING: boolean;
  41385. TONEMAPPING_ACES: boolean;
  41386. CONTRAST: boolean;
  41387. COLORCURVES: boolean;
  41388. COLORGRADING: boolean;
  41389. COLORGRADING3D: boolean;
  41390. SAMPLER3DGREENDEPTH: boolean;
  41391. SAMPLER3DBGRMAP: boolean;
  41392. IMAGEPROCESSINGPOSTPROCESS: boolean;
  41393. MULTIVIEW: boolean;
  41394. /**
  41395. * If the reflection texture on this material is in linear color space
  41396. * @hidden
  41397. */
  41398. IS_REFLECTION_LINEAR: boolean;
  41399. /**
  41400. * If the refraction texture on this material is in linear color space
  41401. * @hidden
  41402. */
  41403. IS_REFRACTION_LINEAR: boolean;
  41404. EXPOSURE: boolean;
  41405. constructor();
  41406. setReflectionMode(modeToEnable: string): void;
  41407. }
  41408. /**
  41409. * This is the default material used in Babylon. It is the best trade off between quality
  41410. * and performances.
  41411. * @see http://doc.babylonjs.com/babylon101/materials
  41412. */
  41413. export class StandardMaterial extends PushMaterial {
  41414. private _diffuseTexture;
  41415. /**
  41416. * The basic texture of the material as viewed under a light.
  41417. */
  41418. diffuseTexture: Nullable<BaseTexture>;
  41419. private _ambientTexture;
  41420. /**
  41421. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  41422. */
  41423. ambientTexture: Nullable<BaseTexture>;
  41424. private _opacityTexture;
  41425. /**
  41426. * Define the transparency of the material from a texture.
  41427. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  41428. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  41429. */
  41430. opacityTexture: Nullable<BaseTexture>;
  41431. private _reflectionTexture;
  41432. /**
  41433. * Define the texture used to display the reflection.
  41434. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41435. */
  41436. reflectionTexture: Nullable<BaseTexture>;
  41437. private _emissiveTexture;
  41438. /**
  41439. * Define texture of the material as if self lit.
  41440. * This will be mixed in the final result even in the absence of light.
  41441. */
  41442. emissiveTexture: Nullable<BaseTexture>;
  41443. private _specularTexture;
  41444. /**
  41445. * Define how the color and intensity of the highlight given by the light in the material.
  41446. */
  41447. specularTexture: Nullable<BaseTexture>;
  41448. private _bumpTexture;
  41449. /**
  41450. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  41451. * These are made by creating a normal map from an image. The means to do this can be found on the web, a search for 'normal map generator' will bring up free and paid for methods of doing this.
  41452. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  41453. */
  41454. bumpTexture: Nullable<BaseTexture>;
  41455. private _lightmapTexture;
  41456. /**
  41457. * Complex lighting can be computationally expensive to compute at runtime.
  41458. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  41459. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  41460. */
  41461. lightmapTexture: Nullable<BaseTexture>;
  41462. private _refractionTexture;
  41463. /**
  41464. * Define the texture used to display the refraction.
  41465. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41466. */
  41467. refractionTexture: Nullable<BaseTexture>;
  41468. /**
  41469. * The color of the material lit by the environmental background lighting.
  41470. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  41471. */
  41472. ambientColor: Color3;
  41473. /**
  41474. * The basic color of the material as viewed under a light.
  41475. */
  41476. diffuseColor: Color3;
  41477. /**
  41478. * Define how the color and intensity of the highlight given by the light in the material.
  41479. */
  41480. specularColor: Color3;
  41481. /**
  41482. * Define the color of the material as if self lit.
  41483. * This will be mixed in the final result even in the absence of light.
  41484. */
  41485. emissiveColor: Color3;
  41486. /**
  41487. * Defines how sharp are the highlights in the material.
  41488. * The bigger the value the sharper giving a more glossy feeling to the result.
  41489. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  41490. */
  41491. specularPower: number;
  41492. private _useAlphaFromDiffuseTexture;
  41493. /**
  41494. * Does the transparency come from the diffuse texture alpha channel.
  41495. */
  41496. useAlphaFromDiffuseTexture: boolean;
  41497. private _useEmissiveAsIllumination;
  41498. /**
  41499. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  41500. */
  41501. useEmissiveAsIllumination: boolean;
  41502. private _linkEmissiveWithDiffuse;
  41503. /**
  41504. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  41505. * the emissive level when the final color is close to one.
  41506. */
  41507. linkEmissiveWithDiffuse: boolean;
  41508. private _useSpecularOverAlpha;
  41509. /**
  41510. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  41511. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  41512. */
  41513. useSpecularOverAlpha: boolean;
  41514. private _useReflectionOverAlpha;
  41515. /**
  41516. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  41517. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  41518. */
  41519. useReflectionOverAlpha: boolean;
  41520. private _disableLighting;
  41521. /**
  41522. * Does lights from the scene impacts this material.
  41523. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  41524. */
  41525. disableLighting: boolean;
  41526. private _useObjectSpaceNormalMap;
  41527. /**
  41528. * Allows using an object space normal map (instead of tangent space).
  41529. */
  41530. useObjectSpaceNormalMap: boolean;
  41531. private _useParallax;
  41532. /**
  41533. * Is parallax enabled or not.
  41534. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41535. */
  41536. useParallax: boolean;
  41537. private _useParallaxOcclusion;
  41538. /**
  41539. * Is parallax occlusion enabled or not.
  41540. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  41541. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41542. */
  41543. useParallaxOcclusion: boolean;
  41544. /**
  41545. * Apply a scaling factor that determine which "depth" the height map should reprensent. A value between 0.05 and 0.1 is reasonnable in Parallax, you can reach 0.2 using Parallax Occlusion.
  41546. */
  41547. parallaxScaleBias: number;
  41548. private _roughness;
  41549. /**
  41550. * Helps to define how blurry the reflections should appears in the material.
  41551. */
  41552. roughness: number;
  41553. /**
  41554. * In case of refraction, define the value of the index of refraction.
  41555. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41556. */
  41557. indexOfRefraction: number;
  41558. /**
  41559. * Invert the refraction texture alongside the y axis.
  41560. * It can be useful with procedural textures or probe for instance.
  41561. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41562. */
  41563. invertRefractionY: boolean;
  41564. /**
  41565. * Defines the alpha limits in alpha test mode.
  41566. */
  41567. alphaCutOff: number;
  41568. private _useLightmapAsShadowmap;
  41569. /**
  41570. * In case of light mapping, define whether the map contains light or shadow informations.
  41571. */
  41572. useLightmapAsShadowmap: boolean;
  41573. private _diffuseFresnelParameters;
  41574. /**
  41575. * Define the diffuse fresnel parameters of the material.
  41576. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41577. */
  41578. diffuseFresnelParameters: FresnelParameters;
  41579. private _opacityFresnelParameters;
  41580. /**
  41581. * Define the opacity fresnel parameters of the material.
  41582. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41583. */
  41584. opacityFresnelParameters: FresnelParameters;
  41585. private _reflectionFresnelParameters;
  41586. /**
  41587. * Define the reflection fresnel parameters of the material.
  41588. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41589. */
  41590. reflectionFresnelParameters: FresnelParameters;
  41591. private _refractionFresnelParameters;
  41592. /**
  41593. * Define the refraction fresnel parameters of the material.
  41594. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41595. */
  41596. refractionFresnelParameters: FresnelParameters;
  41597. private _emissiveFresnelParameters;
  41598. /**
  41599. * Define the emissive fresnel parameters of the material.
  41600. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41601. */
  41602. emissiveFresnelParameters: FresnelParameters;
  41603. private _useReflectionFresnelFromSpecular;
  41604. /**
  41605. * If true automatically deducts the fresnels values from the material specularity.
  41606. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41607. */
  41608. useReflectionFresnelFromSpecular: boolean;
  41609. private _useGlossinessFromSpecularMapAlpha;
  41610. /**
  41611. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  41612. */
  41613. useGlossinessFromSpecularMapAlpha: boolean;
  41614. private _maxSimultaneousLights;
  41615. /**
  41616. * Defines the maximum number of lights that can be used in the material
  41617. */
  41618. maxSimultaneousLights: number;
  41619. private _invertNormalMapX;
  41620. /**
  41621. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  41622. */
  41623. invertNormalMapX: boolean;
  41624. private _invertNormalMapY;
  41625. /**
  41626. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  41627. */
  41628. invertNormalMapY: boolean;
  41629. private _twoSidedLighting;
  41630. /**
  41631. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  41632. */
  41633. twoSidedLighting: boolean;
  41634. /**
  41635. * Default configuration related to image processing available in the standard Material.
  41636. */
  41637. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41638. /**
  41639. * Gets the image processing configuration used either in this material.
  41640. */
  41641. /**
  41642. * Sets the Default image processing configuration used either in the this material.
  41643. *
  41644. * If sets to null, the scene one is in use.
  41645. */
  41646. imageProcessingConfiguration: ImageProcessingConfiguration;
  41647. /**
  41648. * Keep track of the image processing observer to allow dispose and replace.
  41649. */
  41650. private _imageProcessingObserver;
  41651. /**
  41652. * Attaches a new image processing configuration to the Standard Material.
  41653. * @param configuration
  41654. */
  41655. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  41656. /**
  41657. * Gets wether the color curves effect is enabled.
  41658. */
  41659. /**
  41660. * Sets wether the color curves effect is enabled.
  41661. */
  41662. cameraColorCurvesEnabled: boolean;
  41663. /**
  41664. * Gets wether the color grading effect is enabled.
  41665. */
  41666. /**
  41667. * Gets wether the color grading effect is enabled.
  41668. */
  41669. cameraColorGradingEnabled: boolean;
  41670. /**
  41671. * Gets wether tonemapping is enabled or not.
  41672. */
  41673. /**
  41674. * Sets wether tonemapping is enabled or not
  41675. */
  41676. cameraToneMappingEnabled: boolean;
  41677. /**
  41678. * The camera exposure used on this material.
  41679. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41680. * This corresponds to a photographic exposure.
  41681. */
  41682. /**
  41683. * The camera exposure used on this material.
  41684. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41685. * This corresponds to a photographic exposure.
  41686. */
  41687. cameraExposure: number;
  41688. /**
  41689. * Gets The camera contrast used on this material.
  41690. */
  41691. /**
  41692. * Sets The camera contrast used on this material.
  41693. */
  41694. cameraContrast: number;
  41695. /**
  41696. * Gets the Color Grading 2D Lookup Texture.
  41697. */
  41698. /**
  41699. * Sets the Color Grading 2D Lookup Texture.
  41700. */
  41701. cameraColorGradingTexture: Nullable<BaseTexture>;
  41702. /**
  41703. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41704. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41705. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  41706. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41707. */
  41708. /**
  41709. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41710. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41711. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  41712. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41713. */
  41714. cameraColorCurves: Nullable<ColorCurves>;
  41715. /**
  41716. * Custom callback helping to override the default shader used in the material.
  41717. */
  41718. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  41719. protected _renderTargets: SmartArray<RenderTargetTexture>;
  41720. protected _worldViewProjectionMatrix: Matrix;
  41721. protected _globalAmbientColor: Color3;
  41722. protected _useLogarithmicDepth: boolean;
  41723. protected _rebuildInParallel: boolean;
  41724. /**
  41725. * Instantiates a new standard material.
  41726. * This is the default material used in Babylon. It is the best trade off between quality
  41727. * and performances.
  41728. * @see http://doc.babylonjs.com/babylon101/materials
  41729. * @param name Define the name of the material in the scene
  41730. * @param scene Define the scene the material belong to
  41731. */
  41732. constructor(name: string, scene: Scene);
  41733. /**
  41734. * Gets a boolean indicating that current material needs to register RTT
  41735. */
  41736. readonly hasRenderTargetTextures: boolean;
  41737. /**
  41738. * Gets the current class name of the material e.g. "StandardMaterial"
  41739. * Mainly use in serialization.
  41740. * @returns the class name
  41741. */
  41742. getClassName(): string;
  41743. /**
  41744. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  41745. * You can try switching to logarithmic depth.
  41746. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  41747. */
  41748. useLogarithmicDepth: boolean;
  41749. /**
  41750. * Specifies if the material will require alpha blending
  41751. * @returns a boolean specifying if alpha blending is needed
  41752. */
  41753. needAlphaBlending(): boolean;
  41754. /**
  41755. * Specifies if this material should be rendered in alpha test mode
  41756. * @returns a boolean specifying if an alpha test is needed.
  41757. */
  41758. needAlphaTesting(): boolean;
  41759. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  41760. /**
  41761. * Get the texture used for alpha test purpose.
  41762. * @returns the diffuse texture in case of the standard material.
  41763. */
  41764. getAlphaTestTexture(): Nullable<BaseTexture>;
  41765. /**
  41766. * Get if the submesh is ready to be used and all its information available.
  41767. * Child classes can use it to update shaders
  41768. * @param mesh defines the mesh to check
  41769. * @param subMesh defines which submesh to check
  41770. * @param useInstances specifies that instances should be used
  41771. * @returns a boolean indicating that the submesh is ready or not
  41772. */
  41773. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  41774. /**
  41775. * Builds the material UBO layouts.
  41776. * Used internally during the effect preparation.
  41777. */
  41778. buildUniformLayout(): void;
  41779. /**
  41780. * Unbinds the material from the mesh
  41781. */
  41782. unbind(): void;
  41783. /**
  41784. * Binds the submesh to this material by preparing the effect and shader to draw
  41785. * @param world defines the world transformation matrix
  41786. * @param mesh defines the mesh containing the submesh
  41787. * @param subMesh defines the submesh to bind the material to
  41788. */
  41789. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  41790. /**
  41791. * Get the list of animatables in the material.
  41792. * @returns the list of animatables object used in the material
  41793. */
  41794. getAnimatables(): IAnimatable[];
  41795. /**
  41796. * Gets the active textures from the material
  41797. * @returns an array of textures
  41798. */
  41799. getActiveTextures(): BaseTexture[];
  41800. /**
  41801. * Specifies if the material uses a texture
  41802. * @param texture defines the texture to check against the material
  41803. * @returns a boolean specifying if the material uses the texture
  41804. */
  41805. hasTexture(texture: BaseTexture): boolean;
  41806. /**
  41807. * Disposes the material
  41808. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  41809. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  41810. */
  41811. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  41812. /**
  41813. * Makes a duplicate of the material, and gives it a new name
  41814. * @param name defines the new name for the duplicated material
  41815. * @returns the cloned material
  41816. */
  41817. clone(name: string): StandardMaterial;
  41818. /**
  41819. * Serializes this material in a JSON representation
  41820. * @returns the serialized material object
  41821. */
  41822. serialize(): any;
  41823. /**
  41824. * Creates a standard material from parsed material data
  41825. * @param source defines the JSON representation of the material
  41826. * @param scene defines the hosting scene
  41827. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  41828. * @returns a new standard material
  41829. */
  41830. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  41831. /**
  41832. * Are diffuse textures enabled in the application.
  41833. */
  41834. static DiffuseTextureEnabled: boolean;
  41835. /**
  41836. * Are ambient textures enabled in the application.
  41837. */
  41838. static AmbientTextureEnabled: boolean;
  41839. /**
  41840. * Are opacity textures enabled in the application.
  41841. */
  41842. static OpacityTextureEnabled: boolean;
  41843. /**
  41844. * Are reflection textures enabled in the application.
  41845. */
  41846. static ReflectionTextureEnabled: boolean;
  41847. /**
  41848. * Are emissive textures enabled in the application.
  41849. */
  41850. static EmissiveTextureEnabled: boolean;
  41851. /**
  41852. * Are specular textures enabled in the application.
  41853. */
  41854. static SpecularTextureEnabled: boolean;
  41855. /**
  41856. * Are bump textures enabled in the application.
  41857. */
  41858. static BumpTextureEnabled: boolean;
  41859. /**
  41860. * Are lightmap textures enabled in the application.
  41861. */
  41862. static LightmapTextureEnabled: boolean;
  41863. /**
  41864. * Are refraction textures enabled in the application.
  41865. */
  41866. static RefractionTextureEnabled: boolean;
  41867. /**
  41868. * Are color grading textures enabled in the application.
  41869. */
  41870. static ColorGradingTextureEnabled: boolean;
  41871. /**
  41872. * Are fresnels enabled in the application.
  41873. */
  41874. static FresnelEnabled: boolean;
  41875. }
  41876. }
  41877. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  41878. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41879. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41880. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41881. /** @hidden */
  41882. export var imageProcessingPixelShader: {
  41883. name: string;
  41884. shader: string;
  41885. };
  41886. }
  41887. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  41888. import { Nullable } from "babylonjs/types";
  41889. import { Color4 } from "babylonjs/Maths/math.color";
  41890. import { Camera } from "babylonjs/Cameras/camera";
  41891. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41892. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41893. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  41894. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  41895. import { Engine } from "babylonjs/Engines/engine";
  41896. import "babylonjs/Shaders/imageProcessing.fragment";
  41897. import "babylonjs/Shaders/postprocess.vertex";
  41898. /**
  41899. * ImageProcessingPostProcess
  41900. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  41901. */
  41902. export class ImageProcessingPostProcess extends PostProcess {
  41903. /**
  41904. * Default configuration related to image processing available in the PBR Material.
  41905. */
  41906. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41907. /**
  41908. * Gets the image processing configuration used either in this material.
  41909. */
  41910. /**
  41911. * Sets the Default image processing configuration used either in the this material.
  41912. *
  41913. * If sets to null, the scene one is in use.
  41914. */
  41915. imageProcessingConfiguration: ImageProcessingConfiguration;
  41916. /**
  41917. * Keep track of the image processing observer to allow dispose and replace.
  41918. */
  41919. private _imageProcessingObserver;
  41920. /**
  41921. * Attaches a new image processing configuration to the PBR Material.
  41922. * @param configuration
  41923. */
  41924. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  41925. /**
  41926. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41927. */
  41928. /**
  41929. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41930. */
  41931. colorCurves: Nullable<ColorCurves>;
  41932. /**
  41933. * Gets wether the color curves effect is enabled.
  41934. */
  41935. /**
  41936. * Sets wether the color curves effect is enabled.
  41937. */
  41938. colorCurvesEnabled: boolean;
  41939. /**
  41940. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41941. */
  41942. /**
  41943. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41944. */
  41945. colorGradingTexture: Nullable<BaseTexture>;
  41946. /**
  41947. * Gets wether the color grading effect is enabled.
  41948. */
  41949. /**
  41950. * Gets wether the color grading effect is enabled.
  41951. */
  41952. colorGradingEnabled: boolean;
  41953. /**
  41954. * Gets exposure used in the effect.
  41955. */
  41956. /**
  41957. * Sets exposure used in the effect.
  41958. */
  41959. exposure: number;
  41960. /**
  41961. * Gets wether tonemapping is enabled or not.
  41962. */
  41963. /**
  41964. * Sets wether tonemapping is enabled or not
  41965. */
  41966. toneMappingEnabled: boolean;
  41967. /**
  41968. * Gets the type of tone mapping effect.
  41969. */
  41970. /**
  41971. * Sets the type of tone mapping effect.
  41972. */
  41973. toneMappingType: number;
  41974. /**
  41975. * Gets contrast used in the effect.
  41976. */
  41977. /**
  41978. * Sets contrast used in the effect.
  41979. */
  41980. contrast: number;
  41981. /**
  41982. * Gets Vignette stretch size.
  41983. */
  41984. /**
  41985. * Sets Vignette stretch size.
  41986. */
  41987. vignetteStretch: number;
  41988. /**
  41989. * Gets Vignette centre X Offset.
  41990. */
  41991. /**
  41992. * Sets Vignette centre X Offset.
  41993. */
  41994. vignetteCentreX: number;
  41995. /**
  41996. * Gets Vignette centre Y Offset.
  41997. */
  41998. /**
  41999. * Sets Vignette centre Y Offset.
  42000. */
  42001. vignetteCentreY: number;
  42002. /**
  42003. * Gets Vignette weight or intensity of the vignette effect.
  42004. */
  42005. /**
  42006. * Sets Vignette weight or intensity of the vignette effect.
  42007. */
  42008. vignetteWeight: number;
  42009. /**
  42010. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42011. * if vignetteEnabled is set to true.
  42012. */
  42013. /**
  42014. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42015. * if vignetteEnabled is set to true.
  42016. */
  42017. vignetteColor: Color4;
  42018. /**
  42019. * Gets Camera field of view used by the Vignette effect.
  42020. */
  42021. /**
  42022. * Sets Camera field of view used by the Vignette effect.
  42023. */
  42024. vignetteCameraFov: number;
  42025. /**
  42026. * Gets the vignette blend mode allowing different kind of effect.
  42027. */
  42028. /**
  42029. * Sets the vignette blend mode allowing different kind of effect.
  42030. */
  42031. vignetteBlendMode: number;
  42032. /**
  42033. * Gets wether the vignette effect is enabled.
  42034. */
  42035. /**
  42036. * Sets wether the vignette effect is enabled.
  42037. */
  42038. vignetteEnabled: boolean;
  42039. private _fromLinearSpace;
  42040. /**
  42041. * Gets wether the input of the processing is in Gamma or Linear Space.
  42042. */
  42043. /**
  42044. * Sets wether the input of the processing is in Gamma or Linear Space.
  42045. */
  42046. fromLinearSpace: boolean;
  42047. /**
  42048. * Defines cache preventing GC.
  42049. */
  42050. private _defines;
  42051. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42052. /**
  42053. * "ImageProcessingPostProcess"
  42054. * @returns "ImageProcessingPostProcess"
  42055. */
  42056. getClassName(): string;
  42057. protected _updateParameters(): void;
  42058. dispose(camera?: Camera): void;
  42059. }
  42060. }
  42061. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  42062. import { Scene } from "babylonjs/scene";
  42063. import { Color3 } from "babylonjs/Maths/math.color";
  42064. import { Mesh } from "babylonjs/Meshes/mesh";
  42065. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  42066. import { Nullable } from "babylonjs/types";
  42067. /**
  42068. * Class containing static functions to help procedurally build meshes
  42069. */
  42070. export class GroundBuilder {
  42071. /**
  42072. * Creates a ground mesh
  42073. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42074. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42075. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42076. * @param name defines the name of the mesh
  42077. * @param options defines the options used to create the mesh
  42078. * @param scene defines the hosting scene
  42079. * @returns the ground mesh
  42080. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42081. */
  42082. static CreateGround(name: string, options: {
  42083. width?: number;
  42084. height?: number;
  42085. subdivisions?: number;
  42086. subdivisionsX?: number;
  42087. subdivisionsY?: number;
  42088. updatable?: boolean;
  42089. }, scene: any): Mesh;
  42090. /**
  42091. * Creates a tiled ground mesh
  42092. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42093. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42094. * * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the numbers of subdivisions on the ground width and height. Each subdivision is called a tile
  42095. * * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the numbers of subdivisions on the ground width and height of each tile
  42096. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42097. * @param name defines the name of the mesh
  42098. * @param options defines the options used to create the mesh
  42099. * @param scene defines the hosting scene
  42100. * @returns the tiled ground mesh
  42101. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42102. */
  42103. static CreateTiledGround(name: string, options: {
  42104. xmin: number;
  42105. zmin: number;
  42106. xmax: number;
  42107. zmax: number;
  42108. subdivisions?: {
  42109. w: number;
  42110. h: number;
  42111. };
  42112. precision?: {
  42113. w: number;
  42114. h: number;
  42115. };
  42116. updatable?: boolean;
  42117. }, scene?: Nullable<Scene>): Mesh;
  42118. /**
  42119. * Creates a ground mesh from a height map
  42120. * * The parameter `url` sets the URL of the height map image resource.
  42121. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42122. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42123. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42124. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42125. * * The parameter `colorFilter` (optional Color3, default (0.3, 0.59, 0.11) ) is the filter to apply to the image pixel colors to compute the height.
  42126. * * The parameter `onReady` is a javascript callback function that will be called once the mesh is just built (the height map download can last some time).
  42127. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42128. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42129. * @param name defines the name of the mesh
  42130. * @param url defines the url to the height map
  42131. * @param options defines the options used to create the mesh
  42132. * @param scene defines the hosting scene
  42133. * @returns the ground mesh
  42134. * @see https://doc.babylonjs.com/babylon101/height_map
  42135. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42136. */
  42137. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42138. width?: number;
  42139. height?: number;
  42140. subdivisions?: number;
  42141. minHeight?: number;
  42142. maxHeight?: number;
  42143. colorFilter?: Color3;
  42144. alphaFilter?: number;
  42145. updatable?: boolean;
  42146. onReady?: (mesh: GroundMesh) => void;
  42147. }, scene?: Nullable<Scene>): GroundMesh;
  42148. }
  42149. }
  42150. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  42151. import { Vector4 } from "babylonjs/Maths/math.vector";
  42152. import { Mesh } from "babylonjs/Meshes/mesh";
  42153. /**
  42154. * Class containing static functions to help procedurally build meshes
  42155. */
  42156. export class TorusBuilder {
  42157. /**
  42158. * Creates a torus mesh
  42159. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42160. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42161. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42162. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42163. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42164. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42165. * @param name defines the name of the mesh
  42166. * @param options defines the options used to create the mesh
  42167. * @param scene defines the hosting scene
  42168. * @returns the torus mesh
  42169. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42170. */
  42171. static CreateTorus(name: string, options: {
  42172. diameter?: number;
  42173. thickness?: number;
  42174. tessellation?: number;
  42175. updatable?: boolean;
  42176. sideOrientation?: number;
  42177. frontUVs?: Vector4;
  42178. backUVs?: Vector4;
  42179. }, scene: any): Mesh;
  42180. }
  42181. }
  42182. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  42183. import { Vector4 } from "babylonjs/Maths/math.vector";
  42184. import { Color4 } from "babylonjs/Maths/math.color";
  42185. import { Mesh } from "babylonjs/Meshes/mesh";
  42186. /**
  42187. * Class containing static functions to help procedurally build meshes
  42188. */
  42189. export class CylinderBuilder {
  42190. /**
  42191. * Creates a cylinder or a cone mesh
  42192. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42193. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42194. * * The parameters `diameterTop` and `diameterBottom` overwrite the parameter `diameter` and set respectively the top cap and bottom cap diameter (floats, default 1). The parameter "diameterBottom" can't be zero.
  42195. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42196. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42197. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42198. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42199. * * The parameter `cap` sets the way the cylinder is capped. Possible values : BABYLON.Mesh.NO_CAP, BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL (default).
  42200. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42201. * * You can set different colors and different images to each box side by using the parameters `faceColors` (an array of n Color3 elements) and `faceUV` (an array of n Vector4 elements).
  42202. * * The value of n is the number of cylinder faces. If the cylinder has only 1 subdivisions, n equals : top face + cylinder surface + bottom face = 3
  42203. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42204. * * Finally, if the cylinder has 5 independent subdivisions and is enclose, n equals : top face + 5 x (stripe surface + 2 closing faces) + bottom face = 2 + 5 * 3 = 17
  42205. * * Each array (color or UVs) is always ordered the same way : the first element is the bottom cap, the last element is the top cap. The other elements are each a ring surface.
  42206. * * If `enclose` is false, a ring surface is one element.
  42207. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42208. * * Example how to set colors and textures on a sliced cylinder : https://www.html5gamedevs.com/topic/17945-creating-a-closed-slice-of-a-cylinder/#comment-106379
  42209. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42210. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42211. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42212. * @param name defines the name of the mesh
  42213. * @param options defines the options used to create the mesh
  42214. * @param scene defines the hosting scene
  42215. * @returns the cylinder mesh
  42216. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42217. */
  42218. static CreateCylinder(name: string, options: {
  42219. height?: number;
  42220. diameterTop?: number;
  42221. diameterBottom?: number;
  42222. diameter?: number;
  42223. tessellation?: number;
  42224. subdivisions?: number;
  42225. arc?: number;
  42226. faceColors?: Color4[];
  42227. faceUV?: Vector4[];
  42228. updatable?: boolean;
  42229. hasRings?: boolean;
  42230. enclose?: boolean;
  42231. cap?: number;
  42232. sideOrientation?: number;
  42233. frontUVs?: Vector4;
  42234. backUVs?: Vector4;
  42235. }, scene: any): Mesh;
  42236. }
  42237. }
  42238. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  42239. import { Observable } from "babylonjs/Misc/observable";
  42240. import { Nullable } from "babylonjs/types";
  42241. import { Camera } from "babylonjs/Cameras/camera";
  42242. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  42243. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42244. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  42245. import { Scene } from "babylonjs/scene";
  42246. import { Vector3 } from "babylonjs/Maths/math.vector";
  42247. import { Color3 } from "babylonjs/Maths/math.color";
  42248. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42249. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42250. import { Mesh } from "babylonjs/Meshes/mesh";
  42251. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  42252. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42253. import "babylonjs/Meshes/Builders/groundBuilder";
  42254. import "babylonjs/Meshes/Builders/torusBuilder";
  42255. import "babylonjs/Meshes/Builders/cylinderBuilder";
  42256. import "babylonjs/Gamepads/gamepadSceneComponent";
  42257. import "babylonjs/Animations/animatable";
  42258. /**
  42259. * Options to modify the vr teleportation behavior.
  42260. */
  42261. export interface VRTeleportationOptions {
  42262. /**
  42263. * The name of the mesh which should be used as the teleportation floor. (default: null)
  42264. */
  42265. floorMeshName?: string;
  42266. /**
  42267. * A list of meshes to be used as the teleportation floor. (default: empty)
  42268. */
  42269. floorMeshes?: Mesh[];
  42270. }
  42271. /**
  42272. * Options to modify the vr experience helper's behavior.
  42273. */
  42274. export interface VRExperienceHelperOptions extends WebVROptions {
  42275. /**
  42276. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  42277. */
  42278. createDeviceOrientationCamera?: boolean;
  42279. /**
  42280. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  42281. */
  42282. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  42283. /**
  42284. * Uses the main button on the controller to toggle the laser casted. (default: true)
  42285. */
  42286. laserToggle?: boolean;
  42287. /**
  42288. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  42289. */
  42290. floorMeshes?: Mesh[];
  42291. /**
  42292. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  42293. */
  42294. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  42295. }
  42296. /**
  42297. * Event containing information after VR has been entered
  42298. */
  42299. export class OnAfterEnteringVRObservableEvent {
  42300. /**
  42301. * If entering vr was successful
  42302. */
  42303. success: boolean;
  42304. }
  42305. /**
  42306. * Helps to quickly add VR support to an existing scene.
  42307. * See http://doc.babylonjs.com/how_to/webvr_helper
  42308. */
  42309. export class VRExperienceHelper {
  42310. /** Options to modify the vr experience helper's behavior. */
  42311. webVROptions: VRExperienceHelperOptions;
  42312. private _scene;
  42313. private _position;
  42314. private _btnVR;
  42315. private _btnVRDisplayed;
  42316. private _webVRsupported;
  42317. private _webVRready;
  42318. private _webVRrequesting;
  42319. private _webVRpresenting;
  42320. private _hasEnteredVR;
  42321. private _fullscreenVRpresenting;
  42322. private _canvas;
  42323. private _webVRCamera;
  42324. private _vrDeviceOrientationCamera;
  42325. private _deviceOrientationCamera;
  42326. private _existingCamera;
  42327. private _onKeyDown;
  42328. private _onVrDisplayPresentChange;
  42329. private _onVRDisplayChanged;
  42330. private _onVRRequestPresentStart;
  42331. private _onVRRequestPresentComplete;
  42332. /**
  42333. * Gets or sets a boolean indicating that gaze can be enabled even if pointer lock is not engage (useful on iOS where fullscreen mode and pointer lock are not supported)
  42334. */
  42335. enableGazeEvenWhenNoPointerLock: boolean;
  42336. /**
  42337. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  42338. */
  42339. exitVROnDoubleTap: boolean;
  42340. /**
  42341. * Observable raised right before entering VR.
  42342. */
  42343. onEnteringVRObservable: Observable<VRExperienceHelper>;
  42344. /**
  42345. * Observable raised when entering VR has completed.
  42346. */
  42347. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  42348. /**
  42349. * Observable raised when exiting VR.
  42350. */
  42351. onExitingVRObservable: Observable<VRExperienceHelper>;
  42352. /**
  42353. * Observable raised when controller mesh is loaded.
  42354. */
  42355. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42356. /** Return this.onEnteringVRObservable
  42357. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  42358. */
  42359. readonly onEnteringVR: Observable<VRExperienceHelper>;
  42360. /** Return this.onExitingVRObservable
  42361. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  42362. */
  42363. readonly onExitingVR: Observable<VRExperienceHelper>;
  42364. /** Return this.onControllerMeshLoadedObservable
  42365. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  42366. */
  42367. readonly onControllerMeshLoaded: Observable<WebVRController>;
  42368. private _rayLength;
  42369. private _useCustomVRButton;
  42370. private _teleportationRequested;
  42371. private _teleportActive;
  42372. private _floorMeshName;
  42373. private _floorMeshesCollection;
  42374. private _rotationAllowed;
  42375. private _teleportBackwardsVector;
  42376. private _teleportationTarget;
  42377. private _isDefaultTeleportationTarget;
  42378. private _postProcessMove;
  42379. private _teleportationFillColor;
  42380. private _teleportationBorderColor;
  42381. private _rotationAngle;
  42382. private _haloCenter;
  42383. private _cameraGazer;
  42384. private _padSensibilityUp;
  42385. private _padSensibilityDown;
  42386. private _leftController;
  42387. private _rightController;
  42388. /**
  42389. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  42390. */
  42391. onNewMeshSelected: Observable<AbstractMesh>;
  42392. /**
  42393. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  42394. * This observable will provide the mesh and the controller used to select the mesh
  42395. */
  42396. onMeshSelectedWithController: Observable<{
  42397. mesh: AbstractMesh;
  42398. controller: WebVRController;
  42399. }>;
  42400. /**
  42401. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  42402. */
  42403. onNewMeshPicked: Observable<PickingInfo>;
  42404. private _circleEase;
  42405. /**
  42406. * Observable raised before camera teleportation
  42407. */
  42408. onBeforeCameraTeleport: Observable<Vector3>;
  42409. /**
  42410. * Observable raised after camera teleportation
  42411. */
  42412. onAfterCameraTeleport: Observable<Vector3>;
  42413. /**
  42414. * Observable raised when current selected mesh gets unselected
  42415. */
  42416. onSelectedMeshUnselected: Observable<AbstractMesh>;
  42417. private _raySelectionPredicate;
  42418. /**
  42419. * To be optionaly changed by user to define custom ray selection
  42420. */
  42421. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  42422. /**
  42423. * To be optionaly changed by user to define custom selection logic (after ray selection)
  42424. */
  42425. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  42426. /**
  42427. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  42428. */
  42429. teleportationEnabled: boolean;
  42430. private _defaultHeight;
  42431. private _teleportationInitialized;
  42432. private _interactionsEnabled;
  42433. private _interactionsRequested;
  42434. private _displayGaze;
  42435. private _displayLaserPointer;
  42436. /**
  42437. * The mesh used to display where the user is going to teleport.
  42438. */
  42439. /**
  42440. * Sets the mesh to be used to display where the user is going to teleport.
  42441. */
  42442. teleportationTarget: Mesh;
  42443. /**
  42444. * The mesh used to display where the user is selecting, this mesh will be cloned and set as the gazeTracker for the left and right controller
  42445. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  42446. * See http://doc.babylonjs.com/resources/baking_transformations
  42447. */
  42448. gazeTrackerMesh: Mesh;
  42449. /**
  42450. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  42451. */
  42452. updateGazeTrackerScale: boolean;
  42453. /**
  42454. * If the gaze trackers color should be updated when selecting meshes
  42455. */
  42456. updateGazeTrackerColor: boolean;
  42457. /**
  42458. * If the controller laser color should be updated when selecting meshes
  42459. */
  42460. updateControllerLaserColor: boolean;
  42461. /**
  42462. * The gaze tracking mesh corresponding to the left controller
  42463. */
  42464. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  42465. /**
  42466. * The gaze tracking mesh corresponding to the right controller
  42467. */
  42468. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  42469. /**
  42470. * If the ray of the gaze should be displayed.
  42471. */
  42472. /**
  42473. * Sets if the ray of the gaze should be displayed.
  42474. */
  42475. displayGaze: boolean;
  42476. /**
  42477. * If the ray of the LaserPointer should be displayed.
  42478. */
  42479. /**
  42480. * Sets if the ray of the LaserPointer should be displayed.
  42481. */
  42482. displayLaserPointer: boolean;
  42483. /**
  42484. * The deviceOrientationCamera used as the camera when not in VR.
  42485. */
  42486. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  42487. /**
  42488. * Based on the current WebVR support, returns the current VR camera used.
  42489. */
  42490. readonly currentVRCamera: Nullable<Camera>;
  42491. /**
  42492. * The webVRCamera which is used when in VR.
  42493. */
  42494. readonly webVRCamera: WebVRFreeCamera;
  42495. /**
  42496. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  42497. */
  42498. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  42499. /**
  42500. * The html button that is used to trigger entering into VR.
  42501. */
  42502. readonly vrButton: Nullable<HTMLButtonElement>;
  42503. private readonly _teleportationRequestInitiated;
  42504. /**
  42505. * Defines wether or not Pointer lock should be requested when switching to
  42506. * full screen.
  42507. */
  42508. requestPointerLockOnFullScreen: boolean;
  42509. /**
  42510. * Instantiates a VRExperienceHelper.
  42511. * Helps to quickly add VR support to an existing scene.
  42512. * @param scene The scene the VRExperienceHelper belongs to.
  42513. * @param webVROptions Options to modify the vr experience helper's behavior.
  42514. */
  42515. constructor(scene: Scene,
  42516. /** Options to modify the vr experience helper's behavior. */
  42517. webVROptions?: VRExperienceHelperOptions);
  42518. private _onDefaultMeshLoaded;
  42519. private _onResize;
  42520. private _onFullscreenChange;
  42521. /**
  42522. * Gets a value indicating if we are currently in VR mode.
  42523. */
  42524. readonly isInVRMode: boolean;
  42525. private onVrDisplayPresentChange;
  42526. private onVRDisplayChanged;
  42527. private moveButtonToBottomRight;
  42528. private displayVRButton;
  42529. private updateButtonVisibility;
  42530. private _cachedAngularSensibility;
  42531. /**
  42532. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  42533. * Otherwise, will use the fullscreen API.
  42534. */
  42535. enterVR(): void;
  42536. /**
  42537. * Attempt to exit VR, or fullscreen.
  42538. */
  42539. exitVR(): void;
  42540. /**
  42541. * The position of the vr experience helper.
  42542. */
  42543. /**
  42544. * Sets the position of the vr experience helper.
  42545. */
  42546. position: Vector3;
  42547. /**
  42548. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  42549. */
  42550. enableInteractions(): void;
  42551. private readonly _noControllerIsActive;
  42552. private beforeRender;
  42553. private _isTeleportationFloor;
  42554. /**
  42555. * Adds a floor mesh to be used for teleportation.
  42556. * @param floorMesh the mesh to be used for teleportation.
  42557. */
  42558. addFloorMesh(floorMesh: Mesh): void;
  42559. /**
  42560. * Removes a floor mesh from being used for teleportation.
  42561. * @param floorMesh the mesh to be removed.
  42562. */
  42563. removeFloorMesh(floorMesh: Mesh): void;
  42564. /**
  42565. * Enables interactions and teleportation using the VR controllers and gaze.
  42566. * @param vrTeleportationOptions options to modify teleportation behavior.
  42567. */
  42568. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  42569. private _onNewGamepadConnected;
  42570. private _tryEnableInteractionOnController;
  42571. private _onNewGamepadDisconnected;
  42572. private _enableInteractionOnController;
  42573. private _checkTeleportWithRay;
  42574. private _checkRotate;
  42575. private _checkTeleportBackwards;
  42576. private _enableTeleportationOnController;
  42577. private _createTeleportationCircles;
  42578. private _displayTeleportationTarget;
  42579. private _hideTeleportationTarget;
  42580. private _rotateCamera;
  42581. private _moveTeleportationSelectorTo;
  42582. private _workingVector;
  42583. private _workingQuaternion;
  42584. private _workingMatrix;
  42585. /**
  42586. * Teleports the users feet to the desired location
  42587. * @param location The location where the user's feet should be placed
  42588. */
  42589. teleportCamera(location: Vector3): void;
  42590. private _convertNormalToDirectionOfRay;
  42591. private _castRayAndSelectObject;
  42592. private _notifySelectedMeshUnselected;
  42593. /**
  42594. * Sets the color of the laser ray from the vr controllers.
  42595. * @param color new color for the ray.
  42596. */
  42597. changeLaserColor(color: Color3): void;
  42598. /**
  42599. * Sets the color of the ray from the vr headsets gaze.
  42600. * @param color new color for the ray.
  42601. */
  42602. changeGazeColor(color: Color3): void;
  42603. /**
  42604. * Exits VR and disposes of the vr experience helper
  42605. */
  42606. dispose(): void;
  42607. /**
  42608. * Gets the name of the VRExperienceHelper class
  42609. * @returns "VRExperienceHelper"
  42610. */
  42611. getClassName(): string;
  42612. }
  42613. }
  42614. declare module "babylonjs/Cameras/VR/index" {
  42615. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  42616. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  42617. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42618. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  42619. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  42620. export * from "babylonjs/Cameras/VR/webVRCamera";
  42621. }
  42622. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  42623. import { Observable } from "babylonjs/Misc/observable";
  42624. import { Nullable } from "babylonjs/types";
  42625. import { IDisposable, Scene } from "babylonjs/scene";
  42626. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  42627. /**
  42628. * Manages an XRSession to work with Babylon's engine
  42629. * @see https://doc.babylonjs.com/how_to/webxr
  42630. */
  42631. export class WebXRSessionManager implements IDisposable {
  42632. private scene;
  42633. /**
  42634. * Fires every time a new xrFrame arrives which can be used to update the camera
  42635. */
  42636. onXRFrameObservable: Observable<any>;
  42637. /**
  42638. * Fires when the xr session is ended either by the device or manually done
  42639. */
  42640. onXRSessionEnded: Observable<any>;
  42641. /**
  42642. * Underlying xr session
  42643. */
  42644. session: XRSession;
  42645. /**
  42646. * Type of reference space used when creating the session
  42647. */
  42648. referenceSpace: XRReferenceSpace;
  42649. /** @hidden */
  42650. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  42651. /**
  42652. * Current XR frame
  42653. */
  42654. currentFrame: Nullable<XRFrame>;
  42655. private _xrNavigator;
  42656. private baseLayer;
  42657. /**
  42658. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42659. * @param scene The scene which the session should be created for
  42660. */
  42661. constructor(scene: Scene);
  42662. /**
  42663. * Initializes the manager
  42664. * After initialization enterXR can be called to start an XR session
  42665. * @returns Promise which resolves after it is initialized
  42666. */
  42667. initializeAsync(): Promise<void>;
  42668. /**
  42669. * Initializes an xr session
  42670. * @param xrSessionMode mode to initialize
  42671. * @returns a promise which will resolve once the session has been initialized
  42672. */
  42673. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  42674. /**
  42675. * Sets the reference space on the xr session
  42676. * @param referenceSpace space to set
  42677. * @returns a promise that will resolve once the reference space has been set
  42678. */
  42679. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  42680. /**
  42681. * Updates the render state of the session
  42682. * @param state state to set
  42683. * @returns a promise that resolves once the render state has been updated
  42684. */
  42685. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  42686. /**
  42687. * Starts rendering to the xr layer
  42688. * @returns a promise that will resolve once rendering has started
  42689. */
  42690. startRenderingToXRAsync(): Promise<void>;
  42691. /**
  42692. * Stops the xrSession and restores the renderloop
  42693. * @returns Promise which resolves after it exits XR
  42694. */
  42695. exitXRAsync(): Promise<unknown>;
  42696. /**
  42697. * Checks if a session would be supported for the creation options specified
  42698. * @param sessionMode session mode to check if supported eg. immersive-vr
  42699. * @returns true if supported
  42700. */
  42701. supportsSessionAsync(sessionMode: XRSessionMode): any;
  42702. /**
  42703. * @hidden
  42704. * Converts the render layer of xrSession to a render target
  42705. * @param session session to create render target for
  42706. * @param scene scene the new render target should be created for
  42707. */
  42708. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  42709. /**
  42710. * Disposes of the session manager
  42711. */
  42712. dispose(): void;
  42713. }
  42714. }
  42715. declare module "babylonjs/Cameras/XR/webXRCamera" {
  42716. import { Scene } from "babylonjs/scene";
  42717. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42718. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42719. /**
  42720. * WebXR Camera which holds the views for the xrSession
  42721. * @see https://doc.babylonjs.com/how_to/webxr
  42722. */
  42723. export class WebXRCamera extends FreeCamera {
  42724. private static _TmpMatrix;
  42725. /**
  42726. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42727. * @param name the name of the camera
  42728. * @param scene the scene to add the camera to
  42729. */
  42730. constructor(name: string, scene: Scene);
  42731. private _updateNumberOfRigCameras;
  42732. /** @hidden */
  42733. _updateForDualEyeDebugging(pupilDistance?: number): void;
  42734. /**
  42735. * Updates the cameras position from the current pose information of the XR session
  42736. * @param xrSessionManager the session containing pose information
  42737. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  42738. */
  42739. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  42740. }
  42741. }
  42742. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  42743. import { Nullable } from "babylonjs/types";
  42744. import { IDisposable } from "babylonjs/scene";
  42745. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42746. /**
  42747. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42748. */
  42749. export class WebXRManagedOutputCanvas implements IDisposable {
  42750. private helper;
  42751. private _canvas;
  42752. /**
  42753. * xrpresent context of the canvas which can be used to display/mirror xr content
  42754. */
  42755. canvasContext: WebGLRenderingContext;
  42756. /**
  42757. * xr layer for the canvas
  42758. */
  42759. xrLayer: Nullable<XRWebGLLayer>;
  42760. /**
  42761. * Initializes the xr layer for the session
  42762. * @param xrSession xr session
  42763. * @returns a promise that will resolve once the XR Layer has been created
  42764. */
  42765. initializeXRLayerAsync(xrSession: any): any;
  42766. /**
  42767. * Initializes the canvas to be added/removed upon entering/exiting xr
  42768. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  42769. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  42770. */
  42771. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  42772. /**
  42773. * Disposes of the object
  42774. */
  42775. dispose(): void;
  42776. private _setManagedOutputCanvas;
  42777. private _addCanvas;
  42778. private _removeCanvas;
  42779. }
  42780. }
  42781. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  42782. import { Observable } from "babylonjs/Misc/observable";
  42783. import { IDisposable, Scene } from "babylonjs/scene";
  42784. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  42785. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42786. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42787. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  42788. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42789. /**
  42790. * States of the webXR experience
  42791. */
  42792. export enum WebXRState {
  42793. /**
  42794. * Transitioning to being in XR mode
  42795. */
  42796. ENTERING_XR = 0,
  42797. /**
  42798. * Transitioning to non XR mode
  42799. */
  42800. EXITING_XR = 1,
  42801. /**
  42802. * In XR mode and presenting
  42803. */
  42804. IN_XR = 2,
  42805. /**
  42806. * Not entered XR mode
  42807. */
  42808. NOT_IN_XR = 3
  42809. }
  42810. /**
  42811. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  42812. * @see https://doc.babylonjs.com/how_to/webxr
  42813. */
  42814. export class WebXRExperienceHelper implements IDisposable {
  42815. private scene;
  42816. /**
  42817. * Container which stores the xr camera and controllers as children. This can be used to move the camera/user as the camera's position is updated by the xr device
  42818. */
  42819. container: AbstractMesh;
  42820. /**
  42821. * Camera used to render xr content
  42822. */
  42823. camera: WebXRCamera;
  42824. /**
  42825. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  42826. */
  42827. state: WebXRState;
  42828. private _setState;
  42829. private static _TmpVector;
  42830. /**
  42831. * Fires when the state of the experience helper has changed
  42832. */
  42833. onStateChangedObservable: Observable<WebXRState>;
  42834. /** Session manager used to keep track of xr session */
  42835. sessionManager: WebXRSessionManager;
  42836. private _nonVRCamera;
  42837. private _originalSceneAutoClear;
  42838. private _supported;
  42839. /**
  42840. * Creates the experience helper
  42841. * @param scene the scene to attach the experience helper to
  42842. * @returns a promise for the experience helper
  42843. */
  42844. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  42845. /**
  42846. * Creates a WebXRExperienceHelper
  42847. * @param scene The scene the helper should be created in
  42848. */
  42849. private constructor();
  42850. /**
  42851. * Exits XR mode and returns the scene to its original state
  42852. * @returns promise that resolves after xr mode has exited
  42853. */
  42854. exitXRAsync(): Promise<unknown>;
  42855. /**
  42856. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  42857. * @param sessionCreationOptions options for the XR session
  42858. * @param referenceSpaceType frame of reference of the XR session
  42859. * @param outputCanvas the output canvas that will be used to enter XR mode
  42860. * @returns promise that resolves after xr mode has entered
  42861. */
  42862. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  42863. /**
  42864. * Updates the global position of the camera by moving the camera's container
  42865. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  42866. * @param position The desired global position of the camera
  42867. */
  42868. setPositionOfCameraUsingContainer(position: Vector3): void;
  42869. /**
  42870. * Rotates the xr camera by rotating the camera's container around the camera's position
  42871. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  42872. * @param rotation the desired quaternion rotation to apply to the camera
  42873. */
  42874. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  42875. /**
  42876. * Disposes of the experience helper
  42877. */
  42878. dispose(): void;
  42879. }
  42880. }
  42881. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  42882. import { Nullable } from "babylonjs/types";
  42883. import { Observable } from "babylonjs/Misc/observable";
  42884. import { IDisposable, Scene } from "babylonjs/scene";
  42885. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42886. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42887. /**
  42888. * Button which can be used to enter a different mode of XR
  42889. */
  42890. export class WebXREnterExitUIButton {
  42891. /** button element */
  42892. element: HTMLElement;
  42893. /** XR initialization options for the button */
  42894. sessionMode: XRSessionMode;
  42895. /** Reference space type */
  42896. referenceSpaceType: XRReferenceSpaceType;
  42897. /**
  42898. * Creates a WebXREnterExitUIButton
  42899. * @param element button element
  42900. * @param sessionMode XR initialization session mode
  42901. * @param referenceSpaceType the type of reference space to be used
  42902. */
  42903. constructor(
  42904. /** button element */
  42905. element: HTMLElement,
  42906. /** XR initialization options for the button */
  42907. sessionMode: XRSessionMode,
  42908. /** Reference space type */
  42909. referenceSpaceType: XRReferenceSpaceType);
  42910. /**
  42911. * Overwritable function which can be used to update the button's visuals when the state changes
  42912. * @param activeButton the current active button in the UI
  42913. */
  42914. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  42915. }
  42916. /**
  42917. * Options to create the webXR UI
  42918. */
  42919. export class WebXREnterExitUIOptions {
  42920. /**
  42921. * Context to enter xr with
  42922. */
  42923. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  42924. /**
  42925. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  42926. */
  42927. customButtons?: Array<WebXREnterExitUIButton>;
  42928. }
  42929. /**
  42930. * UI to allow the user to enter/exit XR mode
  42931. */
  42932. export class WebXREnterExitUI implements IDisposable {
  42933. private scene;
  42934. private _overlay;
  42935. private _buttons;
  42936. private _activeButton;
  42937. /**
  42938. * Fired every time the active button is changed.
  42939. *
  42940. * When xr is entered via a button that launches xr that button will be the callback parameter
  42941. *
  42942. * When exiting xr the callback parameter will be null)
  42943. */
  42944. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  42945. /**
  42946. * Creates UI to allow the user to enter/exit XR mode
  42947. * @param scene the scene to add the ui to
  42948. * @param helper the xr experience helper to enter/exit xr with
  42949. * @param options options to configure the UI
  42950. * @returns the created ui
  42951. */
  42952. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  42953. private constructor();
  42954. private _updateButtons;
  42955. /**
  42956. * Disposes of the object
  42957. */
  42958. dispose(): void;
  42959. }
  42960. }
  42961. declare module "babylonjs/Cameras/XR/webXRController" {
  42962. import { Nullable } from "babylonjs/types";
  42963. import { Observable } from "babylonjs/Misc/observable";
  42964. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42965. import { Ray } from "babylonjs/Culling/ray";
  42966. import { Scene } from "babylonjs/scene";
  42967. /**
  42968. * Represents an XR input
  42969. */
  42970. export class WebXRController {
  42971. private scene;
  42972. /** The underlying input source for the controller */
  42973. inputSource: XRInputSource;
  42974. private parentContainer;
  42975. /**
  42976. * Represents the part of the controller that is held. This may not exist if the controller is the head mounted display itself, if thats the case only the pointer from the head will be availible
  42977. */
  42978. grip?: AbstractMesh;
  42979. /**
  42980. * Pointer which can be used to select objects or attach a visible laser to
  42981. */
  42982. pointer: AbstractMesh;
  42983. /**
  42984. * Event that fires when the controller is removed/disposed
  42985. */
  42986. onDisposeObservable: Observable<{}>;
  42987. private _tmpMatrix;
  42988. private _tmpQuaternion;
  42989. private _tmpVector;
  42990. /**
  42991. * Creates the controller
  42992. * @see https://doc.babylonjs.com/how_to/webxr
  42993. * @param scene the scene which the controller should be associated to
  42994. * @param inputSource the underlying input source for the controller
  42995. * @param parentContainer parent that the controller meshes should be children of
  42996. */
  42997. constructor(scene: Scene,
  42998. /** The underlying input source for the controller */
  42999. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  43000. /**
  43001. * Updates the controller pose based on the given XRFrame
  43002. * @param xrFrame xr frame to update the pose with
  43003. * @param referenceSpace reference space to use
  43004. */
  43005. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  43006. /**
  43007. * Gets a world space ray coming from the controller
  43008. * @param result the resulting ray
  43009. */
  43010. getWorldPointerRayToRef(result: Ray): void;
  43011. /**
  43012. * Disposes of the object
  43013. */
  43014. dispose(): void;
  43015. }
  43016. }
  43017. declare module "babylonjs/Cameras/XR/webXRInput" {
  43018. import { Observable } from "babylonjs/Misc/observable";
  43019. import { IDisposable } from "babylonjs/scene";
  43020. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43021. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  43022. /**
  43023. * XR input used to track XR inputs such as controllers/rays
  43024. */
  43025. export class WebXRInput implements IDisposable {
  43026. /**
  43027. * Base experience the input listens to
  43028. */
  43029. baseExperience: WebXRExperienceHelper;
  43030. /**
  43031. * XR controllers being tracked
  43032. */
  43033. controllers: Array<WebXRController>;
  43034. private _frameObserver;
  43035. private _stateObserver;
  43036. /**
  43037. * Event when a controller has been connected/added
  43038. */
  43039. onControllerAddedObservable: Observable<WebXRController>;
  43040. /**
  43041. * Event when a controller has been removed/disconnected
  43042. */
  43043. onControllerRemovedObservable: Observable<WebXRController>;
  43044. /**
  43045. * Initializes the WebXRInput
  43046. * @param baseExperience experience helper which the input should be created for
  43047. */
  43048. constructor(
  43049. /**
  43050. * Base experience the input listens to
  43051. */
  43052. baseExperience: WebXRExperienceHelper);
  43053. private _onInputSourcesChange;
  43054. private _addAndRemoveControllers;
  43055. /**
  43056. * Disposes of the object
  43057. */
  43058. dispose(): void;
  43059. }
  43060. }
  43061. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  43062. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43063. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43064. /**
  43065. * Enables teleportation
  43066. */
  43067. export class WebXRControllerTeleportation {
  43068. private _teleportationFillColor;
  43069. private _teleportationBorderColor;
  43070. private _tmpRay;
  43071. private _tmpVector;
  43072. /**
  43073. * Creates a WebXRControllerTeleportation
  43074. * @param input input manager to add teleportation to
  43075. * @param floorMeshes floormeshes which can be teleported to
  43076. */
  43077. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  43078. }
  43079. }
  43080. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  43081. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43082. /**
  43083. * Handles pointer input automatically for the pointer of XR controllers
  43084. */
  43085. export class WebXRControllerPointerSelection {
  43086. private static _idCounter;
  43087. private _tmpRay;
  43088. /**
  43089. * Creates a WebXRControllerPointerSelection
  43090. * @param input input manager to setup pointer selection
  43091. */
  43092. constructor(input: WebXRInput);
  43093. private _convertNormalToDirectionOfRay;
  43094. private _updatePointerDistance;
  43095. }
  43096. }
  43097. declare module "babylonjs/Loading/sceneLoader" {
  43098. import { Observable } from "babylonjs/Misc/observable";
  43099. import { Nullable } from "babylonjs/types";
  43100. import { Scene } from "babylonjs/scene";
  43101. import { Engine } from "babylonjs/Engines/engine";
  43102. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43103. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43104. import { AssetContainer } from "babylonjs/assetContainer";
  43105. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43106. import { Skeleton } from "babylonjs/Bones/skeleton";
  43107. /**
  43108. * Class used to represent data loading progression
  43109. */
  43110. export class SceneLoaderProgressEvent {
  43111. /** defines if data length to load can be evaluated */
  43112. readonly lengthComputable: boolean;
  43113. /** defines the loaded data length */
  43114. readonly loaded: number;
  43115. /** defines the data length to load */
  43116. readonly total: number;
  43117. /**
  43118. * Create a new progress event
  43119. * @param lengthComputable defines if data length to load can be evaluated
  43120. * @param loaded defines the loaded data length
  43121. * @param total defines the data length to load
  43122. */
  43123. constructor(
  43124. /** defines if data length to load can be evaluated */
  43125. lengthComputable: boolean,
  43126. /** defines the loaded data length */
  43127. loaded: number,
  43128. /** defines the data length to load */
  43129. total: number);
  43130. /**
  43131. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43132. * @param event defines the source event
  43133. * @returns a new SceneLoaderProgressEvent
  43134. */
  43135. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43136. }
  43137. /**
  43138. * Interface used by SceneLoader plugins to define supported file extensions
  43139. */
  43140. export interface ISceneLoaderPluginExtensions {
  43141. /**
  43142. * Defines the list of supported extensions
  43143. */
  43144. [extension: string]: {
  43145. isBinary: boolean;
  43146. };
  43147. }
  43148. /**
  43149. * Interface used by SceneLoader plugin factory
  43150. */
  43151. export interface ISceneLoaderPluginFactory {
  43152. /**
  43153. * Defines the name of the factory
  43154. */
  43155. name: string;
  43156. /**
  43157. * Function called to create a new plugin
  43158. * @return the new plugin
  43159. */
  43160. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43161. /**
  43162. * Boolean indicating if the plugin can direct load specific data
  43163. */
  43164. canDirectLoad?: (data: string) => boolean;
  43165. }
  43166. /**
  43167. * Interface used to define a SceneLoader plugin
  43168. */
  43169. export interface ISceneLoaderPlugin {
  43170. /**
  43171. * The friendly name of this plugin.
  43172. */
  43173. name: string;
  43174. /**
  43175. * The file extensions supported by this plugin.
  43176. */
  43177. extensions: string | ISceneLoaderPluginExtensions;
  43178. /**
  43179. * Import meshes into a scene.
  43180. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43181. * @param scene The scene to import into
  43182. * @param data The data to import
  43183. * @param rootUrl The root url for scene and resources
  43184. * @param meshes The meshes array to import into
  43185. * @param particleSystems The particle systems array to import into
  43186. * @param skeletons The skeletons array to import into
  43187. * @param onError The callback when import fails
  43188. * @returns True if successful or false otherwise
  43189. */
  43190. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43191. /**
  43192. * Load into a scene.
  43193. * @param scene The scene to load into
  43194. * @param data The data to import
  43195. * @param rootUrl The root url for scene and resources
  43196. * @param onError The callback when import fails
  43197. * @returns true if successful or false otherwise
  43198. */
  43199. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43200. /**
  43201. * The callback that returns true if the data can be directly loaded.
  43202. */
  43203. canDirectLoad?: (data: string) => boolean;
  43204. /**
  43205. * The callback that allows custom handling of the root url based on the response url.
  43206. */
  43207. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43208. /**
  43209. * Load into an asset container.
  43210. * @param scene The scene to load into
  43211. * @param data The data to import
  43212. * @param rootUrl The root url for scene and resources
  43213. * @param onError The callback when import fails
  43214. * @returns The loaded asset container
  43215. */
  43216. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43217. }
  43218. /**
  43219. * Interface used to define an async SceneLoader plugin
  43220. */
  43221. export interface ISceneLoaderPluginAsync {
  43222. /**
  43223. * The friendly name of this plugin.
  43224. */
  43225. name: string;
  43226. /**
  43227. * The file extensions supported by this plugin.
  43228. */
  43229. extensions: string | ISceneLoaderPluginExtensions;
  43230. /**
  43231. * Import meshes into a scene.
  43232. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43233. * @param scene The scene to import into
  43234. * @param data The data to import
  43235. * @param rootUrl The root url for scene and resources
  43236. * @param onProgress The callback when the load progresses
  43237. * @param fileName Defines the name of the file to load
  43238. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43239. */
  43240. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43241. meshes: AbstractMesh[];
  43242. particleSystems: IParticleSystem[];
  43243. skeletons: Skeleton[];
  43244. animationGroups: AnimationGroup[];
  43245. }>;
  43246. /**
  43247. * Load into a scene.
  43248. * @param scene The scene to load into
  43249. * @param data The data to import
  43250. * @param rootUrl The root url for scene and resources
  43251. * @param onProgress The callback when the load progresses
  43252. * @param fileName Defines the name of the file to load
  43253. * @returns Nothing
  43254. */
  43255. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43256. /**
  43257. * The callback that returns true if the data can be directly loaded.
  43258. */
  43259. canDirectLoad?: (data: string) => boolean;
  43260. /**
  43261. * The callback that allows custom handling of the root url based on the response url.
  43262. */
  43263. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43264. /**
  43265. * Load into an asset container.
  43266. * @param scene The scene to load into
  43267. * @param data The data to import
  43268. * @param rootUrl The root url for scene and resources
  43269. * @param onProgress The callback when the load progresses
  43270. * @param fileName Defines the name of the file to load
  43271. * @returns The loaded asset container
  43272. */
  43273. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43274. }
  43275. /**
  43276. * Class used to load scene from various file formats using registered plugins
  43277. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43278. */
  43279. export class SceneLoader {
  43280. /**
  43281. * No logging while loading
  43282. */
  43283. static readonly NO_LOGGING: number;
  43284. /**
  43285. * Minimal logging while loading
  43286. */
  43287. static readonly MINIMAL_LOGGING: number;
  43288. /**
  43289. * Summary logging while loading
  43290. */
  43291. static readonly SUMMARY_LOGGING: number;
  43292. /**
  43293. * Detailled logging while loading
  43294. */
  43295. static readonly DETAILED_LOGGING: number;
  43296. /**
  43297. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43298. */
  43299. static ForceFullSceneLoadingForIncremental: boolean;
  43300. /**
  43301. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43302. */
  43303. static ShowLoadingScreen: boolean;
  43304. /**
  43305. * Defines the current logging level (while loading the scene)
  43306. * @ignorenaming
  43307. */
  43308. static loggingLevel: number;
  43309. /**
  43310. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43311. */
  43312. static CleanBoneMatrixWeights: boolean;
  43313. /**
  43314. * Event raised when a plugin is used to load a scene
  43315. */
  43316. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43317. private static _registeredPlugins;
  43318. private static _getDefaultPlugin;
  43319. private static _getPluginForExtension;
  43320. private static _getPluginForDirectLoad;
  43321. private static _getPluginForFilename;
  43322. private static _getDirectLoad;
  43323. private static _loadData;
  43324. private static _getFileInfo;
  43325. /**
  43326. * Gets a plugin that can load the given extension
  43327. * @param extension defines the extension to load
  43328. * @returns a plugin or null if none works
  43329. */
  43330. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43331. /**
  43332. * Gets a boolean indicating that the given extension can be loaded
  43333. * @param extension defines the extension to load
  43334. * @returns true if the extension is supported
  43335. */
  43336. static IsPluginForExtensionAvailable(extension: string): boolean;
  43337. /**
  43338. * Adds a new plugin to the list of registered plugins
  43339. * @param plugin defines the plugin to add
  43340. */
  43341. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43342. /**
  43343. * Import meshes into a scene
  43344. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43345. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  43346. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  43347. * @param scene the instance of BABYLON.Scene to append to
  43348. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43349. * @param onProgress a callback with a progress event for each file being loaded
  43350. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43351. * @param pluginExtension the extension used to determine the plugin
  43352. * @returns The loaded plugin
  43353. */
  43354. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[]) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43355. /**
  43356. * Import meshes into a scene
  43357. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43358. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  43359. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  43360. * @param scene the instance of BABYLON.Scene to append to
  43361. * @param onProgress a callback with a progress event for each file being loaded
  43362. * @param pluginExtension the extension used to determine the plugin
  43363. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43364. */
  43365. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43366. meshes: AbstractMesh[];
  43367. particleSystems: IParticleSystem[];
  43368. skeletons: Skeleton[];
  43369. animationGroups: AnimationGroup[];
  43370. }>;
  43371. /**
  43372. * Load a scene
  43373. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  43374. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  43375. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43376. * @param onSuccess a callback with the scene when import succeeds
  43377. * @param onProgress a callback with a progress event for each file being loaded
  43378. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43379. * @param pluginExtension the extension used to determine the plugin
  43380. * @returns The loaded plugin
  43381. */
  43382. static Load(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43383. /**
  43384. * Load a scene
  43385. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  43386. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  43387. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43388. * @param onProgress a callback with a progress event for each file being loaded
  43389. * @param pluginExtension the extension used to determine the plugin
  43390. * @returns The loaded scene
  43391. */
  43392. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43393. /**
  43394. * Append a scene
  43395. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  43396. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  43397. * @param scene is the instance of BABYLON.Scene to append to
  43398. * @param onSuccess a callback with the scene when import succeeds
  43399. * @param onProgress a callback with a progress event for each file being loaded
  43400. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43401. * @param pluginExtension the extension used to determine the plugin
  43402. * @returns The loaded plugin
  43403. */
  43404. static Append(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43405. /**
  43406. * Append a scene
  43407. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  43408. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  43409. * @param scene is the instance of BABYLON.Scene to append to
  43410. * @param onProgress a callback with a progress event for each file being loaded
  43411. * @param pluginExtension the extension used to determine the plugin
  43412. * @returns The given scene
  43413. */
  43414. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43415. /**
  43416. * Load a scene into an asset container
  43417. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  43418. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  43419. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43420. * @param onSuccess a callback with the scene when import succeeds
  43421. * @param onProgress a callback with a progress event for each file being loaded
  43422. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43423. * @param pluginExtension the extension used to determine the plugin
  43424. * @returns The loaded plugin
  43425. */
  43426. static LoadAssetContainer(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(assets: AssetContainer) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43427. /**
  43428. * Load a scene into an asset container
  43429. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  43430. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene (default: empty string)
  43431. * @param scene is the instance of Scene to append to
  43432. * @param onProgress a callback with a progress event for each file being loaded
  43433. * @param pluginExtension the extension used to determine the plugin
  43434. * @returns The loaded asset container
  43435. */
  43436. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43437. }
  43438. }
  43439. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43440. import { Scene } from "babylonjs/scene";
  43441. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43442. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43443. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43444. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43445. /**
  43446. * Generic Controller
  43447. */
  43448. export class GenericController extends WebVRController {
  43449. /**
  43450. * Base Url for the controller model.
  43451. */
  43452. static readonly MODEL_BASE_URL: string;
  43453. /**
  43454. * File name for the controller model.
  43455. */
  43456. static readonly MODEL_FILENAME: string;
  43457. /**
  43458. * Creates a new GenericController from a gamepad
  43459. * @param vrGamepad the gamepad that the controller should be created from
  43460. */
  43461. constructor(vrGamepad: any);
  43462. /**
  43463. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43464. * @param scene scene in which to add meshes
  43465. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43466. */
  43467. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43468. /**
  43469. * Called once for each button that changed state since the last frame
  43470. * @param buttonIdx Which button index changed
  43471. * @param state New state of the button
  43472. * @param changes Which properties on the state changed since last frame
  43473. */
  43474. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43475. }
  43476. }
  43477. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43478. import { Observable } from "babylonjs/Misc/observable";
  43479. import { Scene } from "babylonjs/scene";
  43480. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43481. import { Ray } from "babylonjs/Culling/ray";
  43482. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43483. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43484. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43485. /**
  43486. * Defines the WindowsMotionController object that the state of the windows motion controller
  43487. */
  43488. export class WindowsMotionController extends WebVRController {
  43489. /**
  43490. * The base url used to load the left and right controller models
  43491. */
  43492. static MODEL_BASE_URL: string;
  43493. /**
  43494. * The name of the left controller model file
  43495. */
  43496. static MODEL_LEFT_FILENAME: string;
  43497. /**
  43498. * The name of the right controller model file
  43499. */
  43500. static MODEL_RIGHT_FILENAME: string;
  43501. /**
  43502. * The controller name prefix for this controller type
  43503. */
  43504. static readonly GAMEPAD_ID_PREFIX: string;
  43505. /**
  43506. * The controller id pattern for this controller type
  43507. */
  43508. private static readonly GAMEPAD_ID_PATTERN;
  43509. private _loadedMeshInfo;
  43510. private readonly _mapping;
  43511. /**
  43512. * Fired when the trackpad on this controller is clicked
  43513. */
  43514. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43515. /**
  43516. * Fired when the trackpad on this controller is modified
  43517. */
  43518. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43519. /**
  43520. * The current x and y values of this controller's trackpad
  43521. */
  43522. trackpad: StickValues;
  43523. /**
  43524. * Creates a new WindowsMotionController from a gamepad
  43525. * @param vrGamepad the gamepad that the controller should be created from
  43526. */
  43527. constructor(vrGamepad: any);
  43528. /**
  43529. * Fired when the trigger on this controller is modified
  43530. */
  43531. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43532. /**
  43533. * Fired when the menu button on this controller is modified
  43534. */
  43535. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43536. /**
  43537. * Fired when the grip button on this controller is modified
  43538. */
  43539. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43540. /**
  43541. * Fired when the thumbstick button on this controller is modified
  43542. */
  43543. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43544. /**
  43545. * Fired when the touchpad button on this controller is modified
  43546. */
  43547. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43548. /**
  43549. * Fired when the touchpad values on this controller are modified
  43550. */
  43551. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43552. private _updateTrackpad;
  43553. /**
  43554. * Called once per frame by the engine.
  43555. */
  43556. update(): void;
  43557. /**
  43558. * Called once for each button that changed state since the last frame
  43559. * @param buttonIdx Which button index changed
  43560. * @param state New state of the button
  43561. * @param changes Which properties on the state changed since last frame
  43562. */
  43563. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43564. /**
  43565. * Moves the buttons on the controller mesh based on their current state
  43566. * @param buttonName the name of the button to move
  43567. * @param buttonValue the value of the button which determines the buttons new position
  43568. */
  43569. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43570. /**
  43571. * Moves the axis on the controller mesh based on its current state
  43572. * @param axis the index of the axis
  43573. * @param axisValue the value of the axis which determines the meshes new position
  43574. * @hidden
  43575. */
  43576. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43577. /**
  43578. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43579. * @param scene scene in which to add meshes
  43580. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43581. */
  43582. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43583. /**
  43584. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43585. * can be transformed by button presses and axes values, based on this._mapping.
  43586. *
  43587. * @param scene scene in which the meshes exist
  43588. * @param meshes list of meshes that make up the controller model to process
  43589. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43590. */
  43591. private processModel;
  43592. private createMeshInfo;
  43593. /**
  43594. * Gets the ray of the controller in the direction the controller is pointing
  43595. * @param length the length the resulting ray should be
  43596. * @returns a ray in the direction the controller is pointing
  43597. */
  43598. getForwardRay(length?: number): Ray;
  43599. /**
  43600. * Disposes of the controller
  43601. */
  43602. dispose(): void;
  43603. }
  43604. }
  43605. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43606. import { Observable } from "babylonjs/Misc/observable";
  43607. import { Scene } from "babylonjs/scene";
  43608. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43609. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43610. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43611. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43612. /**
  43613. * Oculus Touch Controller
  43614. */
  43615. export class OculusTouchController extends WebVRController {
  43616. /**
  43617. * Base Url for the controller model.
  43618. */
  43619. static MODEL_BASE_URL: string;
  43620. /**
  43621. * File name for the left controller model.
  43622. */
  43623. static MODEL_LEFT_FILENAME: string;
  43624. /**
  43625. * File name for the right controller model.
  43626. */
  43627. static MODEL_RIGHT_FILENAME: string;
  43628. /**
  43629. * Base Url for the Quest controller model.
  43630. */
  43631. static QUEST_MODEL_BASE_URL: string;
  43632. /**
  43633. * @hidden
  43634. * If the controllers are running on a device that needs the updated Quest controller models
  43635. */
  43636. static _IsQuest: boolean;
  43637. /**
  43638. * Fired when the secondary trigger on this controller is modified
  43639. */
  43640. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43641. /**
  43642. * Fired when the thumb rest on this controller is modified
  43643. */
  43644. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43645. /**
  43646. * Creates a new OculusTouchController from a gamepad
  43647. * @param vrGamepad the gamepad that the controller should be created from
  43648. */
  43649. constructor(vrGamepad: any);
  43650. /**
  43651. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43652. * @param scene scene in which to add meshes
  43653. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43654. */
  43655. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43656. /**
  43657. * Fired when the A button on this controller is modified
  43658. */
  43659. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43660. /**
  43661. * Fired when the B button on this controller is modified
  43662. */
  43663. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43664. /**
  43665. * Fired when the X button on this controller is modified
  43666. */
  43667. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43668. /**
  43669. * Fired when the Y button on this controller is modified
  43670. */
  43671. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43672. /**
  43673. * Called once for each button that changed state since the last frame
  43674. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43675. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43676. * 2) secondary trigger (same)
  43677. * 3) A (right) X (left), touch, pressed = value
  43678. * 4) B / Y
  43679. * 5) thumb rest
  43680. * @param buttonIdx Which button index changed
  43681. * @param state New state of the button
  43682. * @param changes Which properties on the state changed since last frame
  43683. */
  43684. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43685. }
  43686. }
  43687. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43688. import { Scene } from "babylonjs/scene";
  43689. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43690. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43691. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43692. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43693. import { Observable } from "babylonjs/Misc/observable";
  43694. /**
  43695. * Vive Controller
  43696. */
  43697. export class ViveController extends WebVRController {
  43698. /**
  43699. * Base Url for the controller model.
  43700. */
  43701. static MODEL_BASE_URL: string;
  43702. /**
  43703. * File name for the controller model.
  43704. */
  43705. static MODEL_FILENAME: string;
  43706. /**
  43707. * Creates a new ViveController from a gamepad
  43708. * @param vrGamepad the gamepad that the controller should be created from
  43709. */
  43710. constructor(vrGamepad: any);
  43711. /**
  43712. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43713. * @param scene scene in which to add meshes
  43714. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43715. */
  43716. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43717. /**
  43718. * Fired when the left button on this controller is modified
  43719. */
  43720. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43721. /**
  43722. * Fired when the right button on this controller is modified
  43723. */
  43724. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43725. /**
  43726. * Fired when the menu button on this controller is modified
  43727. */
  43728. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43729. /**
  43730. * Called once for each button that changed state since the last frame
  43731. * Vive mapping:
  43732. * 0: touchpad
  43733. * 1: trigger
  43734. * 2: left AND right buttons
  43735. * 3: menu button
  43736. * @param buttonIdx Which button index changed
  43737. * @param state New state of the button
  43738. * @param changes Which properties on the state changed since last frame
  43739. */
  43740. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43741. }
  43742. }
  43743. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  43744. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43745. /**
  43746. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  43747. */
  43748. export class WebXRControllerModelLoader {
  43749. /**
  43750. * Creates the WebXRControllerModelLoader
  43751. * @param input xr input that creates the controllers
  43752. */
  43753. constructor(input: WebXRInput);
  43754. }
  43755. }
  43756. declare module "babylonjs/Cameras/XR/index" {
  43757. export * from "babylonjs/Cameras/XR/webXRCamera";
  43758. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  43759. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43760. export * from "babylonjs/Cameras/XR/webXRInput";
  43761. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  43762. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  43763. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  43764. export * from "babylonjs/Cameras/XR/webXRController";
  43765. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43766. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  43767. }
  43768. declare module "babylonjs/Cameras/RigModes/index" {
  43769. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43770. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43771. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  43772. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  43773. }
  43774. declare module "babylonjs/Cameras/index" {
  43775. export * from "babylonjs/Cameras/Inputs/index";
  43776. export * from "babylonjs/Cameras/cameraInputsManager";
  43777. export * from "babylonjs/Cameras/camera";
  43778. export * from "babylonjs/Cameras/targetCamera";
  43779. export * from "babylonjs/Cameras/freeCamera";
  43780. export * from "babylonjs/Cameras/freeCameraInputsManager";
  43781. export * from "babylonjs/Cameras/touchCamera";
  43782. export * from "babylonjs/Cameras/arcRotateCamera";
  43783. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  43784. export * from "babylonjs/Cameras/deviceOrientationCamera";
  43785. export * from "babylonjs/Cameras/flyCamera";
  43786. export * from "babylonjs/Cameras/flyCameraInputsManager";
  43787. export * from "babylonjs/Cameras/followCamera";
  43788. export * from "babylonjs/Cameras/followCameraInputsManager";
  43789. export * from "babylonjs/Cameras/gamepadCamera";
  43790. export * from "babylonjs/Cameras/Stereoscopic/index";
  43791. export * from "babylonjs/Cameras/universalCamera";
  43792. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  43793. export * from "babylonjs/Cameras/VR/index";
  43794. export * from "babylonjs/Cameras/XR/index";
  43795. export * from "babylonjs/Cameras/RigModes/index";
  43796. }
  43797. declare module "babylonjs/Collisions/index" {
  43798. export * from "babylonjs/Collisions/collider";
  43799. export * from "babylonjs/Collisions/collisionCoordinator";
  43800. export * from "babylonjs/Collisions/pickingInfo";
  43801. export * from "babylonjs/Collisions/intersectionInfo";
  43802. export * from "babylonjs/Collisions/meshCollisionData";
  43803. }
  43804. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  43805. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  43806. import { Vector3 } from "babylonjs/Maths/math.vector";
  43807. import { Ray } from "babylonjs/Culling/ray";
  43808. import { Plane } from "babylonjs/Maths/math.plane";
  43809. /**
  43810. * Contains an array of blocks representing the octree
  43811. */
  43812. export interface IOctreeContainer<T> {
  43813. /**
  43814. * Blocks within the octree
  43815. */
  43816. blocks: Array<OctreeBlock<T>>;
  43817. }
  43818. /**
  43819. * Class used to store a cell in an octree
  43820. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43821. */
  43822. export class OctreeBlock<T> {
  43823. /**
  43824. * Gets the content of the current block
  43825. */
  43826. entries: T[];
  43827. /**
  43828. * Gets the list of block children
  43829. */
  43830. blocks: Array<OctreeBlock<T>>;
  43831. private _depth;
  43832. private _maxDepth;
  43833. private _capacity;
  43834. private _minPoint;
  43835. private _maxPoint;
  43836. private _boundingVectors;
  43837. private _creationFunc;
  43838. /**
  43839. * Creates a new block
  43840. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  43841. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  43842. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43843. * @param depth defines the current depth of this block in the octree
  43844. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  43845. * @param creationFunc defines a callback to call when an element is added to the block
  43846. */
  43847. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  43848. /**
  43849. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43850. */
  43851. readonly capacity: number;
  43852. /**
  43853. * Gets the minimum vector (in world space) of the block's bounding box
  43854. */
  43855. readonly minPoint: Vector3;
  43856. /**
  43857. * Gets the maximum vector (in world space) of the block's bounding box
  43858. */
  43859. readonly maxPoint: Vector3;
  43860. /**
  43861. * Add a new element to this block
  43862. * @param entry defines the element to add
  43863. */
  43864. addEntry(entry: T): void;
  43865. /**
  43866. * Remove an element from this block
  43867. * @param entry defines the element to remove
  43868. */
  43869. removeEntry(entry: T): void;
  43870. /**
  43871. * Add an array of elements to this block
  43872. * @param entries defines the array of elements to add
  43873. */
  43874. addEntries(entries: T[]): void;
  43875. /**
  43876. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  43877. * @param frustumPlanes defines the frustum planes to test
  43878. * @param selection defines the array to store current content if selection is positive
  43879. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43880. */
  43881. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43882. /**
  43883. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  43884. * @param sphereCenter defines the bounding sphere center
  43885. * @param sphereRadius defines the bounding sphere radius
  43886. * @param selection defines the array to store current content if selection is positive
  43887. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43888. */
  43889. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43890. /**
  43891. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  43892. * @param ray defines the ray to test with
  43893. * @param selection defines the array to store current content if selection is positive
  43894. */
  43895. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  43896. /**
  43897. * Subdivide the content into child blocks (this block will then be empty)
  43898. */
  43899. createInnerBlocks(): void;
  43900. /**
  43901. * @hidden
  43902. */
  43903. static _CreateBlocks<T>(worldMin: Vector3, worldMax: Vector3, entries: T[], maxBlockCapacity: number, currentDepth: number, maxDepth: number, target: IOctreeContainer<T>, creationFunc: (entry: T, block: OctreeBlock<T>) => void): void;
  43904. }
  43905. }
  43906. declare module "babylonjs/Culling/Octrees/octree" {
  43907. import { SmartArray } from "babylonjs/Misc/smartArray";
  43908. import { Vector3 } from "babylonjs/Maths/math.vector";
  43909. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43910. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43911. import { Ray } from "babylonjs/Culling/ray";
  43912. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  43913. import { Plane } from "babylonjs/Maths/math.plane";
  43914. /**
  43915. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  43916. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43917. */
  43918. export class Octree<T> {
  43919. /** Defines the maximum depth (sub-levels) for your octree. Default value is 2, which means 8 8 8 = 512 blocks :) (This parameter takes precedence over capacity.) */
  43920. maxDepth: number;
  43921. /**
  43922. * Blocks within the octree containing objects
  43923. */
  43924. blocks: Array<OctreeBlock<T>>;
  43925. /**
  43926. * Content stored in the octree
  43927. */
  43928. dynamicContent: T[];
  43929. private _maxBlockCapacity;
  43930. private _selectionContent;
  43931. private _creationFunc;
  43932. /**
  43933. * Creates a octree
  43934. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43935. * @param creationFunc function to be used to instatiate the octree
  43936. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  43937. * @param maxDepth defines the maximum depth (sub-levels) for your octree. Default value is 2, which means 8 8 8 = 512 blocks :) (This parameter takes precedence over capacity.)
  43938. */
  43939. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  43940. /** Defines the maximum depth (sub-levels) for your octree. Default value is 2, which means 8 8 8 = 512 blocks :) (This parameter takes precedence over capacity.) */
  43941. maxDepth?: number);
  43942. /**
  43943. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  43944. * @param worldMin worldMin for the octree blocks var blockSize = new Vector3((worldMax.x - worldMin.x) / 2, (worldMax.y - worldMin.y) / 2, (worldMax.z - worldMin.z) / 2);
  43945. * @param worldMax worldMax for the octree blocks var blockSize = new Vector3((worldMax.x - worldMin.x) / 2, (worldMax.y - worldMin.y) / 2, (worldMax.z - worldMin.z) / 2);
  43946. * @param entries meshes to be added to the octree blocks
  43947. */
  43948. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  43949. /**
  43950. * Adds a mesh to the octree
  43951. * @param entry Mesh to add to the octree
  43952. */
  43953. addMesh(entry: T): void;
  43954. /**
  43955. * Remove an element from the octree
  43956. * @param entry defines the element to remove
  43957. */
  43958. removeMesh(entry: T): void;
  43959. /**
  43960. * Selects an array of meshes within the frustum
  43961. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  43962. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  43963. * @returns array of meshes within the frustum
  43964. */
  43965. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  43966. /**
  43967. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  43968. * @param sphereCenter defines the bounding sphere center
  43969. * @param sphereRadius defines the bounding sphere radius
  43970. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43971. * @returns an array of objects that intersect the sphere
  43972. */
  43973. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  43974. /**
  43975. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  43976. * @param ray defines the ray to test with
  43977. * @returns array of intersected objects
  43978. */
  43979. intersectsRay(ray: Ray): SmartArray<T>;
  43980. /**
  43981. * Adds a mesh into the octree block if it intersects the block
  43982. */
  43983. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  43984. /**
  43985. * Adds a submesh into the octree block if it intersects the block
  43986. */
  43987. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  43988. }
  43989. }
  43990. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  43991. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  43992. import { Scene } from "babylonjs/scene";
  43993. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43994. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43995. import { Ray } from "babylonjs/Culling/ray";
  43996. import { Octree } from "babylonjs/Culling/Octrees/octree";
  43997. import { Collider } from "babylonjs/Collisions/collider";
  43998. module "babylonjs/scene" {
  43999. interface Scene {
  44000. /**
  44001. * @hidden
  44002. * Backing Filed
  44003. */
  44004. _selectionOctree: Octree<AbstractMesh>;
  44005. /**
  44006. * Gets the octree used to boost mesh selection (picking)
  44007. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44008. */
  44009. selectionOctree: Octree<AbstractMesh>;
  44010. /**
  44011. * Creates or updates the octree used to boost selection (picking)
  44012. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44013. * @param maxCapacity defines the maximum capacity per leaf
  44014. * @param maxDepth defines the maximum depth of the octree
  44015. * @returns an octree of AbstractMesh
  44016. */
  44017. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  44018. }
  44019. }
  44020. module "babylonjs/Meshes/abstractMesh" {
  44021. interface AbstractMesh {
  44022. /**
  44023. * @hidden
  44024. * Backing Field
  44025. */
  44026. _submeshesOctree: Octree<SubMesh>;
  44027. /**
  44028. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  44029. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  44030. * @param maxCapacity defines the maximum size of each block (64 by default)
  44031. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  44032. * @returns the new octree
  44033. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  44034. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44035. */
  44036. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  44037. }
  44038. }
  44039. /**
  44040. * Defines the octree scene component responsible to manage any octrees
  44041. * in a given scene.
  44042. */
  44043. export class OctreeSceneComponent {
  44044. /**
  44045. * The component name help to identify the component in the list of scene components.
  44046. */
  44047. readonly name: string;
  44048. /**
  44049. * The scene the component belongs to.
  44050. */
  44051. scene: Scene;
  44052. /**
  44053. * Indicates if the meshes have been checked to make sure they are isEnabled()
  44054. */
  44055. readonly checksIsEnabled: boolean;
  44056. /**
  44057. * Creates a new instance of the component for the given scene
  44058. * @param scene Defines the scene to register the component in
  44059. */
  44060. constructor(scene: Scene);
  44061. /**
  44062. * Registers the component in a given scene
  44063. */
  44064. register(): void;
  44065. /**
  44066. * Return the list of active meshes
  44067. * @returns the list of active meshes
  44068. */
  44069. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  44070. /**
  44071. * Return the list of active sub meshes
  44072. * @param mesh The mesh to get the candidates sub meshes from
  44073. * @returns the list of active sub meshes
  44074. */
  44075. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  44076. private _tempRay;
  44077. /**
  44078. * Return the list of sub meshes intersecting with a given local ray
  44079. * @param mesh defines the mesh to find the submesh for
  44080. * @param localRay defines the ray in local space
  44081. * @returns the list of intersecting sub meshes
  44082. */
  44083. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  44084. /**
  44085. * Return the list of sub meshes colliding with a collider
  44086. * @param mesh defines the mesh to find the submesh for
  44087. * @param collider defines the collider to evaluate the collision against
  44088. * @returns the list of colliding sub meshes
  44089. */
  44090. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  44091. /**
  44092. * Rebuilds the elements related to this component in case of
  44093. * context lost for instance.
  44094. */
  44095. rebuild(): void;
  44096. /**
  44097. * Disposes the component and the associated ressources.
  44098. */
  44099. dispose(): void;
  44100. }
  44101. }
  44102. declare module "babylonjs/Culling/Octrees/index" {
  44103. export * from "babylonjs/Culling/Octrees/octree";
  44104. export * from "babylonjs/Culling/Octrees/octreeBlock";
  44105. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  44106. }
  44107. declare module "babylonjs/Culling/index" {
  44108. export * from "babylonjs/Culling/boundingBox";
  44109. export * from "babylonjs/Culling/boundingInfo";
  44110. export * from "babylonjs/Culling/boundingSphere";
  44111. export * from "babylonjs/Culling/Octrees/index";
  44112. export * from "babylonjs/Culling/ray";
  44113. }
  44114. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  44115. import { IDisposable, Scene } from "babylonjs/scene";
  44116. import { Nullable } from "babylonjs/types";
  44117. import { Observable } from "babylonjs/Misc/observable";
  44118. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44119. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  44120. import { Camera } from "babylonjs/Cameras/camera";
  44121. /**
  44122. * Renders a layer on top of an existing scene
  44123. */
  44124. export class UtilityLayerRenderer implements IDisposable {
  44125. /** the original scene that will be rendered on top of */
  44126. originalScene: Scene;
  44127. private _pointerCaptures;
  44128. private _lastPointerEvents;
  44129. private static _DefaultUtilityLayer;
  44130. private static _DefaultKeepDepthUtilityLayer;
  44131. private _sharedGizmoLight;
  44132. private _renderCamera;
  44133. /**
  44134. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44135. * @returns the camera that is used when rendering the utility layer
  44136. */
  44137. getRenderCamera(): Nullable<Camera>;
  44138. /**
  44139. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44140. * @param cam the camera that should be used when rendering the utility layer
  44141. */
  44142. setRenderCamera(cam: Nullable<Camera>): void;
  44143. /**
  44144. * @hidden
  44145. * Light which used by gizmos to get light shading
  44146. */
  44147. _getSharedGizmoLight(): HemisphericLight;
  44148. /**
  44149. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44150. */
  44151. pickUtilitySceneFirst: boolean;
  44152. /**
  44153. * A shared utility layer that can be used to overlay objects into a scene (Depth map of the previous scene is cleared before drawing on top of it)
  44154. */
  44155. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  44156. /**
  44157. * A shared utility layer that can be used to embed objects into a scene (Depth map of the previous scene is not cleared before drawing on top of it)
  44158. */
  44159. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  44160. /**
  44161. * The scene that is rendered on top of the original scene
  44162. */
  44163. utilityLayerScene: Scene;
  44164. /**
  44165. * If the utility layer should automatically be rendered on top of existing scene
  44166. */
  44167. shouldRender: boolean;
  44168. /**
  44169. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44170. */
  44171. onlyCheckPointerDownEvents: boolean;
  44172. /**
  44173. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44174. */
  44175. processAllEvents: boolean;
  44176. /**
  44177. * Observable raised when the pointer move from the utility layer scene to the main scene
  44178. */
  44179. onPointerOutObservable: Observable<number>;
  44180. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44181. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44182. private _afterRenderObserver;
  44183. private _sceneDisposeObserver;
  44184. private _originalPointerObserver;
  44185. /**
  44186. * Instantiates a UtilityLayerRenderer
  44187. * @param originalScene the original scene that will be rendered on top of
  44188. * @param handleEvents boolean indicating if the utility layer should handle events
  44189. */
  44190. constructor(
  44191. /** the original scene that will be rendered on top of */
  44192. originalScene: Scene, handleEvents?: boolean);
  44193. private _notifyObservers;
  44194. /**
  44195. * Renders the utility layers scene on top of the original scene
  44196. */
  44197. render(): void;
  44198. /**
  44199. * Disposes of the renderer
  44200. */
  44201. dispose(): void;
  44202. private _updateCamera;
  44203. }
  44204. }
  44205. declare module "babylonjs/Gizmos/gizmo" {
  44206. import { Nullable } from "babylonjs/types";
  44207. import { IDisposable } from "babylonjs/scene";
  44208. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44209. import { Mesh } from "babylonjs/Meshes/mesh";
  44210. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44211. /**
  44212. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  44213. */
  44214. export class Gizmo implements IDisposable {
  44215. /** The utility layer the gizmo will be added to */
  44216. gizmoLayer: UtilityLayerRenderer;
  44217. /**
  44218. * The root mesh of the gizmo
  44219. */
  44220. _rootMesh: Mesh;
  44221. private _attachedMesh;
  44222. /**
  44223. * Ratio for the scale of the gizmo (Default: 1)
  44224. */
  44225. scaleRatio: number;
  44226. /**
  44227. * If a custom mesh has been set (Default: false)
  44228. */
  44229. protected _customMeshSet: boolean;
  44230. /**
  44231. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  44232. * * When set, interactions will be enabled
  44233. */
  44234. attachedMesh: Nullable<AbstractMesh>;
  44235. /**
  44236. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44237. * @param mesh The mesh to replace the default mesh of the gizmo
  44238. */
  44239. setCustomMesh(mesh: Mesh): void;
  44240. /**
  44241. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  44242. */
  44243. updateGizmoRotationToMatchAttachedMesh: boolean;
  44244. /**
  44245. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  44246. */
  44247. updateGizmoPositionToMatchAttachedMesh: boolean;
  44248. /**
  44249. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  44250. */
  44251. updateScale: boolean;
  44252. protected _interactionsEnabled: boolean;
  44253. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44254. private _beforeRenderObserver;
  44255. private _tempVector;
  44256. /**
  44257. * Creates a gizmo
  44258. * @param gizmoLayer The utility layer the gizmo will be added to
  44259. */
  44260. constructor(
  44261. /** The utility layer the gizmo will be added to */
  44262. gizmoLayer?: UtilityLayerRenderer);
  44263. /**
  44264. * Updates the gizmo to match the attached mesh's position/rotation
  44265. */
  44266. protected _update(): void;
  44267. /**
  44268. * Disposes of the gizmo
  44269. */
  44270. dispose(): void;
  44271. }
  44272. }
  44273. declare module "babylonjs/Gizmos/planeDragGizmo" {
  44274. import { Observable } from "babylonjs/Misc/observable";
  44275. import { Nullable } from "babylonjs/types";
  44276. import { Vector3 } from "babylonjs/Maths/math.vector";
  44277. import { Color3 } from "babylonjs/Maths/math.color";
  44278. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44279. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44280. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44281. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44282. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44283. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44284. import { Scene } from "babylonjs/scene";
  44285. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44286. /**
  44287. * Single plane drag gizmo
  44288. */
  44289. export class PlaneDragGizmo extends Gizmo {
  44290. /**
  44291. * Drag behavior responsible for the gizmos dragging interactions
  44292. */
  44293. dragBehavior: PointerDragBehavior;
  44294. private _pointerObserver;
  44295. /**
  44296. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44297. */
  44298. snapDistance: number;
  44299. /**
  44300. * Event that fires each time the gizmo snaps to a new location.
  44301. * * snapDistance is the the change in distance
  44302. */
  44303. onSnapObservable: Observable<{
  44304. snapDistance: number;
  44305. }>;
  44306. private _plane;
  44307. private _coloredMaterial;
  44308. private _hoverMaterial;
  44309. private _isEnabled;
  44310. private _parent;
  44311. /** @hidden */
  44312. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  44313. /** @hidden */
  44314. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44315. /**
  44316. * Creates a PlaneDragGizmo
  44317. * @param gizmoLayer The utility layer the gizmo will be added to
  44318. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  44319. * @param color The color of the gizmo
  44320. */
  44321. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44322. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44323. /**
  44324. * If the gizmo is enabled
  44325. */
  44326. isEnabled: boolean;
  44327. /**
  44328. * Disposes of the gizmo
  44329. */
  44330. dispose(): void;
  44331. }
  44332. }
  44333. declare module "babylonjs/Gizmos/positionGizmo" {
  44334. import { Observable } from "babylonjs/Misc/observable";
  44335. import { Nullable } from "babylonjs/types";
  44336. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44337. import { Mesh } from "babylonjs/Meshes/mesh";
  44338. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44339. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  44340. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  44341. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44342. /**
  44343. * Gizmo that enables dragging a mesh along 3 axis
  44344. */
  44345. export class PositionGizmo extends Gizmo {
  44346. /**
  44347. * Internal gizmo used for interactions on the x axis
  44348. */
  44349. xGizmo: AxisDragGizmo;
  44350. /**
  44351. * Internal gizmo used for interactions on the y axis
  44352. */
  44353. yGizmo: AxisDragGizmo;
  44354. /**
  44355. * Internal gizmo used for interactions on the z axis
  44356. */
  44357. zGizmo: AxisDragGizmo;
  44358. /**
  44359. * Internal gizmo used for interactions on the yz plane
  44360. */
  44361. xPlaneGizmo: PlaneDragGizmo;
  44362. /**
  44363. * Internal gizmo used for interactions on the xz plane
  44364. */
  44365. yPlaneGizmo: PlaneDragGizmo;
  44366. /**
  44367. * Internal gizmo used for interactions on the xy plane
  44368. */
  44369. zPlaneGizmo: PlaneDragGizmo;
  44370. /**
  44371. * private variables
  44372. */
  44373. private _meshAttached;
  44374. private _updateGizmoRotationToMatchAttachedMesh;
  44375. private _snapDistance;
  44376. private _scaleRatio;
  44377. /** Fires an event when any of it's sub gizmos are dragged */
  44378. onDragStartObservable: Observable<unknown>;
  44379. /** Fires an event when any of it's sub gizmos are released from dragging */
  44380. onDragEndObservable: Observable<unknown>;
  44381. /**
  44382. * If set to true, planar drag is enabled
  44383. */
  44384. private _planarGizmoEnabled;
  44385. attachedMesh: Nullable<AbstractMesh>;
  44386. /**
  44387. * Creates a PositionGizmo
  44388. * @param gizmoLayer The utility layer the gizmo will be added to
  44389. */
  44390. constructor(gizmoLayer?: UtilityLayerRenderer);
  44391. /**
  44392. * If the planar drag gizmo is enabled
  44393. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  44394. */
  44395. planarGizmoEnabled: boolean;
  44396. updateGizmoRotationToMatchAttachedMesh: boolean;
  44397. /**
  44398. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44399. */
  44400. snapDistance: number;
  44401. /**
  44402. * Ratio for the scale of the gizmo (Default: 1)
  44403. */
  44404. scaleRatio: number;
  44405. /**
  44406. * Disposes of the gizmo
  44407. */
  44408. dispose(): void;
  44409. /**
  44410. * CustomMeshes are not supported by this gizmo
  44411. * @param mesh The mesh to replace the default mesh of the gizmo
  44412. */
  44413. setCustomMesh(mesh: Mesh): void;
  44414. }
  44415. }
  44416. declare module "babylonjs/Gizmos/axisDragGizmo" {
  44417. import { Observable } from "babylonjs/Misc/observable";
  44418. import { Nullable } from "babylonjs/types";
  44419. import { Vector3 } from "babylonjs/Maths/math.vector";
  44420. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44421. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44422. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44423. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44424. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44425. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44426. import { Scene } from "babylonjs/scene";
  44427. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44428. import { Color3 } from "babylonjs/Maths/math.color";
  44429. /**
  44430. * Single axis drag gizmo
  44431. */
  44432. export class AxisDragGizmo extends Gizmo {
  44433. /**
  44434. * Drag behavior responsible for the gizmos dragging interactions
  44435. */
  44436. dragBehavior: PointerDragBehavior;
  44437. private _pointerObserver;
  44438. /**
  44439. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44440. */
  44441. snapDistance: number;
  44442. /**
  44443. * Event that fires each time the gizmo snaps to a new location.
  44444. * * snapDistance is the the change in distance
  44445. */
  44446. onSnapObservable: Observable<{
  44447. snapDistance: number;
  44448. }>;
  44449. private _isEnabled;
  44450. private _parent;
  44451. private _arrow;
  44452. private _coloredMaterial;
  44453. private _hoverMaterial;
  44454. /** @hidden */
  44455. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  44456. /** @hidden */
  44457. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44458. /**
  44459. * Creates an AxisDragGizmo
  44460. * @param gizmoLayer The utility layer the gizmo will be added to
  44461. * @param dragAxis The axis which the gizmo will be able to drag on
  44462. * @param color The color of the gizmo
  44463. */
  44464. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44465. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44466. /**
  44467. * If the gizmo is enabled
  44468. */
  44469. isEnabled: boolean;
  44470. /**
  44471. * Disposes of the gizmo
  44472. */
  44473. dispose(): void;
  44474. }
  44475. }
  44476. declare module "babylonjs/Debug/axesViewer" {
  44477. import { Vector3 } from "babylonjs/Maths/math.vector";
  44478. import { Nullable } from "babylonjs/types";
  44479. import { Scene } from "babylonjs/scene";
  44480. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44481. /**
  44482. * The Axes viewer will show 3 axes in a specific point in space
  44483. */
  44484. export class AxesViewer {
  44485. private _xAxis;
  44486. private _yAxis;
  44487. private _zAxis;
  44488. private _scaleLinesFactor;
  44489. private _instanced;
  44490. /**
  44491. * Gets the hosting scene
  44492. */
  44493. scene: Scene;
  44494. /**
  44495. * Gets or sets a number used to scale line length
  44496. */
  44497. scaleLines: number;
  44498. /** Gets the node hierarchy used to render x-axis */
  44499. readonly xAxis: TransformNode;
  44500. /** Gets the node hierarchy used to render y-axis */
  44501. readonly yAxis: TransformNode;
  44502. /** Gets the node hierarchy used to render z-axis */
  44503. readonly zAxis: TransformNode;
  44504. /**
  44505. * Creates a new AxesViewer
  44506. * @param scene defines the hosting scene
  44507. * @param scaleLines defines a number used to scale line length (1 by default)
  44508. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  44509. * @param xAxis defines the node hierarchy used to render the x-axis
  44510. * @param yAxis defines the node hierarchy used to render the y-axis
  44511. * @param zAxis defines the node hierarchy used to render the z-axis
  44512. */
  44513. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  44514. /**
  44515. * Force the viewer to update
  44516. * @param position defines the position of the viewer
  44517. * @param xaxis defines the x axis of the viewer
  44518. * @param yaxis defines the y axis of the viewer
  44519. * @param zaxis defines the z axis of the viewer
  44520. */
  44521. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  44522. /**
  44523. * Creates an instance of this axes viewer.
  44524. * @returns a new axes viewer with instanced meshes
  44525. */
  44526. createInstance(): AxesViewer;
  44527. /** Releases resources */
  44528. dispose(): void;
  44529. private static _SetRenderingGroupId;
  44530. }
  44531. }
  44532. declare module "babylonjs/Debug/boneAxesViewer" {
  44533. import { Nullable } from "babylonjs/types";
  44534. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  44535. import { Vector3 } from "babylonjs/Maths/math.vector";
  44536. import { Mesh } from "babylonjs/Meshes/mesh";
  44537. import { Bone } from "babylonjs/Bones/bone";
  44538. import { Scene } from "babylonjs/scene";
  44539. /**
  44540. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  44541. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  44542. */
  44543. export class BoneAxesViewer extends AxesViewer {
  44544. /**
  44545. * Gets or sets the target mesh where to display the axes viewer
  44546. */
  44547. mesh: Nullable<Mesh>;
  44548. /**
  44549. * Gets or sets the target bone where to display the axes viewer
  44550. */
  44551. bone: Nullable<Bone>;
  44552. /** Gets current position */
  44553. pos: Vector3;
  44554. /** Gets direction of X axis */
  44555. xaxis: Vector3;
  44556. /** Gets direction of Y axis */
  44557. yaxis: Vector3;
  44558. /** Gets direction of Z axis */
  44559. zaxis: Vector3;
  44560. /**
  44561. * Creates a new BoneAxesViewer
  44562. * @param scene defines the hosting scene
  44563. * @param bone defines the target bone
  44564. * @param mesh defines the target mesh
  44565. * @param scaleLines defines a scaling factor for line length (1 by default)
  44566. */
  44567. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  44568. /**
  44569. * Force the viewer to update
  44570. */
  44571. update(): void;
  44572. /** Releases resources */
  44573. dispose(): void;
  44574. }
  44575. }
  44576. declare module "babylonjs/Debug/debugLayer" {
  44577. import { Scene } from "babylonjs/scene";
  44578. /**
  44579. * Interface used to define scene explorer extensibility option
  44580. */
  44581. export interface IExplorerExtensibilityOption {
  44582. /**
  44583. * Define the option label
  44584. */
  44585. label: string;
  44586. /**
  44587. * Defines the action to execute on click
  44588. */
  44589. action: (entity: any) => void;
  44590. }
  44591. /**
  44592. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  44593. */
  44594. export interface IExplorerExtensibilityGroup {
  44595. /**
  44596. * Defines a predicate to test if a given type mut be extended
  44597. */
  44598. predicate: (entity: any) => boolean;
  44599. /**
  44600. * Gets the list of options added to a type
  44601. */
  44602. entries: IExplorerExtensibilityOption[];
  44603. }
  44604. /**
  44605. * Interface used to define the options to use to create the Inspector
  44606. */
  44607. export interface IInspectorOptions {
  44608. /**
  44609. * Display in overlay mode (default: false)
  44610. */
  44611. overlay?: boolean;
  44612. /**
  44613. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  44614. */
  44615. globalRoot?: HTMLElement;
  44616. /**
  44617. * Display the Scene explorer
  44618. */
  44619. showExplorer?: boolean;
  44620. /**
  44621. * Display the property inspector
  44622. */
  44623. showInspector?: boolean;
  44624. /**
  44625. * Display in embed mode (both panes on the right)
  44626. */
  44627. embedMode?: boolean;
  44628. /**
  44629. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  44630. */
  44631. handleResize?: boolean;
  44632. /**
  44633. * Allow the panes to popup (default: true)
  44634. */
  44635. enablePopup?: boolean;
  44636. /**
  44637. * Allow the panes to be closed by users (default: true)
  44638. */
  44639. enableClose?: boolean;
  44640. /**
  44641. * Optional list of extensibility entries
  44642. */
  44643. explorerExtensibility?: IExplorerExtensibilityGroup[];
  44644. /**
  44645. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  44646. */
  44647. inspectorURL?: string;
  44648. }
  44649. module "babylonjs/scene" {
  44650. interface Scene {
  44651. /**
  44652. * @hidden
  44653. * Backing field
  44654. */
  44655. _debugLayer: DebugLayer;
  44656. /**
  44657. * Gets the debug layer (aka Inspector) associated with the scene
  44658. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44659. */
  44660. debugLayer: DebugLayer;
  44661. }
  44662. }
  44663. /**
  44664. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44665. * what is happening in your scene
  44666. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44667. */
  44668. export class DebugLayer {
  44669. /**
  44670. * Define the url to get the inspector script from.
  44671. * By default it uses the babylonjs CDN.
  44672. * @ignoreNaming
  44673. */
  44674. static InspectorURL: string;
  44675. private _scene;
  44676. private BJSINSPECTOR;
  44677. private _onPropertyChangedObservable?;
  44678. /**
  44679. * Observable triggered when a property is changed through the inspector.
  44680. */
  44681. readonly onPropertyChangedObservable: any;
  44682. /**
  44683. * Instantiates a new debug layer.
  44684. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44685. * what is happening in your scene
  44686. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44687. * @param scene Defines the scene to inspect
  44688. */
  44689. constructor(scene: Scene);
  44690. /** Creates the inspector window. */
  44691. private _createInspector;
  44692. /**
  44693. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  44694. * @param entity defines the entity to select
  44695. * @param lineContainerTitle defines the specific block to highlight
  44696. */
  44697. select(entity: any, lineContainerTitle?: string): void;
  44698. /** Get the inspector from bundle or global */
  44699. private _getGlobalInspector;
  44700. /**
  44701. * Get if the inspector is visible or not.
  44702. * @returns true if visible otherwise, false
  44703. */
  44704. isVisible(): boolean;
  44705. /**
  44706. * Hide the inspector and close its window.
  44707. */
  44708. hide(): void;
  44709. /**
  44710. * Launch the debugLayer.
  44711. * @param config Define the configuration of the inspector
  44712. * @return a promise fulfilled when the debug layer is visible
  44713. */
  44714. show(config?: IInspectorOptions): Promise<DebugLayer>;
  44715. }
  44716. }
  44717. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  44718. import { Nullable } from "babylonjs/types";
  44719. import { Scene } from "babylonjs/scene";
  44720. import { Vector4 } from "babylonjs/Maths/math.vector";
  44721. import { Color4 } from "babylonjs/Maths/math.color";
  44722. import { Mesh } from "babylonjs/Meshes/mesh";
  44723. /**
  44724. * Class containing static functions to help procedurally build meshes
  44725. */
  44726. export class BoxBuilder {
  44727. /**
  44728. * Creates a box mesh
  44729. * * The parameter `size` sets the size (float) of each box side (default 1)
  44730. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  44731. * * You can set different colors and different images to each box side by using the parameters `faceColors` (an array of 6 Color3 elements) and `faceUV` (an array of 6 Vector4 elements)
  44732. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  44733. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44734. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44735. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44736. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  44737. * @param name defines the name of the mesh
  44738. * @param options defines the options used to create the mesh
  44739. * @param scene defines the hosting scene
  44740. * @returns the box mesh
  44741. */
  44742. static CreateBox(name: string, options: {
  44743. size?: number;
  44744. width?: number;
  44745. height?: number;
  44746. depth?: number;
  44747. faceUV?: Vector4[];
  44748. faceColors?: Color4[];
  44749. sideOrientation?: number;
  44750. frontUVs?: Vector4;
  44751. backUVs?: Vector4;
  44752. wrap?: boolean;
  44753. topBaseAt?: number;
  44754. bottomBaseAt?: number;
  44755. updatable?: boolean;
  44756. }, scene?: Nullable<Scene>): Mesh;
  44757. }
  44758. }
  44759. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  44760. import { Vector4 } from "babylonjs/Maths/math.vector";
  44761. import { Mesh } from "babylonjs/Meshes/mesh";
  44762. import { Scene } from "babylonjs/scene";
  44763. import { Nullable } from "babylonjs/types";
  44764. /**
  44765. * Class containing static functions to help procedurally build meshes
  44766. */
  44767. export class SphereBuilder {
  44768. /**
  44769. * Creates a sphere mesh
  44770. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  44771. * * You can set some different sphere dimensions, for instance to build an ellipsoid, by using the parameters `diameterX`, `diameterY` and `diameterZ` (all by default have the same value of `diameter`)
  44772. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  44773. * * You can create an unclosed sphere with the parameter `arc` (positive float, default 1), valued between 0 and 1, what is the ratio of the circumference (latitude) : 2 x PI x ratio
  44774. * * You can create an unclosed sphere on its height with the parameter `slice` (positive float, default1), valued between 0 and 1, what is the height ratio (longitude)
  44775. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44776. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44777. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44778. * @param name defines the name of the mesh
  44779. * @param options defines the options used to create the mesh
  44780. * @param scene defines the hosting scene
  44781. * @returns the sphere mesh
  44782. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  44783. */
  44784. static CreateSphere(name: string, options: {
  44785. segments?: number;
  44786. diameter?: number;
  44787. diameterX?: number;
  44788. diameterY?: number;
  44789. diameterZ?: number;
  44790. arc?: number;
  44791. slice?: number;
  44792. sideOrientation?: number;
  44793. frontUVs?: Vector4;
  44794. backUVs?: Vector4;
  44795. updatable?: boolean;
  44796. }, scene?: Nullable<Scene>): Mesh;
  44797. }
  44798. }
  44799. declare module "babylonjs/Debug/physicsViewer" {
  44800. import { Nullable } from "babylonjs/types";
  44801. import { Scene } from "babylonjs/scene";
  44802. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44803. import { Mesh } from "babylonjs/Meshes/mesh";
  44804. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  44805. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  44806. /**
  44807. * Used to show the physics impostor around the specific mesh
  44808. */
  44809. export class PhysicsViewer {
  44810. /** @hidden */
  44811. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  44812. /** @hidden */
  44813. protected _meshes: Array<Nullable<AbstractMesh>>;
  44814. /** @hidden */
  44815. protected _scene: Nullable<Scene>;
  44816. /** @hidden */
  44817. protected _numMeshes: number;
  44818. /** @hidden */
  44819. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  44820. private _renderFunction;
  44821. private _utilityLayer;
  44822. private _debugBoxMesh;
  44823. private _debugSphereMesh;
  44824. private _debugCylinderMesh;
  44825. private _debugMaterial;
  44826. private _debugMeshMeshes;
  44827. /**
  44828. * Creates a new PhysicsViewer
  44829. * @param scene defines the hosting scene
  44830. */
  44831. constructor(scene: Scene);
  44832. /** @hidden */
  44833. protected _updateDebugMeshes(): void;
  44834. /**
  44835. * Renders a specified physic impostor
  44836. * @param impostor defines the impostor to render
  44837. * @param targetMesh defines the mesh represented by the impostor
  44838. * @returns the new debug mesh used to render the impostor
  44839. */
  44840. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  44841. /**
  44842. * Hides a specified physic impostor
  44843. * @param impostor defines the impostor to hide
  44844. */
  44845. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  44846. private _getDebugMaterial;
  44847. private _getDebugBoxMesh;
  44848. private _getDebugSphereMesh;
  44849. private _getDebugCylinderMesh;
  44850. private _getDebugMeshMesh;
  44851. private _getDebugMesh;
  44852. /** Releases all resources */
  44853. dispose(): void;
  44854. }
  44855. }
  44856. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  44857. import { Vector3 } from "babylonjs/Maths/math.vector";
  44858. import { Color4 } from "babylonjs/Maths/math.color";
  44859. import { Nullable } from "babylonjs/types";
  44860. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  44861. import { Scene } from "babylonjs/scene";
  44862. /**
  44863. * Class containing static functions to help procedurally build meshes
  44864. */
  44865. export class LinesBuilder {
  44866. /**
  44867. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  44868. * * A line system mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of lines as an input parameter
  44869. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  44870. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  44871. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  44872. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  44873. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  44874. * * Updating a simple Line mesh, you just need to update every line in the `lines` array : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  44875. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  44876. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44877. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  44878. * @param name defines the name of the new line system
  44879. * @param options defines the options used to create the line system
  44880. * @param scene defines the hosting scene
  44881. * @returns a new line system mesh
  44882. */
  44883. static CreateLineSystem(name: string, options: {
  44884. lines: Vector3[][];
  44885. updatable?: boolean;
  44886. instance?: Nullable<LinesMesh>;
  44887. colors?: Nullable<Color4[][]>;
  44888. useVertexAlpha?: boolean;
  44889. }, scene: Nullable<Scene>): LinesMesh;
  44890. /**
  44891. * Creates a line mesh
  44892. * A line mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of points as an input parameter
  44893. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44894. * * The parameter `points` is an array successive Vector3
  44895. * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  44896. * * The optional parameter `colors` is an array of successive Color4, one per line point
  44897. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  44898. * * When updating an instance, remember that only point positions can change, not the number of points
  44899. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44900. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  44901. * @param name defines the name of the new line system
  44902. * @param options defines the options used to create the line system
  44903. * @param scene defines the hosting scene
  44904. * @returns a new line mesh
  44905. */
  44906. static CreateLines(name: string, options: {
  44907. points: Vector3[];
  44908. updatable?: boolean;
  44909. instance?: Nullable<LinesMesh>;
  44910. colors?: Color4[];
  44911. useVertexAlpha?: boolean;
  44912. }, scene?: Nullable<Scene>): LinesMesh;
  44913. /**
  44914. * Creates a dashed line mesh
  44915. * * A dashed line mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of points as an input parameter
  44916. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44917. * * The parameter `points` is an array successive Vector3
  44918. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  44919. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  44920. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  44921. * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  44922. * * When updating an instance, remember that only point positions can change, not the number of points
  44923. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44924. * @param name defines the name of the mesh
  44925. * @param options defines the options used to create the mesh
  44926. * @param scene defines the hosting scene
  44927. * @returns the dashed line mesh
  44928. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  44929. */
  44930. static CreateDashedLines(name: string, options: {
  44931. points: Vector3[];
  44932. dashSize?: number;
  44933. gapSize?: number;
  44934. dashNb?: number;
  44935. updatable?: boolean;
  44936. instance?: LinesMesh;
  44937. }, scene?: Nullable<Scene>): LinesMesh;
  44938. }
  44939. }
  44940. declare module "babylonjs/Debug/rayHelper" {
  44941. import { Nullable } from "babylonjs/types";
  44942. import { Ray } from "babylonjs/Culling/ray";
  44943. import { Vector3 } from "babylonjs/Maths/math.vector";
  44944. import { Color3 } from "babylonjs/Maths/math.color";
  44945. import { Scene } from "babylonjs/scene";
  44946. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44947. import "babylonjs/Meshes/Builders/linesBuilder";
  44948. /**
  44949. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  44950. * in order to better appreciate the issue one might have.
  44951. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  44952. */
  44953. export class RayHelper {
  44954. /**
  44955. * Defines the ray we are currently tryin to visualize.
  44956. */
  44957. ray: Nullable<Ray>;
  44958. private _renderPoints;
  44959. private _renderLine;
  44960. private _renderFunction;
  44961. private _scene;
  44962. private _updateToMeshFunction;
  44963. private _attachedToMesh;
  44964. private _meshSpaceDirection;
  44965. private _meshSpaceOrigin;
  44966. /**
  44967. * Helper function to create a colored helper in a scene in one line.
  44968. * @param ray Defines the ray we are currently tryin to visualize
  44969. * @param scene Defines the scene the ray is used in
  44970. * @param color Defines the color we want to see the ray in
  44971. * @returns The newly created ray helper.
  44972. */
  44973. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  44974. /**
  44975. * Instantiate a new ray helper.
  44976. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  44977. * in order to better appreciate the issue one might have.
  44978. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  44979. * @param ray Defines the ray we are currently tryin to visualize
  44980. */
  44981. constructor(ray: Ray);
  44982. /**
  44983. * Shows the ray we are willing to debug.
  44984. * @param scene Defines the scene the ray needs to be rendered in
  44985. * @param color Defines the color the ray needs to be rendered in
  44986. */
  44987. show(scene: Scene, color?: Color3): void;
  44988. /**
  44989. * Hides the ray we are debugging.
  44990. */
  44991. hide(): void;
  44992. private _render;
  44993. /**
  44994. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  44995. * @param mesh Defines the mesh we want the helper attached to
  44996. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  44997. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  44998. * @param length Defines the length of the ray
  44999. */
  45000. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  45001. /**
  45002. * Detach the ray helper from the mesh it has previously been attached to.
  45003. */
  45004. detachFromMesh(): void;
  45005. private _updateToMesh;
  45006. /**
  45007. * Dispose the helper and release its associated resources.
  45008. */
  45009. dispose(): void;
  45010. }
  45011. }
  45012. declare module "babylonjs/Debug/skeletonViewer" {
  45013. import { Color3 } from "babylonjs/Maths/math.color";
  45014. import { Scene } from "babylonjs/scene";
  45015. import { Nullable } from "babylonjs/types";
  45016. import { Skeleton } from "babylonjs/Bones/skeleton";
  45017. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45018. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45019. /**
  45020. * Class used to render a debug view of a given skeleton
  45021. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  45022. */
  45023. export class SkeletonViewer {
  45024. /** defines the skeleton to render */
  45025. skeleton: Skeleton;
  45026. /** defines the mesh attached to the skeleton */
  45027. mesh: AbstractMesh;
  45028. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45029. autoUpdateBonesMatrices: boolean;
  45030. /** defines the rendering group id to use with the viewer */
  45031. renderingGroupId: number;
  45032. /** Gets or sets the color used to render the skeleton */
  45033. color: Color3;
  45034. private _scene;
  45035. private _debugLines;
  45036. private _debugMesh;
  45037. private _isEnabled;
  45038. private _renderFunction;
  45039. private _utilityLayer;
  45040. /**
  45041. * Returns the mesh used to render the bones
  45042. */
  45043. readonly debugMesh: Nullable<LinesMesh>;
  45044. /**
  45045. * Creates a new SkeletonViewer
  45046. * @param skeleton defines the skeleton to render
  45047. * @param mesh defines the mesh attached to the skeleton
  45048. * @param scene defines the hosting scene
  45049. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  45050. * @param renderingGroupId defines the rendering group id to use with the viewer
  45051. */
  45052. constructor(
  45053. /** defines the skeleton to render */
  45054. skeleton: Skeleton,
  45055. /** defines the mesh attached to the skeleton */
  45056. mesh: AbstractMesh, scene: Scene,
  45057. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45058. autoUpdateBonesMatrices?: boolean,
  45059. /** defines the rendering group id to use with the viewer */
  45060. renderingGroupId?: number);
  45061. /** Gets or sets a boolean indicating if the viewer is enabled */
  45062. isEnabled: boolean;
  45063. private _getBonePosition;
  45064. private _getLinesForBonesWithLength;
  45065. private _getLinesForBonesNoLength;
  45066. /** Update the viewer to sync with current skeleton state */
  45067. update(): void;
  45068. /** Release associated resources */
  45069. dispose(): void;
  45070. }
  45071. }
  45072. declare module "babylonjs/Debug/index" {
  45073. export * from "babylonjs/Debug/axesViewer";
  45074. export * from "babylonjs/Debug/boneAxesViewer";
  45075. export * from "babylonjs/Debug/debugLayer";
  45076. export * from "babylonjs/Debug/physicsViewer";
  45077. export * from "babylonjs/Debug/rayHelper";
  45078. export * from "babylonjs/Debug/skeletonViewer";
  45079. }
  45080. declare module "babylonjs/Engines/nullEngine" {
  45081. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  45082. import { Scene } from "babylonjs/scene";
  45083. import { Engine } from "babylonjs/Engines/engine";
  45084. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  45085. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  45086. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45087. import { Effect } from "babylonjs/Materials/effect";
  45088. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  45089. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45090. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  45091. /**
  45092. * Options to create the null engine
  45093. */
  45094. export class NullEngineOptions {
  45095. /**
  45096. * Render width (Default: 512)
  45097. */
  45098. renderWidth: number;
  45099. /**
  45100. * Render height (Default: 256)
  45101. */
  45102. renderHeight: number;
  45103. /**
  45104. * Texture size (Default: 512)
  45105. */
  45106. textureSize: number;
  45107. /**
  45108. * If delta time between frames should be constant
  45109. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45110. */
  45111. deterministicLockstep: boolean;
  45112. /**
  45113. * Maximum about of steps between frames (Default: 4)
  45114. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45115. */
  45116. lockstepMaxSteps: number;
  45117. }
  45118. /**
  45119. * The null engine class provides support for headless version of babylon.js.
  45120. * This can be used in server side scenario or for testing purposes
  45121. */
  45122. export class NullEngine extends Engine {
  45123. private _options;
  45124. /**
  45125. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45126. */
  45127. isDeterministicLockStep(): boolean;
  45128. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  45129. getLockstepMaxSteps(): number;
  45130. /**
  45131. * Sets hardware scaling, used to save performance if needed
  45132. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  45133. */
  45134. getHardwareScalingLevel(): number;
  45135. constructor(options?: NullEngineOptions);
  45136. createVertexBuffer(vertices: FloatArray): DataBuffer;
  45137. createIndexBuffer(indices: IndicesArray): DataBuffer;
  45138. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45139. getRenderWidth(useScreen?: boolean): number;
  45140. getRenderHeight(useScreen?: boolean): number;
  45141. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  45142. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  45143. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  45144. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45145. bindSamplers(effect: Effect): void;
  45146. enableEffect(effect: Effect): void;
  45147. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45148. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45149. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45150. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45151. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45152. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45153. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45154. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45155. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45156. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45157. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45158. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45159. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45160. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45161. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45162. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45163. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45164. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45165. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45166. setBool(uniform: WebGLUniformLocation, bool: number): void;
  45167. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  45168. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45169. bindBuffers(vertexBuffers: {
  45170. [key: string]: VertexBuffer;
  45171. }, indexBuffer: DataBuffer, effect: Effect): void;
  45172. wipeCaches(bruteForce?: boolean): void;
  45173. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  45174. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45175. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45176. /** @hidden */
  45177. _createTexture(): WebGLTexture;
  45178. /** @hidden */
  45179. _releaseTexture(texture: InternalTexture): void;
  45180. createTexture(urlArg: string, noMipmap: boolean, invertY: boolean, scene: Scene, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<ArrayBuffer | HTMLImageElement>, fallBack?: InternalTexture, format?: number): InternalTexture;
  45181. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  45182. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  45183. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  45184. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45185. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  45186. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  45187. areAllEffectsReady(): boolean;
  45188. /**
  45189. * @hidden
  45190. * Get the current error code of the webGL context
  45191. * @returns the error code
  45192. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  45193. */
  45194. getError(): number;
  45195. /** @hidden */
  45196. _getUnpackAlignement(): number;
  45197. /** @hidden */
  45198. _unpackFlipY(value: boolean): void;
  45199. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  45200. /**
  45201. * Updates a dynamic vertex buffer.
  45202. * @param vertexBuffer the vertex buffer to update
  45203. * @param data the data used to update the vertex buffer
  45204. * @param byteOffset the byte offset of the data (optional)
  45205. * @param byteLength the byte length of the data (optional)
  45206. */
  45207. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  45208. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  45209. /** @hidden */
  45210. _bindTexture(channel: number, texture: InternalTexture): void;
  45211. protected _deleteBuffer(buffer: WebGLBuffer): void;
  45212. releaseEffects(): void;
  45213. displayLoadingUI(): void;
  45214. hideLoadingUI(): void;
  45215. /** @hidden */
  45216. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45217. /** @hidden */
  45218. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45219. /** @hidden */
  45220. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45221. /** @hidden */
  45222. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  45223. }
  45224. }
  45225. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  45226. import { Nullable, int } from "babylonjs/types";
  45227. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  45228. /** @hidden */
  45229. export class _OcclusionDataStorage {
  45230. /** @hidden */
  45231. occlusionInternalRetryCounter: number;
  45232. /** @hidden */
  45233. isOcclusionQueryInProgress: boolean;
  45234. /** @hidden */
  45235. isOccluded: boolean;
  45236. /** @hidden */
  45237. occlusionRetryCount: number;
  45238. /** @hidden */
  45239. occlusionType: number;
  45240. /** @hidden */
  45241. occlusionQueryAlgorithmType: number;
  45242. }
  45243. module "babylonjs/Engines/engine" {
  45244. interface Engine {
  45245. /**
  45246. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  45247. * @return the new query
  45248. */
  45249. createQuery(): WebGLQuery;
  45250. /**
  45251. * Delete and release a webGL query
  45252. * @param query defines the query to delete
  45253. * @return the current engine
  45254. */
  45255. deleteQuery(query: WebGLQuery): Engine;
  45256. /**
  45257. * Check if a given query has resolved and got its value
  45258. * @param query defines the query to check
  45259. * @returns true if the query got its value
  45260. */
  45261. isQueryResultAvailable(query: WebGLQuery): boolean;
  45262. /**
  45263. * Gets the value of a given query
  45264. * @param query defines the query to check
  45265. * @returns the value of the query
  45266. */
  45267. getQueryResult(query: WebGLQuery): number;
  45268. /**
  45269. * Initiates an occlusion query
  45270. * @param algorithmType defines the algorithm to use
  45271. * @param query defines the query to use
  45272. * @returns the current engine
  45273. * @see http://doc.babylonjs.com/features/occlusionquery
  45274. */
  45275. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  45276. /**
  45277. * Ends an occlusion query
  45278. * @see http://doc.babylonjs.com/features/occlusionquery
  45279. * @param algorithmType defines the algorithm to use
  45280. * @returns the current engine
  45281. */
  45282. endOcclusionQuery(algorithmType: number): Engine;
  45283. /**
  45284. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  45285. * Please note that only one query can be issued at a time
  45286. * @returns a time token used to track the time span
  45287. */
  45288. startTimeQuery(): Nullable<_TimeToken>;
  45289. /**
  45290. * Ends a time query
  45291. * @param token defines the token used to measure the time span
  45292. * @returns the time spent (in ns)
  45293. */
  45294. endTimeQuery(token: _TimeToken): int;
  45295. /** @hidden */
  45296. _currentNonTimestampToken: Nullable<_TimeToken>;
  45297. /** @hidden */
  45298. _createTimeQuery(): WebGLQuery;
  45299. /** @hidden */
  45300. _deleteTimeQuery(query: WebGLQuery): void;
  45301. /** @hidden */
  45302. _getGlAlgorithmType(algorithmType: number): number;
  45303. /** @hidden */
  45304. _getTimeQueryResult(query: WebGLQuery): any;
  45305. /** @hidden */
  45306. _getTimeQueryAvailability(query: WebGLQuery): any;
  45307. }
  45308. }
  45309. module "babylonjs/Meshes/abstractMesh" {
  45310. interface AbstractMesh {
  45311. /**
  45312. * Backing filed
  45313. * @hidden
  45314. */
  45315. __occlusionDataStorage: _OcclusionDataStorage;
  45316. /**
  45317. * Access property
  45318. * @hidden
  45319. */
  45320. _occlusionDataStorage: _OcclusionDataStorage;
  45321. /**
  45322. * This number indicates the number of allowed retries before stop the occlusion query, this is useful if the occlusion query is taking long time before to the query result is retireved, the query result indicates if the object is visible within the scene or not and based on that Babylon.Js engine decideds to show or hide the object.
  45323. * The default value is -1 which means don't break the query and wait till the result
  45324. * @see http://doc.babylonjs.com/features/occlusionquery
  45325. */
  45326. occlusionRetryCount: number;
  45327. /**
  45328. * This property is responsible for starting the occlusion query within the Mesh or not, this property is also used to determine what should happen when the occlusionRetryCount is reached. It has supports 3 values:
  45329. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  45330. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  45331. * * OCCLUSION_TYPE_STRICT: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken restore the last state of the mesh occlusion if the mesh was visible then show the mesh if was hidden then hide don't show.
  45332. * @see http://doc.babylonjs.com/features/occlusionquery
  45333. */
  45334. occlusionType: number;
  45335. /**
  45336. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  45337. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  45338. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE (Default Value) which is mapped to GL_ANY_SAMPLES_PASSED_CONSERVATIVE which is a false positive algorithm that is faster than GL_ANY_SAMPLES_PASSED but less accurate.
  45339. * @see http://doc.babylonjs.com/features/occlusionquery
  45340. */
  45341. occlusionQueryAlgorithmType: number;
  45342. /**
  45343. * Gets or sets whether the mesh is occluded or not, it is used also to set the intial state of the mesh to be occluded or not
  45344. * @see http://doc.babylonjs.com/features/occlusionquery
  45345. */
  45346. isOccluded: boolean;
  45347. /**
  45348. * Flag to check the progress status of the query
  45349. * @see http://doc.babylonjs.com/features/occlusionquery
  45350. */
  45351. isOcclusionQueryInProgress: boolean;
  45352. }
  45353. }
  45354. }
  45355. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  45356. import { Nullable } from "babylonjs/types";
  45357. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45358. /** @hidden */
  45359. export var _forceTransformFeedbackToBundle: boolean;
  45360. module "babylonjs/Engines/engine" {
  45361. interface Engine {
  45362. /**
  45363. * Creates a webGL transform feedback object
  45364. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  45365. * @returns the webGL transform feedback object
  45366. */
  45367. createTransformFeedback(): WebGLTransformFeedback;
  45368. /**
  45369. * Delete a webGL transform feedback object
  45370. * @param value defines the webGL transform feedback object to delete
  45371. */
  45372. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  45373. /**
  45374. * Bind a webGL transform feedback object to the webgl context
  45375. * @param value defines the webGL transform feedback object to bind
  45376. */
  45377. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  45378. /**
  45379. * Begins a transform feedback operation
  45380. * @param usePoints defines if points or triangles must be used
  45381. */
  45382. beginTransformFeedback(usePoints: boolean): void;
  45383. /**
  45384. * Ends a transform feedback operation
  45385. */
  45386. endTransformFeedback(): void;
  45387. /**
  45388. * Specify the varyings to use with transform feedback
  45389. * @param program defines the associated webGL program
  45390. * @param value defines the list of strings representing the varying names
  45391. */
  45392. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  45393. /**
  45394. * Bind a webGL buffer for a transform feedback operation
  45395. * @param value defines the webGL buffer to bind
  45396. */
  45397. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  45398. }
  45399. }
  45400. }
  45401. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  45402. import { Scene } from "babylonjs/scene";
  45403. import { Engine } from "babylonjs/Engines/engine";
  45404. import { Texture } from "babylonjs/Materials/Textures/texture";
  45405. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  45406. import "babylonjs/Engines/Extensions/engine.multiRender";
  45407. /**
  45408. * Creation options of the multi render target texture.
  45409. */
  45410. export interface IMultiRenderTargetOptions {
  45411. /**
  45412. * Define if the texture needs to create mip maps after render.
  45413. */
  45414. generateMipMaps?: boolean;
  45415. /**
  45416. * Define the types of all the draw buffers we want to create
  45417. */
  45418. types?: number[];
  45419. /**
  45420. * Define the sampling modes of all the draw buffers we want to create
  45421. */
  45422. samplingModes?: number[];
  45423. /**
  45424. * Define if a depth buffer is required
  45425. */
  45426. generateDepthBuffer?: boolean;
  45427. /**
  45428. * Define if a stencil buffer is required
  45429. */
  45430. generateStencilBuffer?: boolean;
  45431. /**
  45432. * Define if a depth texture is required instead of a depth buffer
  45433. */
  45434. generateDepthTexture?: boolean;
  45435. /**
  45436. * Define the number of desired draw buffers
  45437. */
  45438. textureCount?: number;
  45439. /**
  45440. * Define if aspect ratio should be adapted to the texture or stay the scene one
  45441. */
  45442. doNotChangeAspectRatio?: boolean;
  45443. /**
  45444. * Define the default type of the buffers we are creating
  45445. */
  45446. defaultType?: number;
  45447. }
  45448. /**
  45449. * A multi render target, like a render target provides the ability to render to a texture.
  45450. * Unlike the render target, it can render to several draw buffers in one draw.
  45451. * This is specially interesting in deferred rendering or for any effects requiring more than
  45452. * just one color from a single pass.
  45453. */
  45454. export class MultiRenderTarget extends RenderTargetTexture {
  45455. private _internalTextures;
  45456. private _textures;
  45457. private _multiRenderTargetOptions;
  45458. /**
  45459. * Get if draw buffers are currently supported by the used hardware and browser.
  45460. */
  45461. readonly isSupported: boolean;
  45462. /**
  45463. * Get the list of textures generated by the multi render target.
  45464. */
  45465. readonly textures: Texture[];
  45466. /**
  45467. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  45468. */
  45469. readonly depthTexture: Texture;
  45470. /**
  45471. * Set the wrapping mode on U of all the textures we are rendering to.
  45472. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45473. */
  45474. wrapU: number;
  45475. /**
  45476. * Set the wrapping mode on V of all the textures we are rendering to.
  45477. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45478. */
  45479. wrapV: number;
  45480. /**
  45481. * Instantiate a new multi render target texture.
  45482. * A multi render target, like a render target provides the ability to render to a texture.
  45483. * Unlike the render target, it can render to several draw buffers in one draw.
  45484. * This is specially interesting in deferred rendering or for any effects requiring more than
  45485. * just one color from a single pass.
  45486. * @param name Define the name of the texture
  45487. * @param size Define the size of the buffers to render to
  45488. * @param count Define the number of target we are rendering into
  45489. * @param scene Define the scene the texture belongs to
  45490. * @param options Define the options used to create the multi render target
  45491. */
  45492. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  45493. /** @hidden */
  45494. _rebuild(): void;
  45495. private _createInternalTextures;
  45496. private _createTextures;
  45497. /**
  45498. * Define the number of samples used if MSAA is enabled.
  45499. */
  45500. samples: number;
  45501. /**
  45502. * Resize all the textures in the multi render target.
  45503. * Be carrefull as it will recreate all the data in the new texture.
  45504. * @param size Define the new size
  45505. */
  45506. resize(size: any): void;
  45507. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  45508. /**
  45509. * Dispose the render targets and their associated resources
  45510. */
  45511. dispose(): void;
  45512. /**
  45513. * Release all the underlying texture used as draw buffers.
  45514. */
  45515. releaseInternalTextures(): void;
  45516. }
  45517. }
  45518. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  45519. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45520. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  45521. import { Nullable } from "babylonjs/types";
  45522. module "babylonjs/Engines/engine" {
  45523. interface Engine {
  45524. /**
  45525. * Unbind a list of render target textures from the webGL context
  45526. * This is used only when drawBuffer extension or webGL2 are active
  45527. * @param textures defines the render target textures to unbind
  45528. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45529. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45530. */
  45531. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  45532. /**
  45533. * Create a multi render target texture
  45534. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  45535. * @param size defines the size of the texture
  45536. * @param options defines the creation options
  45537. * @returns the cube texture as an InternalTexture
  45538. */
  45539. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  45540. /**
  45541. * Update the sample count for a given multiple render target texture
  45542. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  45543. * @param textures defines the textures to update
  45544. * @param samples defines the sample count to set
  45545. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  45546. */
  45547. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  45548. }
  45549. }
  45550. }
  45551. declare module "babylonjs/Engines/Extensions/index" {
  45552. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  45553. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  45554. export * from "babylonjs/Engines/Extensions/engine.multiview";
  45555. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  45556. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  45557. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  45558. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  45559. export * from "babylonjs/Engines/Extensions/engine.webVR";
  45560. }
  45561. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  45562. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45563. /** @hidden */
  45564. export var rgbdEncodePixelShader: {
  45565. name: string;
  45566. shader: string;
  45567. };
  45568. }
  45569. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  45570. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45571. /** @hidden */
  45572. export var rgbdDecodePixelShader: {
  45573. name: string;
  45574. shader: string;
  45575. };
  45576. }
  45577. declare module "babylonjs/Misc/environmentTextureTools" {
  45578. import { Nullable } from "babylonjs/types";
  45579. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  45580. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45581. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  45582. import "babylonjs/Engines/Extensions/engine.renderTarget";
  45583. import "babylonjs/Shaders/rgbdEncode.fragment";
  45584. import "babylonjs/Shaders/rgbdDecode.fragment";
  45585. /**
  45586. * Raw texture data and descriptor sufficient for WebGL texture upload
  45587. */
  45588. export interface EnvironmentTextureInfo {
  45589. /**
  45590. * Version of the environment map
  45591. */
  45592. version: number;
  45593. /**
  45594. * Width of image
  45595. */
  45596. width: number;
  45597. /**
  45598. * Irradiance information stored in the file.
  45599. */
  45600. irradiance: any;
  45601. /**
  45602. * Specular information stored in the file.
  45603. */
  45604. specular: any;
  45605. }
  45606. /**
  45607. * Defines One Image in the file. It requires only the position in the file
  45608. * as well as the length.
  45609. */
  45610. interface BufferImageData {
  45611. /**
  45612. * Length of the image data.
  45613. */
  45614. length: number;
  45615. /**
  45616. * Position of the data from the null terminator delimiting the end of the JSON.
  45617. */
  45618. position: number;
  45619. }
  45620. /**
  45621. * Defines the specular data enclosed in the file.
  45622. * This corresponds to the version 1 of the data.
  45623. */
  45624. export interface EnvironmentTextureSpecularInfoV1 {
  45625. /**
  45626. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  45627. */
  45628. specularDataPosition?: number;
  45629. /**
  45630. * This contains all the images data needed to reconstruct the cubemap.
  45631. */
  45632. mipmaps: Array<BufferImageData>;
  45633. /**
  45634. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  45635. */
  45636. lodGenerationScale: number;
  45637. }
  45638. /**
  45639. * Sets of helpers addressing the serialization and deserialization of environment texture
  45640. * stored in a BabylonJS env file.
  45641. * Those files are usually stored as .env files.
  45642. */
  45643. export class EnvironmentTextureTools {
  45644. /**
  45645. * Magic number identifying the env file.
  45646. */
  45647. private static _MagicBytes;
  45648. /**
  45649. * Gets the environment info from an env file.
  45650. * @param data The array buffer containing the .env bytes.
  45651. * @returns the environment file info (the json header) if successfully parsed.
  45652. */
  45653. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  45654. /**
  45655. * Creates an environment texture from a loaded cube texture.
  45656. * @param texture defines the cube texture to convert in env file
  45657. * @return a promise containing the environment data if succesfull.
  45658. */
  45659. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  45660. /**
  45661. * Creates a JSON representation of the spherical data.
  45662. * @param texture defines the texture containing the polynomials
  45663. * @return the JSON representation of the spherical info
  45664. */
  45665. private static _CreateEnvTextureIrradiance;
  45666. /**
  45667. * Creates the ArrayBufferViews used for initializing environment texture image data.
  45668. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  45669. * @param info parameters that determine what views will be created for accessing the underlying buffer
  45670. * @return the views described by info providing access to the underlying buffer
  45671. */
  45672. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  45673. /**
  45674. * Uploads the texture info contained in the env file to the GPU.
  45675. * @param texture defines the internal texture to upload to
  45676. * @param arrayBuffer defines the buffer cotaining the data to load
  45677. * @param info defines the texture info retrieved through the GetEnvInfo method
  45678. * @returns a promise
  45679. */
  45680. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  45681. /**
  45682. * Uploads the levels of image data to the GPU.
  45683. * @param texture defines the internal texture to upload to
  45684. * @param imageData defines the array buffer views of image data [mipmap][face]
  45685. * @returns a promise
  45686. */
  45687. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  45688. /**
  45689. * Uploads spherical polynomials information to the texture.
  45690. * @param texture defines the texture we are trying to upload the information to
  45691. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  45692. */
  45693. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  45694. /** @hidden */
  45695. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  45696. }
  45697. }
  45698. declare module "babylonjs/Maths/math.vertexFormat" {
  45699. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  45700. /**
  45701. * Contains position and normal vectors for a vertex
  45702. */
  45703. export class PositionNormalVertex {
  45704. /** the position of the vertex (defaut: 0,0,0) */
  45705. position: Vector3;
  45706. /** the normal of the vertex (defaut: 0,1,0) */
  45707. normal: Vector3;
  45708. /**
  45709. * Creates a PositionNormalVertex
  45710. * @param position the position of the vertex (defaut: 0,0,0)
  45711. * @param normal the normal of the vertex (defaut: 0,1,0)
  45712. */
  45713. constructor(
  45714. /** the position of the vertex (defaut: 0,0,0) */
  45715. position?: Vector3,
  45716. /** the normal of the vertex (defaut: 0,1,0) */
  45717. normal?: Vector3);
  45718. /**
  45719. * Clones the PositionNormalVertex
  45720. * @returns the cloned PositionNormalVertex
  45721. */
  45722. clone(): PositionNormalVertex;
  45723. }
  45724. /**
  45725. * Contains position, normal and uv vectors for a vertex
  45726. */
  45727. export class PositionNormalTextureVertex {
  45728. /** the position of the vertex (defaut: 0,0,0) */
  45729. position: Vector3;
  45730. /** the normal of the vertex (defaut: 0,1,0) */
  45731. normal: Vector3;
  45732. /** the uv of the vertex (default: 0,0) */
  45733. uv: Vector2;
  45734. /**
  45735. * Creates a PositionNormalTextureVertex
  45736. * @param position the position of the vertex (defaut: 0,0,0)
  45737. * @param normal the normal of the vertex (defaut: 0,1,0)
  45738. * @param uv the uv of the vertex (default: 0,0)
  45739. */
  45740. constructor(
  45741. /** the position of the vertex (defaut: 0,0,0) */
  45742. position?: Vector3,
  45743. /** the normal of the vertex (defaut: 0,1,0) */
  45744. normal?: Vector3,
  45745. /** the uv of the vertex (default: 0,0) */
  45746. uv?: Vector2);
  45747. /**
  45748. * Clones the PositionNormalTextureVertex
  45749. * @returns the cloned PositionNormalTextureVertex
  45750. */
  45751. clone(): PositionNormalTextureVertex;
  45752. }
  45753. }
  45754. declare module "babylonjs/Maths/math" {
  45755. export * from "babylonjs/Maths/math.axis";
  45756. export * from "babylonjs/Maths/math.color";
  45757. export * from "babylonjs/Maths/math.constants";
  45758. export * from "babylonjs/Maths/math.frustum";
  45759. export * from "babylonjs/Maths/math.path";
  45760. export * from "babylonjs/Maths/math.plane";
  45761. export * from "babylonjs/Maths/math.size";
  45762. export * from "babylonjs/Maths/math.vector";
  45763. export * from "babylonjs/Maths/math.vertexFormat";
  45764. export * from "babylonjs/Maths/math.viewport";
  45765. }
  45766. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  45767. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  45768. /** @hidden */
  45769. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  45770. private _genericAttributeLocation;
  45771. private _varyingLocationCount;
  45772. private _varyingLocationMap;
  45773. private _replacements;
  45774. private _textureCount;
  45775. private _uniforms;
  45776. lineProcessor(line: string): string;
  45777. attributeProcessor(attribute: string): string;
  45778. varyingProcessor(varying: string, isFragment: boolean): string;
  45779. uniformProcessor(uniform: string): string;
  45780. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  45781. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  45782. }
  45783. }
  45784. declare module "babylonjs/Engines/nativeEngine" {
  45785. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  45786. import { Engine } from "babylonjs/Engines/engine";
  45787. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  45788. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45789. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45790. import { Effect } from "babylonjs/Materials/effect";
  45791. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45792. import { Color4, Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  45793. import { Scene } from "babylonjs/scene";
  45794. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  45795. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  45796. /**
  45797. * Container for accessors for natively-stored mesh data buffers.
  45798. */
  45799. class NativeDataBuffer extends DataBuffer {
  45800. /**
  45801. * Accessor value used to identify/retrieve a natively-stored index buffer.
  45802. */
  45803. nativeIndexBuffer?: any;
  45804. /**
  45805. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  45806. */
  45807. nativeVertexBuffer?: any;
  45808. }
  45809. /** @hidden */
  45810. export class NativeEngine extends Engine {
  45811. private readonly _native;
  45812. getHardwareScalingLevel(): number;
  45813. constructor();
  45814. /**
  45815. * Can be used to override the current requestAnimationFrame requester.
  45816. * @hidden
  45817. */
  45818. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  45819. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45820. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  45821. createVertexBuffer(data: DataArray): NativeDataBuffer;
  45822. recordVertexArrayObject(vertexBuffers: {
  45823. [key: string]: VertexBuffer;
  45824. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  45825. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  45826. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  45827. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45828. /**
  45829. * Draw a list of indexed primitives
  45830. * @param fillMode defines the primitive to use
  45831. * @param indexStart defines the starting index
  45832. * @param indexCount defines the number of index to draw
  45833. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45834. */
  45835. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45836. /**
  45837. * Draw a list of unindexed primitives
  45838. * @param fillMode defines the primitive to use
  45839. * @param verticesStart defines the index of first vertex to draw
  45840. * @param verticesCount defines the count of vertices to draw
  45841. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45842. */
  45843. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45844. createPipelineContext(): IPipelineContext;
  45845. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  45846. /** @hidden */
  45847. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  45848. /** @hidden */
  45849. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  45850. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  45851. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  45852. protected _setProgram(program: WebGLProgram): void;
  45853. _releaseEffect(effect: Effect): void;
  45854. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  45855. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  45856. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  45857. bindSamplers(effect: Effect): void;
  45858. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  45859. getRenderWidth(useScreen?: boolean): number;
  45860. getRenderHeight(useScreen?: boolean): number;
  45861. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  45862. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45863. /**
  45864. * Set the z offset to apply to current rendering
  45865. * @param value defines the offset to apply
  45866. */
  45867. setZOffset(value: number): void;
  45868. /**
  45869. * Gets the current value of the zOffset
  45870. * @returns the current zOffset state
  45871. */
  45872. getZOffset(): number;
  45873. /**
  45874. * Enable or disable depth buffering
  45875. * @param enable defines the state to set
  45876. */
  45877. setDepthBuffer(enable: boolean): void;
  45878. /**
  45879. * Gets a boolean indicating if depth writing is enabled
  45880. * @returns the current depth writing state
  45881. */
  45882. getDepthWrite(): boolean;
  45883. /**
  45884. * Enable or disable depth writing
  45885. * @param enable defines the state to set
  45886. */
  45887. setDepthWrite(enable: boolean): void;
  45888. /**
  45889. * Enable or disable color writing
  45890. * @param enable defines the state to set
  45891. */
  45892. setColorWrite(enable: boolean): void;
  45893. /**
  45894. * Gets a boolean indicating if color writing is enabled
  45895. * @returns the current color writing state
  45896. */
  45897. getColorWrite(): boolean;
  45898. /**
  45899. * Sets alpha constants used by some alpha blending modes
  45900. * @param r defines the red component
  45901. * @param g defines the green component
  45902. * @param b defines the blue component
  45903. * @param a defines the alpha component
  45904. */
  45905. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  45906. /**
  45907. * Sets the current alpha mode
  45908. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  45909. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  45910. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45911. */
  45912. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45913. /**
  45914. * Gets the current alpha mode
  45915. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45916. * @returns the current alpha mode
  45917. */
  45918. getAlphaMode(): number;
  45919. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45920. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45921. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45922. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45923. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45924. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45925. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45926. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45927. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45928. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45929. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45930. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45931. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45932. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45933. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45934. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45935. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45936. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45937. setBool(uniform: WebGLUniformLocation, bool: number): void;
  45938. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  45939. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  45940. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  45941. wipeCaches(bruteForce?: boolean): void;
  45942. _createTexture(): WebGLTexture;
  45943. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  45944. /**
  45945. * Usually called from BABYLON.Texture.ts.
  45946. * Passed information to create a WebGLTexture
  45947. * @param urlArg defines a value which contains one of the following:
  45948. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  45949. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  45950. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  45951. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  45952. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  45953. * @param scene needed for loading to the correct scene
  45954. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  45955. * @param onLoad optional callback to be called upon successful completion
  45956. * @param onError optional callback to be called upon failure
  45957. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  45958. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  45959. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  45960. * @param forcedExtension defines the extension to use to pick the right loader
  45961. * @returns a InternalTexture for assignment back into BABYLON.Texture
  45962. */
  45963. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>): InternalTexture;
  45964. /**
  45965. * Creates a cube texture
  45966. * @param rootUrl defines the url where the files to load is located
  45967. * @param scene defines the current scene
  45968. * @param files defines the list of files to load (1 per face)
  45969. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  45970. * @param onLoad defines an optional callback raised when the texture is loaded
  45971. * @param onError defines an optional callback raised if there is an issue to load the texture
  45972. * @param format defines the format of the data
  45973. * @param forcedExtension defines the extension to use to pick the right loader
  45974. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  45975. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  45976. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  45977. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  45978. * @returns the cube texture as an InternalTexture
  45979. */
  45980. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>): InternalTexture;
  45981. private _getSamplingFilter;
  45982. private static _GetNativeTextureFormat;
  45983. createRenderTargetTexture(size: number | {
  45984. width: number;
  45985. height: number;
  45986. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  45987. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  45988. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  45989. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45990. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  45991. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  45992. /**
  45993. * Updates a dynamic vertex buffer.
  45994. * @param vertexBuffer the vertex buffer to update
  45995. * @param data the data used to update the vertex buffer
  45996. * @param byteOffset the byte offset of the data (optional)
  45997. * @param byteLength the byte length of the data (optional)
  45998. */
  45999. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  46000. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  46001. private _updateAnisotropicLevel;
  46002. private _getAddressMode;
  46003. /** @hidden */
  46004. _bindTexture(channel: number, texture: InternalTexture): void;
  46005. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  46006. releaseEffects(): void;
  46007. /** @hidden */
  46008. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46009. /** @hidden */
  46010. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46011. /** @hidden */
  46012. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46013. /** @hidden */
  46014. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46015. }
  46016. }
  46017. declare module "babylonjs/Engines/index" {
  46018. export * from "babylonjs/Engines/constants";
  46019. export * from "babylonjs/Engines/engine";
  46020. export * from "babylonjs/Engines/engineStore";
  46021. export * from "babylonjs/Engines/nullEngine";
  46022. export * from "babylonjs/Engines/Extensions/index";
  46023. export * from "babylonjs/Engines/IPipelineContext";
  46024. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  46025. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  46026. export * from "babylonjs/Engines/nativeEngine";
  46027. }
  46028. declare module "babylonjs/Events/clipboardEvents" {
  46029. /**
  46030. * Gather the list of clipboard event types as constants.
  46031. */
  46032. export class ClipboardEventTypes {
  46033. /**
  46034. * The clipboard event is fired when a copy command is active (pressed).
  46035. */
  46036. static readonly COPY: number;
  46037. /**
  46038. * The clipboard event is fired when a cut command is active (pressed).
  46039. */
  46040. static readonly CUT: number;
  46041. /**
  46042. * The clipboard event is fired when a paste command is active (pressed).
  46043. */
  46044. static readonly PASTE: number;
  46045. }
  46046. /**
  46047. * This class is used to store clipboard related info for the onClipboardObservable event.
  46048. */
  46049. export class ClipboardInfo {
  46050. /**
  46051. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46052. */
  46053. type: number;
  46054. /**
  46055. * Defines the related dom event
  46056. */
  46057. event: ClipboardEvent;
  46058. /**
  46059. *Creates an instance of ClipboardInfo.
  46060. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  46061. * @param event Defines the related dom event
  46062. */
  46063. constructor(
  46064. /**
  46065. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46066. */
  46067. type: number,
  46068. /**
  46069. * Defines the related dom event
  46070. */
  46071. event: ClipboardEvent);
  46072. /**
  46073. * Get the clipboard event's type from the keycode.
  46074. * @param keyCode Defines the keyCode for the current keyboard event.
  46075. * @return {number}
  46076. */
  46077. static GetTypeFromCharacter(keyCode: number): number;
  46078. }
  46079. }
  46080. declare module "babylonjs/Events/index" {
  46081. export * from "babylonjs/Events/keyboardEvents";
  46082. export * from "babylonjs/Events/pointerEvents";
  46083. export * from "babylonjs/Events/clipboardEvents";
  46084. }
  46085. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  46086. import { Scene } from "babylonjs/scene";
  46087. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46088. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  46089. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46090. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46091. /**
  46092. * Google Daydream controller
  46093. */
  46094. export class DaydreamController extends WebVRController {
  46095. /**
  46096. * Base Url for the controller model.
  46097. */
  46098. static MODEL_BASE_URL: string;
  46099. /**
  46100. * File name for the controller model.
  46101. */
  46102. static MODEL_FILENAME: string;
  46103. /**
  46104. * Gamepad Id prefix used to identify Daydream Controller.
  46105. */
  46106. static readonly GAMEPAD_ID_PREFIX: string;
  46107. /**
  46108. * Creates a new DaydreamController from a gamepad
  46109. * @param vrGamepad the gamepad that the controller should be created from
  46110. */
  46111. constructor(vrGamepad: any);
  46112. /**
  46113. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46114. * @param scene scene in which to add meshes
  46115. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46116. */
  46117. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46118. /**
  46119. * Called once for each button that changed state since the last frame
  46120. * @param buttonIdx Which button index changed
  46121. * @param state New state of the button
  46122. * @param changes Which properties on the state changed since last frame
  46123. */
  46124. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46125. }
  46126. }
  46127. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  46128. import { Scene } from "babylonjs/scene";
  46129. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46130. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  46131. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46132. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46133. /**
  46134. * Gear VR Controller
  46135. */
  46136. export class GearVRController extends WebVRController {
  46137. /**
  46138. * Base Url for the controller model.
  46139. */
  46140. static MODEL_BASE_URL: string;
  46141. /**
  46142. * File name for the controller model.
  46143. */
  46144. static MODEL_FILENAME: string;
  46145. /**
  46146. * Gamepad Id prefix used to identify this controller.
  46147. */
  46148. static readonly GAMEPAD_ID_PREFIX: string;
  46149. private readonly _buttonIndexToObservableNameMap;
  46150. /**
  46151. * Creates a new GearVRController from a gamepad
  46152. * @param vrGamepad the gamepad that the controller should be created from
  46153. */
  46154. constructor(vrGamepad: any);
  46155. /**
  46156. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46157. * @param scene scene in which to add meshes
  46158. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46159. */
  46160. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46161. /**
  46162. * Called once for each button that changed state since the last frame
  46163. * @param buttonIdx Which button index changed
  46164. * @param state New state of the button
  46165. * @param changes Which properties on the state changed since last frame
  46166. */
  46167. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46168. }
  46169. }
  46170. declare module "babylonjs/Gamepads/Controllers/index" {
  46171. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  46172. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  46173. export * from "babylonjs/Gamepads/Controllers/genericController";
  46174. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  46175. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46176. export * from "babylonjs/Gamepads/Controllers/viveController";
  46177. export * from "babylonjs/Gamepads/Controllers/webVRController";
  46178. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  46179. }
  46180. declare module "babylonjs/Gamepads/index" {
  46181. export * from "babylonjs/Gamepads/Controllers/index";
  46182. export * from "babylonjs/Gamepads/gamepad";
  46183. export * from "babylonjs/Gamepads/gamepadManager";
  46184. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  46185. export * from "babylonjs/Gamepads/xboxGamepad";
  46186. export * from "babylonjs/Gamepads/dualShockGamepad";
  46187. }
  46188. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  46189. import { Scene } from "babylonjs/scene";
  46190. import { Vector4 } from "babylonjs/Maths/math.vector";
  46191. import { Color4 } from "babylonjs/Maths/math.color";
  46192. import { Mesh } from "babylonjs/Meshes/mesh";
  46193. import { Nullable } from "babylonjs/types";
  46194. /**
  46195. * Class containing static functions to help procedurally build meshes
  46196. */
  46197. export class PolyhedronBuilder {
  46198. /**
  46199. * Creates a polyhedron mesh
  46200. * * The parameter `type` (positive integer, max 14, default 0) sets the polyhedron type to build among the 15 embbeded types. Please refer to the type sheet in the tutorial to choose the wanted type
  46201. * * The parameter `size` (positive float, default 1) sets the polygon size
  46202. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  46203. * * You can build other polyhedron types than the 15 embbeded ones by setting the parameter `custom` (`polyhedronObject`, default null). If you set the parameter `custom`, this overwrittes the parameter `type`
  46204. * * A `polyhedronObject` is a formatted javascript object. You'll find a full file with pre-set polyhedra here : https://github.com/BabylonJS/Extensions/tree/master/Polyhedron
  46205. * * You can set the color and the UV of each side of the polyhedron with the parameters `faceColors` (Color4, default `(1, 1, 1, 1)`) and faceUV (Vector4, default `(0, 0, 1, 1)`)
  46206. * * To understand how to set `faceUV` or `faceColors`, please read this by considering the right number of faces of your polyhedron, instead of only 6 for the box : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  46207. * * The parameter `flat` (boolean, default true). If set to false, it gives the polyhedron a single global face, so less vertices and shared normals. In this case, `faceColors` and `faceUV` are ignored
  46208. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46209. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  46210. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46211. * @param name defines the name of the mesh
  46212. * @param options defines the options used to create the mesh
  46213. * @param scene defines the hosting scene
  46214. * @returns the polyhedron mesh
  46215. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  46216. */
  46217. static CreatePolyhedron(name: string, options: {
  46218. type?: number;
  46219. size?: number;
  46220. sizeX?: number;
  46221. sizeY?: number;
  46222. sizeZ?: number;
  46223. custom?: any;
  46224. faceUV?: Vector4[];
  46225. faceColors?: Color4[];
  46226. flat?: boolean;
  46227. updatable?: boolean;
  46228. sideOrientation?: number;
  46229. frontUVs?: Vector4;
  46230. backUVs?: Vector4;
  46231. }, scene?: Nullable<Scene>): Mesh;
  46232. }
  46233. }
  46234. declare module "babylonjs/Gizmos/scaleGizmo" {
  46235. import { Observable } from "babylonjs/Misc/observable";
  46236. import { Nullable } from "babylonjs/types";
  46237. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46238. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46239. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  46240. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46241. /**
  46242. * Gizmo that enables scaling a mesh along 3 axis
  46243. */
  46244. export class ScaleGizmo extends Gizmo {
  46245. /**
  46246. * Internal gizmo used for interactions on the x axis
  46247. */
  46248. xGizmo: AxisScaleGizmo;
  46249. /**
  46250. * Internal gizmo used for interactions on the y axis
  46251. */
  46252. yGizmo: AxisScaleGizmo;
  46253. /**
  46254. * Internal gizmo used for interactions on the z axis
  46255. */
  46256. zGizmo: AxisScaleGizmo;
  46257. /**
  46258. * Internal gizmo used to scale all axis equally
  46259. */
  46260. uniformScaleGizmo: AxisScaleGizmo;
  46261. private _meshAttached;
  46262. private _updateGizmoRotationToMatchAttachedMesh;
  46263. private _snapDistance;
  46264. private _scaleRatio;
  46265. private _uniformScalingMesh;
  46266. private _octahedron;
  46267. /** Fires an event when any of it's sub gizmos are dragged */
  46268. onDragStartObservable: Observable<unknown>;
  46269. /** Fires an event when any of it's sub gizmos are released from dragging */
  46270. onDragEndObservable: Observable<unknown>;
  46271. attachedMesh: Nullable<AbstractMesh>;
  46272. /**
  46273. * Creates a ScaleGizmo
  46274. * @param gizmoLayer The utility layer the gizmo will be added to
  46275. */
  46276. constructor(gizmoLayer?: UtilityLayerRenderer);
  46277. updateGizmoRotationToMatchAttachedMesh: boolean;
  46278. /**
  46279. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46280. */
  46281. snapDistance: number;
  46282. /**
  46283. * Ratio for the scale of the gizmo (Default: 1)
  46284. */
  46285. scaleRatio: number;
  46286. /**
  46287. * Disposes of the gizmo
  46288. */
  46289. dispose(): void;
  46290. }
  46291. }
  46292. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  46293. import { Observable } from "babylonjs/Misc/observable";
  46294. import { Nullable } from "babylonjs/types";
  46295. import { Vector3 } from "babylonjs/Maths/math.vector";
  46296. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46297. import { Mesh } from "babylonjs/Meshes/mesh";
  46298. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  46299. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46300. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46301. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  46302. import { Color3 } from "babylonjs/Maths/math.color";
  46303. /**
  46304. * Single axis scale gizmo
  46305. */
  46306. export class AxisScaleGizmo extends Gizmo {
  46307. /**
  46308. * Drag behavior responsible for the gizmos dragging interactions
  46309. */
  46310. dragBehavior: PointerDragBehavior;
  46311. private _pointerObserver;
  46312. /**
  46313. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46314. */
  46315. snapDistance: number;
  46316. /**
  46317. * Event that fires each time the gizmo snaps to a new location.
  46318. * * snapDistance is the the change in distance
  46319. */
  46320. onSnapObservable: Observable<{
  46321. snapDistance: number;
  46322. }>;
  46323. /**
  46324. * If the scaling operation should be done on all axis (default: false)
  46325. */
  46326. uniformScaling: boolean;
  46327. private _isEnabled;
  46328. private _parent;
  46329. private _arrow;
  46330. private _coloredMaterial;
  46331. private _hoverMaterial;
  46332. /**
  46333. * Creates an AxisScaleGizmo
  46334. * @param gizmoLayer The utility layer the gizmo will be added to
  46335. * @param dragAxis The axis which the gizmo will be able to scale on
  46336. * @param color The color of the gizmo
  46337. */
  46338. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  46339. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46340. /**
  46341. * If the gizmo is enabled
  46342. */
  46343. isEnabled: boolean;
  46344. /**
  46345. * Disposes of the gizmo
  46346. */
  46347. dispose(): void;
  46348. /**
  46349. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  46350. * @param mesh The mesh to replace the default mesh of the gizmo
  46351. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  46352. */
  46353. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  46354. }
  46355. }
  46356. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  46357. import { Observable } from "babylonjs/Misc/observable";
  46358. import { Nullable } from "babylonjs/types";
  46359. import { Vector3 } from "babylonjs/Maths/math.vector";
  46360. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46361. import { Mesh } from "babylonjs/Meshes/mesh";
  46362. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46363. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46364. import { Color3 } from "babylonjs/Maths/math.color";
  46365. import "babylonjs/Meshes/Builders/boxBuilder";
  46366. /**
  46367. * Bounding box gizmo
  46368. */
  46369. export class BoundingBoxGizmo extends Gizmo {
  46370. private _lineBoundingBox;
  46371. private _rotateSpheresParent;
  46372. private _scaleBoxesParent;
  46373. private _boundingDimensions;
  46374. private _renderObserver;
  46375. private _pointerObserver;
  46376. private _scaleDragSpeed;
  46377. private _tmpQuaternion;
  46378. private _tmpVector;
  46379. private _tmpRotationMatrix;
  46380. /**
  46381. * If child meshes should be ignored when calculating the boudning box. This should be set to true to avoid perf hits with heavily nested meshes (Default: false)
  46382. */
  46383. ignoreChildren: boolean;
  46384. /**
  46385. * Returns true if a descendant should be included when computing the bounding box. When null, all descendants are included. If ignoreChildren is set this will be ignored. (Default: null)
  46386. */
  46387. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  46388. /**
  46389. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  46390. */
  46391. rotationSphereSize: number;
  46392. /**
  46393. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  46394. */
  46395. scaleBoxSize: number;
  46396. /**
  46397. * If set, the rotation spheres and scale boxes will increase in size based on the distance away from the camera to have a consistent screen size (Default: false)
  46398. */
  46399. fixedDragMeshScreenSize: boolean;
  46400. /**
  46401. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  46402. */
  46403. fixedDragMeshScreenSizeDistanceFactor: number;
  46404. /**
  46405. * Fired when a rotation sphere or scale box is dragged
  46406. */
  46407. onDragStartObservable: Observable<{}>;
  46408. /**
  46409. * Fired when a scale box is dragged
  46410. */
  46411. onScaleBoxDragObservable: Observable<{}>;
  46412. /**
  46413. * Fired when a scale box drag is ended
  46414. */
  46415. onScaleBoxDragEndObservable: Observable<{}>;
  46416. /**
  46417. * Fired when a rotation sphere is dragged
  46418. */
  46419. onRotationSphereDragObservable: Observable<{}>;
  46420. /**
  46421. * Fired when a rotation sphere drag is ended
  46422. */
  46423. onRotationSphereDragEndObservable: Observable<{}>;
  46424. /**
  46425. * Relative bounding box pivot used when scaling the attached mesh. When null object with scale from the opposite corner. 0.5,0.5,0.5 for center and 0.5,0,0.5 for bottom (Default: null)
  46426. */
  46427. scalePivot: Nullable<Vector3>;
  46428. /**
  46429. * Mesh used as a pivot to rotate the attached mesh
  46430. */
  46431. private _anchorMesh;
  46432. private _existingMeshScale;
  46433. private _dragMesh;
  46434. private pointerDragBehavior;
  46435. private coloredMaterial;
  46436. private hoverColoredMaterial;
  46437. /**
  46438. * Sets the color of the bounding box gizmo
  46439. * @param color the color to set
  46440. */
  46441. setColor(color: Color3): void;
  46442. /**
  46443. * Creates an BoundingBoxGizmo
  46444. * @param gizmoLayer The utility layer the gizmo will be added to
  46445. * @param color The color of the gizmo
  46446. */
  46447. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  46448. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46449. private _selectNode;
  46450. /**
  46451. * Updates the bounding box information for the Gizmo
  46452. */
  46453. updateBoundingBox(): void;
  46454. private _updateRotationSpheres;
  46455. private _updateScaleBoxes;
  46456. /**
  46457. * Enables rotation on the specified axis and disables rotation on the others
  46458. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  46459. */
  46460. setEnabledRotationAxis(axis: string): void;
  46461. /**
  46462. * Enables/disables scaling
  46463. * @param enable if scaling should be enabled
  46464. */
  46465. setEnabledScaling(enable: boolean): void;
  46466. private _updateDummy;
  46467. /**
  46468. * Enables a pointer drag behavior on the bounding box of the gizmo
  46469. */
  46470. enableDragBehavior(): void;
  46471. /**
  46472. * Disposes of the gizmo
  46473. */
  46474. dispose(): void;
  46475. /**
  46476. * Makes a mesh not pickable and wraps the mesh inside of a bounding box mesh that is pickable. (This is useful to avoid picking within complex geometry)
  46477. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  46478. * @returns the bounding box mesh with the passed in mesh as a child
  46479. */
  46480. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  46481. /**
  46482. * CustomMeshes are not supported by this gizmo
  46483. * @param mesh The mesh to replace the default mesh of the gizmo
  46484. */
  46485. setCustomMesh(mesh: Mesh): void;
  46486. }
  46487. }
  46488. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  46489. import { Observable } from "babylonjs/Misc/observable";
  46490. import { Nullable } from "babylonjs/types";
  46491. import { Vector3 } from "babylonjs/Maths/math.vector";
  46492. import { Color3 } from "babylonjs/Maths/math.color";
  46493. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46494. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  46495. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46496. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46497. import "babylonjs/Meshes/Builders/linesBuilder";
  46498. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  46499. /**
  46500. * Single plane rotation gizmo
  46501. */
  46502. export class PlaneRotationGizmo extends Gizmo {
  46503. /**
  46504. * Drag behavior responsible for the gizmos dragging interactions
  46505. */
  46506. dragBehavior: PointerDragBehavior;
  46507. private _pointerObserver;
  46508. /**
  46509. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  46510. */
  46511. snapDistance: number;
  46512. /**
  46513. * Event that fires each time the gizmo snaps to a new location.
  46514. * * snapDistance is the the change in distance
  46515. */
  46516. onSnapObservable: Observable<{
  46517. snapDistance: number;
  46518. }>;
  46519. private _isEnabled;
  46520. private _parent;
  46521. /**
  46522. * Creates a PlaneRotationGizmo
  46523. * @param gizmoLayer The utility layer the gizmo will be added to
  46524. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  46525. * @param color The color of the gizmo
  46526. * @param tessellation Amount of tessellation to be used when creating rotation circles
  46527. * @param useEulerRotation Use and update Euler angle instead of quaternion
  46528. */
  46529. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  46530. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46531. /**
  46532. * If the gizmo is enabled
  46533. */
  46534. isEnabled: boolean;
  46535. /**
  46536. * Disposes of the gizmo
  46537. */
  46538. dispose(): void;
  46539. }
  46540. }
  46541. declare module "babylonjs/Gizmos/rotationGizmo" {
  46542. import { Observable } from "babylonjs/Misc/observable";
  46543. import { Nullable } from "babylonjs/types";
  46544. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46545. import { Mesh } from "babylonjs/Meshes/mesh";
  46546. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46547. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  46548. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46549. /**
  46550. * Gizmo that enables rotating a mesh along 3 axis
  46551. */
  46552. export class RotationGizmo extends Gizmo {
  46553. /**
  46554. * Internal gizmo used for interactions on the x axis
  46555. */
  46556. xGizmo: PlaneRotationGizmo;
  46557. /**
  46558. * Internal gizmo used for interactions on the y axis
  46559. */
  46560. yGizmo: PlaneRotationGizmo;
  46561. /**
  46562. * Internal gizmo used for interactions on the z axis
  46563. */
  46564. zGizmo: PlaneRotationGizmo;
  46565. /** Fires an event when any of it's sub gizmos are dragged */
  46566. onDragStartObservable: Observable<unknown>;
  46567. /** Fires an event when any of it's sub gizmos are released from dragging */
  46568. onDragEndObservable: Observable<unknown>;
  46569. private _meshAttached;
  46570. attachedMesh: Nullable<AbstractMesh>;
  46571. /**
  46572. * Creates a RotationGizmo
  46573. * @param gizmoLayer The utility layer the gizmo will be added to
  46574. * @param tessellation Amount of tessellation to be used when creating rotation circles
  46575. * @param useEulerRotation Use and update Euler angle instead of quaternion
  46576. */
  46577. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  46578. updateGizmoRotationToMatchAttachedMesh: boolean;
  46579. /**
  46580. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46581. */
  46582. snapDistance: number;
  46583. /**
  46584. * Ratio for the scale of the gizmo (Default: 1)
  46585. */
  46586. scaleRatio: number;
  46587. /**
  46588. * Disposes of the gizmo
  46589. */
  46590. dispose(): void;
  46591. /**
  46592. * CustomMeshes are not supported by this gizmo
  46593. * @param mesh The mesh to replace the default mesh of the gizmo
  46594. */
  46595. setCustomMesh(mesh: Mesh): void;
  46596. }
  46597. }
  46598. declare module "babylonjs/Gizmos/gizmoManager" {
  46599. import { Observable } from "babylonjs/Misc/observable";
  46600. import { Nullable } from "babylonjs/types";
  46601. import { Scene, IDisposable } from "babylonjs/scene";
  46602. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46603. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46604. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  46605. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  46606. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  46607. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  46608. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  46609. /**
  46610. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  46611. */
  46612. export class GizmoManager implements IDisposable {
  46613. private scene;
  46614. /**
  46615. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  46616. */
  46617. gizmos: {
  46618. positionGizmo: Nullable<PositionGizmo>;
  46619. rotationGizmo: Nullable<RotationGizmo>;
  46620. scaleGizmo: Nullable<ScaleGizmo>;
  46621. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  46622. };
  46623. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  46624. clearGizmoOnEmptyPointerEvent: boolean;
  46625. /** Fires an event when the manager is attached to a mesh */
  46626. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  46627. private _gizmosEnabled;
  46628. private _pointerObserver;
  46629. private _attachedMesh;
  46630. private _boundingBoxColor;
  46631. private _defaultUtilityLayer;
  46632. private _defaultKeepDepthUtilityLayer;
  46633. /**
  46634. * When bounding box gizmo is enabled, this can be used to track drag/end events
  46635. */
  46636. boundingBoxDragBehavior: SixDofDragBehavior;
  46637. /**
  46638. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  46639. */
  46640. attachableMeshes: Nullable<Array<AbstractMesh>>;
  46641. /**
  46642. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  46643. */
  46644. usePointerToAttachGizmos: boolean;
  46645. /**
  46646. * Utility layer that the bounding box gizmo belongs to
  46647. */
  46648. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  46649. /**
  46650. * Utility layer that all gizmos besides bounding box belong to
  46651. */
  46652. readonly utilityLayer: UtilityLayerRenderer;
  46653. /**
  46654. * Instatiates a gizmo manager
  46655. * @param scene the scene to overlay the gizmos on top of
  46656. */
  46657. constructor(scene: Scene);
  46658. /**
  46659. * Attaches a set of gizmos to the specified mesh
  46660. * @param mesh The mesh the gizmo's should be attached to
  46661. */
  46662. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  46663. /**
  46664. * If the position gizmo is enabled
  46665. */
  46666. positionGizmoEnabled: boolean;
  46667. /**
  46668. * If the rotation gizmo is enabled
  46669. */
  46670. rotationGizmoEnabled: boolean;
  46671. /**
  46672. * If the scale gizmo is enabled
  46673. */
  46674. scaleGizmoEnabled: boolean;
  46675. /**
  46676. * If the boundingBox gizmo is enabled
  46677. */
  46678. boundingBoxGizmoEnabled: boolean;
  46679. /**
  46680. * Disposes of the gizmo manager
  46681. */
  46682. dispose(): void;
  46683. }
  46684. }
  46685. declare module "babylonjs/Lights/directionalLight" {
  46686. import { Camera } from "babylonjs/Cameras/camera";
  46687. import { Scene } from "babylonjs/scene";
  46688. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  46689. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46690. import { Light } from "babylonjs/Lights/light";
  46691. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  46692. import { Effect } from "babylonjs/Materials/effect";
  46693. /**
  46694. * A directional light is defined by a direction (what a surprise!).
  46695. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  46696. * An example of a directional light is when a distance planet is lit by the apparently parallel lines of light from its sun. Light in a downward direction will light the top of an object.
  46697. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46698. */
  46699. export class DirectionalLight extends ShadowLight {
  46700. private _shadowFrustumSize;
  46701. /**
  46702. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  46703. */
  46704. /**
  46705. * Specifies a fix frustum size for the shadow generation.
  46706. */
  46707. shadowFrustumSize: number;
  46708. private _shadowOrthoScale;
  46709. /**
  46710. * Gets the shadow projection scale against the optimal computed one.
  46711. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46712. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46713. */
  46714. /**
  46715. * Sets the shadow projection scale against the optimal computed one.
  46716. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46717. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46718. */
  46719. shadowOrthoScale: number;
  46720. /**
  46721. * Automatically compute the projection matrix to best fit (including all the casters)
  46722. * on each frame.
  46723. */
  46724. autoUpdateExtends: boolean;
  46725. private _orthoLeft;
  46726. private _orthoRight;
  46727. private _orthoTop;
  46728. private _orthoBottom;
  46729. /**
  46730. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  46731. * The directional light is emitted from everywhere in the given direction.
  46732. * It can cast shadows.
  46733. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46734. * @param name The friendly name of the light
  46735. * @param direction The direction of the light
  46736. * @param scene The scene the light belongs to
  46737. */
  46738. constructor(name: string, direction: Vector3, scene: Scene);
  46739. /**
  46740. * Returns the string "DirectionalLight".
  46741. * @return The class name
  46742. */
  46743. getClassName(): string;
  46744. /**
  46745. * Returns the integer 1.
  46746. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46747. */
  46748. getTypeID(): number;
  46749. /**
  46750. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  46751. * Returns the DirectionalLight Shadow projection matrix.
  46752. */
  46753. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46754. /**
  46755. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  46756. * Returns the DirectionalLight Shadow projection matrix.
  46757. */
  46758. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  46759. /**
  46760. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  46761. * Returns the DirectionalLight Shadow projection matrix.
  46762. */
  46763. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46764. protected _buildUniformLayout(): void;
  46765. /**
  46766. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  46767. * @param effect The effect to update
  46768. * @param lightIndex The index of the light in the effect to update
  46769. * @returns The directional light
  46770. */
  46771. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  46772. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  46773. /**
  46774. * Gets the minZ used for shadow according to both the scene and the light.
  46775. *
  46776. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46777. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46778. * @param activeCamera The camera we are returning the min for
  46779. * @returns the depth min z
  46780. */
  46781. getDepthMinZ(activeCamera: Camera): number;
  46782. /**
  46783. * Gets the maxZ used for shadow according to both the scene and the light.
  46784. *
  46785. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46786. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46787. * @param activeCamera The camera we are returning the max for
  46788. * @returns the depth max z
  46789. */
  46790. getDepthMaxZ(activeCamera: Camera): number;
  46791. /**
  46792. * Prepares the list of defines specific to the light type.
  46793. * @param defines the list of defines
  46794. * @param lightIndex defines the index of the light for the effect
  46795. */
  46796. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46797. }
  46798. }
  46799. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  46800. import { Mesh } from "babylonjs/Meshes/mesh";
  46801. /**
  46802. * Class containing static functions to help procedurally build meshes
  46803. */
  46804. export class HemisphereBuilder {
  46805. /**
  46806. * Creates a hemisphere mesh
  46807. * @param name defines the name of the mesh
  46808. * @param options defines the options used to create the mesh
  46809. * @param scene defines the hosting scene
  46810. * @returns the hemisphere mesh
  46811. */
  46812. static CreateHemisphere(name: string, options: {
  46813. segments?: number;
  46814. diameter?: number;
  46815. sideOrientation?: number;
  46816. }, scene: any): Mesh;
  46817. }
  46818. }
  46819. declare module "babylonjs/Lights/spotLight" {
  46820. import { Nullable } from "babylonjs/types";
  46821. import { Scene } from "babylonjs/scene";
  46822. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  46823. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46824. import { Effect } from "babylonjs/Materials/effect";
  46825. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46826. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  46827. /**
  46828. * A spot light is defined by a position, a direction, an angle, and an exponent.
  46829. * These values define a cone of light starting from the position, emitting toward the direction.
  46830. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  46831. * and the exponent defines the speed of the decay of the light with distance (reach).
  46832. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46833. */
  46834. export class SpotLight extends ShadowLight {
  46835. private _angle;
  46836. private _innerAngle;
  46837. private _cosHalfAngle;
  46838. private _lightAngleScale;
  46839. private _lightAngleOffset;
  46840. /**
  46841. * Gets the cone angle of the spot light in Radians.
  46842. */
  46843. /**
  46844. * Sets the cone angle of the spot light in Radians.
  46845. */
  46846. angle: number;
  46847. /**
  46848. * Only used in gltf falloff mode, this defines the angle where
  46849. * the directional falloff will start before cutting at angle which could be seen
  46850. * as outer angle.
  46851. */
  46852. /**
  46853. * Only used in gltf falloff mode, this defines the angle where
  46854. * the directional falloff will start before cutting at angle which could be seen
  46855. * as outer angle.
  46856. */
  46857. innerAngle: number;
  46858. private _shadowAngleScale;
  46859. /**
  46860. * Allows scaling the angle of the light for shadow generation only.
  46861. */
  46862. /**
  46863. * Allows scaling the angle of the light for shadow generation only.
  46864. */
  46865. shadowAngleScale: number;
  46866. /**
  46867. * The light decay speed with the distance from the emission spot.
  46868. */
  46869. exponent: number;
  46870. private _projectionTextureMatrix;
  46871. /**
  46872. * Allows reading the projecton texture
  46873. */
  46874. readonly projectionTextureMatrix: Matrix;
  46875. protected _projectionTextureLightNear: number;
  46876. /**
  46877. * Gets the near clip of the Spotlight for texture projection.
  46878. */
  46879. /**
  46880. * Sets the near clip of the Spotlight for texture projection.
  46881. */
  46882. projectionTextureLightNear: number;
  46883. protected _projectionTextureLightFar: number;
  46884. /**
  46885. * Gets the far clip of the Spotlight for texture projection.
  46886. */
  46887. /**
  46888. * Sets the far clip of the Spotlight for texture projection.
  46889. */
  46890. projectionTextureLightFar: number;
  46891. protected _projectionTextureUpDirection: Vector3;
  46892. /**
  46893. * Gets the Up vector of the Spotlight for texture projection.
  46894. */
  46895. /**
  46896. * Sets the Up vector of the Spotlight for texture projection.
  46897. */
  46898. projectionTextureUpDirection: Vector3;
  46899. private _projectionTexture;
  46900. /**
  46901. * Gets the projection texture of the light.
  46902. */
  46903. /**
  46904. * Sets the projection texture of the light.
  46905. */
  46906. projectionTexture: Nullable<BaseTexture>;
  46907. private _projectionTextureViewLightDirty;
  46908. private _projectionTextureProjectionLightDirty;
  46909. private _projectionTextureDirty;
  46910. private _projectionTextureViewTargetVector;
  46911. private _projectionTextureViewLightMatrix;
  46912. private _projectionTextureProjectionLightMatrix;
  46913. private _projectionTextureScalingMatrix;
  46914. /**
  46915. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  46916. * It can cast shadows.
  46917. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46918. * @param name The light friendly name
  46919. * @param position The position of the spot light in the scene
  46920. * @param direction The direction of the light in the scene
  46921. * @param angle The cone angle of the light in Radians
  46922. * @param exponent The light decay speed with the distance from the emission spot
  46923. * @param scene The scene the lights belongs to
  46924. */
  46925. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  46926. /**
  46927. * Returns the string "SpotLight".
  46928. * @returns the class name
  46929. */
  46930. getClassName(): string;
  46931. /**
  46932. * Returns the integer 2.
  46933. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46934. */
  46935. getTypeID(): number;
  46936. /**
  46937. * Overrides the direction setter to recompute the projection texture view light Matrix.
  46938. */
  46939. protected _setDirection(value: Vector3): void;
  46940. /**
  46941. * Overrides the position setter to recompute the projection texture view light Matrix.
  46942. */
  46943. protected _setPosition(value: Vector3): void;
  46944. /**
  46945. * Sets the passed matrix "matrix" as perspective projection matrix for the shadows and the passed view matrix with the fov equal to the SpotLight angle and and aspect ratio of 1.0.
  46946. * Returns the SpotLight.
  46947. */
  46948. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46949. protected _computeProjectionTextureViewLightMatrix(): void;
  46950. protected _computeProjectionTextureProjectionLightMatrix(): void;
  46951. /**
  46952. * Main function for light texture projection matrix computing.
  46953. */
  46954. protected _computeProjectionTextureMatrix(): void;
  46955. protected _buildUniformLayout(): void;
  46956. private _computeAngleValues;
  46957. /**
  46958. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  46959. * @param effect The effect to update
  46960. * @param lightIndex The index of the light in the effect to update
  46961. * @returns The spot light
  46962. */
  46963. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  46964. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  46965. /**
  46966. * Disposes the light and the associated resources.
  46967. */
  46968. dispose(): void;
  46969. /**
  46970. * Prepares the list of defines specific to the light type.
  46971. * @param defines the list of defines
  46972. * @param lightIndex defines the index of the light for the effect
  46973. */
  46974. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46975. }
  46976. }
  46977. declare module "babylonjs/Gizmos/lightGizmo" {
  46978. import { Nullable } from "babylonjs/types";
  46979. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46980. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46981. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  46982. import { Light } from "babylonjs/Lights/light";
  46983. /**
  46984. * Gizmo that enables viewing a light
  46985. */
  46986. export class LightGizmo extends Gizmo {
  46987. private _lightMesh;
  46988. private _material;
  46989. private cachedPosition;
  46990. private cachedForward;
  46991. /**
  46992. * Creates a LightGizmo
  46993. * @param gizmoLayer The utility layer the gizmo will be added to
  46994. */
  46995. constructor(gizmoLayer?: UtilityLayerRenderer);
  46996. private _light;
  46997. /**
  46998. * The light that the gizmo is attached to
  46999. */
  47000. light: Nullable<Light>;
  47001. /**
  47002. * Gets the material used to render the light gizmo
  47003. */
  47004. readonly material: StandardMaterial;
  47005. /**
  47006. * @hidden
  47007. * Updates the gizmo to match the attached mesh's position/rotation
  47008. */
  47009. protected _update(): void;
  47010. private static _Scale;
  47011. /**
  47012. * Creates the lines for a light mesh
  47013. */
  47014. private static _createLightLines;
  47015. /**
  47016. * Disposes of the light gizmo
  47017. */
  47018. dispose(): void;
  47019. private static _CreateHemisphericLightMesh;
  47020. private static _CreatePointLightMesh;
  47021. private static _CreateSpotLightMesh;
  47022. private static _CreateDirectionalLightMesh;
  47023. }
  47024. }
  47025. declare module "babylonjs/Gizmos/index" {
  47026. export * from "babylonjs/Gizmos/axisDragGizmo";
  47027. export * from "babylonjs/Gizmos/axisScaleGizmo";
  47028. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  47029. export * from "babylonjs/Gizmos/gizmo";
  47030. export * from "babylonjs/Gizmos/gizmoManager";
  47031. export * from "babylonjs/Gizmos/planeRotationGizmo";
  47032. export * from "babylonjs/Gizmos/positionGizmo";
  47033. export * from "babylonjs/Gizmos/rotationGizmo";
  47034. export * from "babylonjs/Gizmos/scaleGizmo";
  47035. export * from "babylonjs/Gizmos/lightGizmo";
  47036. export * from "babylonjs/Gizmos/planeDragGizmo";
  47037. }
  47038. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  47039. /** @hidden */
  47040. export var backgroundFragmentDeclaration: {
  47041. name: string;
  47042. shader: string;
  47043. };
  47044. }
  47045. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  47046. /** @hidden */
  47047. export var backgroundUboDeclaration: {
  47048. name: string;
  47049. shader: string;
  47050. };
  47051. }
  47052. declare module "babylonjs/Shaders/background.fragment" {
  47053. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  47054. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  47055. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  47056. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  47057. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47058. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47059. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47060. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  47061. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  47062. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  47063. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  47064. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  47065. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  47066. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  47067. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  47068. /** @hidden */
  47069. export var backgroundPixelShader: {
  47070. name: string;
  47071. shader: string;
  47072. };
  47073. }
  47074. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  47075. /** @hidden */
  47076. export var backgroundVertexDeclaration: {
  47077. name: string;
  47078. shader: string;
  47079. };
  47080. }
  47081. declare module "babylonjs/Shaders/background.vertex" {
  47082. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  47083. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  47084. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47085. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  47086. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  47087. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  47088. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  47089. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47090. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47091. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  47092. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  47093. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  47094. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  47095. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  47096. /** @hidden */
  47097. export var backgroundVertexShader: {
  47098. name: string;
  47099. shader: string;
  47100. };
  47101. }
  47102. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  47103. import { Nullable, int, float } from "babylonjs/types";
  47104. import { Scene } from "babylonjs/scene";
  47105. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47106. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47107. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47108. import { Mesh } from "babylonjs/Meshes/mesh";
  47109. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  47110. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  47111. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47112. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47113. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  47114. import { Color3 } from "babylonjs/Maths/math.color";
  47115. import "babylonjs/Shaders/background.fragment";
  47116. import "babylonjs/Shaders/background.vertex";
  47117. /**
  47118. * Background material used to create an efficient environement around your scene.
  47119. */
  47120. export class BackgroundMaterial extends PushMaterial {
  47121. /**
  47122. * Standard reflectance value at parallel view angle.
  47123. */
  47124. static StandardReflectance0: number;
  47125. /**
  47126. * Standard reflectance value at grazing angle.
  47127. */
  47128. static StandardReflectance90: number;
  47129. protected _primaryColor: Color3;
  47130. /**
  47131. * Key light Color (multiply against the environement texture)
  47132. */
  47133. primaryColor: Color3;
  47134. protected __perceptualColor: Nullable<Color3>;
  47135. /**
  47136. * Experimental Internal Use Only.
  47137. *
  47138. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  47139. * This acts as a helper to set the primary color to a more "human friendly" value.
  47140. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  47141. * output color as close as possible from the chosen value.
  47142. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  47143. * part of lighting setup.)
  47144. */
  47145. _perceptualColor: Nullable<Color3>;
  47146. protected _primaryColorShadowLevel: float;
  47147. /**
  47148. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  47149. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  47150. */
  47151. primaryColorShadowLevel: float;
  47152. protected _primaryColorHighlightLevel: float;
  47153. /**
  47154. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  47155. * The primary color is used at the level chosen to define what the white area would look.
  47156. */
  47157. primaryColorHighlightLevel: float;
  47158. protected _reflectionTexture: Nullable<BaseTexture>;
  47159. /**
  47160. * Reflection Texture used in the material.
  47161. * Should be author in a specific way for the best result (refer to the documentation).
  47162. */
  47163. reflectionTexture: Nullable<BaseTexture>;
  47164. protected _reflectionBlur: float;
  47165. /**
  47166. * Reflection Texture level of blur.
  47167. *
  47168. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  47169. * texture twice.
  47170. */
  47171. reflectionBlur: float;
  47172. protected _diffuseTexture: Nullable<BaseTexture>;
  47173. /**
  47174. * Diffuse Texture used in the material.
  47175. * Should be author in a specific way for the best result (refer to the documentation).
  47176. */
  47177. diffuseTexture: Nullable<BaseTexture>;
  47178. protected _shadowLights: Nullable<IShadowLight[]>;
  47179. /**
  47180. * Specify the list of lights casting shadow on the material.
  47181. * All scene shadow lights will be included if null.
  47182. */
  47183. shadowLights: Nullable<IShadowLight[]>;
  47184. protected _shadowLevel: float;
  47185. /**
  47186. * Helps adjusting the shadow to a softer level if required.
  47187. * 0 means black shadows and 1 means no shadows.
  47188. */
  47189. shadowLevel: float;
  47190. protected _sceneCenter: Vector3;
  47191. /**
  47192. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  47193. * It is usually zero but might be interesting to modify according to your setup.
  47194. */
  47195. sceneCenter: Vector3;
  47196. protected _opacityFresnel: boolean;
  47197. /**
  47198. * This helps specifying that the material is falling off to the sky box at grazing angle.
  47199. * This helps ensuring a nice transition when the camera goes under the ground.
  47200. */
  47201. opacityFresnel: boolean;
  47202. protected _reflectionFresnel: boolean;
  47203. /**
  47204. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  47205. * This helps adding a mirror texture on the ground.
  47206. */
  47207. reflectionFresnel: boolean;
  47208. protected _reflectionFalloffDistance: number;
  47209. /**
  47210. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  47211. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  47212. */
  47213. reflectionFalloffDistance: number;
  47214. protected _reflectionAmount: number;
  47215. /**
  47216. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  47217. */
  47218. reflectionAmount: number;
  47219. protected _reflectionReflectance0: number;
  47220. /**
  47221. * This specifies the weight of the reflection at grazing angle.
  47222. */
  47223. reflectionReflectance0: number;
  47224. protected _reflectionReflectance90: number;
  47225. /**
  47226. * This specifies the weight of the reflection at a perpendicular point of view.
  47227. */
  47228. reflectionReflectance90: number;
  47229. /**
  47230. * Sets the reflection reflectance fresnel values according to the default standard
  47231. * empirically know to work well :-)
  47232. */
  47233. reflectionStandardFresnelWeight: number;
  47234. protected _useRGBColor: boolean;
  47235. /**
  47236. * Helps to directly use the maps channels instead of their level.
  47237. */
  47238. useRGBColor: boolean;
  47239. protected _enableNoise: boolean;
  47240. /**
  47241. * This helps reducing the banding effect that could occur on the background.
  47242. */
  47243. enableNoise: boolean;
  47244. /**
  47245. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47246. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  47247. * Recommended to be keep at 1.0 except for special cases.
  47248. */
  47249. fovMultiplier: number;
  47250. private _fovMultiplier;
  47251. /**
  47252. * Enable the FOV adjustment feature controlled by fovMultiplier.
  47253. */
  47254. useEquirectangularFOV: boolean;
  47255. private _maxSimultaneousLights;
  47256. /**
  47257. * Number of Simultaneous lights allowed on the material.
  47258. */
  47259. maxSimultaneousLights: int;
  47260. /**
  47261. * Default configuration related to image processing available in the Background Material.
  47262. */
  47263. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47264. /**
  47265. * Keep track of the image processing observer to allow dispose and replace.
  47266. */
  47267. private _imageProcessingObserver;
  47268. /**
  47269. * Attaches a new image processing configuration to the PBR Material.
  47270. * @param configuration (if null the scene configuration will be use)
  47271. */
  47272. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47273. /**
  47274. * Gets the image processing configuration used either in this material.
  47275. */
  47276. /**
  47277. * Sets the Default image processing configuration used either in the this material.
  47278. *
  47279. * If sets to null, the scene one is in use.
  47280. */
  47281. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  47282. /**
  47283. * Gets wether the color curves effect is enabled.
  47284. */
  47285. /**
  47286. * Sets wether the color curves effect is enabled.
  47287. */
  47288. cameraColorCurvesEnabled: boolean;
  47289. /**
  47290. * Gets wether the color grading effect is enabled.
  47291. */
  47292. /**
  47293. * Gets wether the color grading effect is enabled.
  47294. */
  47295. cameraColorGradingEnabled: boolean;
  47296. /**
  47297. * Gets wether tonemapping is enabled or not.
  47298. */
  47299. /**
  47300. * Sets wether tonemapping is enabled or not
  47301. */
  47302. cameraToneMappingEnabled: boolean;
  47303. /**
  47304. * The camera exposure used on this material.
  47305. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47306. * This corresponds to a photographic exposure.
  47307. */
  47308. /**
  47309. * The camera exposure used on this material.
  47310. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47311. * This corresponds to a photographic exposure.
  47312. */
  47313. cameraExposure: float;
  47314. /**
  47315. * Gets The camera contrast used on this material.
  47316. */
  47317. /**
  47318. * Sets The camera contrast used on this material.
  47319. */
  47320. cameraContrast: float;
  47321. /**
  47322. * Gets the Color Grading 2D Lookup Texture.
  47323. */
  47324. /**
  47325. * Sets the Color Grading 2D Lookup Texture.
  47326. */
  47327. cameraColorGradingTexture: Nullable<BaseTexture>;
  47328. /**
  47329. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47330. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47331. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  47332. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47333. */
  47334. /**
  47335. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47336. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47337. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  47338. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47339. */
  47340. cameraColorCurves: Nullable<ColorCurves>;
  47341. /**
  47342. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  47343. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  47344. */
  47345. switchToBGR: boolean;
  47346. private _renderTargets;
  47347. private _reflectionControls;
  47348. private _white;
  47349. private _primaryShadowColor;
  47350. private _primaryHighlightColor;
  47351. /**
  47352. * Instantiates a Background Material in the given scene
  47353. * @param name The friendly name of the material
  47354. * @param scene The scene to add the material to
  47355. */
  47356. constructor(name: string, scene: Scene);
  47357. /**
  47358. * Gets a boolean indicating that current material needs to register RTT
  47359. */
  47360. readonly hasRenderTargetTextures: boolean;
  47361. /**
  47362. * The entire material has been created in order to prevent overdraw.
  47363. * @returns false
  47364. */
  47365. needAlphaTesting(): boolean;
  47366. /**
  47367. * The entire material has been created in order to prevent overdraw.
  47368. * @returns true if blending is enable
  47369. */
  47370. needAlphaBlending(): boolean;
  47371. /**
  47372. * Checks wether the material is ready to be rendered for a given mesh.
  47373. * @param mesh The mesh to render
  47374. * @param subMesh The submesh to check against
  47375. * @param useInstances Specify wether or not the material is used with instances
  47376. * @returns true if all the dependencies are ready (Textures, Effects...)
  47377. */
  47378. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47379. /**
  47380. * Compute the primary color according to the chosen perceptual color.
  47381. */
  47382. private _computePrimaryColorFromPerceptualColor;
  47383. /**
  47384. * Compute the highlights and shadow colors according to their chosen levels.
  47385. */
  47386. private _computePrimaryColors;
  47387. /**
  47388. * Build the uniform buffer used in the material.
  47389. */
  47390. buildUniformLayout(): void;
  47391. /**
  47392. * Unbind the material.
  47393. */
  47394. unbind(): void;
  47395. /**
  47396. * Bind only the world matrix to the material.
  47397. * @param world The world matrix to bind.
  47398. */
  47399. bindOnlyWorldMatrix(world: Matrix): void;
  47400. /**
  47401. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  47402. * @param world The world matrix to bind.
  47403. * @param subMesh The submesh to bind for.
  47404. */
  47405. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  47406. /**
  47407. * Checks to see if a texture is used in the material.
  47408. * @param texture - Base texture to use.
  47409. * @returns - Boolean specifying if a texture is used in the material.
  47410. */
  47411. hasTexture(texture: BaseTexture): boolean;
  47412. /**
  47413. * Dispose the material.
  47414. * @param forceDisposeEffect Force disposal of the associated effect.
  47415. * @param forceDisposeTextures Force disposal of the associated textures.
  47416. */
  47417. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  47418. /**
  47419. * Clones the material.
  47420. * @param name The cloned name.
  47421. * @returns The cloned material.
  47422. */
  47423. clone(name: string): BackgroundMaterial;
  47424. /**
  47425. * Serializes the current material to its JSON representation.
  47426. * @returns The JSON representation.
  47427. */
  47428. serialize(): any;
  47429. /**
  47430. * Gets the class name of the material
  47431. * @returns "BackgroundMaterial"
  47432. */
  47433. getClassName(): string;
  47434. /**
  47435. * Parse a JSON input to create back a background material.
  47436. * @param source The JSON data to parse
  47437. * @param scene The scene to create the parsed material in
  47438. * @param rootUrl The root url of the assets the material depends upon
  47439. * @returns the instantiated BackgroundMaterial.
  47440. */
  47441. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  47442. }
  47443. }
  47444. declare module "babylonjs/Helpers/environmentHelper" {
  47445. import { Observable } from "babylonjs/Misc/observable";
  47446. import { Nullable } from "babylonjs/types";
  47447. import { Scene } from "babylonjs/scene";
  47448. import { Vector3 } from "babylonjs/Maths/math.vector";
  47449. import { Color3 } from "babylonjs/Maths/math.color";
  47450. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47451. import { Mesh } from "babylonjs/Meshes/mesh";
  47452. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47453. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  47454. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  47455. import "babylonjs/Meshes/Builders/planeBuilder";
  47456. import "babylonjs/Meshes/Builders/boxBuilder";
  47457. /**
  47458. * Represents the different options available during the creation of
  47459. * a Environment helper.
  47460. *
  47461. * This can control the default ground, skybox and image processing setup of your scene.
  47462. */
  47463. export interface IEnvironmentHelperOptions {
  47464. /**
  47465. * Specifies wether or not to create a ground.
  47466. * True by default.
  47467. */
  47468. createGround: boolean;
  47469. /**
  47470. * Specifies the ground size.
  47471. * 15 by default.
  47472. */
  47473. groundSize: number;
  47474. /**
  47475. * The texture used on the ground for the main color.
  47476. * Comes from the BabylonJS CDN by default.
  47477. *
  47478. * Remarks: Can be either a texture or a url.
  47479. */
  47480. groundTexture: string | BaseTexture;
  47481. /**
  47482. * The color mixed in the ground texture by default.
  47483. * BabylonJS clearColor by default.
  47484. */
  47485. groundColor: Color3;
  47486. /**
  47487. * Specifies the ground opacity.
  47488. * 1 by default.
  47489. */
  47490. groundOpacity: number;
  47491. /**
  47492. * Enables the ground to receive shadows.
  47493. * True by default.
  47494. */
  47495. enableGroundShadow: boolean;
  47496. /**
  47497. * Helps preventing the shadow to be fully black on the ground.
  47498. * 0.5 by default.
  47499. */
  47500. groundShadowLevel: number;
  47501. /**
  47502. * Creates a mirror texture attach to the ground.
  47503. * false by default.
  47504. */
  47505. enableGroundMirror: boolean;
  47506. /**
  47507. * Specifies the ground mirror size ratio.
  47508. * 0.3 by default as the default kernel is 64.
  47509. */
  47510. groundMirrorSizeRatio: number;
  47511. /**
  47512. * Specifies the ground mirror blur kernel size.
  47513. * 64 by default.
  47514. */
  47515. groundMirrorBlurKernel: number;
  47516. /**
  47517. * Specifies the ground mirror visibility amount.
  47518. * 1 by default
  47519. */
  47520. groundMirrorAmount: number;
  47521. /**
  47522. * Specifies the ground mirror reflectance weight.
  47523. * This uses the standard weight of the background material to setup the fresnel effect
  47524. * of the mirror.
  47525. * 1 by default.
  47526. */
  47527. groundMirrorFresnelWeight: number;
  47528. /**
  47529. * Specifies the ground mirror Falloff distance.
  47530. * This can helps reducing the size of the reflection.
  47531. * 0 by Default.
  47532. */
  47533. groundMirrorFallOffDistance: number;
  47534. /**
  47535. * Specifies the ground mirror texture type.
  47536. * Unsigned Int by Default.
  47537. */
  47538. groundMirrorTextureType: number;
  47539. /**
  47540. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  47541. * the shown objects.
  47542. */
  47543. groundYBias: number;
  47544. /**
  47545. * Specifies wether or not to create a skybox.
  47546. * True by default.
  47547. */
  47548. createSkybox: boolean;
  47549. /**
  47550. * Specifies the skybox size.
  47551. * 20 by default.
  47552. */
  47553. skyboxSize: number;
  47554. /**
  47555. * The texture used on the skybox for the main color.
  47556. * Comes from the BabylonJS CDN by default.
  47557. *
  47558. * Remarks: Can be either a texture or a url.
  47559. */
  47560. skyboxTexture: string | BaseTexture;
  47561. /**
  47562. * The color mixed in the skybox texture by default.
  47563. * BabylonJS clearColor by default.
  47564. */
  47565. skyboxColor: Color3;
  47566. /**
  47567. * The background rotation around the Y axis of the scene.
  47568. * This helps aligning the key lights of your scene with the background.
  47569. * 0 by default.
  47570. */
  47571. backgroundYRotation: number;
  47572. /**
  47573. * Compute automatically the size of the elements to best fit with the scene.
  47574. */
  47575. sizeAuto: boolean;
  47576. /**
  47577. * Default position of the rootMesh if autoSize is not true.
  47578. */
  47579. rootPosition: Vector3;
  47580. /**
  47581. * Sets up the image processing in the scene.
  47582. * true by default.
  47583. */
  47584. setupImageProcessing: boolean;
  47585. /**
  47586. * The texture used as your environment texture in the scene.
  47587. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  47588. *
  47589. * Remarks: Can be either a texture or a url.
  47590. */
  47591. environmentTexture: string | BaseTexture;
  47592. /**
  47593. * The value of the exposure to apply to the scene.
  47594. * 0.6 by default if setupImageProcessing is true.
  47595. */
  47596. cameraExposure: number;
  47597. /**
  47598. * The value of the contrast to apply to the scene.
  47599. * 1.6 by default if setupImageProcessing is true.
  47600. */
  47601. cameraContrast: number;
  47602. /**
  47603. * Specifies wether or not tonemapping should be enabled in the scene.
  47604. * true by default if setupImageProcessing is true.
  47605. */
  47606. toneMappingEnabled: boolean;
  47607. }
  47608. /**
  47609. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  47610. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  47611. * It also helps with the default setup of your imageProcessing configuration.
  47612. */
  47613. export class EnvironmentHelper {
  47614. /**
  47615. * Default ground texture URL.
  47616. */
  47617. private static _groundTextureCDNUrl;
  47618. /**
  47619. * Default skybox texture URL.
  47620. */
  47621. private static _skyboxTextureCDNUrl;
  47622. /**
  47623. * Default environment texture URL.
  47624. */
  47625. private static _environmentTextureCDNUrl;
  47626. /**
  47627. * Creates the default options for the helper.
  47628. */
  47629. private static _getDefaultOptions;
  47630. private _rootMesh;
  47631. /**
  47632. * Gets the root mesh created by the helper.
  47633. */
  47634. readonly rootMesh: Mesh;
  47635. private _skybox;
  47636. /**
  47637. * Gets the skybox created by the helper.
  47638. */
  47639. readonly skybox: Nullable<Mesh>;
  47640. private _skyboxTexture;
  47641. /**
  47642. * Gets the skybox texture created by the helper.
  47643. */
  47644. readonly skyboxTexture: Nullable<BaseTexture>;
  47645. private _skyboxMaterial;
  47646. /**
  47647. * Gets the skybox material created by the helper.
  47648. */
  47649. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  47650. private _ground;
  47651. /**
  47652. * Gets the ground mesh created by the helper.
  47653. */
  47654. readonly ground: Nullable<Mesh>;
  47655. private _groundTexture;
  47656. /**
  47657. * Gets the ground texture created by the helper.
  47658. */
  47659. readonly groundTexture: Nullable<BaseTexture>;
  47660. private _groundMirror;
  47661. /**
  47662. * Gets the ground mirror created by the helper.
  47663. */
  47664. readonly groundMirror: Nullable<MirrorTexture>;
  47665. /**
  47666. * Gets the ground mirror render list to helps pushing the meshes
  47667. * you wish in the ground reflection.
  47668. */
  47669. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  47670. private _groundMaterial;
  47671. /**
  47672. * Gets the ground material created by the helper.
  47673. */
  47674. readonly groundMaterial: Nullable<BackgroundMaterial>;
  47675. /**
  47676. * Stores the creation options.
  47677. */
  47678. private readonly _scene;
  47679. private _options;
  47680. /**
  47681. * This observable will be notified with any error during the creation of the environment,
  47682. * mainly texture creation errors.
  47683. */
  47684. onErrorObservable: Observable<{
  47685. message?: string;
  47686. exception?: any;
  47687. }>;
  47688. /**
  47689. * constructor
  47690. * @param options Defines the options we want to customize the helper
  47691. * @param scene The scene to add the material to
  47692. */
  47693. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  47694. /**
  47695. * Updates the background according to the new options
  47696. * @param options
  47697. */
  47698. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  47699. /**
  47700. * Sets the primary color of all the available elements.
  47701. * @param color the main color to affect to the ground and the background
  47702. */
  47703. setMainColor(color: Color3): void;
  47704. /**
  47705. * Setup the image processing according to the specified options.
  47706. */
  47707. private _setupImageProcessing;
  47708. /**
  47709. * Setup the environment texture according to the specified options.
  47710. */
  47711. private _setupEnvironmentTexture;
  47712. /**
  47713. * Setup the background according to the specified options.
  47714. */
  47715. private _setupBackground;
  47716. /**
  47717. * Get the scene sizes according to the setup.
  47718. */
  47719. private _getSceneSize;
  47720. /**
  47721. * Setup the ground according to the specified options.
  47722. */
  47723. private _setupGround;
  47724. /**
  47725. * Setup the ground material according to the specified options.
  47726. */
  47727. private _setupGroundMaterial;
  47728. /**
  47729. * Setup the ground diffuse texture according to the specified options.
  47730. */
  47731. private _setupGroundDiffuseTexture;
  47732. /**
  47733. * Setup the ground mirror texture according to the specified options.
  47734. */
  47735. private _setupGroundMirrorTexture;
  47736. /**
  47737. * Setup the ground to receive the mirror texture.
  47738. */
  47739. private _setupMirrorInGroundMaterial;
  47740. /**
  47741. * Setup the skybox according to the specified options.
  47742. */
  47743. private _setupSkybox;
  47744. /**
  47745. * Setup the skybox material according to the specified options.
  47746. */
  47747. private _setupSkyboxMaterial;
  47748. /**
  47749. * Setup the skybox reflection texture according to the specified options.
  47750. */
  47751. private _setupSkyboxReflectionTexture;
  47752. private _errorHandler;
  47753. /**
  47754. * Dispose all the elements created by the Helper.
  47755. */
  47756. dispose(): void;
  47757. }
  47758. }
  47759. declare module "babylonjs/Helpers/photoDome" {
  47760. import { Observable } from "babylonjs/Misc/observable";
  47761. import { Nullable } from "babylonjs/types";
  47762. import { Scene } from "babylonjs/scene";
  47763. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47764. import { Mesh } from "babylonjs/Meshes/mesh";
  47765. import { Texture } from "babylonjs/Materials/Textures/texture";
  47766. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  47767. import "babylonjs/Meshes/Builders/sphereBuilder";
  47768. /**
  47769. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  47770. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  47771. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  47772. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  47773. */
  47774. export class PhotoDome extends TransformNode {
  47775. /**
  47776. * Define the image as a Monoscopic panoramic 360 image.
  47777. */
  47778. static readonly MODE_MONOSCOPIC: number;
  47779. /**
  47780. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  47781. */
  47782. static readonly MODE_TOPBOTTOM: number;
  47783. /**
  47784. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  47785. */
  47786. static readonly MODE_SIDEBYSIDE: number;
  47787. private _useDirectMapping;
  47788. /**
  47789. * The texture being displayed on the sphere
  47790. */
  47791. protected _photoTexture: Texture;
  47792. /**
  47793. * Gets or sets the texture being displayed on the sphere
  47794. */
  47795. photoTexture: Texture;
  47796. /**
  47797. * Observable raised when an error occured while loading the 360 image
  47798. */
  47799. onLoadErrorObservable: Observable<string>;
  47800. /**
  47801. * The skybox material
  47802. */
  47803. protected _material: BackgroundMaterial;
  47804. /**
  47805. * The surface used for the skybox
  47806. */
  47807. protected _mesh: Mesh;
  47808. /**
  47809. * Gets the mesh used for the skybox.
  47810. */
  47811. readonly mesh: Mesh;
  47812. /**
  47813. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47814. * Also see the options.resolution property.
  47815. */
  47816. fovMultiplier: number;
  47817. private _imageMode;
  47818. /**
  47819. * Gets or set the current video mode for the video. It can be:
  47820. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  47821. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  47822. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  47823. */
  47824. imageMode: number;
  47825. /**
  47826. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  47827. * @param name Element's name, child elements will append suffixes for their own names.
  47828. * @param urlsOfPhoto defines the url of the photo to display
  47829. * @param options defines an object containing optional or exposed sub element properties
  47830. * @param onError defines a callback called when an error occured while loading the texture
  47831. */
  47832. constructor(name: string, urlOfPhoto: string, options: {
  47833. resolution?: number;
  47834. size?: number;
  47835. useDirectMapping?: boolean;
  47836. faceForward?: boolean;
  47837. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  47838. private _onBeforeCameraRenderObserver;
  47839. private _changeImageMode;
  47840. /**
  47841. * Releases resources associated with this node.
  47842. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  47843. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  47844. */
  47845. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  47846. }
  47847. }
  47848. declare module "babylonjs/Misc/rgbdTextureTools" {
  47849. import "babylonjs/Shaders/rgbdDecode.fragment";
  47850. import { Texture } from "babylonjs/Materials/Textures/texture";
  47851. /**
  47852. * Class used to host RGBD texture specific utilities
  47853. */
  47854. export class RGBDTextureTools {
  47855. /**
  47856. * Expand the RGBD Texture from RGBD to Half Float if possible.
  47857. * @param texture the texture to expand.
  47858. */
  47859. static ExpandRGBDTexture(texture: Texture): void;
  47860. }
  47861. }
  47862. declare module "babylonjs/Misc/brdfTextureTools" {
  47863. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47864. import { Scene } from "babylonjs/scene";
  47865. /**
  47866. * Class used to host texture specific utilities
  47867. */
  47868. export class BRDFTextureTools {
  47869. /**
  47870. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  47871. * @param scene defines the hosting scene
  47872. * @returns the environment BRDF texture
  47873. */
  47874. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  47875. private static _environmentBRDFBase64Texture;
  47876. }
  47877. }
  47878. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  47879. import { Nullable } from "babylonjs/types";
  47880. import { Color3 } from "babylonjs/Maths/math.color";
  47881. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47882. import { EffectFallbacks } from "babylonjs/Materials/effect";
  47883. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47884. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47885. import { Engine } from "babylonjs/Engines/engine";
  47886. import { Scene } from "babylonjs/scene";
  47887. /**
  47888. * @hidden
  47889. */
  47890. export interface IMaterialClearCoatDefines {
  47891. CLEARCOAT: boolean;
  47892. CLEARCOAT_DEFAULTIOR: boolean;
  47893. CLEARCOAT_TEXTURE: boolean;
  47894. CLEARCOAT_TEXTUREDIRECTUV: number;
  47895. CLEARCOAT_BUMP: boolean;
  47896. CLEARCOAT_BUMPDIRECTUV: number;
  47897. CLEARCOAT_TINT: boolean;
  47898. CLEARCOAT_TINT_TEXTURE: boolean;
  47899. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  47900. /** @hidden */
  47901. _areTexturesDirty: boolean;
  47902. }
  47903. /**
  47904. * Define the code related to the clear coat parameters of the pbr material.
  47905. */
  47906. export class PBRClearCoatConfiguration {
  47907. /**
  47908. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  47909. * The default fits with a polyurethane material.
  47910. */
  47911. private static readonly _DefaultIndexOfRefraction;
  47912. private _isEnabled;
  47913. /**
  47914. * Defines if the clear coat is enabled in the material.
  47915. */
  47916. isEnabled: boolean;
  47917. /**
  47918. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  47919. */
  47920. intensity: number;
  47921. /**
  47922. * Defines the clear coat layer roughness.
  47923. */
  47924. roughness: number;
  47925. private _indexOfRefraction;
  47926. /**
  47927. * Defines the index of refraction of the clear coat.
  47928. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  47929. * The default fits with a polyurethane material.
  47930. * Changing the default value is more performance intensive.
  47931. */
  47932. indexOfRefraction: number;
  47933. private _texture;
  47934. /**
  47935. * Stores the clear coat values in a texture.
  47936. */
  47937. texture: Nullable<BaseTexture>;
  47938. private _bumpTexture;
  47939. /**
  47940. * Define the clear coat specific bump texture.
  47941. */
  47942. bumpTexture: Nullable<BaseTexture>;
  47943. private _isTintEnabled;
  47944. /**
  47945. * Defines if the clear coat tint is enabled in the material.
  47946. */
  47947. isTintEnabled: boolean;
  47948. /**
  47949. * Defines the clear coat tint of the material.
  47950. * This is only use if tint is enabled
  47951. */
  47952. tintColor: Color3;
  47953. /**
  47954. * Defines the distance at which the tint color should be found in the
  47955. * clear coat media.
  47956. * This is only use if tint is enabled
  47957. */
  47958. tintColorAtDistance: number;
  47959. /**
  47960. * Defines the clear coat layer thickness.
  47961. * This is only use if tint is enabled
  47962. */
  47963. tintThickness: number;
  47964. private _tintTexture;
  47965. /**
  47966. * Stores the clear tint values in a texture.
  47967. * rgb is tint
  47968. * a is a thickness factor
  47969. */
  47970. tintTexture: Nullable<BaseTexture>;
  47971. /** @hidden */
  47972. private _internalMarkAllSubMeshesAsTexturesDirty;
  47973. /** @hidden */
  47974. _markAllSubMeshesAsTexturesDirty(): void;
  47975. /**
  47976. * Instantiate a new istance of clear coat configuration.
  47977. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47978. */
  47979. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47980. /**
  47981. * Gets wehter the submesh is ready to be used or not.
  47982. * @param defines the list of "defines" to update.
  47983. * @param scene defines the scene the material belongs to.
  47984. * @param engine defines the engine the material belongs to.
  47985. * @param disableBumpMap defines wether the material disables bump or not.
  47986. * @returns - boolean indicating that the submesh is ready or not.
  47987. */
  47988. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  47989. /**
  47990. * Checks to see if a texture is used in the material.
  47991. * @param defines the list of "defines" to update.
  47992. * @param scene defines the scene to the material belongs to.
  47993. */
  47994. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  47995. /**
  47996. * Binds the material data.
  47997. * @param uniformBuffer defines the Uniform buffer to fill in.
  47998. * @param scene defines the scene the material belongs to.
  47999. * @param engine defines the engine the material belongs to.
  48000. * @param disableBumpMap defines wether the material disables bump or not.
  48001. * @param isFrozen defines wether the material is frozen or not.
  48002. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  48003. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  48004. */
  48005. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  48006. /**
  48007. * Checks to see if a texture is used in the material.
  48008. * @param texture - Base texture to use.
  48009. * @returns - Boolean specifying if a texture is used in the material.
  48010. */
  48011. hasTexture(texture: BaseTexture): boolean;
  48012. /**
  48013. * Returns an array of the actively used textures.
  48014. * @param activeTextures Array of BaseTextures
  48015. */
  48016. getActiveTextures(activeTextures: BaseTexture[]): void;
  48017. /**
  48018. * Returns the animatable textures.
  48019. * @param animatables Array of animatable textures.
  48020. */
  48021. getAnimatables(animatables: IAnimatable[]): void;
  48022. /**
  48023. * Disposes the resources of the material.
  48024. * @param forceDisposeTextures - Forces the disposal of all textures.
  48025. */
  48026. dispose(forceDisposeTextures?: boolean): void;
  48027. /**
  48028. * Get the current class name of the texture useful for serialization or dynamic coding.
  48029. * @returns "PBRClearCoatConfiguration"
  48030. */
  48031. getClassName(): string;
  48032. /**
  48033. * Add fallbacks to the effect fallbacks list.
  48034. * @param defines defines the Base texture to use.
  48035. * @param fallbacks defines the current fallback list.
  48036. * @param currentRank defines the current fallback rank.
  48037. * @returns the new fallback rank.
  48038. */
  48039. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48040. /**
  48041. * Add the required uniforms to the current list.
  48042. * @param uniforms defines the current uniform list.
  48043. */
  48044. static AddUniforms(uniforms: string[]): void;
  48045. /**
  48046. * Add the required samplers to the current list.
  48047. * @param samplers defines the current sampler list.
  48048. */
  48049. static AddSamplers(samplers: string[]): void;
  48050. /**
  48051. * Add the required uniforms to the current buffer.
  48052. * @param uniformBuffer defines the current uniform buffer.
  48053. */
  48054. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48055. /**
  48056. * Makes a duplicate of the current configuration into another one.
  48057. * @param clearCoatConfiguration define the config where to copy the info
  48058. */
  48059. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  48060. /**
  48061. * Serializes this clear coat configuration.
  48062. * @returns - An object with the serialized config.
  48063. */
  48064. serialize(): any;
  48065. /**
  48066. * Parses a anisotropy Configuration from a serialized object.
  48067. * @param source - Serialized object.
  48068. * @param scene Defines the scene we are parsing for
  48069. * @param rootUrl Defines the rootUrl to load from
  48070. */
  48071. parse(source: any, scene: Scene, rootUrl: string): void;
  48072. }
  48073. }
  48074. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  48075. import { EffectFallbacks } from "babylonjs/Materials/effect";
  48076. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48077. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48078. import { Vector2 } from "babylonjs/Maths/math.vector";
  48079. import { Scene } from "babylonjs/scene";
  48080. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48081. import { Nullable } from "babylonjs/types";
  48082. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48083. /**
  48084. * @hidden
  48085. */
  48086. export interface IMaterialAnisotropicDefines {
  48087. ANISOTROPIC: boolean;
  48088. ANISOTROPIC_TEXTURE: boolean;
  48089. ANISOTROPIC_TEXTUREDIRECTUV: number;
  48090. MAINUV1: boolean;
  48091. _areTexturesDirty: boolean;
  48092. _needUVs: boolean;
  48093. }
  48094. /**
  48095. * Define the code related to the anisotropic parameters of the pbr material.
  48096. */
  48097. export class PBRAnisotropicConfiguration {
  48098. private _isEnabled;
  48099. /**
  48100. * Defines if the anisotropy is enabled in the material.
  48101. */
  48102. isEnabled: boolean;
  48103. /**
  48104. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  48105. */
  48106. intensity: number;
  48107. /**
  48108. * Defines if the effect is along the tangents, bitangents or in between.
  48109. * By default, the effect is "strectching" the highlights along the tangents.
  48110. */
  48111. direction: Vector2;
  48112. private _texture;
  48113. /**
  48114. * Stores the anisotropy values in a texture.
  48115. * rg is direction (like normal from -1 to 1)
  48116. * b is a intensity
  48117. */
  48118. texture: Nullable<BaseTexture>;
  48119. /** @hidden */
  48120. private _internalMarkAllSubMeshesAsTexturesDirty;
  48121. /** @hidden */
  48122. _markAllSubMeshesAsTexturesDirty(): void;
  48123. /**
  48124. * Instantiate a new istance of anisotropy configuration.
  48125. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48126. */
  48127. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48128. /**
  48129. * Specifies that the submesh is ready to be used.
  48130. * @param defines the list of "defines" to update.
  48131. * @param scene defines the scene the material belongs to.
  48132. * @returns - boolean indicating that the submesh is ready or not.
  48133. */
  48134. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  48135. /**
  48136. * Checks to see if a texture is used in the material.
  48137. * @param defines the list of "defines" to update.
  48138. * @param mesh the mesh we are preparing the defines for.
  48139. * @param scene defines the scene the material belongs to.
  48140. */
  48141. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  48142. /**
  48143. * Binds the material data.
  48144. * @param uniformBuffer defines the Uniform buffer to fill in.
  48145. * @param scene defines the scene the material belongs to.
  48146. * @param isFrozen defines wether the material is frozen or not.
  48147. */
  48148. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  48149. /**
  48150. * Checks to see if a texture is used in the material.
  48151. * @param texture - Base texture to use.
  48152. * @returns - Boolean specifying if a texture is used in the material.
  48153. */
  48154. hasTexture(texture: BaseTexture): boolean;
  48155. /**
  48156. * Returns an array of the actively used textures.
  48157. * @param activeTextures Array of BaseTextures
  48158. */
  48159. getActiveTextures(activeTextures: BaseTexture[]): void;
  48160. /**
  48161. * Returns the animatable textures.
  48162. * @param animatables Array of animatable textures.
  48163. */
  48164. getAnimatables(animatables: IAnimatable[]): void;
  48165. /**
  48166. * Disposes the resources of the material.
  48167. * @param forceDisposeTextures - Forces the disposal of all textures.
  48168. */
  48169. dispose(forceDisposeTextures?: boolean): void;
  48170. /**
  48171. * Get the current class name of the texture useful for serialization or dynamic coding.
  48172. * @returns "PBRAnisotropicConfiguration"
  48173. */
  48174. getClassName(): string;
  48175. /**
  48176. * Add fallbacks to the effect fallbacks list.
  48177. * @param defines defines the Base texture to use.
  48178. * @param fallbacks defines the current fallback list.
  48179. * @param currentRank defines the current fallback rank.
  48180. * @returns the new fallback rank.
  48181. */
  48182. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48183. /**
  48184. * Add the required uniforms to the current list.
  48185. * @param uniforms defines the current uniform list.
  48186. */
  48187. static AddUniforms(uniforms: string[]): void;
  48188. /**
  48189. * Add the required uniforms to the current buffer.
  48190. * @param uniformBuffer defines the current uniform buffer.
  48191. */
  48192. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48193. /**
  48194. * Add the required samplers to the current list.
  48195. * @param samplers defines the current sampler list.
  48196. */
  48197. static AddSamplers(samplers: string[]): void;
  48198. /**
  48199. * Makes a duplicate of the current configuration into another one.
  48200. * @param anisotropicConfiguration define the config where to copy the info
  48201. */
  48202. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  48203. /**
  48204. * Serializes this anisotropy configuration.
  48205. * @returns - An object with the serialized config.
  48206. */
  48207. serialize(): any;
  48208. /**
  48209. * Parses a anisotropy Configuration from a serialized object.
  48210. * @param source - Serialized object.
  48211. * @param scene Defines the scene we are parsing for
  48212. * @param rootUrl Defines the rootUrl to load from
  48213. */
  48214. parse(source: any, scene: Scene, rootUrl: string): void;
  48215. }
  48216. }
  48217. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  48218. import { Scene } from "babylonjs/scene";
  48219. /**
  48220. * @hidden
  48221. */
  48222. export interface IMaterialBRDFDefines {
  48223. BRDF_V_HEIGHT_CORRELATED: boolean;
  48224. MS_BRDF_ENERGY_CONSERVATION: boolean;
  48225. SPHERICAL_HARMONICS: boolean;
  48226. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  48227. /** @hidden */
  48228. _areMiscDirty: boolean;
  48229. }
  48230. /**
  48231. * Define the code related to the BRDF parameters of the pbr material.
  48232. */
  48233. export class PBRBRDFConfiguration {
  48234. /**
  48235. * Default value used for the energy conservation.
  48236. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  48237. */
  48238. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  48239. /**
  48240. * Default value used for the Smith Visibility Height Correlated mode.
  48241. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  48242. */
  48243. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  48244. /**
  48245. * Default value used for the IBL diffuse part.
  48246. * This can help switching back to the polynomials mode globally which is a tiny bit
  48247. * less GPU intensive at the drawback of a lower quality.
  48248. */
  48249. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  48250. /**
  48251. * Default value used for activating energy conservation for the specular workflow.
  48252. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  48253. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  48254. */
  48255. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  48256. private _useEnergyConservation;
  48257. /**
  48258. * Defines if the material uses energy conservation.
  48259. */
  48260. useEnergyConservation: boolean;
  48261. private _useSmithVisibilityHeightCorrelated;
  48262. /**
  48263. * LEGACY Mode set to false
  48264. * Defines if the material uses height smith correlated visibility term.
  48265. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  48266. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  48267. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  48268. * Not relying on height correlated will also disable energy conservation.
  48269. */
  48270. useSmithVisibilityHeightCorrelated: boolean;
  48271. private _useSphericalHarmonics;
  48272. /**
  48273. * LEGACY Mode set to false
  48274. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  48275. * diffuse part of the IBL.
  48276. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  48277. * to the ground truth.
  48278. */
  48279. useSphericalHarmonics: boolean;
  48280. private _useSpecularGlossinessInputEnergyConservation;
  48281. /**
  48282. * Defines if the material uses energy conservation, when the specular workflow is active.
  48283. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  48284. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  48285. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  48286. */
  48287. useSpecularGlossinessInputEnergyConservation: boolean;
  48288. /** @hidden */
  48289. private _internalMarkAllSubMeshesAsMiscDirty;
  48290. /** @hidden */
  48291. _markAllSubMeshesAsMiscDirty(): void;
  48292. /**
  48293. * Instantiate a new istance of clear coat configuration.
  48294. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  48295. */
  48296. constructor(markAllSubMeshesAsMiscDirty: () => void);
  48297. /**
  48298. * Checks to see if a texture is used in the material.
  48299. * @param defines the list of "defines" to update.
  48300. */
  48301. prepareDefines(defines: IMaterialBRDFDefines): void;
  48302. /**
  48303. * Get the current class name of the texture useful for serialization or dynamic coding.
  48304. * @returns "PBRClearCoatConfiguration"
  48305. */
  48306. getClassName(): string;
  48307. /**
  48308. * Makes a duplicate of the current configuration into another one.
  48309. * @param brdfConfiguration define the config where to copy the info
  48310. */
  48311. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  48312. /**
  48313. * Serializes this BRDF configuration.
  48314. * @returns - An object with the serialized config.
  48315. */
  48316. serialize(): any;
  48317. /**
  48318. * Parses a anisotropy Configuration from a serialized object.
  48319. * @param source - Serialized object.
  48320. * @param scene Defines the scene we are parsing for
  48321. * @param rootUrl Defines the rootUrl to load from
  48322. */
  48323. parse(source: any, scene: Scene, rootUrl: string): void;
  48324. }
  48325. }
  48326. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  48327. import { EffectFallbacks } from "babylonjs/Materials/effect";
  48328. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48329. import { Color3 } from "babylonjs/Maths/math.color";
  48330. import { Scene } from "babylonjs/scene";
  48331. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48332. import { Nullable } from "babylonjs/types";
  48333. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48334. /**
  48335. * @hidden
  48336. */
  48337. export interface IMaterialSheenDefines {
  48338. SHEEN: boolean;
  48339. SHEEN_TEXTURE: boolean;
  48340. SHEEN_TEXTUREDIRECTUV: number;
  48341. SHEEN_LINKWITHALBEDO: boolean;
  48342. /** @hidden */
  48343. _areTexturesDirty: boolean;
  48344. }
  48345. /**
  48346. * Define the code related to the Sheen parameters of the pbr material.
  48347. */
  48348. export class PBRSheenConfiguration {
  48349. private _isEnabled;
  48350. /**
  48351. * Defines if the material uses sheen.
  48352. */
  48353. isEnabled: boolean;
  48354. private _linkSheenWithAlbedo;
  48355. /**
  48356. * Defines if the sheen is linked to the sheen color.
  48357. */
  48358. linkSheenWithAlbedo: boolean;
  48359. /**
  48360. * Defines the sheen intensity.
  48361. */
  48362. intensity: number;
  48363. /**
  48364. * Defines the sheen color.
  48365. */
  48366. color: Color3;
  48367. private _texture;
  48368. /**
  48369. * Stores the sheen tint values in a texture.
  48370. * rgb is tint
  48371. * a is a intensity
  48372. */
  48373. texture: Nullable<BaseTexture>;
  48374. /** @hidden */
  48375. private _internalMarkAllSubMeshesAsTexturesDirty;
  48376. /** @hidden */
  48377. _markAllSubMeshesAsTexturesDirty(): void;
  48378. /**
  48379. * Instantiate a new istance of clear coat configuration.
  48380. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48381. */
  48382. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48383. /**
  48384. * Specifies that the submesh is ready to be used.
  48385. * @param defines the list of "defines" to update.
  48386. * @param scene defines the scene the material belongs to.
  48387. * @returns - boolean indicating that the submesh is ready or not.
  48388. */
  48389. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  48390. /**
  48391. * Checks to see if a texture is used in the material.
  48392. * @param defines the list of "defines" to update.
  48393. * @param scene defines the scene the material belongs to.
  48394. */
  48395. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  48396. /**
  48397. * Binds the material data.
  48398. * @param uniformBuffer defines the Uniform buffer to fill in.
  48399. * @param scene defines the scene the material belongs to.
  48400. * @param isFrozen defines wether the material is frozen or not.
  48401. */
  48402. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  48403. /**
  48404. * Checks to see if a texture is used in the material.
  48405. * @param texture - Base texture to use.
  48406. * @returns - Boolean specifying if a texture is used in the material.
  48407. */
  48408. hasTexture(texture: BaseTexture): boolean;
  48409. /**
  48410. * Returns an array of the actively used textures.
  48411. * @param activeTextures Array of BaseTextures
  48412. */
  48413. getActiveTextures(activeTextures: BaseTexture[]): void;
  48414. /**
  48415. * Returns the animatable textures.
  48416. * @param animatables Array of animatable textures.
  48417. */
  48418. getAnimatables(animatables: IAnimatable[]): void;
  48419. /**
  48420. * Disposes the resources of the material.
  48421. * @param forceDisposeTextures - Forces the disposal of all textures.
  48422. */
  48423. dispose(forceDisposeTextures?: boolean): void;
  48424. /**
  48425. * Get the current class name of the texture useful for serialization or dynamic coding.
  48426. * @returns "PBRSheenConfiguration"
  48427. */
  48428. getClassName(): string;
  48429. /**
  48430. * Add fallbacks to the effect fallbacks list.
  48431. * @param defines defines the Base texture to use.
  48432. * @param fallbacks defines the current fallback list.
  48433. * @param currentRank defines the current fallback rank.
  48434. * @returns the new fallback rank.
  48435. */
  48436. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48437. /**
  48438. * Add the required uniforms to the current list.
  48439. * @param uniforms defines the current uniform list.
  48440. */
  48441. static AddUniforms(uniforms: string[]): void;
  48442. /**
  48443. * Add the required uniforms to the current buffer.
  48444. * @param uniformBuffer defines the current uniform buffer.
  48445. */
  48446. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48447. /**
  48448. * Add the required samplers to the current list.
  48449. * @param samplers defines the current sampler list.
  48450. */
  48451. static AddSamplers(samplers: string[]): void;
  48452. /**
  48453. * Makes a duplicate of the current configuration into another one.
  48454. * @param sheenConfiguration define the config where to copy the info
  48455. */
  48456. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  48457. /**
  48458. * Serializes this BRDF configuration.
  48459. * @returns - An object with the serialized config.
  48460. */
  48461. serialize(): any;
  48462. /**
  48463. * Parses a anisotropy Configuration from a serialized object.
  48464. * @param source - Serialized object.
  48465. * @param scene Defines the scene we are parsing for
  48466. * @param rootUrl Defines the rootUrl to load from
  48467. */
  48468. parse(source: any, scene: Scene, rootUrl: string): void;
  48469. }
  48470. }
  48471. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  48472. import { Nullable } from "babylonjs/types";
  48473. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48474. import { Color3 } from "babylonjs/Maths/math.color";
  48475. import { SmartArray } from "babylonjs/Misc/smartArray";
  48476. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48477. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48478. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  48479. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48480. import { Engine } from "babylonjs/Engines/engine";
  48481. import { Scene } from "babylonjs/scene";
  48482. /**
  48483. * @hidden
  48484. */
  48485. export interface IMaterialSubSurfaceDefines {
  48486. SUBSURFACE: boolean;
  48487. SS_REFRACTION: boolean;
  48488. SS_TRANSLUCENCY: boolean;
  48489. SS_SCATERRING: boolean;
  48490. SS_THICKNESSANDMASK_TEXTURE: boolean;
  48491. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  48492. SS_REFRACTIONMAP_3D: boolean;
  48493. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  48494. SS_LODINREFRACTIONALPHA: boolean;
  48495. SS_GAMMAREFRACTION: boolean;
  48496. SS_RGBDREFRACTION: boolean;
  48497. SS_LINEARSPECULARREFRACTION: boolean;
  48498. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  48499. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  48500. /** @hidden */
  48501. _areTexturesDirty: boolean;
  48502. }
  48503. /**
  48504. * Define the code related to the sub surface parameters of the pbr material.
  48505. */
  48506. export class PBRSubSurfaceConfiguration {
  48507. private _isRefractionEnabled;
  48508. /**
  48509. * Defines if the refraction is enabled in the material.
  48510. */
  48511. isRefractionEnabled: boolean;
  48512. private _isTranslucencyEnabled;
  48513. /**
  48514. * Defines if the translucency is enabled in the material.
  48515. */
  48516. isTranslucencyEnabled: boolean;
  48517. private _isScatteringEnabled;
  48518. /**
  48519. * Defines the refraction intensity of the material.
  48520. * The refraction when enabled replaces the Diffuse part of the material.
  48521. * The intensity helps transitionning between diffuse and refraction.
  48522. */
  48523. refractionIntensity: number;
  48524. /**
  48525. * Defines the translucency intensity of the material.
  48526. * When translucency has been enabled, this defines how much of the "translucency"
  48527. * is addded to the diffuse part of the material.
  48528. */
  48529. translucencyIntensity: number;
  48530. /**
  48531. * Defines the scattering intensity of the material.
  48532. * When scattering has been enabled, this defines how much of the "scattered light"
  48533. * is addded to the diffuse part of the material.
  48534. */
  48535. scatteringIntensity: number;
  48536. private _thicknessTexture;
  48537. /**
  48538. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  48539. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  48540. * 0 would mean minimumThickness
  48541. * 1 would mean maximumThickness
  48542. * The other channels might be use as a mask to vary the different effects intensity.
  48543. */
  48544. thicknessTexture: Nullable<BaseTexture>;
  48545. private _refractionTexture;
  48546. /**
  48547. * Defines the texture to use for refraction.
  48548. */
  48549. refractionTexture: Nullable<BaseTexture>;
  48550. private _indexOfRefraction;
  48551. /**
  48552. * Defines the index of refraction used in the material.
  48553. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  48554. */
  48555. indexOfRefraction: number;
  48556. private _invertRefractionY;
  48557. /**
  48558. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  48559. */
  48560. invertRefractionY: boolean;
  48561. private _linkRefractionWithTransparency;
  48562. /**
  48563. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  48564. * Materials half opaque for instance using refraction could benefit from this control.
  48565. */
  48566. linkRefractionWithTransparency: boolean;
  48567. /**
  48568. * Defines the minimum thickness stored in the thickness map.
  48569. * If no thickness map is defined, this value will be used to simulate thickness.
  48570. */
  48571. minimumThickness: number;
  48572. /**
  48573. * Defines the maximum thickness stored in the thickness map.
  48574. */
  48575. maximumThickness: number;
  48576. /**
  48577. * Defines the volume tint of the material.
  48578. * This is used for both translucency and scattering.
  48579. */
  48580. tintColor: Color3;
  48581. /**
  48582. * Defines the distance at which the tint color should be found in the media.
  48583. * This is used for refraction only.
  48584. */
  48585. tintColorAtDistance: number;
  48586. /**
  48587. * Defines how far each channel transmit through the media.
  48588. * It is defined as a color to simplify it selection.
  48589. */
  48590. diffusionDistance: Color3;
  48591. private _useMaskFromThicknessTexture;
  48592. /**
  48593. * Stores the intensity of the different subsurface effects in the thickness texture.
  48594. * * the green channel is the translucency intensity.
  48595. * * the blue channel is the scattering intensity.
  48596. * * the alpha channel is the refraction intensity.
  48597. */
  48598. useMaskFromThicknessTexture: boolean;
  48599. /** @hidden */
  48600. private _internalMarkAllSubMeshesAsTexturesDirty;
  48601. /** @hidden */
  48602. _markAllSubMeshesAsTexturesDirty(): void;
  48603. /**
  48604. * Instantiate a new istance of sub surface configuration.
  48605. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48606. */
  48607. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48608. /**
  48609. * Gets wehter the submesh is ready to be used or not.
  48610. * @param defines the list of "defines" to update.
  48611. * @param scene defines the scene the material belongs to.
  48612. * @returns - boolean indicating that the submesh is ready or not.
  48613. */
  48614. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  48615. /**
  48616. * Checks to see if a texture is used in the material.
  48617. * @param defines the list of "defines" to update.
  48618. * @param scene defines the scene to the material belongs to.
  48619. */
  48620. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  48621. /**
  48622. * Binds the material data.
  48623. * @param uniformBuffer defines the Uniform buffer to fill in.
  48624. * @param scene defines the scene the material belongs to.
  48625. * @param engine defines the engine the material belongs to.
  48626. * @param isFrozen defines wether the material is frozen or not.
  48627. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  48628. */
  48629. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  48630. /**
  48631. * Unbinds the material from the mesh.
  48632. * @param activeEffect defines the effect that should be unbound from.
  48633. * @returns true if unbound, otherwise false
  48634. */
  48635. unbind(activeEffect: Effect): boolean;
  48636. /**
  48637. * Returns the texture used for refraction or null if none is used.
  48638. * @param scene defines the scene the material belongs to.
  48639. * @returns - Refraction texture if present. If no refraction texture and refraction
  48640. * is linked with transparency, returns environment texture. Otherwise, returns null.
  48641. */
  48642. private _getRefractionTexture;
  48643. /**
  48644. * Returns true if alpha blending should be disabled.
  48645. */
  48646. readonly disableAlphaBlending: boolean;
  48647. /**
  48648. * Fills the list of render target textures.
  48649. * @param renderTargets the list of render targets to update
  48650. */
  48651. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  48652. /**
  48653. * Checks to see if a texture is used in the material.
  48654. * @param texture - Base texture to use.
  48655. * @returns - Boolean specifying if a texture is used in the material.
  48656. */
  48657. hasTexture(texture: BaseTexture): boolean;
  48658. /**
  48659. * Gets a boolean indicating that current material needs to register RTT
  48660. * @returns true if this uses a render target otherwise false.
  48661. */
  48662. hasRenderTargetTextures(): boolean;
  48663. /**
  48664. * Returns an array of the actively used textures.
  48665. * @param activeTextures Array of BaseTextures
  48666. */
  48667. getActiveTextures(activeTextures: BaseTexture[]): void;
  48668. /**
  48669. * Returns the animatable textures.
  48670. * @param animatables Array of animatable textures.
  48671. */
  48672. getAnimatables(animatables: IAnimatable[]): void;
  48673. /**
  48674. * Disposes the resources of the material.
  48675. * @param forceDisposeTextures - Forces the disposal of all textures.
  48676. */
  48677. dispose(forceDisposeTextures?: boolean): void;
  48678. /**
  48679. * Get the current class name of the texture useful for serialization or dynamic coding.
  48680. * @returns "PBRSubSurfaceConfiguration"
  48681. */
  48682. getClassName(): string;
  48683. /**
  48684. * Add fallbacks to the effect fallbacks list.
  48685. * @param defines defines the Base texture to use.
  48686. * @param fallbacks defines the current fallback list.
  48687. * @param currentRank defines the current fallback rank.
  48688. * @returns the new fallback rank.
  48689. */
  48690. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48691. /**
  48692. * Add the required uniforms to the current list.
  48693. * @param uniforms defines the current uniform list.
  48694. */
  48695. static AddUniforms(uniforms: string[]): void;
  48696. /**
  48697. * Add the required samplers to the current list.
  48698. * @param samplers defines the current sampler list.
  48699. */
  48700. static AddSamplers(samplers: string[]): void;
  48701. /**
  48702. * Add the required uniforms to the current buffer.
  48703. * @param uniformBuffer defines the current uniform buffer.
  48704. */
  48705. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48706. /**
  48707. * Makes a duplicate of the current configuration into another one.
  48708. * @param configuration define the config where to copy the info
  48709. */
  48710. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  48711. /**
  48712. * Serializes this Sub Surface configuration.
  48713. * @returns - An object with the serialized config.
  48714. */
  48715. serialize(): any;
  48716. /**
  48717. * Parses a anisotropy Configuration from a serialized object.
  48718. * @param source - Serialized object.
  48719. * @param scene Defines the scene we are parsing for
  48720. * @param rootUrl Defines the rootUrl to load from
  48721. */
  48722. parse(source: any, scene: Scene, rootUrl: string): void;
  48723. }
  48724. }
  48725. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  48726. /** @hidden */
  48727. export var pbrFragmentDeclaration: {
  48728. name: string;
  48729. shader: string;
  48730. };
  48731. }
  48732. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  48733. /** @hidden */
  48734. export var pbrUboDeclaration: {
  48735. name: string;
  48736. shader: string;
  48737. };
  48738. }
  48739. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  48740. /** @hidden */
  48741. export var pbrFragmentExtraDeclaration: {
  48742. name: string;
  48743. shader: string;
  48744. };
  48745. }
  48746. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  48747. /** @hidden */
  48748. export var pbrFragmentSamplersDeclaration: {
  48749. name: string;
  48750. shader: string;
  48751. };
  48752. }
  48753. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  48754. /** @hidden */
  48755. export var pbrHelperFunctions: {
  48756. name: string;
  48757. shader: string;
  48758. };
  48759. }
  48760. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  48761. /** @hidden */
  48762. export var harmonicsFunctions: {
  48763. name: string;
  48764. shader: string;
  48765. };
  48766. }
  48767. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  48768. /** @hidden */
  48769. export var pbrDirectLightingSetupFunctions: {
  48770. name: string;
  48771. shader: string;
  48772. };
  48773. }
  48774. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  48775. /** @hidden */
  48776. export var pbrDirectLightingFalloffFunctions: {
  48777. name: string;
  48778. shader: string;
  48779. };
  48780. }
  48781. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  48782. /** @hidden */
  48783. export var pbrBRDFFunctions: {
  48784. name: string;
  48785. shader: string;
  48786. };
  48787. }
  48788. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  48789. /** @hidden */
  48790. export var pbrDirectLightingFunctions: {
  48791. name: string;
  48792. shader: string;
  48793. };
  48794. }
  48795. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  48796. /** @hidden */
  48797. export var pbrIBLFunctions: {
  48798. name: string;
  48799. shader: string;
  48800. };
  48801. }
  48802. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  48803. /** @hidden */
  48804. export var pbrDebug: {
  48805. name: string;
  48806. shader: string;
  48807. };
  48808. }
  48809. declare module "babylonjs/Shaders/pbr.fragment" {
  48810. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  48811. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  48812. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  48813. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48814. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48815. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  48816. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  48817. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  48818. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  48819. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  48820. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48821. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  48822. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  48823. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  48824. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  48825. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  48826. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  48827. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  48828. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  48829. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  48830. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  48831. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  48832. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  48833. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  48834. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  48835. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  48836. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  48837. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  48838. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  48839. /** @hidden */
  48840. export var pbrPixelShader: {
  48841. name: string;
  48842. shader: string;
  48843. };
  48844. }
  48845. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  48846. /** @hidden */
  48847. export var pbrVertexDeclaration: {
  48848. name: string;
  48849. shader: string;
  48850. };
  48851. }
  48852. declare module "babylonjs/Shaders/pbr.vertex" {
  48853. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  48854. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  48855. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48856. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  48857. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  48858. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  48859. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  48860. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  48861. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  48862. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48863. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48864. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  48865. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  48866. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  48867. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  48868. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  48869. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  48870. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  48871. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  48872. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  48873. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  48874. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  48875. /** @hidden */
  48876. export var pbrVertexShader: {
  48877. name: string;
  48878. shader: string;
  48879. };
  48880. }
  48881. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  48882. import { Nullable } from "babylonjs/types";
  48883. import { Scene } from "babylonjs/scene";
  48884. import { Matrix } from "babylonjs/Maths/math.vector";
  48885. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48886. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48887. import { Mesh } from "babylonjs/Meshes/mesh";
  48888. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  48889. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  48890. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  48891. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  48892. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  48893. import { Color3 } from "babylonjs/Maths/math.color";
  48894. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  48895. import { Material } from "babylonjs/Materials/material";
  48896. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  48897. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  48898. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48899. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48900. import "babylonjs/Shaders/pbr.fragment";
  48901. import "babylonjs/Shaders/pbr.vertex";
  48902. /**
  48903. * Manages the defines for the PBR Material.
  48904. * @hidden
  48905. */
  48906. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  48907. PBR: boolean;
  48908. MAINUV1: boolean;
  48909. MAINUV2: boolean;
  48910. UV1: boolean;
  48911. UV2: boolean;
  48912. ALBEDO: boolean;
  48913. ALBEDODIRECTUV: number;
  48914. VERTEXCOLOR: boolean;
  48915. AMBIENT: boolean;
  48916. AMBIENTDIRECTUV: number;
  48917. AMBIENTINGRAYSCALE: boolean;
  48918. OPACITY: boolean;
  48919. VERTEXALPHA: boolean;
  48920. OPACITYDIRECTUV: number;
  48921. OPACITYRGB: boolean;
  48922. ALPHATEST: boolean;
  48923. DEPTHPREPASS: boolean;
  48924. ALPHABLEND: boolean;
  48925. ALPHAFROMALBEDO: boolean;
  48926. ALPHATESTVALUE: string;
  48927. SPECULAROVERALPHA: boolean;
  48928. RADIANCEOVERALPHA: boolean;
  48929. ALPHAFRESNEL: boolean;
  48930. LINEARALPHAFRESNEL: boolean;
  48931. PREMULTIPLYALPHA: boolean;
  48932. EMISSIVE: boolean;
  48933. EMISSIVEDIRECTUV: number;
  48934. REFLECTIVITY: boolean;
  48935. REFLECTIVITYDIRECTUV: number;
  48936. SPECULARTERM: boolean;
  48937. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  48938. MICROSURFACEAUTOMATIC: boolean;
  48939. LODBASEDMICROSFURACE: boolean;
  48940. MICROSURFACEMAP: boolean;
  48941. MICROSURFACEMAPDIRECTUV: number;
  48942. METALLICWORKFLOW: boolean;
  48943. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  48944. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  48945. METALLNESSSTOREINMETALMAPBLUE: boolean;
  48946. AOSTOREINMETALMAPRED: boolean;
  48947. ENVIRONMENTBRDF: boolean;
  48948. ENVIRONMENTBRDF_RGBD: boolean;
  48949. NORMAL: boolean;
  48950. TANGENT: boolean;
  48951. BUMP: boolean;
  48952. BUMPDIRECTUV: number;
  48953. OBJECTSPACE_NORMALMAP: boolean;
  48954. PARALLAX: boolean;
  48955. PARALLAXOCCLUSION: boolean;
  48956. NORMALXYSCALE: boolean;
  48957. LIGHTMAP: boolean;
  48958. LIGHTMAPDIRECTUV: number;
  48959. USELIGHTMAPASSHADOWMAP: boolean;
  48960. GAMMALIGHTMAP: boolean;
  48961. RGBDLIGHTMAP: boolean;
  48962. REFLECTION: boolean;
  48963. REFLECTIONMAP_3D: boolean;
  48964. REFLECTIONMAP_SPHERICAL: boolean;
  48965. REFLECTIONMAP_PLANAR: boolean;
  48966. REFLECTIONMAP_CUBIC: boolean;
  48967. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  48968. REFLECTIONMAP_PROJECTION: boolean;
  48969. REFLECTIONMAP_SKYBOX: boolean;
  48970. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  48971. REFLECTIONMAP_EXPLICIT: boolean;
  48972. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  48973. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  48974. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  48975. INVERTCUBICMAP: boolean;
  48976. USESPHERICALFROMREFLECTIONMAP: boolean;
  48977. USEIRRADIANCEMAP: boolean;
  48978. SPHERICAL_HARMONICS: boolean;
  48979. USESPHERICALINVERTEX: boolean;
  48980. REFLECTIONMAP_OPPOSITEZ: boolean;
  48981. LODINREFLECTIONALPHA: boolean;
  48982. GAMMAREFLECTION: boolean;
  48983. RGBDREFLECTION: boolean;
  48984. LINEARSPECULARREFLECTION: boolean;
  48985. RADIANCEOCCLUSION: boolean;
  48986. HORIZONOCCLUSION: boolean;
  48987. INSTANCES: boolean;
  48988. NUM_BONE_INFLUENCERS: number;
  48989. BonesPerMesh: number;
  48990. BONETEXTURE: boolean;
  48991. NONUNIFORMSCALING: boolean;
  48992. MORPHTARGETS: boolean;
  48993. MORPHTARGETS_NORMAL: boolean;
  48994. MORPHTARGETS_TANGENT: boolean;
  48995. MORPHTARGETS_UV: boolean;
  48996. NUM_MORPH_INFLUENCERS: number;
  48997. IMAGEPROCESSING: boolean;
  48998. VIGNETTE: boolean;
  48999. VIGNETTEBLENDMODEMULTIPLY: boolean;
  49000. VIGNETTEBLENDMODEOPAQUE: boolean;
  49001. TONEMAPPING: boolean;
  49002. TONEMAPPING_ACES: boolean;
  49003. CONTRAST: boolean;
  49004. COLORCURVES: boolean;
  49005. COLORGRADING: boolean;
  49006. COLORGRADING3D: boolean;
  49007. SAMPLER3DGREENDEPTH: boolean;
  49008. SAMPLER3DBGRMAP: boolean;
  49009. IMAGEPROCESSINGPOSTPROCESS: boolean;
  49010. EXPOSURE: boolean;
  49011. MULTIVIEW: boolean;
  49012. USEPHYSICALLIGHTFALLOFF: boolean;
  49013. USEGLTFLIGHTFALLOFF: boolean;
  49014. TWOSIDEDLIGHTING: boolean;
  49015. SHADOWFLOAT: boolean;
  49016. CLIPPLANE: boolean;
  49017. CLIPPLANE2: boolean;
  49018. CLIPPLANE3: boolean;
  49019. CLIPPLANE4: boolean;
  49020. POINTSIZE: boolean;
  49021. FOG: boolean;
  49022. LOGARITHMICDEPTH: boolean;
  49023. FORCENORMALFORWARD: boolean;
  49024. SPECULARAA: boolean;
  49025. CLEARCOAT: boolean;
  49026. CLEARCOAT_DEFAULTIOR: boolean;
  49027. CLEARCOAT_TEXTURE: boolean;
  49028. CLEARCOAT_TEXTUREDIRECTUV: number;
  49029. CLEARCOAT_BUMP: boolean;
  49030. CLEARCOAT_BUMPDIRECTUV: number;
  49031. CLEARCOAT_TINT: boolean;
  49032. CLEARCOAT_TINT_TEXTURE: boolean;
  49033. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  49034. ANISOTROPIC: boolean;
  49035. ANISOTROPIC_TEXTURE: boolean;
  49036. ANISOTROPIC_TEXTUREDIRECTUV: number;
  49037. BRDF_V_HEIGHT_CORRELATED: boolean;
  49038. MS_BRDF_ENERGY_CONSERVATION: boolean;
  49039. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  49040. SHEEN: boolean;
  49041. SHEEN_TEXTURE: boolean;
  49042. SHEEN_TEXTUREDIRECTUV: number;
  49043. SHEEN_LINKWITHALBEDO: boolean;
  49044. SUBSURFACE: boolean;
  49045. SS_REFRACTION: boolean;
  49046. SS_TRANSLUCENCY: boolean;
  49047. SS_SCATERRING: boolean;
  49048. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49049. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49050. SS_REFRACTIONMAP_3D: boolean;
  49051. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49052. SS_LODINREFRACTIONALPHA: boolean;
  49053. SS_GAMMAREFRACTION: boolean;
  49054. SS_RGBDREFRACTION: boolean;
  49055. SS_LINEARSPECULARREFRACTION: boolean;
  49056. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49057. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49058. UNLIT: boolean;
  49059. DEBUGMODE: number;
  49060. /**
  49061. * Initializes the PBR Material defines.
  49062. */
  49063. constructor();
  49064. /**
  49065. * Resets the PBR Material defines.
  49066. */
  49067. reset(): void;
  49068. }
  49069. /**
  49070. * The Physically based material base class of BJS.
  49071. *
  49072. * This offers the main features of a standard PBR material.
  49073. * For more information, please refer to the documentation :
  49074. * https://doc.babylonjs.com/how_to/physically_based_rendering
  49075. */
  49076. export abstract class PBRBaseMaterial extends PushMaterial {
  49077. /**
  49078. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  49079. */
  49080. static readonly PBRMATERIAL_OPAQUE: number;
  49081. /**
  49082. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  49083. */
  49084. static readonly PBRMATERIAL_ALPHATEST: number;
  49085. /**
  49086. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49087. */
  49088. static readonly PBRMATERIAL_ALPHABLEND: number;
  49089. /**
  49090. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49091. * They are also discarded below the alpha cutoff threshold to improve performances.
  49092. */
  49093. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  49094. /**
  49095. * Defines the default value of how much AO map is occluding the analytical lights
  49096. * (point spot...).
  49097. */
  49098. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  49099. /**
  49100. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  49101. */
  49102. static readonly LIGHTFALLOFF_PHYSICAL: number;
  49103. /**
  49104. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  49105. * to enhance interoperability with other engines.
  49106. */
  49107. static readonly LIGHTFALLOFF_GLTF: number;
  49108. /**
  49109. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  49110. * to enhance interoperability with other materials.
  49111. */
  49112. static readonly LIGHTFALLOFF_STANDARD: number;
  49113. /**
  49114. * Intensity of the direct lights e.g. the four lights available in your scene.
  49115. * This impacts both the direct diffuse and specular highlights.
  49116. */
  49117. protected _directIntensity: number;
  49118. /**
  49119. * Intensity of the emissive part of the material.
  49120. * This helps controlling the emissive effect without modifying the emissive color.
  49121. */
  49122. protected _emissiveIntensity: number;
  49123. /**
  49124. * Intensity of the environment e.g. how much the environment will light the object
  49125. * either through harmonics for rough material or through the refelction for shiny ones.
  49126. */
  49127. protected _environmentIntensity: number;
  49128. /**
  49129. * This is a special control allowing the reduction of the specular highlights coming from the
  49130. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  49131. */
  49132. protected _specularIntensity: number;
  49133. /**
  49134. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  49135. */
  49136. private _lightingInfos;
  49137. /**
  49138. * Debug Control allowing disabling the bump map on this material.
  49139. */
  49140. protected _disableBumpMap: boolean;
  49141. /**
  49142. * AKA Diffuse Texture in standard nomenclature.
  49143. */
  49144. protected _albedoTexture: Nullable<BaseTexture>;
  49145. /**
  49146. * AKA Occlusion Texture in other nomenclature.
  49147. */
  49148. protected _ambientTexture: Nullable<BaseTexture>;
  49149. /**
  49150. * AKA Occlusion Texture Intensity in other nomenclature.
  49151. */
  49152. protected _ambientTextureStrength: number;
  49153. /**
  49154. * Defines how much the AO map is occluding the analytical lights (point spot...).
  49155. * 1 means it completely occludes it
  49156. * 0 mean it has no impact
  49157. */
  49158. protected _ambientTextureImpactOnAnalyticalLights: number;
  49159. /**
  49160. * Stores the alpha values in a texture.
  49161. */
  49162. protected _opacityTexture: Nullable<BaseTexture>;
  49163. /**
  49164. * Stores the reflection values in a texture.
  49165. */
  49166. protected _reflectionTexture: Nullable<BaseTexture>;
  49167. /**
  49168. * Stores the emissive values in a texture.
  49169. */
  49170. protected _emissiveTexture: Nullable<BaseTexture>;
  49171. /**
  49172. * AKA Specular texture in other nomenclature.
  49173. */
  49174. protected _reflectivityTexture: Nullable<BaseTexture>;
  49175. /**
  49176. * Used to switch from specular/glossiness to metallic/roughness workflow.
  49177. */
  49178. protected _metallicTexture: Nullable<BaseTexture>;
  49179. /**
  49180. * Specifies the metallic scalar of the metallic/roughness workflow.
  49181. * Can also be used to scale the metalness values of the metallic texture.
  49182. */
  49183. protected _metallic: Nullable<number>;
  49184. /**
  49185. * Specifies the roughness scalar of the metallic/roughness workflow.
  49186. * Can also be used to scale the roughness values of the metallic texture.
  49187. */
  49188. protected _roughness: Nullable<number>;
  49189. /**
  49190. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  49191. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  49192. */
  49193. protected _microSurfaceTexture: Nullable<BaseTexture>;
  49194. /**
  49195. * Stores surface normal data used to displace a mesh in a texture.
  49196. */
  49197. protected _bumpTexture: Nullable<BaseTexture>;
  49198. /**
  49199. * Stores the pre-calculated light information of a mesh in a texture.
  49200. */
  49201. protected _lightmapTexture: Nullable<BaseTexture>;
  49202. /**
  49203. * The color of a material in ambient lighting.
  49204. */
  49205. protected _ambientColor: Color3;
  49206. /**
  49207. * AKA Diffuse Color in other nomenclature.
  49208. */
  49209. protected _albedoColor: Color3;
  49210. /**
  49211. * AKA Specular Color in other nomenclature.
  49212. */
  49213. protected _reflectivityColor: Color3;
  49214. /**
  49215. * The color applied when light is reflected from a material.
  49216. */
  49217. protected _reflectionColor: Color3;
  49218. /**
  49219. * The color applied when light is emitted from a material.
  49220. */
  49221. protected _emissiveColor: Color3;
  49222. /**
  49223. * AKA Glossiness in other nomenclature.
  49224. */
  49225. protected _microSurface: number;
  49226. /**
  49227. * Specifies that the material will use the light map as a show map.
  49228. */
  49229. protected _useLightmapAsShadowmap: boolean;
  49230. /**
  49231. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  49232. * makes the reflect vector face the model (under horizon).
  49233. */
  49234. protected _useHorizonOcclusion: boolean;
  49235. /**
  49236. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  49237. * too much the area relying on ambient texture to define their ambient occlusion.
  49238. */
  49239. protected _useRadianceOcclusion: boolean;
  49240. /**
  49241. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  49242. */
  49243. protected _useAlphaFromAlbedoTexture: boolean;
  49244. /**
  49245. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  49246. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  49247. */
  49248. protected _useSpecularOverAlpha: boolean;
  49249. /**
  49250. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  49251. */
  49252. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  49253. /**
  49254. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  49255. */
  49256. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  49257. /**
  49258. * Specifies if the metallic texture contains the roughness information in its green channel.
  49259. */
  49260. protected _useRoughnessFromMetallicTextureGreen: boolean;
  49261. /**
  49262. * Specifies if the metallic texture contains the metallness information in its blue channel.
  49263. */
  49264. protected _useMetallnessFromMetallicTextureBlue: boolean;
  49265. /**
  49266. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  49267. */
  49268. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  49269. /**
  49270. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  49271. */
  49272. protected _useAmbientInGrayScale: boolean;
  49273. /**
  49274. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  49275. * The material will try to infer what glossiness each pixel should be.
  49276. */
  49277. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  49278. /**
  49279. * Defines the falloff type used in this material.
  49280. * It by default is Physical.
  49281. */
  49282. protected _lightFalloff: number;
  49283. /**
  49284. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  49285. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  49286. */
  49287. protected _useRadianceOverAlpha: boolean;
  49288. /**
  49289. * Allows using an object space normal map (instead of tangent space).
  49290. */
  49291. protected _useObjectSpaceNormalMap: boolean;
  49292. /**
  49293. * Allows using the bump map in parallax mode.
  49294. */
  49295. protected _useParallax: boolean;
  49296. /**
  49297. * Allows using the bump map in parallax occlusion mode.
  49298. */
  49299. protected _useParallaxOcclusion: boolean;
  49300. /**
  49301. * Controls the scale bias of the parallax mode.
  49302. */
  49303. protected _parallaxScaleBias: number;
  49304. /**
  49305. * If sets to true, disables all the lights affecting the material.
  49306. */
  49307. protected _disableLighting: boolean;
  49308. /**
  49309. * Number of Simultaneous lights allowed on the material.
  49310. */
  49311. protected _maxSimultaneousLights: number;
  49312. /**
  49313. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  49314. */
  49315. protected _invertNormalMapX: boolean;
  49316. /**
  49317. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  49318. */
  49319. protected _invertNormalMapY: boolean;
  49320. /**
  49321. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49322. */
  49323. protected _twoSidedLighting: boolean;
  49324. /**
  49325. * Defines the alpha limits in alpha test mode.
  49326. */
  49327. protected _alphaCutOff: number;
  49328. /**
  49329. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  49330. */
  49331. protected _forceAlphaTest: boolean;
  49332. /**
  49333. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49334. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  49335. */
  49336. protected _useAlphaFresnel: boolean;
  49337. /**
  49338. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49339. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  49340. */
  49341. protected _useLinearAlphaFresnel: boolean;
  49342. /**
  49343. * The transparency mode of the material.
  49344. */
  49345. protected _transparencyMode: Nullable<number>;
  49346. /**
  49347. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  49348. * from cos thetav and roughness:
  49349. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  49350. */
  49351. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  49352. /**
  49353. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  49354. */
  49355. protected _forceIrradianceInFragment: boolean;
  49356. /**
  49357. * Force normal to face away from face.
  49358. */
  49359. protected _forceNormalForward: boolean;
  49360. /**
  49361. * Enables specular anti aliasing in the PBR shader.
  49362. * It will both interacts on the Geometry for analytical and IBL lighting.
  49363. * It also prefilter the roughness map based on the bump values.
  49364. */
  49365. protected _enableSpecularAntiAliasing: boolean;
  49366. /**
  49367. * Default configuration related to image processing available in the PBR Material.
  49368. */
  49369. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49370. /**
  49371. * Keep track of the image processing observer to allow dispose and replace.
  49372. */
  49373. private _imageProcessingObserver;
  49374. /**
  49375. * Attaches a new image processing configuration to the PBR Material.
  49376. * @param configuration
  49377. */
  49378. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49379. /**
  49380. * Stores the available render targets.
  49381. */
  49382. private _renderTargets;
  49383. /**
  49384. * Sets the global ambient color for the material used in lighting calculations.
  49385. */
  49386. private _globalAmbientColor;
  49387. /**
  49388. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  49389. */
  49390. private _useLogarithmicDepth;
  49391. /**
  49392. * If set to true, no lighting calculations will be applied.
  49393. */
  49394. private _unlit;
  49395. private _debugMode;
  49396. /**
  49397. * @hidden
  49398. * This is reserved for the inspector.
  49399. * Defines the material debug mode.
  49400. * It helps seeing only some components of the material while troubleshooting.
  49401. */
  49402. debugMode: number;
  49403. /**
  49404. * @hidden
  49405. * This is reserved for the inspector.
  49406. * Specify from where on screen the debug mode should start.
  49407. * The value goes from -1 (full screen) to 1 (not visible)
  49408. * It helps with side by side comparison against the final render
  49409. * This defaults to -1
  49410. */
  49411. private debugLimit;
  49412. /**
  49413. * @hidden
  49414. * This is reserved for the inspector.
  49415. * As the default viewing range might not be enough (if the ambient is really small for instance)
  49416. * You can use the factor to better multiply the final value.
  49417. */
  49418. private debugFactor;
  49419. /**
  49420. * Defines the clear coat layer parameters for the material.
  49421. */
  49422. readonly clearCoat: PBRClearCoatConfiguration;
  49423. /**
  49424. * Defines the anisotropic parameters for the material.
  49425. */
  49426. readonly anisotropy: PBRAnisotropicConfiguration;
  49427. /**
  49428. * Defines the BRDF parameters for the material.
  49429. */
  49430. readonly brdf: PBRBRDFConfiguration;
  49431. /**
  49432. * Defines the Sheen parameters for the material.
  49433. */
  49434. readonly sheen: PBRSheenConfiguration;
  49435. /**
  49436. * Defines the SubSurface parameters for the material.
  49437. */
  49438. readonly subSurface: PBRSubSurfaceConfiguration;
  49439. /**
  49440. * Custom callback helping to override the default shader used in the material.
  49441. */
  49442. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  49443. protected _rebuildInParallel: boolean;
  49444. /**
  49445. * Instantiates a new PBRMaterial instance.
  49446. *
  49447. * @param name The material name
  49448. * @param scene The scene the material will be use in.
  49449. */
  49450. constructor(name: string, scene: Scene);
  49451. /**
  49452. * Gets a boolean indicating that current material needs to register RTT
  49453. */
  49454. readonly hasRenderTargetTextures: boolean;
  49455. /**
  49456. * Gets the name of the material class.
  49457. */
  49458. getClassName(): string;
  49459. /**
  49460. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  49461. */
  49462. /**
  49463. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  49464. */
  49465. useLogarithmicDepth: boolean;
  49466. /**
  49467. * Gets the current transparency mode.
  49468. */
  49469. /**
  49470. * Sets the transparency mode of the material.
  49471. *
  49472. * | Value | Type | Description |
  49473. * | ----- | ----------------------------------- | ----------- |
  49474. * | 0 | OPAQUE | |
  49475. * | 1 | ALPHATEST | |
  49476. * | 2 | ALPHABLEND | |
  49477. * | 3 | ALPHATESTANDBLEND | |
  49478. *
  49479. */
  49480. transparencyMode: Nullable<number>;
  49481. /**
  49482. * Returns true if alpha blending should be disabled.
  49483. */
  49484. private readonly _disableAlphaBlending;
  49485. /**
  49486. * Specifies whether or not this material should be rendered in alpha blend mode.
  49487. */
  49488. needAlphaBlending(): boolean;
  49489. /**
  49490. * Specifies if the mesh will require alpha blending.
  49491. * @param mesh - BJS mesh.
  49492. */
  49493. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  49494. /**
  49495. * Specifies whether or not this material should be rendered in alpha test mode.
  49496. */
  49497. needAlphaTesting(): boolean;
  49498. /**
  49499. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  49500. */
  49501. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  49502. /**
  49503. * Gets the texture used for the alpha test.
  49504. */
  49505. getAlphaTestTexture(): Nullable<BaseTexture>;
  49506. /**
  49507. * Specifies that the submesh is ready to be used.
  49508. * @param mesh - BJS mesh.
  49509. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  49510. * @param useInstances - Specifies that instances should be used.
  49511. * @returns - boolean indicating that the submesh is ready or not.
  49512. */
  49513. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  49514. /**
  49515. * Specifies if the material uses metallic roughness workflow.
  49516. * @returns boolean specifiying if the material uses metallic roughness workflow.
  49517. */
  49518. isMetallicWorkflow(): boolean;
  49519. private _prepareEffect;
  49520. private _prepareDefines;
  49521. /**
  49522. * Force shader compilation
  49523. */
  49524. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  49525. clipPlane: boolean;
  49526. }>): void;
  49527. /**
  49528. * Initializes the uniform buffer layout for the shader.
  49529. */
  49530. buildUniformLayout(): void;
  49531. /**
  49532. * Unbinds the material from the mesh
  49533. */
  49534. unbind(): void;
  49535. /**
  49536. * Binds the submesh data.
  49537. * @param world - The world matrix.
  49538. * @param mesh - The BJS mesh.
  49539. * @param subMesh - A submesh of the BJS mesh.
  49540. */
  49541. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  49542. /**
  49543. * Returns the animatable textures.
  49544. * @returns - Array of animatable textures.
  49545. */
  49546. getAnimatables(): IAnimatable[];
  49547. /**
  49548. * Returns the texture used for reflections.
  49549. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  49550. */
  49551. private _getReflectionTexture;
  49552. /**
  49553. * Returns an array of the actively used textures.
  49554. * @returns - Array of BaseTextures
  49555. */
  49556. getActiveTextures(): BaseTexture[];
  49557. /**
  49558. * Checks to see if a texture is used in the material.
  49559. * @param texture - Base texture to use.
  49560. * @returns - Boolean specifying if a texture is used in the material.
  49561. */
  49562. hasTexture(texture: BaseTexture): boolean;
  49563. /**
  49564. * Disposes the resources of the material.
  49565. * @param forceDisposeEffect - Forces the disposal of effects.
  49566. * @param forceDisposeTextures - Forces the disposal of all textures.
  49567. */
  49568. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  49569. }
  49570. }
  49571. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  49572. import { Nullable } from "babylonjs/types";
  49573. import { Scene } from "babylonjs/scene";
  49574. import { Color3 } from "babylonjs/Maths/math.color";
  49575. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  49576. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  49577. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49578. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  49579. /**
  49580. * The Physically based material of BJS.
  49581. *
  49582. * This offers the main features of a standard PBR material.
  49583. * For more information, please refer to the documentation :
  49584. * https://doc.babylonjs.com/how_to/physically_based_rendering
  49585. */
  49586. export class PBRMaterial extends PBRBaseMaterial {
  49587. /**
  49588. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  49589. */
  49590. static readonly PBRMATERIAL_OPAQUE: number;
  49591. /**
  49592. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  49593. */
  49594. static readonly PBRMATERIAL_ALPHATEST: number;
  49595. /**
  49596. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49597. */
  49598. static readonly PBRMATERIAL_ALPHABLEND: number;
  49599. /**
  49600. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49601. * They are also discarded below the alpha cutoff threshold to improve performances.
  49602. */
  49603. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  49604. /**
  49605. * Defines the default value of how much AO map is occluding the analytical lights
  49606. * (point spot...).
  49607. */
  49608. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  49609. /**
  49610. * Intensity of the direct lights e.g. the four lights available in your scene.
  49611. * This impacts both the direct diffuse and specular highlights.
  49612. */
  49613. directIntensity: number;
  49614. /**
  49615. * Intensity of the emissive part of the material.
  49616. * This helps controlling the emissive effect without modifying the emissive color.
  49617. */
  49618. emissiveIntensity: number;
  49619. /**
  49620. * Intensity of the environment e.g. how much the environment will light the object
  49621. * either through harmonics for rough material or through the refelction for shiny ones.
  49622. */
  49623. environmentIntensity: number;
  49624. /**
  49625. * This is a special control allowing the reduction of the specular highlights coming from the
  49626. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  49627. */
  49628. specularIntensity: number;
  49629. /**
  49630. * Debug Control allowing disabling the bump map on this material.
  49631. */
  49632. disableBumpMap: boolean;
  49633. /**
  49634. * AKA Diffuse Texture in standard nomenclature.
  49635. */
  49636. albedoTexture: BaseTexture;
  49637. /**
  49638. * AKA Occlusion Texture in other nomenclature.
  49639. */
  49640. ambientTexture: BaseTexture;
  49641. /**
  49642. * AKA Occlusion Texture Intensity in other nomenclature.
  49643. */
  49644. ambientTextureStrength: number;
  49645. /**
  49646. * Defines how much the AO map is occluding the analytical lights (point spot...).
  49647. * 1 means it completely occludes it
  49648. * 0 mean it has no impact
  49649. */
  49650. ambientTextureImpactOnAnalyticalLights: number;
  49651. /**
  49652. * Stores the alpha values in a texture.
  49653. */
  49654. opacityTexture: BaseTexture;
  49655. /**
  49656. * Stores the reflection values in a texture.
  49657. */
  49658. reflectionTexture: Nullable<BaseTexture>;
  49659. /**
  49660. * Stores the emissive values in a texture.
  49661. */
  49662. emissiveTexture: BaseTexture;
  49663. /**
  49664. * AKA Specular texture in other nomenclature.
  49665. */
  49666. reflectivityTexture: BaseTexture;
  49667. /**
  49668. * Used to switch from specular/glossiness to metallic/roughness workflow.
  49669. */
  49670. metallicTexture: BaseTexture;
  49671. /**
  49672. * Specifies the metallic scalar of the metallic/roughness workflow.
  49673. * Can also be used to scale the metalness values of the metallic texture.
  49674. */
  49675. metallic: Nullable<number>;
  49676. /**
  49677. * Specifies the roughness scalar of the metallic/roughness workflow.
  49678. * Can also be used to scale the roughness values of the metallic texture.
  49679. */
  49680. roughness: Nullable<number>;
  49681. /**
  49682. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  49683. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  49684. */
  49685. microSurfaceTexture: BaseTexture;
  49686. /**
  49687. * Stores surface normal data used to displace a mesh in a texture.
  49688. */
  49689. bumpTexture: BaseTexture;
  49690. /**
  49691. * Stores the pre-calculated light information of a mesh in a texture.
  49692. */
  49693. lightmapTexture: BaseTexture;
  49694. /**
  49695. * Stores the refracted light information in a texture.
  49696. */
  49697. refractionTexture: Nullable<BaseTexture>;
  49698. /**
  49699. * The color of a material in ambient lighting.
  49700. */
  49701. ambientColor: Color3;
  49702. /**
  49703. * AKA Diffuse Color in other nomenclature.
  49704. */
  49705. albedoColor: Color3;
  49706. /**
  49707. * AKA Specular Color in other nomenclature.
  49708. */
  49709. reflectivityColor: Color3;
  49710. /**
  49711. * The color reflected from the material.
  49712. */
  49713. reflectionColor: Color3;
  49714. /**
  49715. * The color emitted from the material.
  49716. */
  49717. emissiveColor: Color3;
  49718. /**
  49719. * AKA Glossiness in other nomenclature.
  49720. */
  49721. microSurface: number;
  49722. /**
  49723. * source material index of refraction (IOR)' / 'destination material IOR.
  49724. */
  49725. indexOfRefraction: number;
  49726. /**
  49727. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  49728. */
  49729. invertRefractionY: boolean;
  49730. /**
  49731. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  49732. * Materials half opaque for instance using refraction could benefit from this control.
  49733. */
  49734. linkRefractionWithTransparency: boolean;
  49735. /**
  49736. * If true, the light map contains occlusion information instead of lighting info.
  49737. */
  49738. useLightmapAsShadowmap: boolean;
  49739. /**
  49740. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  49741. */
  49742. useAlphaFromAlbedoTexture: boolean;
  49743. /**
  49744. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  49745. */
  49746. forceAlphaTest: boolean;
  49747. /**
  49748. * Defines the alpha limits in alpha test mode.
  49749. */
  49750. alphaCutOff: number;
  49751. /**
  49752. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  49753. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  49754. */
  49755. useSpecularOverAlpha: boolean;
  49756. /**
  49757. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  49758. */
  49759. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  49760. /**
  49761. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  49762. */
  49763. useRoughnessFromMetallicTextureAlpha: boolean;
  49764. /**
  49765. * Specifies if the metallic texture contains the roughness information in its green channel.
  49766. */
  49767. useRoughnessFromMetallicTextureGreen: boolean;
  49768. /**
  49769. * Specifies if the metallic texture contains the metallness information in its blue channel.
  49770. */
  49771. useMetallnessFromMetallicTextureBlue: boolean;
  49772. /**
  49773. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  49774. */
  49775. useAmbientOcclusionFromMetallicTextureRed: boolean;
  49776. /**
  49777. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  49778. */
  49779. useAmbientInGrayScale: boolean;
  49780. /**
  49781. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  49782. * The material will try to infer what glossiness each pixel should be.
  49783. */
  49784. useAutoMicroSurfaceFromReflectivityMap: boolean;
  49785. /**
  49786. * BJS is using an harcoded light falloff based on a manually sets up range.
  49787. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  49788. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  49789. */
  49790. /**
  49791. * BJS is using an harcoded light falloff based on a manually sets up range.
  49792. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  49793. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  49794. */
  49795. usePhysicalLightFalloff: boolean;
  49796. /**
  49797. * In order to support the falloff compatibility with gltf, a special mode has been added
  49798. * to reproduce the gltf light falloff.
  49799. */
  49800. /**
  49801. * In order to support the falloff compatibility with gltf, a special mode has been added
  49802. * to reproduce the gltf light falloff.
  49803. */
  49804. useGLTFLightFalloff: boolean;
  49805. /**
  49806. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  49807. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  49808. */
  49809. useRadianceOverAlpha: boolean;
  49810. /**
  49811. * Allows using an object space normal map (instead of tangent space).
  49812. */
  49813. useObjectSpaceNormalMap: boolean;
  49814. /**
  49815. * Allows using the bump map in parallax mode.
  49816. */
  49817. useParallax: boolean;
  49818. /**
  49819. * Allows using the bump map in parallax occlusion mode.
  49820. */
  49821. useParallaxOcclusion: boolean;
  49822. /**
  49823. * Controls the scale bias of the parallax mode.
  49824. */
  49825. parallaxScaleBias: number;
  49826. /**
  49827. * If sets to true, disables all the lights affecting the material.
  49828. */
  49829. disableLighting: boolean;
  49830. /**
  49831. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  49832. */
  49833. forceIrradianceInFragment: boolean;
  49834. /**
  49835. * Number of Simultaneous lights allowed on the material.
  49836. */
  49837. maxSimultaneousLights: number;
  49838. /**
  49839. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  49840. */
  49841. invertNormalMapX: boolean;
  49842. /**
  49843. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  49844. */
  49845. invertNormalMapY: boolean;
  49846. /**
  49847. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49848. */
  49849. twoSidedLighting: boolean;
  49850. /**
  49851. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49852. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  49853. */
  49854. useAlphaFresnel: boolean;
  49855. /**
  49856. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49857. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  49858. */
  49859. useLinearAlphaFresnel: boolean;
  49860. /**
  49861. * Let user defines the brdf lookup texture used for IBL.
  49862. * A default 8bit version is embedded but you could point at :
  49863. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  49864. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  49865. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  49866. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  49867. */
  49868. environmentBRDFTexture: Nullable<BaseTexture>;
  49869. /**
  49870. * Force normal to face away from face.
  49871. */
  49872. forceNormalForward: boolean;
  49873. /**
  49874. * Enables specular anti aliasing in the PBR shader.
  49875. * It will both interacts on the Geometry for analytical and IBL lighting.
  49876. * It also prefilter the roughness map based on the bump values.
  49877. */
  49878. enableSpecularAntiAliasing: boolean;
  49879. /**
  49880. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  49881. * makes the reflect vector face the model (under horizon).
  49882. */
  49883. useHorizonOcclusion: boolean;
  49884. /**
  49885. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  49886. * too much the area relying on ambient texture to define their ambient occlusion.
  49887. */
  49888. useRadianceOcclusion: boolean;
  49889. /**
  49890. * If set to true, no lighting calculations will be applied.
  49891. */
  49892. unlit: boolean;
  49893. /**
  49894. * Gets the image processing configuration used either in this material.
  49895. */
  49896. /**
  49897. * Sets the Default image processing configuration used either in the this material.
  49898. *
  49899. * If sets to null, the scene one is in use.
  49900. */
  49901. imageProcessingConfiguration: ImageProcessingConfiguration;
  49902. /**
  49903. * Gets wether the color curves effect is enabled.
  49904. */
  49905. /**
  49906. * Sets wether the color curves effect is enabled.
  49907. */
  49908. cameraColorCurvesEnabled: boolean;
  49909. /**
  49910. * Gets wether the color grading effect is enabled.
  49911. */
  49912. /**
  49913. * Gets wether the color grading effect is enabled.
  49914. */
  49915. cameraColorGradingEnabled: boolean;
  49916. /**
  49917. * Gets wether tonemapping is enabled or not.
  49918. */
  49919. /**
  49920. * Sets wether tonemapping is enabled or not
  49921. */
  49922. cameraToneMappingEnabled: boolean;
  49923. /**
  49924. * The camera exposure used on this material.
  49925. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49926. * This corresponds to a photographic exposure.
  49927. */
  49928. /**
  49929. * The camera exposure used on this material.
  49930. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49931. * This corresponds to a photographic exposure.
  49932. */
  49933. cameraExposure: number;
  49934. /**
  49935. * Gets The camera contrast used on this material.
  49936. */
  49937. /**
  49938. * Sets The camera contrast used on this material.
  49939. */
  49940. cameraContrast: number;
  49941. /**
  49942. * Gets the Color Grading 2D Lookup Texture.
  49943. */
  49944. /**
  49945. * Sets the Color Grading 2D Lookup Texture.
  49946. */
  49947. cameraColorGradingTexture: Nullable<BaseTexture>;
  49948. /**
  49949. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49950. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49951. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  49952. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49953. */
  49954. /**
  49955. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49956. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49957. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  49958. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49959. */
  49960. cameraColorCurves: Nullable<ColorCurves>;
  49961. /**
  49962. * Instantiates a new PBRMaterial instance.
  49963. *
  49964. * @param name The material name
  49965. * @param scene The scene the material will be use in.
  49966. */
  49967. constructor(name: string, scene: Scene);
  49968. /**
  49969. * Returns the name of this material class.
  49970. */
  49971. getClassName(): string;
  49972. /**
  49973. * Makes a duplicate of the current material.
  49974. * @param name - name to use for the new material.
  49975. */
  49976. clone(name: string): PBRMaterial;
  49977. /**
  49978. * Serializes this PBR Material.
  49979. * @returns - An object with the serialized material.
  49980. */
  49981. serialize(): any;
  49982. /**
  49983. * Parses a PBR Material from a serialized object.
  49984. * @param source - Serialized object.
  49985. * @param scene - BJS scene instance.
  49986. * @param rootUrl - url for the scene object
  49987. * @returns - PBRMaterial
  49988. */
  49989. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  49990. }
  49991. }
  49992. declare module "babylonjs/Misc/dds" {
  49993. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49994. import { Engine } from "babylonjs/Engines/engine";
  49995. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49996. import { Nullable } from "babylonjs/types";
  49997. import { Scene } from "babylonjs/scene";
  49998. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  49999. /**
  50000. * Direct draw surface info
  50001. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  50002. */
  50003. export interface DDSInfo {
  50004. /**
  50005. * Width of the texture
  50006. */
  50007. width: number;
  50008. /**
  50009. * Width of the texture
  50010. */
  50011. height: number;
  50012. /**
  50013. * Number of Mipmaps for the texture
  50014. * @see https://en.wikipedia.org/wiki/Mipmap
  50015. */
  50016. mipmapCount: number;
  50017. /**
  50018. * If the textures format is a known fourCC format
  50019. * @see https://www.fourcc.org/
  50020. */
  50021. isFourCC: boolean;
  50022. /**
  50023. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  50024. */
  50025. isRGB: boolean;
  50026. /**
  50027. * If the texture is a lumincance format
  50028. */
  50029. isLuminance: boolean;
  50030. /**
  50031. * If this is a cube texture
  50032. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  50033. */
  50034. isCube: boolean;
  50035. /**
  50036. * If the texture is a compressed format eg. FOURCC_DXT1
  50037. */
  50038. isCompressed: boolean;
  50039. /**
  50040. * The dxgiFormat of the texture
  50041. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  50042. */
  50043. dxgiFormat: number;
  50044. /**
  50045. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  50046. */
  50047. textureType: number;
  50048. /**
  50049. * Sphericle polynomial created for the dds texture
  50050. */
  50051. sphericalPolynomial?: SphericalPolynomial;
  50052. }
  50053. /**
  50054. * Class used to provide DDS decompression tools
  50055. */
  50056. export class DDSTools {
  50057. /**
  50058. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  50059. */
  50060. static StoreLODInAlphaChannel: boolean;
  50061. /**
  50062. * Gets DDS information from an array buffer
  50063. * @param arrayBuffer defines the array buffer to read data from
  50064. * @returns the DDS information
  50065. */
  50066. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  50067. private static _FloatView;
  50068. private static _Int32View;
  50069. private static _ToHalfFloat;
  50070. private static _FromHalfFloat;
  50071. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  50072. private static _GetHalfFloatRGBAArrayBuffer;
  50073. private static _GetFloatRGBAArrayBuffer;
  50074. private static _GetFloatAsUIntRGBAArrayBuffer;
  50075. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  50076. private static _GetRGBAArrayBuffer;
  50077. private static _ExtractLongWordOrder;
  50078. private static _GetRGBArrayBuffer;
  50079. private static _GetLuminanceArrayBuffer;
  50080. /**
  50081. * Uploads DDS Levels to a Babylon Texture
  50082. * @hidden
  50083. */
  50084. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  50085. }
  50086. module "babylonjs/Engines/engine" {
  50087. interface Engine {
  50088. /**
  50089. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  50090. * @param rootUrl defines the url where the file to load is located
  50091. * @param scene defines the current scene
  50092. * @param lodScale defines scale to apply to the mip map selection
  50093. * @param lodOffset defines offset to apply to the mip map selection
  50094. * @param onLoad defines an optional callback raised when the texture is loaded
  50095. * @param onError defines an optional callback raised if there is an issue to load the texture
  50096. * @param format defines the format of the data
  50097. * @param forcedExtension defines the extension to use to pick the right loader
  50098. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  50099. * @returns the cube texture as an InternalTexture
  50100. */
  50101. createPrefilteredCubeTexture(rootUrl: string, scene: Nullable<Scene>, lodScale: number, lodOffset: number, onLoad?: Nullable<(internalTexture: Nullable<InternalTexture>) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean): InternalTexture;
  50102. }
  50103. }
  50104. }
  50105. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  50106. import { Nullable } from "babylonjs/types";
  50107. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50108. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50109. /**
  50110. * Implementation of the DDS Texture Loader.
  50111. * @hidden
  50112. */
  50113. export class _DDSTextureLoader implements IInternalTextureLoader {
  50114. /**
  50115. * Defines wether the loader supports cascade loading the different faces.
  50116. */
  50117. readonly supportCascades: boolean;
  50118. /**
  50119. * This returns if the loader support the current file information.
  50120. * @param extension defines the file extension of the file being loaded
  50121. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50122. * @param fallback defines the fallback internal texture if any
  50123. * @param isBase64 defines whether the texture is encoded as a base64
  50124. * @param isBuffer defines whether the texture data are stored as a buffer
  50125. * @returns true if the loader can load the specified file
  50126. */
  50127. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50128. /**
  50129. * Transform the url before loading if required.
  50130. * @param rootUrl the url of the texture
  50131. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50132. * @returns the transformed texture
  50133. */
  50134. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50135. /**
  50136. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50137. * @param rootUrl the url of the texture
  50138. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50139. * @returns the fallback texture
  50140. */
  50141. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50142. /**
  50143. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50144. * @param data contains the texture data
  50145. * @param texture defines the BabylonJS internal texture
  50146. * @param createPolynomials will be true if polynomials have been requested
  50147. * @param onLoad defines the callback to trigger once the texture is ready
  50148. * @param onError defines the callback to trigger in case of error
  50149. */
  50150. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50151. /**
  50152. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50153. * @param data contains the texture data
  50154. * @param texture defines the BabylonJS internal texture
  50155. * @param callback defines the method to call once ready to upload
  50156. */
  50157. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50158. }
  50159. }
  50160. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  50161. import { Nullable } from "babylonjs/types";
  50162. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50163. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50164. /**
  50165. * Implementation of the ENV Texture Loader.
  50166. * @hidden
  50167. */
  50168. export class _ENVTextureLoader implements IInternalTextureLoader {
  50169. /**
  50170. * Defines wether the loader supports cascade loading the different faces.
  50171. */
  50172. readonly supportCascades: boolean;
  50173. /**
  50174. * This returns if the loader support the current file information.
  50175. * @param extension defines the file extension of the file being loaded
  50176. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50177. * @param fallback defines the fallback internal texture if any
  50178. * @param isBase64 defines whether the texture is encoded as a base64
  50179. * @param isBuffer defines whether the texture data are stored as a buffer
  50180. * @returns true if the loader can load the specified file
  50181. */
  50182. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50183. /**
  50184. * Transform the url before loading if required.
  50185. * @param rootUrl the url of the texture
  50186. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50187. * @returns the transformed texture
  50188. */
  50189. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50190. /**
  50191. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50192. * @param rootUrl the url of the texture
  50193. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50194. * @returns the fallback texture
  50195. */
  50196. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50197. /**
  50198. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50199. * @param data contains the texture data
  50200. * @param texture defines the BabylonJS internal texture
  50201. * @param createPolynomials will be true if polynomials have been requested
  50202. * @param onLoad defines the callback to trigger once the texture is ready
  50203. * @param onError defines the callback to trigger in case of error
  50204. */
  50205. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50206. /**
  50207. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50208. * @param data contains the texture data
  50209. * @param texture defines the BabylonJS internal texture
  50210. * @param callback defines the method to call once ready to upload
  50211. */
  50212. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50213. }
  50214. }
  50215. declare module "babylonjs/Misc/khronosTextureContainer" {
  50216. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50217. /**
  50218. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  50219. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  50220. */
  50221. export class KhronosTextureContainer {
  50222. /** contents of the KTX container file */
  50223. arrayBuffer: any;
  50224. private static HEADER_LEN;
  50225. private static COMPRESSED_2D;
  50226. private static COMPRESSED_3D;
  50227. private static TEX_2D;
  50228. private static TEX_3D;
  50229. /**
  50230. * Gets the openGL type
  50231. */
  50232. glType: number;
  50233. /**
  50234. * Gets the openGL type size
  50235. */
  50236. glTypeSize: number;
  50237. /**
  50238. * Gets the openGL format
  50239. */
  50240. glFormat: number;
  50241. /**
  50242. * Gets the openGL internal format
  50243. */
  50244. glInternalFormat: number;
  50245. /**
  50246. * Gets the base internal format
  50247. */
  50248. glBaseInternalFormat: number;
  50249. /**
  50250. * Gets image width in pixel
  50251. */
  50252. pixelWidth: number;
  50253. /**
  50254. * Gets image height in pixel
  50255. */
  50256. pixelHeight: number;
  50257. /**
  50258. * Gets image depth in pixels
  50259. */
  50260. pixelDepth: number;
  50261. /**
  50262. * Gets the number of array elements
  50263. */
  50264. numberOfArrayElements: number;
  50265. /**
  50266. * Gets the number of faces
  50267. */
  50268. numberOfFaces: number;
  50269. /**
  50270. * Gets the number of mipmap levels
  50271. */
  50272. numberOfMipmapLevels: number;
  50273. /**
  50274. * Gets the bytes of key value data
  50275. */
  50276. bytesOfKeyValueData: number;
  50277. /**
  50278. * Gets the load type
  50279. */
  50280. loadType: number;
  50281. /**
  50282. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  50283. */
  50284. isInvalid: boolean;
  50285. /**
  50286. * Creates a new KhronosTextureContainer
  50287. * @param arrayBuffer contents of the KTX container file
  50288. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  50289. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  50290. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  50291. */
  50292. constructor(
  50293. /** contents of the KTX container file */
  50294. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  50295. /**
  50296. * Uploads KTX content to a Babylon Texture.
  50297. * It is assumed that the texture has already been created & is currently bound
  50298. * @hidden
  50299. */
  50300. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  50301. private _upload2DCompressedLevels;
  50302. }
  50303. }
  50304. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  50305. import { Nullable } from "babylonjs/types";
  50306. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50307. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50308. /**
  50309. * Implementation of the KTX Texture Loader.
  50310. * @hidden
  50311. */
  50312. export class _KTXTextureLoader implements IInternalTextureLoader {
  50313. /**
  50314. * Defines wether the loader supports cascade loading the different faces.
  50315. */
  50316. readonly supportCascades: boolean;
  50317. /**
  50318. * This returns if the loader support the current file information.
  50319. * @param extension defines the file extension of the file being loaded
  50320. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50321. * @param fallback defines the fallback internal texture if any
  50322. * @param isBase64 defines whether the texture is encoded as a base64
  50323. * @param isBuffer defines whether the texture data are stored as a buffer
  50324. * @returns true if the loader can load the specified file
  50325. */
  50326. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50327. /**
  50328. * Transform the url before loading if required.
  50329. * @param rootUrl the url of the texture
  50330. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50331. * @returns the transformed texture
  50332. */
  50333. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50334. /**
  50335. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50336. * @param rootUrl the url of the texture
  50337. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50338. * @returns the fallback texture
  50339. */
  50340. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50341. /**
  50342. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50343. * @param data contains the texture data
  50344. * @param texture defines the BabylonJS internal texture
  50345. * @param createPolynomials will be true if polynomials have been requested
  50346. * @param onLoad defines the callback to trigger once the texture is ready
  50347. * @param onError defines the callback to trigger in case of error
  50348. */
  50349. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50350. /**
  50351. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50352. * @param data contains the texture data
  50353. * @param texture defines the BabylonJS internal texture
  50354. * @param callback defines the method to call once ready to upload
  50355. */
  50356. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  50357. }
  50358. }
  50359. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  50360. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  50361. import { Scene } from "babylonjs/scene";
  50362. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  50363. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  50364. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  50365. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  50366. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  50367. import { WebXREnterExitUI } from "babylonjs/Cameras/XR/webXREnterExitUI";
  50368. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50369. /**
  50370. * Options for the default xr helper
  50371. */
  50372. export class WebXRDefaultExperienceOptions {
  50373. /**
  50374. * Floor meshes that should be used for teleporting
  50375. */
  50376. floorMeshes: Array<AbstractMesh>;
  50377. }
  50378. /**
  50379. * Default experience which provides a similar setup to the previous webVRExperience
  50380. */
  50381. export class WebXRDefaultExperience {
  50382. /**
  50383. * Base experience
  50384. */
  50385. baseExperience: WebXRExperienceHelper;
  50386. /**
  50387. * Input experience extension
  50388. */
  50389. input: WebXRInput;
  50390. /**
  50391. * Loads the controller models
  50392. */
  50393. controllerModelLoader: WebXRControllerModelLoader;
  50394. /**
  50395. * Enables laser pointer and selection
  50396. */
  50397. pointerSelection: WebXRControllerPointerSelection;
  50398. /**
  50399. * Enables teleportation
  50400. */
  50401. teleportation: WebXRControllerTeleportation;
  50402. /**
  50403. * Enables ui for enetering/exiting xr
  50404. */
  50405. enterExitUI: WebXREnterExitUI;
  50406. /**
  50407. * Default output canvas xr should render to
  50408. */
  50409. outputCanvas: WebXRManagedOutputCanvas;
  50410. /**
  50411. * Creates the default xr experience
  50412. * @param scene scene
  50413. * @param options options for basic configuration
  50414. * @returns resulting WebXRDefaultExperience
  50415. */
  50416. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  50417. private constructor();
  50418. /**
  50419. * DIsposes of the experience helper
  50420. */
  50421. dispose(): void;
  50422. }
  50423. }
  50424. declare module "babylonjs/Helpers/sceneHelpers" {
  50425. import { Nullable } from "babylonjs/types";
  50426. import { Mesh } from "babylonjs/Meshes/mesh";
  50427. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50428. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  50429. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  50430. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  50431. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  50432. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  50433. import "babylonjs/Meshes/Builders/boxBuilder";
  50434. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  50435. /** @hidden */
  50436. export var _forceSceneHelpersToBundle: boolean;
  50437. module "babylonjs/scene" {
  50438. interface Scene {
  50439. /**
  50440. * Creates a default light for the scene.
  50441. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  50442. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  50443. */
  50444. createDefaultLight(replace?: boolean): void;
  50445. /**
  50446. * Creates a default camera for the scene.
  50447. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  50448. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  50449. * @param replace has default false, when true replaces the active camera in the scene
  50450. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  50451. */
  50452. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  50453. /**
  50454. * Creates a default camera and a default light.
  50455. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  50456. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  50457. * @param replace has the default false, when true replaces the active camera/light in the scene
  50458. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  50459. */
  50460. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  50461. /**
  50462. * Creates a new sky box
  50463. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  50464. * @param environmentTexture defines the texture to use as environment texture
  50465. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  50466. * @param scale defines the overall scale of the skybox
  50467. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  50468. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  50469. * @returns a new mesh holding the sky box
  50470. */
  50471. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  50472. /**
  50473. * Creates a new environment
  50474. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  50475. * @param options defines the options you can use to configure the environment
  50476. * @returns the new EnvironmentHelper
  50477. */
  50478. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  50479. /**
  50480. * Creates a new VREXperienceHelper
  50481. * @see http://doc.babylonjs.com/how_to/webvr_helper
  50482. * @param webVROptions defines the options used to create the new VREXperienceHelper
  50483. * @returns a new VREXperienceHelper
  50484. */
  50485. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  50486. /**
  50487. * Creates a new WebXRDefaultExperience
  50488. * @see http://doc.babylonjs.com/how_to/webxr
  50489. * @param options experience options
  50490. * @returns a promise for a new WebXRDefaultExperience
  50491. */
  50492. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  50493. }
  50494. }
  50495. }
  50496. declare module "babylonjs/Helpers/videoDome" {
  50497. import { Scene } from "babylonjs/scene";
  50498. import { TransformNode } from "babylonjs/Meshes/transformNode";
  50499. import { Mesh } from "babylonjs/Meshes/mesh";
  50500. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  50501. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  50502. import "babylonjs/Meshes/Builders/sphereBuilder";
  50503. /**
  50504. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  50505. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  50506. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  50507. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  50508. */
  50509. export class VideoDome extends TransformNode {
  50510. /**
  50511. * Define the video source as a Monoscopic panoramic 360 video.
  50512. */
  50513. static readonly MODE_MONOSCOPIC: number;
  50514. /**
  50515. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  50516. */
  50517. static readonly MODE_TOPBOTTOM: number;
  50518. /**
  50519. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  50520. */
  50521. static readonly MODE_SIDEBYSIDE: number;
  50522. private _halfDome;
  50523. private _useDirectMapping;
  50524. /**
  50525. * The video texture being displayed on the sphere
  50526. */
  50527. protected _videoTexture: VideoTexture;
  50528. /**
  50529. * Gets the video texture being displayed on the sphere
  50530. */
  50531. readonly videoTexture: VideoTexture;
  50532. /**
  50533. * The skybox material
  50534. */
  50535. protected _material: BackgroundMaterial;
  50536. /**
  50537. * The surface used for the skybox
  50538. */
  50539. protected _mesh: Mesh;
  50540. /**
  50541. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  50542. */
  50543. private _halfDomeMask;
  50544. /**
  50545. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50546. * Also see the options.resolution property.
  50547. */
  50548. fovMultiplier: number;
  50549. private _videoMode;
  50550. /**
  50551. * Gets or set the current video mode for the video. It can be:
  50552. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  50553. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  50554. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  50555. */
  50556. videoMode: number;
  50557. /**
  50558. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  50559. *
  50560. */
  50561. /**
  50562. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  50563. */
  50564. halfDome: boolean;
  50565. /**
  50566. * Oberserver used in Stereoscopic VR Mode.
  50567. */
  50568. private _onBeforeCameraRenderObserver;
  50569. /**
  50570. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  50571. * @param name Element's name, child elements will append suffixes for their own names.
  50572. * @param urlsOrVideo defines the url(s) or the video element to use
  50573. * @param options An object containing optional or exposed sub element properties
  50574. */
  50575. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  50576. resolution?: number;
  50577. clickToPlay?: boolean;
  50578. autoPlay?: boolean;
  50579. loop?: boolean;
  50580. size?: number;
  50581. poster?: string;
  50582. faceForward?: boolean;
  50583. useDirectMapping?: boolean;
  50584. halfDomeMode?: boolean;
  50585. }, scene: Scene);
  50586. private _changeVideoMode;
  50587. /**
  50588. * Releases resources associated with this node.
  50589. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  50590. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  50591. */
  50592. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  50593. }
  50594. }
  50595. declare module "babylonjs/Helpers/index" {
  50596. export * from "babylonjs/Helpers/environmentHelper";
  50597. export * from "babylonjs/Helpers/photoDome";
  50598. export * from "babylonjs/Helpers/sceneHelpers";
  50599. export * from "babylonjs/Helpers/videoDome";
  50600. }
  50601. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  50602. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  50603. import { IDisposable } from "babylonjs/scene";
  50604. import { Engine } from "babylonjs/Engines/engine";
  50605. /**
  50606. * This class can be used to get instrumentation data from a Babylon engine
  50607. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  50608. */
  50609. export class EngineInstrumentation implements IDisposable {
  50610. /**
  50611. * Define the instrumented engine.
  50612. */
  50613. engine: Engine;
  50614. private _captureGPUFrameTime;
  50615. private _gpuFrameTimeToken;
  50616. private _gpuFrameTime;
  50617. private _captureShaderCompilationTime;
  50618. private _shaderCompilationTime;
  50619. private _onBeginFrameObserver;
  50620. private _onEndFrameObserver;
  50621. private _onBeforeShaderCompilationObserver;
  50622. private _onAfterShaderCompilationObserver;
  50623. /**
  50624. * Gets the perf counter used for GPU frame time
  50625. */
  50626. readonly gpuFrameTimeCounter: PerfCounter;
  50627. /**
  50628. * Gets the GPU frame time capture status
  50629. */
  50630. /**
  50631. * Enable or disable the GPU frame time capture
  50632. */
  50633. captureGPUFrameTime: boolean;
  50634. /**
  50635. * Gets the perf counter used for shader compilation time
  50636. */
  50637. readonly shaderCompilationTimeCounter: PerfCounter;
  50638. /**
  50639. * Gets the shader compilation time capture status
  50640. */
  50641. /**
  50642. * Enable or disable the shader compilation time capture
  50643. */
  50644. captureShaderCompilationTime: boolean;
  50645. /**
  50646. * Instantiates a new engine instrumentation.
  50647. * This class can be used to get instrumentation data from a Babylon engine
  50648. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  50649. * @param engine Defines the engine to instrument
  50650. */
  50651. constructor(
  50652. /**
  50653. * Define the instrumented engine.
  50654. */
  50655. engine: Engine);
  50656. /**
  50657. * Dispose and release associated resources.
  50658. */
  50659. dispose(): void;
  50660. }
  50661. }
  50662. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  50663. import { Scene, IDisposable } from "babylonjs/scene";
  50664. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  50665. /**
  50666. * This class can be used to get instrumentation data from a Babylon engine
  50667. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  50668. */
  50669. export class SceneInstrumentation implements IDisposable {
  50670. /**
  50671. * Defines the scene to instrument
  50672. */
  50673. scene: Scene;
  50674. private _captureActiveMeshesEvaluationTime;
  50675. private _activeMeshesEvaluationTime;
  50676. private _captureRenderTargetsRenderTime;
  50677. private _renderTargetsRenderTime;
  50678. private _captureFrameTime;
  50679. private _frameTime;
  50680. private _captureRenderTime;
  50681. private _renderTime;
  50682. private _captureInterFrameTime;
  50683. private _interFrameTime;
  50684. private _captureParticlesRenderTime;
  50685. private _particlesRenderTime;
  50686. private _captureSpritesRenderTime;
  50687. private _spritesRenderTime;
  50688. private _capturePhysicsTime;
  50689. private _physicsTime;
  50690. private _captureAnimationsTime;
  50691. private _animationsTime;
  50692. private _captureCameraRenderTime;
  50693. private _cameraRenderTime;
  50694. private _onBeforeActiveMeshesEvaluationObserver;
  50695. private _onAfterActiveMeshesEvaluationObserver;
  50696. private _onBeforeRenderTargetsRenderObserver;
  50697. private _onAfterRenderTargetsRenderObserver;
  50698. private _onAfterRenderObserver;
  50699. private _onBeforeDrawPhaseObserver;
  50700. private _onAfterDrawPhaseObserver;
  50701. private _onBeforeAnimationsObserver;
  50702. private _onBeforeParticlesRenderingObserver;
  50703. private _onAfterParticlesRenderingObserver;
  50704. private _onBeforeSpritesRenderingObserver;
  50705. private _onAfterSpritesRenderingObserver;
  50706. private _onBeforePhysicsObserver;
  50707. private _onAfterPhysicsObserver;
  50708. private _onAfterAnimationsObserver;
  50709. private _onBeforeCameraRenderObserver;
  50710. private _onAfterCameraRenderObserver;
  50711. /**
  50712. * Gets the perf counter used for active meshes evaluation time
  50713. */
  50714. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  50715. /**
  50716. * Gets the active meshes evaluation time capture status
  50717. */
  50718. /**
  50719. * Enable or disable the active meshes evaluation time capture
  50720. */
  50721. captureActiveMeshesEvaluationTime: boolean;
  50722. /**
  50723. * Gets the perf counter used for render targets render time
  50724. */
  50725. readonly renderTargetsRenderTimeCounter: PerfCounter;
  50726. /**
  50727. * Gets the render targets render time capture status
  50728. */
  50729. /**
  50730. * Enable or disable the render targets render time capture
  50731. */
  50732. captureRenderTargetsRenderTime: boolean;
  50733. /**
  50734. * Gets the perf counter used for particles render time
  50735. */
  50736. readonly particlesRenderTimeCounter: PerfCounter;
  50737. /**
  50738. * Gets the particles render time capture status
  50739. */
  50740. /**
  50741. * Enable or disable the particles render time capture
  50742. */
  50743. captureParticlesRenderTime: boolean;
  50744. /**
  50745. * Gets the perf counter used for sprites render time
  50746. */
  50747. readonly spritesRenderTimeCounter: PerfCounter;
  50748. /**
  50749. * Gets the sprites render time capture status
  50750. */
  50751. /**
  50752. * Enable or disable the sprites render time capture
  50753. */
  50754. captureSpritesRenderTime: boolean;
  50755. /**
  50756. * Gets the perf counter used for physics time
  50757. */
  50758. readonly physicsTimeCounter: PerfCounter;
  50759. /**
  50760. * Gets the physics time capture status
  50761. */
  50762. /**
  50763. * Enable or disable the physics time capture
  50764. */
  50765. capturePhysicsTime: boolean;
  50766. /**
  50767. * Gets the perf counter used for animations time
  50768. */
  50769. readonly animationsTimeCounter: PerfCounter;
  50770. /**
  50771. * Gets the animations time capture status
  50772. */
  50773. /**
  50774. * Enable or disable the animations time capture
  50775. */
  50776. captureAnimationsTime: boolean;
  50777. /**
  50778. * Gets the perf counter used for frame time capture
  50779. */
  50780. readonly frameTimeCounter: PerfCounter;
  50781. /**
  50782. * Gets the frame time capture status
  50783. */
  50784. /**
  50785. * Enable or disable the frame time capture
  50786. */
  50787. captureFrameTime: boolean;
  50788. /**
  50789. * Gets the perf counter used for inter-frames time capture
  50790. */
  50791. readonly interFrameTimeCounter: PerfCounter;
  50792. /**
  50793. * Gets the inter-frames time capture status
  50794. */
  50795. /**
  50796. * Enable or disable the inter-frames time capture
  50797. */
  50798. captureInterFrameTime: boolean;
  50799. /**
  50800. * Gets the perf counter used for render time capture
  50801. */
  50802. readonly renderTimeCounter: PerfCounter;
  50803. /**
  50804. * Gets the render time capture status
  50805. */
  50806. /**
  50807. * Enable or disable the render time capture
  50808. */
  50809. captureRenderTime: boolean;
  50810. /**
  50811. * Gets the perf counter used for camera render time capture
  50812. */
  50813. readonly cameraRenderTimeCounter: PerfCounter;
  50814. /**
  50815. * Gets the camera render time capture status
  50816. */
  50817. /**
  50818. * Enable or disable the camera render time capture
  50819. */
  50820. captureCameraRenderTime: boolean;
  50821. /**
  50822. * Gets the perf counter used for draw calls
  50823. */
  50824. readonly drawCallsCounter: PerfCounter;
  50825. /**
  50826. * Instantiates a new scene instrumentation.
  50827. * This class can be used to get instrumentation data from a Babylon engine
  50828. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  50829. * @param scene Defines the scene to instrument
  50830. */
  50831. constructor(
  50832. /**
  50833. * Defines the scene to instrument
  50834. */
  50835. scene: Scene);
  50836. /**
  50837. * Dispose and release associated resources.
  50838. */
  50839. dispose(): void;
  50840. }
  50841. }
  50842. declare module "babylonjs/Instrumentation/index" {
  50843. export * from "babylonjs/Instrumentation/engineInstrumentation";
  50844. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  50845. export * from "babylonjs/Instrumentation/timeToken";
  50846. }
  50847. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  50848. /** @hidden */
  50849. export var glowMapGenerationPixelShader: {
  50850. name: string;
  50851. shader: string;
  50852. };
  50853. }
  50854. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  50855. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  50856. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  50857. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  50858. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  50859. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  50860. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  50861. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  50862. /** @hidden */
  50863. export var glowMapGenerationVertexShader: {
  50864. name: string;
  50865. shader: string;
  50866. };
  50867. }
  50868. declare module "babylonjs/Layers/effectLayer" {
  50869. import { Observable } from "babylonjs/Misc/observable";
  50870. import { Nullable } from "babylonjs/types";
  50871. import { Camera } from "babylonjs/Cameras/camera";
  50872. import { Scene } from "babylonjs/scene";
  50873. import { ISize } from "babylonjs/Maths/math.size";
  50874. import { Color4 } from "babylonjs/Maths/math.color";
  50875. import { Engine } from "babylonjs/Engines/engine";
  50876. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50877. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50878. import { Mesh } from "babylonjs/Meshes/mesh";
  50879. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  50880. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50881. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50882. import { Effect } from "babylonjs/Materials/effect";
  50883. import { Material } from "babylonjs/Materials/material";
  50884. import "babylonjs/Shaders/glowMapGeneration.fragment";
  50885. import "babylonjs/Shaders/glowMapGeneration.vertex";
  50886. /**
  50887. * Effect layer options. This helps customizing the behaviour
  50888. * of the effect layer.
  50889. */
  50890. export interface IEffectLayerOptions {
  50891. /**
  50892. * Multiplication factor apply to the canvas size to compute the render target size
  50893. * used to generated the objects (the smaller the faster).
  50894. */
  50895. mainTextureRatio: number;
  50896. /**
  50897. * Enforces a fixed size texture to ensure effect stability across devices.
  50898. */
  50899. mainTextureFixedSize?: number;
  50900. /**
  50901. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  50902. */
  50903. alphaBlendingMode: number;
  50904. /**
  50905. * The camera attached to the layer.
  50906. */
  50907. camera: Nullable<Camera>;
  50908. /**
  50909. * The rendering group to draw the layer in.
  50910. */
  50911. renderingGroupId: number;
  50912. }
  50913. /**
  50914. * The effect layer Helps adding post process effect blended with the main pass.
  50915. *
  50916. * This can be for instance use to generate glow or higlight effects on the scene.
  50917. *
  50918. * The effect layer class can not be used directly and is intented to inherited from to be
  50919. * customized per effects.
  50920. */
  50921. export abstract class EffectLayer {
  50922. private _vertexBuffers;
  50923. private _indexBuffer;
  50924. private _cachedDefines;
  50925. private _effectLayerMapGenerationEffect;
  50926. private _effectLayerOptions;
  50927. private _mergeEffect;
  50928. protected _scene: Scene;
  50929. protected _engine: Engine;
  50930. protected _maxSize: number;
  50931. protected _mainTextureDesiredSize: ISize;
  50932. protected _mainTexture: RenderTargetTexture;
  50933. protected _shouldRender: boolean;
  50934. protected _postProcesses: PostProcess[];
  50935. protected _textures: BaseTexture[];
  50936. protected _emissiveTextureAndColor: {
  50937. texture: Nullable<BaseTexture>;
  50938. color: Color4;
  50939. };
  50940. /**
  50941. * The name of the layer
  50942. */
  50943. name: string;
  50944. /**
  50945. * The clear color of the texture used to generate the glow map.
  50946. */
  50947. neutralColor: Color4;
  50948. /**
  50949. * Specifies wether the highlight layer is enabled or not.
  50950. */
  50951. isEnabled: boolean;
  50952. /**
  50953. * Gets the camera attached to the layer.
  50954. */
  50955. readonly camera: Nullable<Camera>;
  50956. /**
  50957. * Gets the rendering group id the layer should render in.
  50958. */
  50959. renderingGroupId: number;
  50960. /**
  50961. * An event triggered when the effect layer has been disposed.
  50962. */
  50963. onDisposeObservable: Observable<EffectLayer>;
  50964. /**
  50965. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  50966. */
  50967. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  50968. /**
  50969. * An event triggered when the generated texture is being merged in the scene.
  50970. */
  50971. onBeforeComposeObservable: Observable<EffectLayer>;
  50972. /**
  50973. * An event triggered when the generated texture has been merged in the scene.
  50974. */
  50975. onAfterComposeObservable: Observable<EffectLayer>;
  50976. /**
  50977. * An event triggered when the efffect layer changes its size.
  50978. */
  50979. onSizeChangedObservable: Observable<EffectLayer>;
  50980. /** @hidden */
  50981. static _SceneComponentInitialization: (scene: Scene) => void;
  50982. /**
  50983. * Instantiates a new effect Layer and references it in the scene.
  50984. * @param name The name of the layer
  50985. * @param scene The scene to use the layer in
  50986. */
  50987. constructor(
  50988. /** The Friendly of the effect in the scene */
  50989. name: string, scene: Scene);
  50990. /**
  50991. * Get the effect name of the layer.
  50992. * @return The effect name
  50993. */
  50994. abstract getEffectName(): string;
  50995. /**
  50996. * Checks for the readiness of the element composing the layer.
  50997. * @param subMesh the mesh to check for
  50998. * @param useInstances specify wether or not to use instances to render the mesh
  50999. * @return true if ready otherwise, false
  51000. */
  51001. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51002. /**
  51003. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51004. * @returns true if the effect requires stencil during the main canvas render pass.
  51005. */
  51006. abstract needStencil(): boolean;
  51007. /**
  51008. * Create the merge effect. This is the shader use to blit the information back
  51009. * to the main canvas at the end of the scene rendering.
  51010. * @returns The effect containing the shader used to merge the effect on the main canvas
  51011. */
  51012. protected abstract _createMergeEffect(): Effect;
  51013. /**
  51014. * Creates the render target textures and post processes used in the effect layer.
  51015. */
  51016. protected abstract _createTextureAndPostProcesses(): void;
  51017. /**
  51018. * Implementation specific of rendering the generating effect on the main canvas.
  51019. * @param effect The effect used to render through
  51020. */
  51021. protected abstract _internalRender(effect: Effect): void;
  51022. /**
  51023. * Sets the required values for both the emissive texture and and the main color.
  51024. */
  51025. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51026. /**
  51027. * Free any resources and references associated to a mesh.
  51028. * Internal use
  51029. * @param mesh The mesh to free.
  51030. */
  51031. abstract _disposeMesh(mesh: Mesh): void;
  51032. /**
  51033. * Serializes this layer (Glow or Highlight for example)
  51034. * @returns a serialized layer object
  51035. */
  51036. abstract serialize?(): any;
  51037. /**
  51038. * Initializes the effect layer with the required options.
  51039. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  51040. */
  51041. protected _init(options: Partial<IEffectLayerOptions>): void;
  51042. /**
  51043. * Generates the index buffer of the full screen quad blending to the main canvas.
  51044. */
  51045. private _generateIndexBuffer;
  51046. /**
  51047. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  51048. */
  51049. private _generateVertexBuffer;
  51050. /**
  51051. * Sets the main texture desired size which is the closest power of two
  51052. * of the engine canvas size.
  51053. */
  51054. private _setMainTextureSize;
  51055. /**
  51056. * Creates the main texture for the effect layer.
  51057. */
  51058. protected _createMainTexture(): void;
  51059. /**
  51060. * Adds specific effects defines.
  51061. * @param defines The defines to add specifics to.
  51062. */
  51063. protected _addCustomEffectDefines(defines: string[]): void;
  51064. /**
  51065. * Checks for the readiness of the element composing the layer.
  51066. * @param subMesh the mesh to check for
  51067. * @param useInstances specify wether or not to use instances to render the mesh
  51068. * @param emissiveTexture the associated emissive texture used to generate the glow
  51069. * @return true if ready otherwise, false
  51070. */
  51071. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  51072. /**
  51073. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  51074. */
  51075. render(): void;
  51076. /**
  51077. * Determine if a given mesh will be used in the current effect.
  51078. * @param mesh mesh to test
  51079. * @returns true if the mesh will be used
  51080. */
  51081. hasMesh(mesh: AbstractMesh): boolean;
  51082. /**
  51083. * Returns true if the layer contains information to display, otherwise false.
  51084. * @returns true if the glow layer should be rendered
  51085. */
  51086. shouldRender(): boolean;
  51087. /**
  51088. * Returns true if the mesh should render, otherwise false.
  51089. * @param mesh The mesh to render
  51090. * @returns true if it should render otherwise false
  51091. */
  51092. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  51093. /**
  51094. * Returns true if the mesh can be rendered, otherwise false.
  51095. * @param mesh The mesh to render
  51096. * @param material The material used on the mesh
  51097. * @returns true if it can be rendered otherwise false
  51098. */
  51099. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51100. /**
  51101. * Returns true if the mesh should render, otherwise false.
  51102. * @param mesh The mesh to render
  51103. * @returns true if it should render otherwise false
  51104. */
  51105. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  51106. /**
  51107. * Renders the submesh passed in parameter to the generation map.
  51108. */
  51109. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  51110. /**
  51111. * Rebuild the required buffers.
  51112. * @hidden Internal use only.
  51113. */
  51114. _rebuild(): void;
  51115. /**
  51116. * Dispose only the render target textures and post process.
  51117. */
  51118. private _disposeTextureAndPostProcesses;
  51119. /**
  51120. * Dispose the highlight layer and free resources.
  51121. */
  51122. dispose(): void;
  51123. /**
  51124. * Gets the class name of the effect layer
  51125. * @returns the string with the class name of the effect layer
  51126. */
  51127. getClassName(): string;
  51128. /**
  51129. * Creates an effect layer from parsed effect layer data
  51130. * @param parsedEffectLayer defines effect layer data
  51131. * @param scene defines the current scene
  51132. * @param rootUrl defines the root URL containing the effect layer information
  51133. * @returns a parsed effect Layer
  51134. */
  51135. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  51136. }
  51137. }
  51138. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  51139. import { Scene } from "babylonjs/scene";
  51140. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  51141. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51142. import { AbstractScene } from "babylonjs/abstractScene";
  51143. module "babylonjs/abstractScene" {
  51144. interface AbstractScene {
  51145. /**
  51146. * The list of effect layers (highlights/glow) added to the scene
  51147. * @see http://doc.babylonjs.com/how_to/highlight_layer
  51148. * @see http://doc.babylonjs.com/how_to/glow_layer
  51149. */
  51150. effectLayers: Array<EffectLayer>;
  51151. /**
  51152. * Removes the given effect layer from this scene.
  51153. * @param toRemove defines the effect layer to remove
  51154. * @returns the index of the removed effect layer
  51155. */
  51156. removeEffectLayer(toRemove: EffectLayer): number;
  51157. /**
  51158. * Adds the given effect layer to this scene
  51159. * @param newEffectLayer defines the effect layer to add
  51160. */
  51161. addEffectLayer(newEffectLayer: EffectLayer): void;
  51162. }
  51163. }
  51164. /**
  51165. * Defines the layer scene component responsible to manage any effect layers
  51166. * in a given scene.
  51167. */
  51168. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  51169. /**
  51170. * The component name helpfull to identify the component in the list of scene components.
  51171. */
  51172. readonly name: string;
  51173. /**
  51174. * The scene the component belongs to.
  51175. */
  51176. scene: Scene;
  51177. private _engine;
  51178. private _renderEffects;
  51179. private _needStencil;
  51180. private _previousStencilState;
  51181. /**
  51182. * Creates a new instance of the component for the given scene
  51183. * @param scene Defines the scene to register the component in
  51184. */
  51185. constructor(scene: Scene);
  51186. /**
  51187. * Registers the component in a given scene
  51188. */
  51189. register(): void;
  51190. /**
  51191. * Rebuilds the elements related to this component in case of
  51192. * context lost for instance.
  51193. */
  51194. rebuild(): void;
  51195. /**
  51196. * Serializes the component data to the specified json object
  51197. * @param serializationObject The object to serialize to
  51198. */
  51199. serialize(serializationObject: any): void;
  51200. /**
  51201. * Adds all the elements from the container to the scene
  51202. * @param container the container holding the elements
  51203. */
  51204. addFromContainer(container: AbstractScene): void;
  51205. /**
  51206. * Removes all the elements in the container from the scene
  51207. * @param container contains the elements to remove
  51208. * @param dispose if the removed element should be disposed (default: false)
  51209. */
  51210. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51211. /**
  51212. * Disposes the component and the associated ressources.
  51213. */
  51214. dispose(): void;
  51215. private _isReadyForMesh;
  51216. private _renderMainTexture;
  51217. private _setStencil;
  51218. private _setStencilBack;
  51219. private _draw;
  51220. private _drawCamera;
  51221. private _drawRenderingGroup;
  51222. }
  51223. }
  51224. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  51225. /** @hidden */
  51226. export var glowMapMergePixelShader: {
  51227. name: string;
  51228. shader: string;
  51229. };
  51230. }
  51231. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  51232. /** @hidden */
  51233. export var glowMapMergeVertexShader: {
  51234. name: string;
  51235. shader: string;
  51236. };
  51237. }
  51238. declare module "babylonjs/Layers/glowLayer" {
  51239. import { Nullable } from "babylonjs/types";
  51240. import { Camera } from "babylonjs/Cameras/camera";
  51241. import { Scene } from "babylonjs/scene";
  51242. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51243. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51244. import { Mesh } from "babylonjs/Meshes/mesh";
  51245. import { Texture } from "babylonjs/Materials/Textures/texture";
  51246. import { Effect } from "babylonjs/Materials/effect";
  51247. import { Material } from "babylonjs/Materials/material";
  51248. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51249. import { Color4 } from "babylonjs/Maths/math.color";
  51250. import "babylonjs/Shaders/glowMapMerge.fragment";
  51251. import "babylonjs/Shaders/glowMapMerge.vertex";
  51252. import "babylonjs/Layers/effectLayerSceneComponent";
  51253. module "babylonjs/abstractScene" {
  51254. interface AbstractScene {
  51255. /**
  51256. * Return a the first highlight layer of the scene with a given name.
  51257. * @param name The name of the highlight layer to look for.
  51258. * @return The highlight layer if found otherwise null.
  51259. */
  51260. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  51261. }
  51262. }
  51263. /**
  51264. * Glow layer options. This helps customizing the behaviour
  51265. * of the glow layer.
  51266. */
  51267. export interface IGlowLayerOptions {
  51268. /**
  51269. * Multiplication factor apply to the canvas size to compute the render target size
  51270. * used to generated the glowing objects (the smaller the faster).
  51271. */
  51272. mainTextureRatio: number;
  51273. /**
  51274. * Enforces a fixed size texture to ensure resize independant blur.
  51275. */
  51276. mainTextureFixedSize?: number;
  51277. /**
  51278. * How big is the kernel of the blur texture.
  51279. */
  51280. blurKernelSize: number;
  51281. /**
  51282. * The camera attached to the layer.
  51283. */
  51284. camera: Nullable<Camera>;
  51285. /**
  51286. * Enable MSAA by chosing the number of samples.
  51287. */
  51288. mainTextureSamples?: number;
  51289. /**
  51290. * The rendering group to draw the layer in.
  51291. */
  51292. renderingGroupId: number;
  51293. }
  51294. /**
  51295. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  51296. *
  51297. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  51298. * glowy meshes to your scene.
  51299. *
  51300. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  51301. */
  51302. export class GlowLayer extends EffectLayer {
  51303. /**
  51304. * Effect Name of the layer.
  51305. */
  51306. static readonly EffectName: string;
  51307. /**
  51308. * The default blur kernel size used for the glow.
  51309. */
  51310. static DefaultBlurKernelSize: number;
  51311. /**
  51312. * The default texture size ratio used for the glow.
  51313. */
  51314. static DefaultTextureRatio: number;
  51315. /**
  51316. * Sets the kernel size of the blur.
  51317. */
  51318. /**
  51319. * Gets the kernel size of the blur.
  51320. */
  51321. blurKernelSize: number;
  51322. /**
  51323. * Sets the glow intensity.
  51324. */
  51325. /**
  51326. * Gets the glow intensity.
  51327. */
  51328. intensity: number;
  51329. private _options;
  51330. private _intensity;
  51331. private _horizontalBlurPostprocess1;
  51332. private _verticalBlurPostprocess1;
  51333. private _horizontalBlurPostprocess2;
  51334. private _verticalBlurPostprocess2;
  51335. private _blurTexture1;
  51336. private _blurTexture2;
  51337. private _postProcesses1;
  51338. private _postProcesses2;
  51339. private _includedOnlyMeshes;
  51340. private _excludedMeshes;
  51341. /**
  51342. * Callback used to let the user override the color selection on a per mesh basis
  51343. */
  51344. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  51345. /**
  51346. * Callback used to let the user override the texture selection on a per mesh basis
  51347. */
  51348. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  51349. /**
  51350. * Instantiates a new glow Layer and references it to the scene.
  51351. * @param name The name of the layer
  51352. * @param scene The scene to use the layer in
  51353. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  51354. */
  51355. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  51356. /**
  51357. * Get the effect name of the layer.
  51358. * @return The effect name
  51359. */
  51360. getEffectName(): string;
  51361. /**
  51362. * Create the merge effect. This is the shader use to blit the information back
  51363. * to the main canvas at the end of the scene rendering.
  51364. */
  51365. protected _createMergeEffect(): Effect;
  51366. /**
  51367. * Creates the render target textures and post processes used in the glow layer.
  51368. */
  51369. protected _createTextureAndPostProcesses(): void;
  51370. /**
  51371. * Checks for the readiness of the element composing the layer.
  51372. * @param subMesh the mesh to check for
  51373. * @param useInstances specify wether or not to use instances to render the mesh
  51374. * @param emissiveTexture the associated emissive texture used to generate the glow
  51375. * @return true if ready otherwise, false
  51376. */
  51377. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51378. /**
  51379. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51380. */
  51381. needStencil(): boolean;
  51382. /**
  51383. * Returns true if the mesh can be rendered, otherwise false.
  51384. * @param mesh The mesh to render
  51385. * @param material The material used on the mesh
  51386. * @returns true if it can be rendered otherwise false
  51387. */
  51388. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51389. /**
  51390. * Implementation specific of rendering the generating effect on the main canvas.
  51391. * @param effect The effect used to render through
  51392. */
  51393. protected _internalRender(effect: Effect): void;
  51394. /**
  51395. * Sets the required values for both the emissive texture and and the main color.
  51396. */
  51397. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51398. /**
  51399. * Returns true if the mesh should render, otherwise false.
  51400. * @param mesh The mesh to render
  51401. * @returns true if it should render otherwise false
  51402. */
  51403. protected _shouldRenderMesh(mesh: Mesh): boolean;
  51404. /**
  51405. * Adds specific effects defines.
  51406. * @param defines The defines to add specifics to.
  51407. */
  51408. protected _addCustomEffectDefines(defines: string[]): void;
  51409. /**
  51410. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  51411. * @param mesh The mesh to exclude from the glow layer
  51412. */
  51413. addExcludedMesh(mesh: Mesh): void;
  51414. /**
  51415. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  51416. * @param mesh The mesh to remove
  51417. */
  51418. removeExcludedMesh(mesh: Mesh): void;
  51419. /**
  51420. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  51421. * @param mesh The mesh to include in the glow layer
  51422. */
  51423. addIncludedOnlyMesh(mesh: Mesh): void;
  51424. /**
  51425. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  51426. * @param mesh The mesh to remove
  51427. */
  51428. removeIncludedOnlyMesh(mesh: Mesh): void;
  51429. /**
  51430. * Determine if a given mesh will be used in the glow layer
  51431. * @param mesh The mesh to test
  51432. * @returns true if the mesh will be highlighted by the current glow layer
  51433. */
  51434. hasMesh(mesh: AbstractMesh): boolean;
  51435. /**
  51436. * Free any resources and references associated to a mesh.
  51437. * Internal use
  51438. * @param mesh The mesh to free.
  51439. * @hidden
  51440. */
  51441. _disposeMesh(mesh: Mesh): void;
  51442. /**
  51443. * Gets the class name of the effect layer
  51444. * @returns the string with the class name of the effect layer
  51445. */
  51446. getClassName(): string;
  51447. /**
  51448. * Serializes this glow layer
  51449. * @returns a serialized glow layer object
  51450. */
  51451. serialize(): any;
  51452. /**
  51453. * Creates a Glow Layer from parsed glow layer data
  51454. * @param parsedGlowLayer defines glow layer data
  51455. * @param scene defines the current scene
  51456. * @param rootUrl defines the root URL containing the glow layer information
  51457. * @returns a parsed Glow Layer
  51458. */
  51459. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  51460. }
  51461. }
  51462. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  51463. /** @hidden */
  51464. export var glowBlurPostProcessPixelShader: {
  51465. name: string;
  51466. shader: string;
  51467. };
  51468. }
  51469. declare module "babylonjs/Layers/highlightLayer" {
  51470. import { Observable } from "babylonjs/Misc/observable";
  51471. import { Nullable } from "babylonjs/types";
  51472. import { Camera } from "babylonjs/Cameras/camera";
  51473. import { Scene } from "babylonjs/scene";
  51474. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51475. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51476. import { Mesh } from "babylonjs/Meshes/mesh";
  51477. import { Effect } from "babylonjs/Materials/effect";
  51478. import { Material } from "babylonjs/Materials/material";
  51479. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51480. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  51481. import "babylonjs/Shaders/glowMapMerge.fragment";
  51482. import "babylonjs/Shaders/glowMapMerge.vertex";
  51483. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  51484. module "babylonjs/abstractScene" {
  51485. interface AbstractScene {
  51486. /**
  51487. * Return a the first highlight layer of the scene with a given name.
  51488. * @param name The name of the highlight layer to look for.
  51489. * @return The highlight layer if found otherwise null.
  51490. */
  51491. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  51492. }
  51493. }
  51494. /**
  51495. * Highlight layer options. This helps customizing the behaviour
  51496. * of the highlight layer.
  51497. */
  51498. export interface IHighlightLayerOptions {
  51499. /**
  51500. * Multiplication factor apply to the canvas size to compute the render target size
  51501. * used to generated the glowing objects (the smaller the faster).
  51502. */
  51503. mainTextureRatio: number;
  51504. /**
  51505. * Enforces a fixed size texture to ensure resize independant blur.
  51506. */
  51507. mainTextureFixedSize?: number;
  51508. /**
  51509. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  51510. * of the picture to blur (the smaller the faster).
  51511. */
  51512. blurTextureSizeRatio: number;
  51513. /**
  51514. * How big in texel of the blur texture is the vertical blur.
  51515. */
  51516. blurVerticalSize: number;
  51517. /**
  51518. * How big in texel of the blur texture is the horizontal blur.
  51519. */
  51520. blurHorizontalSize: number;
  51521. /**
  51522. * Alpha blending mode used to apply the blur. Default is combine.
  51523. */
  51524. alphaBlendingMode: number;
  51525. /**
  51526. * The camera attached to the layer.
  51527. */
  51528. camera: Nullable<Camera>;
  51529. /**
  51530. * Should we display highlight as a solid stroke?
  51531. */
  51532. isStroke?: boolean;
  51533. /**
  51534. * The rendering group to draw the layer in.
  51535. */
  51536. renderingGroupId: number;
  51537. }
  51538. /**
  51539. * The highlight layer Helps adding a glow effect around a mesh.
  51540. *
  51541. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  51542. * glowy meshes to your scene.
  51543. *
  51544. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  51545. */
  51546. export class HighlightLayer extends EffectLayer {
  51547. name: string;
  51548. /**
  51549. * Effect Name of the highlight layer.
  51550. */
  51551. static readonly EffectName: string;
  51552. /**
  51553. * The neutral color used during the preparation of the glow effect.
  51554. * This is black by default as the blend operation is a blend operation.
  51555. */
  51556. static NeutralColor: Color4;
  51557. /**
  51558. * Stencil value used for glowing meshes.
  51559. */
  51560. static GlowingMeshStencilReference: number;
  51561. /**
  51562. * Stencil value used for the other meshes in the scene.
  51563. */
  51564. static NormalMeshStencilReference: number;
  51565. /**
  51566. * Specifies whether or not the inner glow is ACTIVE in the layer.
  51567. */
  51568. innerGlow: boolean;
  51569. /**
  51570. * Specifies whether or not the outer glow is ACTIVE in the layer.
  51571. */
  51572. outerGlow: boolean;
  51573. /**
  51574. * Specifies the horizontal size of the blur.
  51575. */
  51576. /**
  51577. * Gets the horizontal size of the blur.
  51578. */
  51579. blurHorizontalSize: number;
  51580. /**
  51581. * Specifies the vertical size of the blur.
  51582. */
  51583. /**
  51584. * Gets the vertical size of the blur.
  51585. */
  51586. blurVerticalSize: number;
  51587. /**
  51588. * An event triggered when the highlight layer is being blurred.
  51589. */
  51590. onBeforeBlurObservable: Observable<HighlightLayer>;
  51591. /**
  51592. * An event triggered when the highlight layer has been blurred.
  51593. */
  51594. onAfterBlurObservable: Observable<HighlightLayer>;
  51595. private _instanceGlowingMeshStencilReference;
  51596. private _options;
  51597. private _downSamplePostprocess;
  51598. private _horizontalBlurPostprocess;
  51599. private _verticalBlurPostprocess;
  51600. private _blurTexture;
  51601. private _meshes;
  51602. private _excludedMeshes;
  51603. /**
  51604. * Instantiates a new highlight Layer and references it to the scene..
  51605. * @param name The name of the layer
  51606. * @param scene The scene to use the layer in
  51607. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  51608. */
  51609. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  51610. /**
  51611. * Get the effect name of the layer.
  51612. * @return The effect name
  51613. */
  51614. getEffectName(): string;
  51615. /**
  51616. * Create the merge effect. This is the shader use to blit the information back
  51617. * to the main canvas at the end of the scene rendering.
  51618. */
  51619. protected _createMergeEffect(): Effect;
  51620. /**
  51621. * Creates the render target textures and post processes used in the highlight layer.
  51622. */
  51623. protected _createTextureAndPostProcesses(): void;
  51624. /**
  51625. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51626. */
  51627. needStencil(): boolean;
  51628. /**
  51629. * Checks for the readiness of the element composing the layer.
  51630. * @param subMesh the mesh to check for
  51631. * @param useInstances specify wether or not to use instances to render the mesh
  51632. * @param emissiveTexture the associated emissive texture used to generate the glow
  51633. * @return true if ready otherwise, false
  51634. */
  51635. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51636. /**
  51637. * Implementation specific of rendering the generating effect on the main canvas.
  51638. * @param effect The effect used to render through
  51639. */
  51640. protected _internalRender(effect: Effect): void;
  51641. /**
  51642. * Returns true if the layer contains information to display, otherwise false.
  51643. */
  51644. shouldRender(): boolean;
  51645. /**
  51646. * Returns true if the mesh should render, otherwise false.
  51647. * @param mesh The mesh to render
  51648. * @returns true if it should render otherwise false
  51649. */
  51650. protected _shouldRenderMesh(mesh: Mesh): boolean;
  51651. /**
  51652. * Sets the required values for both the emissive texture and and the main color.
  51653. */
  51654. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51655. /**
  51656. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  51657. * @param mesh The mesh to exclude from the highlight layer
  51658. */
  51659. addExcludedMesh(mesh: Mesh): void;
  51660. /**
  51661. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  51662. * @param mesh The mesh to highlight
  51663. */
  51664. removeExcludedMesh(mesh: Mesh): void;
  51665. /**
  51666. * Determine if a given mesh will be highlighted by the current HighlightLayer
  51667. * @param mesh mesh to test
  51668. * @returns true if the mesh will be highlighted by the current HighlightLayer
  51669. */
  51670. hasMesh(mesh: AbstractMesh): boolean;
  51671. /**
  51672. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  51673. * @param mesh The mesh to highlight
  51674. * @param color The color of the highlight
  51675. * @param glowEmissiveOnly Extract the glow from the emissive texture
  51676. */
  51677. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  51678. /**
  51679. * Remove a mesh from the highlight layer in order to make it stop glowing.
  51680. * @param mesh The mesh to highlight
  51681. */
  51682. removeMesh(mesh: Mesh): void;
  51683. /**
  51684. * Force the stencil to the normal expected value for none glowing parts
  51685. */
  51686. private _defaultStencilReference;
  51687. /**
  51688. * Free any resources and references associated to a mesh.
  51689. * Internal use
  51690. * @param mesh The mesh to free.
  51691. * @hidden
  51692. */
  51693. _disposeMesh(mesh: Mesh): void;
  51694. /**
  51695. * Dispose the highlight layer and free resources.
  51696. */
  51697. dispose(): void;
  51698. /**
  51699. * Gets the class name of the effect layer
  51700. * @returns the string with the class name of the effect layer
  51701. */
  51702. getClassName(): string;
  51703. /**
  51704. * Serializes this Highlight layer
  51705. * @returns a serialized Highlight layer object
  51706. */
  51707. serialize(): any;
  51708. /**
  51709. * Creates a Highlight layer from parsed Highlight layer data
  51710. * @param parsedHightlightLayer defines the Highlight layer data
  51711. * @param scene defines the current scene
  51712. * @param rootUrl defines the root URL containing the Highlight layer information
  51713. * @returns a parsed Highlight layer
  51714. */
  51715. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  51716. }
  51717. }
  51718. declare module "babylonjs/Layers/layerSceneComponent" {
  51719. import { Scene } from "babylonjs/scene";
  51720. import { ISceneComponent } from "babylonjs/sceneComponent";
  51721. import { Layer } from "babylonjs/Layers/layer";
  51722. import { AbstractScene } from "babylonjs/abstractScene";
  51723. module "babylonjs/abstractScene" {
  51724. interface AbstractScene {
  51725. /**
  51726. * The list of layers (background and foreground) of the scene
  51727. */
  51728. layers: Array<Layer>;
  51729. }
  51730. }
  51731. /**
  51732. * Defines the layer scene component responsible to manage any layers
  51733. * in a given scene.
  51734. */
  51735. export class LayerSceneComponent implements ISceneComponent {
  51736. /**
  51737. * The component name helpfull to identify the component in the list of scene components.
  51738. */
  51739. readonly name: string;
  51740. /**
  51741. * The scene the component belongs to.
  51742. */
  51743. scene: Scene;
  51744. private _engine;
  51745. /**
  51746. * Creates a new instance of the component for the given scene
  51747. * @param scene Defines the scene to register the component in
  51748. */
  51749. constructor(scene: Scene);
  51750. /**
  51751. * Registers the component in a given scene
  51752. */
  51753. register(): void;
  51754. /**
  51755. * Rebuilds the elements related to this component in case of
  51756. * context lost for instance.
  51757. */
  51758. rebuild(): void;
  51759. /**
  51760. * Disposes the component and the associated ressources.
  51761. */
  51762. dispose(): void;
  51763. private _draw;
  51764. private _drawCameraPredicate;
  51765. private _drawCameraBackground;
  51766. private _drawCameraForeground;
  51767. private _drawRenderTargetPredicate;
  51768. private _drawRenderTargetBackground;
  51769. private _drawRenderTargetForeground;
  51770. /**
  51771. * Adds all the elements from the container to the scene
  51772. * @param container the container holding the elements
  51773. */
  51774. addFromContainer(container: AbstractScene): void;
  51775. /**
  51776. * Removes all the elements in the container from the scene
  51777. * @param container contains the elements to remove
  51778. * @param dispose if the removed element should be disposed (default: false)
  51779. */
  51780. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51781. }
  51782. }
  51783. declare module "babylonjs/Shaders/layer.fragment" {
  51784. /** @hidden */
  51785. export var layerPixelShader: {
  51786. name: string;
  51787. shader: string;
  51788. };
  51789. }
  51790. declare module "babylonjs/Shaders/layer.vertex" {
  51791. /** @hidden */
  51792. export var layerVertexShader: {
  51793. name: string;
  51794. shader: string;
  51795. };
  51796. }
  51797. declare module "babylonjs/Layers/layer" {
  51798. import { Observable } from "babylonjs/Misc/observable";
  51799. import { Nullable } from "babylonjs/types";
  51800. import { Scene } from "babylonjs/scene";
  51801. import { Vector2 } from "babylonjs/Maths/math.vector";
  51802. import { Color4 } from "babylonjs/Maths/math.color";
  51803. import { Texture } from "babylonjs/Materials/Textures/texture";
  51804. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51805. import "babylonjs/Shaders/layer.fragment";
  51806. import "babylonjs/Shaders/layer.vertex";
  51807. /**
  51808. * This represents a full screen 2d layer.
  51809. * This can be useful to display a picture in the background of your scene for instance.
  51810. * @see https://www.babylonjs-playground.com/#08A2BS#1
  51811. */
  51812. export class Layer {
  51813. /**
  51814. * Define the name of the layer.
  51815. */
  51816. name: string;
  51817. /**
  51818. * Define the texture the layer should display.
  51819. */
  51820. texture: Nullable<Texture>;
  51821. /**
  51822. * Is the layer in background or foreground.
  51823. */
  51824. isBackground: boolean;
  51825. /**
  51826. * Define the color of the layer (instead of texture).
  51827. */
  51828. color: Color4;
  51829. /**
  51830. * Define the scale of the layer in order to zoom in out of the texture.
  51831. */
  51832. scale: Vector2;
  51833. /**
  51834. * Define an offset for the layer in order to shift the texture.
  51835. */
  51836. offset: Vector2;
  51837. /**
  51838. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  51839. */
  51840. alphaBlendingMode: number;
  51841. /**
  51842. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  51843. * Alpha test will not mix with the background color in case of transparency.
  51844. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  51845. */
  51846. alphaTest: boolean;
  51847. /**
  51848. * Define a mask to restrict the layer to only some of the scene cameras.
  51849. */
  51850. layerMask: number;
  51851. /**
  51852. * Define the list of render target the layer is visible into.
  51853. */
  51854. renderTargetTextures: RenderTargetTexture[];
  51855. /**
  51856. * Define if the layer is only used in renderTarget or if it also
  51857. * renders in the main frame buffer of the canvas.
  51858. */
  51859. renderOnlyInRenderTargetTextures: boolean;
  51860. private _scene;
  51861. private _vertexBuffers;
  51862. private _indexBuffer;
  51863. private _effect;
  51864. private _alphaTestEffect;
  51865. /**
  51866. * An event triggered when the layer is disposed.
  51867. */
  51868. onDisposeObservable: Observable<Layer>;
  51869. private _onDisposeObserver;
  51870. /**
  51871. * Back compatibility with callback before the onDisposeObservable existed.
  51872. * The set callback will be triggered when the layer has been disposed.
  51873. */
  51874. onDispose: () => void;
  51875. /**
  51876. * An event triggered before rendering the scene
  51877. */
  51878. onBeforeRenderObservable: Observable<Layer>;
  51879. private _onBeforeRenderObserver;
  51880. /**
  51881. * Back compatibility with callback before the onBeforeRenderObservable existed.
  51882. * The set callback will be triggered just before rendering the layer.
  51883. */
  51884. onBeforeRender: () => void;
  51885. /**
  51886. * An event triggered after rendering the scene
  51887. */
  51888. onAfterRenderObservable: Observable<Layer>;
  51889. private _onAfterRenderObserver;
  51890. /**
  51891. * Back compatibility with callback before the onAfterRenderObservable existed.
  51892. * The set callback will be triggered just after rendering the layer.
  51893. */
  51894. onAfterRender: () => void;
  51895. /**
  51896. * Instantiates a new layer.
  51897. * This represents a full screen 2d layer.
  51898. * This can be useful to display a picture in the background of your scene for instance.
  51899. * @see https://www.babylonjs-playground.com/#08A2BS#1
  51900. * @param name Define the name of the layer in the scene
  51901. * @param imgUrl Define the url of the texture to display in the layer
  51902. * @param scene Define the scene the layer belongs to
  51903. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  51904. * @param color Defines a color for the layer
  51905. */
  51906. constructor(
  51907. /**
  51908. * Define the name of the layer.
  51909. */
  51910. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  51911. private _createIndexBuffer;
  51912. /** @hidden */
  51913. _rebuild(): void;
  51914. /**
  51915. * Renders the layer in the scene.
  51916. */
  51917. render(): void;
  51918. /**
  51919. * Disposes and releases the associated ressources.
  51920. */
  51921. dispose(): void;
  51922. }
  51923. }
  51924. declare module "babylonjs/Layers/index" {
  51925. export * from "babylonjs/Layers/effectLayer";
  51926. export * from "babylonjs/Layers/effectLayerSceneComponent";
  51927. export * from "babylonjs/Layers/glowLayer";
  51928. export * from "babylonjs/Layers/highlightLayer";
  51929. export * from "babylonjs/Layers/layer";
  51930. export * from "babylonjs/Layers/layerSceneComponent";
  51931. }
  51932. declare module "babylonjs/Shaders/lensFlare.fragment" {
  51933. /** @hidden */
  51934. export var lensFlarePixelShader: {
  51935. name: string;
  51936. shader: string;
  51937. };
  51938. }
  51939. declare module "babylonjs/Shaders/lensFlare.vertex" {
  51940. /** @hidden */
  51941. export var lensFlareVertexShader: {
  51942. name: string;
  51943. shader: string;
  51944. };
  51945. }
  51946. declare module "babylonjs/LensFlares/lensFlareSystem" {
  51947. import { Scene } from "babylonjs/scene";
  51948. import { Vector3 } from "babylonjs/Maths/math.vector";
  51949. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51950. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  51951. import "babylonjs/Shaders/lensFlare.fragment";
  51952. import "babylonjs/Shaders/lensFlare.vertex";
  51953. import { Viewport } from "babylonjs/Maths/math.viewport";
  51954. /**
  51955. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  51956. * It is usually composed of several `lensFlare`.
  51957. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51958. */
  51959. export class LensFlareSystem {
  51960. /**
  51961. * Define the name of the lens flare system
  51962. */
  51963. name: string;
  51964. /**
  51965. * List of lens flares used in this system.
  51966. */
  51967. lensFlares: LensFlare[];
  51968. /**
  51969. * Define a limit from the border the lens flare can be visible.
  51970. */
  51971. borderLimit: number;
  51972. /**
  51973. * Define a viewport border we do not want to see the lens flare in.
  51974. */
  51975. viewportBorder: number;
  51976. /**
  51977. * Define a predicate which could limit the list of meshes able to occlude the effect.
  51978. */
  51979. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  51980. /**
  51981. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  51982. */
  51983. layerMask: number;
  51984. /**
  51985. * Define the id of the lens flare system in the scene.
  51986. * (equal to name by default)
  51987. */
  51988. id: string;
  51989. private _scene;
  51990. private _emitter;
  51991. private _vertexBuffers;
  51992. private _indexBuffer;
  51993. private _effect;
  51994. private _positionX;
  51995. private _positionY;
  51996. private _isEnabled;
  51997. /** @hidden */
  51998. static _SceneComponentInitialization: (scene: Scene) => void;
  51999. /**
  52000. * Instantiates a lens flare system.
  52001. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  52002. * It is usually composed of several `lensFlare`.
  52003. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52004. * @param name Define the name of the lens flare system in the scene
  52005. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  52006. * @param scene Define the scene the lens flare system belongs to
  52007. */
  52008. constructor(
  52009. /**
  52010. * Define the name of the lens flare system
  52011. */
  52012. name: string, emitter: any, scene: Scene);
  52013. /**
  52014. * Define if the lens flare system is enabled.
  52015. */
  52016. isEnabled: boolean;
  52017. /**
  52018. * Get the scene the effects belongs to.
  52019. * @returns the scene holding the lens flare system
  52020. */
  52021. getScene(): Scene;
  52022. /**
  52023. * Get the emitter of the lens flare system.
  52024. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52025. * @returns the emitter of the lens flare system
  52026. */
  52027. getEmitter(): any;
  52028. /**
  52029. * Set the emitter of the lens flare system.
  52030. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52031. * @param newEmitter Define the new emitter of the system
  52032. */
  52033. setEmitter(newEmitter: any): void;
  52034. /**
  52035. * Get the lens flare system emitter position.
  52036. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  52037. * @returns the position
  52038. */
  52039. getEmitterPosition(): Vector3;
  52040. /**
  52041. * @hidden
  52042. */
  52043. computeEffectivePosition(globalViewport: Viewport): boolean;
  52044. /** @hidden */
  52045. _isVisible(): boolean;
  52046. /**
  52047. * @hidden
  52048. */
  52049. render(): boolean;
  52050. /**
  52051. * Dispose and release the lens flare with its associated resources.
  52052. */
  52053. dispose(): void;
  52054. /**
  52055. * Parse a lens flare system from a JSON repressentation
  52056. * @param parsedLensFlareSystem Define the JSON to parse
  52057. * @param scene Define the scene the parsed system should be instantiated in
  52058. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  52059. * @returns the parsed system
  52060. */
  52061. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  52062. /**
  52063. * Serialize the current Lens Flare System into a JSON representation.
  52064. * @returns the serialized JSON
  52065. */
  52066. serialize(): any;
  52067. }
  52068. }
  52069. declare module "babylonjs/LensFlares/lensFlare" {
  52070. import { Nullable } from "babylonjs/types";
  52071. import { Color3 } from "babylonjs/Maths/math.color";
  52072. import { Texture } from "babylonjs/Materials/Textures/texture";
  52073. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  52074. /**
  52075. * This represents one of the lens effect in a `lensFlareSystem`.
  52076. * It controls one of the indiviual texture used in the effect.
  52077. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52078. */
  52079. export class LensFlare {
  52080. /**
  52081. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52082. */
  52083. size: number;
  52084. /**
  52085. * Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
  52086. */
  52087. position: number;
  52088. /**
  52089. * Define the lens color.
  52090. */
  52091. color: Color3;
  52092. /**
  52093. * Define the lens texture.
  52094. */
  52095. texture: Nullable<Texture>;
  52096. /**
  52097. * Define the alpha mode to render this particular lens.
  52098. */
  52099. alphaMode: number;
  52100. private _system;
  52101. /**
  52102. * Creates a new Lens Flare.
  52103. * This represents one of the lens effect in a `lensFlareSystem`.
  52104. * It controls one of the indiviual texture used in the effect.
  52105. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52106. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  52107. * @param position Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
  52108. * @param color Define the lens color
  52109. * @param imgUrl Define the lens texture url
  52110. * @param system Define the `lensFlareSystem` this flare is part of
  52111. * @returns The newly created Lens Flare
  52112. */
  52113. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  52114. /**
  52115. * Instantiates a new Lens Flare.
  52116. * This represents one of the lens effect in a `lensFlareSystem`.
  52117. * It controls one of the indiviual texture used in the effect.
  52118. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52119. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  52120. * @param position Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
  52121. * @param color Define the lens color
  52122. * @param imgUrl Define the lens texture url
  52123. * @param system Define the `lensFlareSystem` this flare is part of
  52124. */
  52125. constructor(
  52126. /**
  52127. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52128. */
  52129. size: number,
  52130. /**
  52131. * Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
  52132. */
  52133. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  52134. /**
  52135. * Dispose and release the lens flare with its associated resources.
  52136. */
  52137. dispose(): void;
  52138. }
  52139. }
  52140. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  52141. import { Nullable } from "babylonjs/types";
  52142. import { Scene } from "babylonjs/scene";
  52143. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52144. import { AbstractScene } from "babylonjs/abstractScene";
  52145. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  52146. module "babylonjs/abstractScene" {
  52147. interface AbstractScene {
  52148. /**
  52149. * The list of lens flare system added to the scene
  52150. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52151. */
  52152. lensFlareSystems: Array<LensFlareSystem>;
  52153. /**
  52154. * Removes the given lens flare system from this scene.
  52155. * @param toRemove The lens flare system to remove
  52156. * @returns The index of the removed lens flare system
  52157. */
  52158. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  52159. /**
  52160. * Adds the given lens flare system to this scene
  52161. * @param newLensFlareSystem The lens flare system to add
  52162. */
  52163. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  52164. /**
  52165. * Gets a lens flare system using its name
  52166. * @param name defines the name to look for
  52167. * @returns the lens flare system or null if not found
  52168. */
  52169. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  52170. /**
  52171. * Gets a lens flare system using its id
  52172. * @param id defines the id to look for
  52173. * @returns the lens flare system or null if not found
  52174. */
  52175. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  52176. }
  52177. }
  52178. /**
  52179. * Defines the lens flare scene component responsible to manage any lens flares
  52180. * in a given scene.
  52181. */
  52182. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  52183. /**
  52184. * The component name helpfull to identify the component in the list of scene components.
  52185. */
  52186. readonly name: string;
  52187. /**
  52188. * The scene the component belongs to.
  52189. */
  52190. scene: Scene;
  52191. /**
  52192. * Creates a new instance of the component for the given scene
  52193. * @param scene Defines the scene to register the component in
  52194. */
  52195. constructor(scene: Scene);
  52196. /**
  52197. * Registers the component in a given scene
  52198. */
  52199. register(): void;
  52200. /**
  52201. * Rebuilds the elements related to this component in case of
  52202. * context lost for instance.
  52203. */
  52204. rebuild(): void;
  52205. /**
  52206. * Adds all the elements from the container to the scene
  52207. * @param container the container holding the elements
  52208. */
  52209. addFromContainer(container: AbstractScene): void;
  52210. /**
  52211. * Removes all the elements in the container from the scene
  52212. * @param container contains the elements to remove
  52213. * @param dispose if the removed element should be disposed (default: false)
  52214. */
  52215. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52216. /**
  52217. * Serializes the component data to the specified json object
  52218. * @param serializationObject The object to serialize to
  52219. */
  52220. serialize(serializationObject: any): void;
  52221. /**
  52222. * Disposes the component and the associated ressources.
  52223. */
  52224. dispose(): void;
  52225. private _draw;
  52226. }
  52227. }
  52228. declare module "babylonjs/LensFlares/index" {
  52229. export * from "babylonjs/LensFlares/lensFlare";
  52230. export * from "babylonjs/LensFlares/lensFlareSystem";
  52231. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  52232. }
  52233. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  52234. import { Scene } from "babylonjs/scene";
  52235. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52236. import { AbstractScene } from "babylonjs/abstractScene";
  52237. /**
  52238. * Defines the shadow generator component responsible to manage any shadow generators
  52239. * in a given scene.
  52240. */
  52241. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  52242. /**
  52243. * The component name helpfull to identify the component in the list of scene components.
  52244. */
  52245. readonly name: string;
  52246. /**
  52247. * The scene the component belongs to.
  52248. */
  52249. scene: Scene;
  52250. /**
  52251. * Creates a new instance of the component for the given scene
  52252. * @param scene Defines the scene to register the component in
  52253. */
  52254. constructor(scene: Scene);
  52255. /**
  52256. * Registers the component in a given scene
  52257. */
  52258. register(): void;
  52259. /**
  52260. * Rebuilds the elements related to this component in case of
  52261. * context lost for instance.
  52262. */
  52263. rebuild(): void;
  52264. /**
  52265. * Serializes the component data to the specified json object
  52266. * @param serializationObject The object to serialize to
  52267. */
  52268. serialize(serializationObject: any): void;
  52269. /**
  52270. * Adds all the elements from the container to the scene
  52271. * @param container the container holding the elements
  52272. */
  52273. addFromContainer(container: AbstractScene): void;
  52274. /**
  52275. * Removes all the elements in the container from the scene
  52276. * @param container contains the elements to remove
  52277. * @param dispose if the removed element should be disposed (default: false)
  52278. */
  52279. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52280. /**
  52281. * Rebuilds the elements related to this component in case of
  52282. * context lost for instance.
  52283. */
  52284. dispose(): void;
  52285. private _gatherRenderTargets;
  52286. }
  52287. }
  52288. declare module "babylonjs/Lights/Shadows/index" {
  52289. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  52290. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  52291. }
  52292. declare module "babylonjs/Lights/pointLight" {
  52293. import { Scene } from "babylonjs/scene";
  52294. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  52295. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52296. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  52297. import { Effect } from "babylonjs/Materials/effect";
  52298. /**
  52299. * A point light is a light defined by an unique point in world space.
  52300. * The light is emitted in every direction from this point.
  52301. * A good example of a point light is a standard light bulb.
  52302. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52303. */
  52304. export class PointLight extends ShadowLight {
  52305. private _shadowAngle;
  52306. /**
  52307. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52308. * This specifies what angle the shadow will use to be created.
  52309. *
  52310. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  52311. */
  52312. /**
  52313. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52314. * This specifies what angle the shadow will use to be created.
  52315. *
  52316. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  52317. */
  52318. shadowAngle: number;
  52319. /**
  52320. * Gets the direction if it has been set.
  52321. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52322. */
  52323. /**
  52324. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52325. */
  52326. direction: Vector3;
  52327. /**
  52328. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  52329. * A PointLight emits the light in every direction.
  52330. * It can cast shadows.
  52331. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  52332. * ```javascript
  52333. * var pointLight = new PointLight("pl", camera.position, scene);
  52334. * ```
  52335. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52336. * @param name The light friendly name
  52337. * @param position The position of the point light in the scene
  52338. * @param scene The scene the lights belongs to
  52339. */
  52340. constructor(name: string, position: Vector3, scene: Scene);
  52341. /**
  52342. * Returns the string "PointLight"
  52343. * @returns the class name
  52344. */
  52345. getClassName(): string;
  52346. /**
  52347. * Returns the integer 0.
  52348. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52349. */
  52350. getTypeID(): number;
  52351. /**
  52352. * Specifies wether or not the shadowmap should be a cube texture.
  52353. * @returns true if the shadowmap needs to be a cube texture.
  52354. */
  52355. needCube(): boolean;
  52356. /**
  52357. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  52358. * @param faceIndex The index of the face we are computed the direction to generate shadow
  52359. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  52360. */
  52361. getShadowDirection(faceIndex?: number): Vector3;
  52362. /**
  52363. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  52364. * - fov = PI / 2
  52365. * - aspect ratio : 1.0
  52366. * - z-near and far equal to the active camera minZ and maxZ.
  52367. * Returns the PointLight.
  52368. */
  52369. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52370. protected _buildUniformLayout(): void;
  52371. /**
  52372. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  52373. * @param effect The effect to update
  52374. * @param lightIndex The index of the light in the effect to update
  52375. * @returns The point light
  52376. */
  52377. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  52378. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  52379. /**
  52380. * Prepares the list of defines specific to the light type.
  52381. * @param defines the list of defines
  52382. * @param lightIndex defines the index of the light for the effect
  52383. */
  52384. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52385. }
  52386. }
  52387. declare module "babylonjs/Lights/index" {
  52388. export * from "babylonjs/Lights/light";
  52389. export * from "babylonjs/Lights/shadowLight";
  52390. export * from "babylonjs/Lights/Shadows/index";
  52391. export * from "babylonjs/Lights/directionalLight";
  52392. export * from "babylonjs/Lights/hemisphericLight";
  52393. export * from "babylonjs/Lights/pointLight";
  52394. export * from "babylonjs/Lights/spotLight";
  52395. }
  52396. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  52397. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  52398. /**
  52399. * Header information of HDR texture files.
  52400. */
  52401. export interface HDRInfo {
  52402. /**
  52403. * The height of the texture in pixels.
  52404. */
  52405. height: number;
  52406. /**
  52407. * The width of the texture in pixels.
  52408. */
  52409. width: number;
  52410. /**
  52411. * The index of the beginning of the data in the binary file.
  52412. */
  52413. dataPosition: number;
  52414. }
  52415. /**
  52416. * This groups tools to convert HDR texture to native colors array.
  52417. */
  52418. export class HDRTools {
  52419. private static Ldexp;
  52420. private static Rgbe2float;
  52421. private static readStringLine;
  52422. /**
  52423. * Reads header information from an RGBE texture stored in a native array.
  52424. * More information on this format are available here:
  52425. * https://en.wikipedia.org/wiki/RGBE_image_format
  52426. *
  52427. * @param uint8array The binary file stored in native array.
  52428. * @return The header information.
  52429. */
  52430. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  52431. /**
  52432. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  52433. * This RGBE texture needs to store the information as a panorama.
  52434. *
  52435. * More information on this format are available here:
  52436. * https://en.wikipedia.org/wiki/RGBE_image_format
  52437. *
  52438. * @param buffer The binary file stored in an array buffer.
  52439. * @param size The expected size of the extracted cubemap.
  52440. * @return The Cube Map information.
  52441. */
  52442. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  52443. /**
  52444. * Returns the pixels data extracted from an RGBE texture.
  52445. * This pixels will be stored left to right up to down in the R G B order in one array.
  52446. *
  52447. * More information on this format are available here:
  52448. * https://en.wikipedia.org/wiki/RGBE_image_format
  52449. *
  52450. * @param uint8array The binary file stored in an array buffer.
  52451. * @param hdrInfo The header information of the file.
  52452. * @return The pixels data in RGB right to left up to down order.
  52453. */
  52454. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  52455. private static RGBE_ReadPixels_RLE;
  52456. }
  52457. }
  52458. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  52459. import { Nullable } from "babylonjs/types";
  52460. import { Scene } from "babylonjs/scene";
  52461. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  52462. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52463. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52464. /**
  52465. * This represents a texture coming from an HDR input.
  52466. *
  52467. * The only supported format is currently panorama picture stored in RGBE format.
  52468. * Example of such files can be found on HDRLib: http://hdrlib.com/
  52469. */
  52470. export class HDRCubeTexture extends BaseTexture {
  52471. private static _facesMapping;
  52472. private _generateHarmonics;
  52473. private _noMipmap;
  52474. private _textureMatrix;
  52475. private _size;
  52476. private _onLoad;
  52477. private _onError;
  52478. /**
  52479. * The texture URL.
  52480. */
  52481. url: string;
  52482. /**
  52483. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  52484. */
  52485. coordinatesMode: number;
  52486. protected _isBlocking: boolean;
  52487. /**
  52488. * Sets wether or not the texture is blocking during loading.
  52489. */
  52490. /**
  52491. * Gets wether or not the texture is blocking during loading.
  52492. */
  52493. isBlocking: boolean;
  52494. protected _rotationY: number;
  52495. /**
  52496. * Sets texture matrix rotation angle around Y axis in radians.
  52497. */
  52498. /**
  52499. * Gets texture matrix rotation angle around Y axis radians.
  52500. */
  52501. rotationY: number;
  52502. /**
  52503. * Gets or sets the center of the bounding box associated with the cube texture
  52504. * It must define where the camera used to render the texture was set
  52505. */
  52506. boundingBoxPosition: Vector3;
  52507. private _boundingBoxSize;
  52508. /**
  52509. * Gets or sets the size of the bounding box associated with the cube texture
  52510. * When defined, the cubemap will switch to local mode
  52511. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  52512. * @example https://www.babylonjs-playground.com/#RNASML
  52513. */
  52514. boundingBoxSize: Vector3;
  52515. /**
  52516. * Instantiates an HDRTexture from the following parameters.
  52517. *
  52518. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  52519. * @param scene The scene the texture will be used in
  52520. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  52521. * @param noMipmap Forces to not generate the mipmap if true
  52522. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  52523. * @param gammaSpace Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  52524. * @param reserved Reserved flag for internal use.
  52525. */
  52526. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  52527. /**
  52528. * Get the current class name of the texture useful for serialization or dynamic coding.
  52529. * @returns "HDRCubeTexture"
  52530. */
  52531. getClassName(): string;
  52532. /**
  52533. * Occurs when the file is raw .hdr file.
  52534. */
  52535. private loadTexture;
  52536. clone(): HDRCubeTexture;
  52537. delayLoad(): void;
  52538. /**
  52539. * Get the texture reflection matrix used to rotate/transform the reflection.
  52540. * @returns the reflection matrix
  52541. */
  52542. getReflectionTextureMatrix(): Matrix;
  52543. /**
  52544. * Set the texture reflection matrix used to rotate/transform the reflection.
  52545. * @param value Define the reflection matrix to set
  52546. */
  52547. setReflectionTextureMatrix(value: Matrix): void;
  52548. /**
  52549. * Parses a JSON representation of an HDR Texture in order to create the texture
  52550. * @param parsedTexture Define the JSON representation
  52551. * @param scene Define the scene the texture should be created in
  52552. * @param rootUrl Define the root url in case we need to load relative dependencies
  52553. * @returns the newly created texture after parsing
  52554. */
  52555. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  52556. serialize(): any;
  52557. }
  52558. }
  52559. declare module "babylonjs/Physics/physicsEngine" {
  52560. import { Nullable } from "babylonjs/types";
  52561. import { Vector3 } from "babylonjs/Maths/math.vector";
  52562. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  52563. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  52564. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  52565. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52566. /**
  52567. * Class used to control physics engine
  52568. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  52569. */
  52570. export class PhysicsEngine implements IPhysicsEngine {
  52571. private _physicsPlugin;
  52572. /**
  52573. * Global value used to control the smallest number supported by the simulation
  52574. */
  52575. static Epsilon: number;
  52576. private _impostors;
  52577. private _joints;
  52578. /**
  52579. * Gets the gravity vector used by the simulation
  52580. */
  52581. gravity: Vector3;
  52582. /**
  52583. * Factory used to create the default physics plugin.
  52584. * @returns The default physics plugin
  52585. */
  52586. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  52587. /**
  52588. * Creates a new Physics Engine
  52589. * @param gravity defines the gravity vector used by the simulation
  52590. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  52591. */
  52592. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  52593. /**
  52594. * Sets the gravity vector used by the simulation
  52595. * @param gravity defines the gravity vector to use
  52596. */
  52597. setGravity(gravity: Vector3): void;
  52598. /**
  52599. * Set the time step of the physics engine.
  52600. * Default is 1/60.
  52601. * To slow it down, enter 1/600 for example.
  52602. * To speed it up, 1/30
  52603. * @param newTimeStep defines the new timestep to apply to this world.
  52604. */
  52605. setTimeStep(newTimeStep?: number): void;
  52606. /**
  52607. * Get the time step of the physics engine.
  52608. * @returns the current time step
  52609. */
  52610. getTimeStep(): number;
  52611. /**
  52612. * Release all resources
  52613. */
  52614. dispose(): void;
  52615. /**
  52616. * Gets the name of the current physics plugin
  52617. * @returns the name of the plugin
  52618. */
  52619. getPhysicsPluginName(): string;
  52620. /**
  52621. * Adding a new impostor for the impostor tracking.
  52622. * This will be done by the impostor itself.
  52623. * @param impostor the impostor to add
  52624. */
  52625. addImpostor(impostor: PhysicsImpostor): void;
  52626. /**
  52627. * Remove an impostor from the engine.
  52628. * This impostor and its mesh will not longer be updated by the physics engine.
  52629. * @param impostor the impostor to remove
  52630. */
  52631. removeImpostor(impostor: PhysicsImpostor): void;
  52632. /**
  52633. * Add a joint to the physics engine
  52634. * @param mainImpostor defines the main impostor to which the joint is added.
  52635. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  52636. * @param joint defines the joint that will connect both impostors.
  52637. */
  52638. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  52639. /**
  52640. * Removes a joint from the simulation
  52641. * @param mainImpostor defines the impostor used with the joint
  52642. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  52643. * @param joint defines the joint to remove
  52644. */
  52645. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  52646. /**
  52647. * Called by the scene. No need to call it.
  52648. * @param delta defines the timespam between frames
  52649. */
  52650. _step(delta: number): void;
  52651. /**
  52652. * Gets the current plugin used to run the simulation
  52653. * @returns current plugin
  52654. */
  52655. getPhysicsPlugin(): IPhysicsEnginePlugin;
  52656. /**
  52657. * Gets the list of physic impostors
  52658. * @returns an array of PhysicsImpostor
  52659. */
  52660. getImpostors(): Array<PhysicsImpostor>;
  52661. /**
  52662. * Gets the impostor for a physics enabled object
  52663. * @param object defines the object impersonated by the impostor
  52664. * @returns the PhysicsImpostor or null if not found
  52665. */
  52666. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  52667. /**
  52668. * Gets the impostor for a physics body object
  52669. * @param body defines physics body used by the impostor
  52670. * @returns the PhysicsImpostor or null if not found
  52671. */
  52672. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  52673. /**
  52674. * Does a raycast in the physics world
  52675. * @param from when should the ray start?
  52676. * @param to when should the ray end?
  52677. * @returns PhysicsRaycastResult
  52678. */
  52679. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52680. }
  52681. }
  52682. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  52683. import { Nullable } from "babylonjs/types";
  52684. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  52685. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52686. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52687. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52688. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52689. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52690. /** @hidden */
  52691. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  52692. private _useDeltaForWorldStep;
  52693. world: any;
  52694. name: string;
  52695. private _physicsMaterials;
  52696. private _fixedTimeStep;
  52697. private _cannonRaycastResult;
  52698. private _raycastResult;
  52699. private _physicsBodysToRemoveAfterStep;
  52700. BJSCANNON: any;
  52701. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  52702. setGravity(gravity: Vector3): void;
  52703. setTimeStep(timeStep: number): void;
  52704. getTimeStep(): number;
  52705. executeStep(delta: number): void;
  52706. private _removeMarkedPhysicsBodiesFromWorld;
  52707. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52708. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52709. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52710. private _processChildMeshes;
  52711. removePhysicsBody(impostor: PhysicsImpostor): void;
  52712. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52713. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52714. private _addMaterial;
  52715. private _checkWithEpsilon;
  52716. private _createShape;
  52717. private _createHeightmap;
  52718. private _minus90X;
  52719. private _plus90X;
  52720. private _tmpPosition;
  52721. private _tmpDeltaPosition;
  52722. private _tmpUnityRotation;
  52723. private _updatePhysicsBodyTransformation;
  52724. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52725. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52726. isSupported(): boolean;
  52727. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52728. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52729. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52730. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52731. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52732. getBodyMass(impostor: PhysicsImpostor): number;
  52733. getBodyFriction(impostor: PhysicsImpostor): number;
  52734. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52735. getBodyRestitution(impostor: PhysicsImpostor): number;
  52736. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52737. sleepBody(impostor: PhysicsImpostor): void;
  52738. wakeUpBody(impostor: PhysicsImpostor): void;
  52739. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  52740. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  52741. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  52742. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52743. getRadius(impostor: PhysicsImpostor): number;
  52744. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52745. dispose(): void;
  52746. private _extendNamespace;
  52747. /**
  52748. * Does a raycast in the physics world
  52749. * @param from when should the ray start?
  52750. * @param to when should the ray end?
  52751. * @returns PhysicsRaycastResult
  52752. */
  52753. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52754. }
  52755. }
  52756. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  52757. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52758. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52759. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52760. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52761. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  52762. import { Nullable } from "babylonjs/types";
  52763. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52764. /** @hidden */
  52765. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  52766. world: any;
  52767. name: string;
  52768. BJSOIMO: any;
  52769. private _raycastResult;
  52770. constructor(iterations?: number, oimoInjection?: any);
  52771. setGravity(gravity: Vector3): void;
  52772. setTimeStep(timeStep: number): void;
  52773. getTimeStep(): number;
  52774. private _tmpImpostorsArray;
  52775. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  52776. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52777. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52778. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52779. private _tmpPositionVector;
  52780. removePhysicsBody(impostor: PhysicsImpostor): void;
  52781. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52782. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52783. isSupported(): boolean;
  52784. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52785. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52786. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52787. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52788. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52789. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52790. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52791. getBodyMass(impostor: PhysicsImpostor): number;
  52792. getBodyFriction(impostor: PhysicsImpostor): number;
  52793. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52794. getBodyRestitution(impostor: PhysicsImpostor): number;
  52795. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52796. sleepBody(impostor: PhysicsImpostor): void;
  52797. wakeUpBody(impostor: PhysicsImpostor): void;
  52798. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  52799. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  52800. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  52801. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52802. getRadius(impostor: PhysicsImpostor): number;
  52803. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52804. dispose(): void;
  52805. /**
  52806. * Does a raycast in the physics world
  52807. * @param from when should the ray start?
  52808. * @param to when should the ray end?
  52809. * @returns PhysicsRaycastResult
  52810. */
  52811. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52812. }
  52813. }
  52814. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  52815. import { Nullable } from "babylonjs/types";
  52816. import { Scene } from "babylonjs/scene";
  52817. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  52818. import { Color4 } from "babylonjs/Maths/math.color";
  52819. import { Mesh } from "babylonjs/Meshes/mesh";
  52820. /**
  52821. * Class containing static functions to help procedurally build meshes
  52822. */
  52823. export class RibbonBuilder {
  52824. /**
  52825. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52826. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  52827. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  52828. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  52829. * * The parameter `offset` (positive integer, default : rounded half size of the pathArray length), is taken in account only if the `pathArray` is containing a single path
  52830. * * It's the offset to join the points from the same path. Ex : offset = 10 means the point 1 is joined to the point 11
  52831. * * The optional parameter `instance` is an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#ribbon
  52832. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52833. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52834. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52835. * * The parameter `uvs` is an optional flat array of `Vector2` to update/set each ribbon vertex with its own custom UV values instead of the computed ones
  52836. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  52837. * * Note that if you use the parameters `uvs` or `colors`, the passed arrays must be populated with the right number of elements, it is to say the number of ribbon vertices. Remember that if you set `closePath` to `true`, there's one extra vertex per path in the geometry
  52838. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  52839. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52840. * @param name defines the name of the mesh
  52841. * @param options defines the options used to create the mesh
  52842. * @param scene defines the hosting scene
  52843. * @returns the ribbon mesh
  52844. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  52845. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52846. */
  52847. static CreateRibbon(name: string, options: {
  52848. pathArray: Vector3[][];
  52849. closeArray?: boolean;
  52850. closePath?: boolean;
  52851. offset?: number;
  52852. updatable?: boolean;
  52853. sideOrientation?: number;
  52854. frontUVs?: Vector4;
  52855. backUVs?: Vector4;
  52856. instance?: Mesh;
  52857. invertUV?: boolean;
  52858. uvs?: Vector2[];
  52859. colors?: Color4[];
  52860. }, scene?: Nullable<Scene>): Mesh;
  52861. }
  52862. }
  52863. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  52864. import { Nullable } from "babylonjs/types";
  52865. import { Scene } from "babylonjs/scene";
  52866. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  52867. import { Mesh } from "babylonjs/Meshes/mesh";
  52868. /**
  52869. * Class containing static functions to help procedurally build meshes
  52870. */
  52871. export class ShapeBuilder {
  52872. /**
  52873. * Creates an extruded shape mesh. The extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  52874. * * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis.
  52875. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52876. * * The parameter `rotation` (float, default 0 radians) is the angle value to rotate the shape each step (each path point), from the former step (so rotation added each step) along the curve.
  52877. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  52878. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  52879. * * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape
  52880. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  52881. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52882. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52883. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  52884. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52885. * @param name defines the name of the mesh
  52886. * @param options defines the options used to create the mesh
  52887. * @param scene defines the hosting scene
  52888. * @returns the extruded shape mesh
  52889. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52890. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52891. */
  52892. static ExtrudeShape(name: string, options: {
  52893. shape: Vector3[];
  52894. path: Vector3[];
  52895. scale?: number;
  52896. rotation?: number;
  52897. cap?: number;
  52898. updatable?: boolean;
  52899. sideOrientation?: number;
  52900. frontUVs?: Vector4;
  52901. backUVs?: Vector4;
  52902. instance?: Mesh;
  52903. invertUV?: boolean;
  52904. }, scene?: Nullable<Scene>): Mesh;
  52905. /**
  52906. * Creates an custom extruded shape mesh.
  52907. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  52908. * * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis.
  52909. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52910. * * The parameter `rotationFunction` (JS function) is a custom Javascript function called on each path point. This function is passed the position i of the point in the path and the distance of this point from the begining of the path
  52911. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  52912. * * The parameter `scaleFunction` (JS function) is a custom Javascript function called on each path point. This function is passed the position i of the point in the path and the distance of this point from the begining of the path
  52913. * * It must returns a float value that will be the scale value applied to the shape on each path point
  52914. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  52915. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  52916. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  52917. * * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape
  52918. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  52919. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52920. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52921. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52922. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52923. * @param name defines the name of the mesh
  52924. * @param options defines the options used to create the mesh
  52925. * @param scene defines the hosting scene
  52926. * @returns the custom extruded shape mesh
  52927. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  52928. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52929. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52930. */
  52931. static ExtrudeShapeCustom(name: string, options: {
  52932. shape: Vector3[];
  52933. path: Vector3[];
  52934. scaleFunction?: any;
  52935. rotationFunction?: any;
  52936. ribbonCloseArray?: boolean;
  52937. ribbonClosePath?: boolean;
  52938. cap?: number;
  52939. updatable?: boolean;
  52940. sideOrientation?: number;
  52941. frontUVs?: Vector4;
  52942. backUVs?: Vector4;
  52943. instance?: Mesh;
  52944. invertUV?: boolean;
  52945. }, scene?: Nullable<Scene>): Mesh;
  52946. private static _ExtrudeShapeGeneric;
  52947. }
  52948. }
  52949. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  52950. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  52951. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52952. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52953. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52954. import { Nullable } from "babylonjs/types";
  52955. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52956. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52957. /**
  52958. * AmmoJS Physics plugin
  52959. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52960. * @see https://github.com/kripken/ammo.js/
  52961. */
  52962. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  52963. private _useDeltaForWorldStep;
  52964. /**
  52965. * Reference to the Ammo library
  52966. */
  52967. bjsAMMO: any;
  52968. /**
  52969. * Created ammoJS world which physics bodies are added to
  52970. */
  52971. world: any;
  52972. /**
  52973. * Name of the plugin
  52974. */
  52975. name: string;
  52976. private _timeStep;
  52977. private _fixedTimeStep;
  52978. private _maxSteps;
  52979. private _tmpQuaternion;
  52980. private _tmpAmmoTransform;
  52981. private _tmpAmmoQuaternion;
  52982. private _tmpAmmoConcreteContactResultCallback;
  52983. private _collisionConfiguration;
  52984. private _dispatcher;
  52985. private _overlappingPairCache;
  52986. private _solver;
  52987. private _softBodySolver;
  52988. private _tmpAmmoVectorA;
  52989. private _tmpAmmoVectorB;
  52990. private _tmpAmmoVectorC;
  52991. private _tmpAmmoVectorD;
  52992. private _tmpContactCallbackResult;
  52993. private _tmpAmmoVectorRCA;
  52994. private _tmpAmmoVectorRCB;
  52995. private _raycastResult;
  52996. private static readonly DISABLE_COLLISION_FLAG;
  52997. private static readonly KINEMATIC_FLAG;
  52998. private static readonly DISABLE_DEACTIVATION_FLAG;
  52999. /**
  53000. * Initializes the ammoJS plugin
  53001. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  53002. * @param ammoInjection can be used to inject your own ammo reference
  53003. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  53004. */
  53005. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  53006. /**
  53007. * Sets the gravity of the physics world (m/(s^2))
  53008. * @param gravity Gravity to set
  53009. */
  53010. setGravity(gravity: Vector3): void;
  53011. /**
  53012. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  53013. * @param timeStep timestep to use in seconds
  53014. */
  53015. setTimeStep(timeStep: number): void;
  53016. /**
  53017. * Increment to step forward in the physics engine (If timeStep is set to 1/60 and fixedTimeStep is set to 1/120 the physics engine should run 2 steps per frame) (Default: 1/60)
  53018. * @param fixedTimeStep fixedTimeStep to use in seconds
  53019. */
  53020. setFixedTimeStep(fixedTimeStep: number): void;
  53021. /**
  53022. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  53023. * @param maxSteps the maximum number of steps by the physics engine per frame
  53024. */
  53025. setMaxSteps(maxSteps: number): void;
  53026. /**
  53027. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  53028. * @returns the current timestep in seconds
  53029. */
  53030. getTimeStep(): number;
  53031. private _isImpostorInContact;
  53032. private _isImpostorPairInContact;
  53033. private _stepSimulation;
  53034. /**
  53035. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  53036. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  53037. * After the step the babylon meshes are set to the position of the physics imposters
  53038. * @param delta amount of time to step forward
  53039. * @param impostors array of imposters to update before/after the step
  53040. */
  53041. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53042. /**
  53043. * Update babylon mesh to match physics world object
  53044. * @param impostor imposter to match
  53045. */
  53046. private _afterSoftStep;
  53047. /**
  53048. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53049. * @param impostor imposter to match
  53050. */
  53051. private _ropeStep;
  53052. /**
  53053. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53054. * @param impostor imposter to match
  53055. */
  53056. private _softbodyOrClothStep;
  53057. private _tmpVector;
  53058. private _tmpMatrix;
  53059. /**
  53060. * Applies an impulse on the imposter
  53061. * @param impostor imposter to apply impulse to
  53062. * @param force amount of force to be applied to the imposter
  53063. * @param contactPoint the location to apply the impulse on the imposter
  53064. */
  53065. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53066. /**
  53067. * Applies a force on the imposter
  53068. * @param impostor imposter to apply force
  53069. * @param force amount of force to be applied to the imposter
  53070. * @param contactPoint the location to apply the force on the imposter
  53071. */
  53072. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53073. /**
  53074. * Creates a physics body using the plugin
  53075. * @param impostor the imposter to create the physics body on
  53076. */
  53077. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53078. /**
  53079. * Removes the physics body from the imposter and disposes of the body's memory
  53080. * @param impostor imposter to remove the physics body from
  53081. */
  53082. removePhysicsBody(impostor: PhysicsImpostor): void;
  53083. /**
  53084. * Generates a joint
  53085. * @param impostorJoint the imposter joint to create the joint with
  53086. */
  53087. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53088. /**
  53089. * Removes a joint
  53090. * @param impostorJoint the imposter joint to remove the joint from
  53091. */
  53092. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53093. private _addMeshVerts;
  53094. /**
  53095. * Initialise the soft body vertices to match its object's (mesh) vertices
  53096. * Softbody vertices (nodes) are in world space and to match this
  53097. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  53098. * @param impostor to create the softbody for
  53099. */
  53100. private _softVertexData;
  53101. /**
  53102. * Create an impostor's soft body
  53103. * @param impostor to create the softbody for
  53104. */
  53105. private _createSoftbody;
  53106. /**
  53107. * Create cloth for an impostor
  53108. * @param impostor to create the softbody for
  53109. */
  53110. private _createCloth;
  53111. /**
  53112. * Create rope for an impostor
  53113. * @param impostor to create the softbody for
  53114. */
  53115. private _createRope;
  53116. private _addHullVerts;
  53117. private _createShape;
  53118. /**
  53119. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  53120. * @param impostor imposter containing the physics body and babylon object
  53121. */
  53122. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53123. /**
  53124. * Sets the babylon object's position/rotation from the physics body's position/rotation
  53125. * @param impostor imposter containing the physics body and babylon object
  53126. * @param newPosition new position
  53127. * @param newRotation new rotation
  53128. */
  53129. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53130. /**
  53131. * If this plugin is supported
  53132. * @returns true if its supported
  53133. */
  53134. isSupported(): boolean;
  53135. /**
  53136. * Sets the linear velocity of the physics body
  53137. * @param impostor imposter to set the velocity on
  53138. * @param velocity velocity to set
  53139. */
  53140. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53141. /**
  53142. * Sets the angular velocity of the physics body
  53143. * @param impostor imposter to set the velocity on
  53144. * @param velocity velocity to set
  53145. */
  53146. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53147. /**
  53148. * gets the linear velocity
  53149. * @param impostor imposter to get linear velocity from
  53150. * @returns linear velocity
  53151. */
  53152. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53153. /**
  53154. * gets the angular velocity
  53155. * @param impostor imposter to get angular velocity from
  53156. * @returns angular velocity
  53157. */
  53158. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53159. /**
  53160. * Sets the mass of physics body
  53161. * @param impostor imposter to set the mass on
  53162. * @param mass mass to set
  53163. */
  53164. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53165. /**
  53166. * Gets the mass of the physics body
  53167. * @param impostor imposter to get the mass from
  53168. * @returns mass
  53169. */
  53170. getBodyMass(impostor: PhysicsImpostor): number;
  53171. /**
  53172. * Gets friction of the impostor
  53173. * @param impostor impostor to get friction from
  53174. * @returns friction value
  53175. */
  53176. getBodyFriction(impostor: PhysicsImpostor): number;
  53177. /**
  53178. * Sets friction of the impostor
  53179. * @param impostor impostor to set friction on
  53180. * @param friction friction value
  53181. */
  53182. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53183. /**
  53184. * Gets restitution of the impostor
  53185. * @param impostor impostor to get restitution from
  53186. * @returns restitution value
  53187. */
  53188. getBodyRestitution(impostor: PhysicsImpostor): number;
  53189. /**
  53190. * Sets resitution of the impostor
  53191. * @param impostor impostor to set resitution on
  53192. * @param restitution resitution value
  53193. */
  53194. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53195. /**
  53196. * Gets pressure inside the impostor
  53197. * @param impostor impostor to get pressure from
  53198. * @returns pressure value
  53199. */
  53200. getBodyPressure(impostor: PhysicsImpostor): number;
  53201. /**
  53202. * Sets pressure inside a soft body impostor
  53203. * Cloth and rope must remain 0 pressure
  53204. * @param impostor impostor to set pressure on
  53205. * @param pressure pressure value
  53206. */
  53207. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  53208. /**
  53209. * Gets stiffness of the impostor
  53210. * @param impostor impostor to get stiffness from
  53211. * @returns pressure value
  53212. */
  53213. getBodyStiffness(impostor: PhysicsImpostor): number;
  53214. /**
  53215. * Sets stiffness of the impostor
  53216. * @param impostor impostor to set stiffness on
  53217. * @param stiffness stiffness value from 0 to 1
  53218. */
  53219. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  53220. /**
  53221. * Gets velocityIterations of the impostor
  53222. * @param impostor impostor to get velocity iterations from
  53223. * @returns velocityIterations value
  53224. */
  53225. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  53226. /**
  53227. * Sets velocityIterations of the impostor
  53228. * @param impostor impostor to set velocity iterations on
  53229. * @param velocityIterations velocityIterations value
  53230. */
  53231. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  53232. /**
  53233. * Gets positionIterations of the impostor
  53234. * @param impostor impostor to get position iterations from
  53235. * @returns positionIterations value
  53236. */
  53237. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  53238. /**
  53239. * Sets positionIterations of the impostor
  53240. * @param impostor impostor to set position on
  53241. * @param positionIterations positionIterations value
  53242. */
  53243. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  53244. /**
  53245. * Append an anchor to a cloth object
  53246. * @param impostor is the cloth impostor to add anchor to
  53247. * @param otherImpostor is the rigid impostor to anchor to
  53248. * @param width ratio across width from 0 to 1
  53249. * @param height ratio up height from 0 to 1
  53250. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  53251. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53252. */
  53253. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53254. /**
  53255. * Append an hook to a rope object
  53256. * @param impostor is the rope impostor to add hook to
  53257. * @param otherImpostor is the rigid impostor to hook to
  53258. * @param length ratio along the rope from 0 to 1
  53259. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  53260. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53261. */
  53262. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53263. /**
  53264. * Sleeps the physics body and stops it from being active
  53265. * @param impostor impostor to sleep
  53266. */
  53267. sleepBody(impostor: PhysicsImpostor): void;
  53268. /**
  53269. * Activates the physics body
  53270. * @param impostor impostor to activate
  53271. */
  53272. wakeUpBody(impostor: PhysicsImpostor): void;
  53273. /**
  53274. * Updates the distance parameters of the joint
  53275. * @param joint joint to update
  53276. * @param maxDistance maximum distance of the joint
  53277. * @param minDistance minimum distance of the joint
  53278. */
  53279. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  53280. /**
  53281. * Sets a motor on the joint
  53282. * @param joint joint to set motor on
  53283. * @param speed speed of the motor
  53284. * @param maxForce maximum force of the motor
  53285. * @param motorIndex index of the motor
  53286. */
  53287. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53288. /**
  53289. * Sets the motors limit
  53290. * @param joint joint to set limit on
  53291. * @param upperLimit upper limit
  53292. * @param lowerLimit lower limit
  53293. */
  53294. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53295. /**
  53296. * Syncs the position and rotation of a mesh with the impostor
  53297. * @param mesh mesh to sync
  53298. * @param impostor impostor to update the mesh with
  53299. */
  53300. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53301. /**
  53302. * Gets the radius of the impostor
  53303. * @param impostor impostor to get radius from
  53304. * @returns the radius
  53305. */
  53306. getRadius(impostor: PhysicsImpostor): number;
  53307. /**
  53308. * Gets the box size of the impostor
  53309. * @param impostor impostor to get box size from
  53310. * @param result the resulting box size
  53311. */
  53312. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53313. /**
  53314. * Disposes of the impostor
  53315. */
  53316. dispose(): void;
  53317. /**
  53318. * Does a raycast in the physics world
  53319. * @param from when should the ray start?
  53320. * @param to when should the ray end?
  53321. * @returns PhysicsRaycastResult
  53322. */
  53323. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53324. }
  53325. }
  53326. declare module "babylonjs/Probes/reflectionProbe" {
  53327. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53328. import { Vector3 } from "babylonjs/Maths/math.vector";
  53329. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53330. import { Nullable } from "babylonjs/types";
  53331. import { Scene } from "babylonjs/scene";
  53332. module "babylonjs/abstractScene" {
  53333. interface AbstractScene {
  53334. /**
  53335. * The list of reflection probes added to the scene
  53336. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  53337. */
  53338. reflectionProbes: Array<ReflectionProbe>;
  53339. /**
  53340. * Removes the given reflection probe from this scene.
  53341. * @param toRemove The reflection probe to remove
  53342. * @returns The index of the removed reflection probe
  53343. */
  53344. removeReflectionProbe(toRemove: ReflectionProbe): number;
  53345. /**
  53346. * Adds the given reflection probe to this scene.
  53347. * @param newReflectionProbe The reflection probe to add
  53348. */
  53349. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  53350. }
  53351. }
  53352. /**
  53353. * Class used to generate realtime reflection / refraction cube textures
  53354. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  53355. */
  53356. export class ReflectionProbe {
  53357. /** defines the name of the probe */
  53358. name: string;
  53359. private _scene;
  53360. private _renderTargetTexture;
  53361. private _projectionMatrix;
  53362. private _viewMatrix;
  53363. private _target;
  53364. private _add;
  53365. private _attachedMesh;
  53366. private _invertYAxis;
  53367. /** Gets or sets probe position (center of the cube map) */
  53368. position: Vector3;
  53369. /**
  53370. * Creates a new reflection probe
  53371. * @param name defines the name of the probe
  53372. * @param size defines the texture resolution (for each face)
  53373. * @param scene defines the hosting scene
  53374. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  53375. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  53376. */
  53377. constructor(
  53378. /** defines the name of the probe */
  53379. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  53380. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  53381. samples: number;
  53382. /** Gets or sets the refresh rate to use (on every frame by default) */
  53383. refreshRate: number;
  53384. /**
  53385. * Gets the hosting scene
  53386. * @returns a Scene
  53387. */
  53388. getScene(): Scene;
  53389. /** Gets the internal CubeTexture used to render to */
  53390. readonly cubeTexture: RenderTargetTexture;
  53391. /** Gets the list of meshes to render */
  53392. readonly renderList: Nullable<AbstractMesh[]>;
  53393. /**
  53394. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  53395. * @param mesh defines the mesh to attach to
  53396. */
  53397. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  53398. /**
  53399. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  53400. * @param renderingGroupId The rendering group id corresponding to its index
  53401. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  53402. */
  53403. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  53404. /**
  53405. * Clean all associated resources
  53406. */
  53407. dispose(): void;
  53408. /**
  53409. * Converts the reflection probe information to a readable string for debug purpose.
  53410. * @param fullDetails Supports for multiple levels of logging within scene loading
  53411. * @returns the human readable reflection probe info
  53412. */
  53413. toString(fullDetails?: boolean): string;
  53414. /**
  53415. * Get the class name of the relfection probe.
  53416. * @returns "ReflectionProbe"
  53417. */
  53418. getClassName(): string;
  53419. /**
  53420. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  53421. * @returns The JSON representation of the texture
  53422. */
  53423. serialize(): any;
  53424. /**
  53425. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  53426. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  53427. * @param scene Define the scene the parsed reflection probe should be instantiated in
  53428. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  53429. * @returns The parsed reflection probe if successful
  53430. */
  53431. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  53432. }
  53433. }
  53434. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  53435. /** @hidden */
  53436. export var _BabylonLoaderRegistered: boolean;
  53437. }
  53438. declare module "babylonjs/Loading/Plugins/index" {
  53439. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  53440. }
  53441. declare module "babylonjs/Loading/index" {
  53442. export * from "babylonjs/Loading/loadingScreen";
  53443. export * from "babylonjs/Loading/Plugins/index";
  53444. export * from "babylonjs/Loading/sceneLoader";
  53445. export * from "babylonjs/Loading/sceneLoaderFlags";
  53446. }
  53447. declare module "babylonjs/Materials/Background/index" {
  53448. export * from "babylonjs/Materials/Background/backgroundMaterial";
  53449. }
  53450. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  53451. import { Scene } from "babylonjs/scene";
  53452. import { Color3 } from "babylonjs/Maths/math.color";
  53453. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53454. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53455. /**
  53456. * The Physically based simple base material of BJS.
  53457. *
  53458. * This enables better naming and convention enforcements on top of the pbrMaterial.
  53459. * It is used as the base class for both the specGloss and metalRough conventions.
  53460. */
  53461. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  53462. /**
  53463. * Number of Simultaneous lights allowed on the material.
  53464. */
  53465. maxSimultaneousLights: number;
  53466. /**
  53467. * If sets to true, disables all the lights affecting the material.
  53468. */
  53469. disableLighting: boolean;
  53470. /**
  53471. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  53472. */
  53473. environmentTexture: BaseTexture;
  53474. /**
  53475. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  53476. */
  53477. invertNormalMapX: boolean;
  53478. /**
  53479. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  53480. */
  53481. invertNormalMapY: boolean;
  53482. /**
  53483. * Normal map used in the model.
  53484. */
  53485. normalTexture: BaseTexture;
  53486. /**
  53487. * Emissivie color used to self-illuminate the model.
  53488. */
  53489. emissiveColor: Color3;
  53490. /**
  53491. * Emissivie texture used to self-illuminate the model.
  53492. */
  53493. emissiveTexture: BaseTexture;
  53494. /**
  53495. * Occlusion Channel Strenght.
  53496. */
  53497. occlusionStrength: number;
  53498. /**
  53499. * Occlusion Texture of the material (adding extra occlusion effects).
  53500. */
  53501. occlusionTexture: BaseTexture;
  53502. /**
  53503. * Defines the alpha limits in alpha test mode.
  53504. */
  53505. alphaCutOff: number;
  53506. /**
  53507. * Gets the current double sided mode.
  53508. */
  53509. /**
  53510. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53511. */
  53512. doubleSided: boolean;
  53513. /**
  53514. * Stores the pre-calculated light information of a mesh in a texture.
  53515. */
  53516. lightmapTexture: BaseTexture;
  53517. /**
  53518. * If true, the light map contains occlusion information instead of lighting info.
  53519. */
  53520. useLightmapAsShadowmap: boolean;
  53521. /**
  53522. * Instantiates a new PBRMaterial instance.
  53523. *
  53524. * @param name The material name
  53525. * @param scene The scene the material will be use in.
  53526. */
  53527. constructor(name: string, scene: Scene);
  53528. getClassName(): string;
  53529. }
  53530. }
  53531. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  53532. import { Scene } from "babylonjs/scene";
  53533. import { Color3 } from "babylonjs/Maths/math.color";
  53534. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53535. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  53536. /**
  53537. * The PBR material of BJS following the metal roughness convention.
  53538. *
  53539. * This fits to the PBR convention in the GLTF definition:
  53540. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  53541. */
  53542. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  53543. /**
  53544. * The base color has two different interpretations depending on the value of metalness.
  53545. * When the material is a metal, the base color is the specific measured reflectance value
  53546. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  53547. * of the material.
  53548. */
  53549. baseColor: Color3;
  53550. /**
  53551. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  53552. * well as opacity information in the alpha channel.
  53553. */
  53554. baseTexture: BaseTexture;
  53555. /**
  53556. * Specifies the metallic scalar value of the material.
  53557. * Can also be used to scale the metalness values of the metallic texture.
  53558. */
  53559. metallic: number;
  53560. /**
  53561. * Specifies the roughness scalar value of the material.
  53562. * Can also be used to scale the roughness values of the metallic texture.
  53563. */
  53564. roughness: number;
  53565. /**
  53566. * Texture containing both the metallic value in the B channel and the
  53567. * roughness value in the G channel to keep better precision.
  53568. */
  53569. metallicRoughnessTexture: BaseTexture;
  53570. /**
  53571. * Instantiates a new PBRMetalRoughnessMaterial instance.
  53572. *
  53573. * @param name The material name
  53574. * @param scene The scene the material will be use in.
  53575. */
  53576. constructor(name: string, scene: Scene);
  53577. /**
  53578. * Return the currrent class name of the material.
  53579. */
  53580. getClassName(): string;
  53581. /**
  53582. * Makes a duplicate of the current material.
  53583. * @param name - name to use for the new material.
  53584. */
  53585. clone(name: string): PBRMetallicRoughnessMaterial;
  53586. /**
  53587. * Serialize the material to a parsable JSON object.
  53588. */
  53589. serialize(): any;
  53590. /**
  53591. * Parses a JSON object correponding to the serialize function.
  53592. */
  53593. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  53594. }
  53595. }
  53596. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  53597. import { Scene } from "babylonjs/scene";
  53598. import { Color3 } from "babylonjs/Maths/math.color";
  53599. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53600. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  53601. /**
  53602. * The PBR material of BJS following the specular glossiness convention.
  53603. *
  53604. * This fits to the PBR convention in the GLTF definition:
  53605. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  53606. */
  53607. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  53608. /**
  53609. * Specifies the diffuse color of the material.
  53610. */
  53611. diffuseColor: Color3;
  53612. /**
  53613. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  53614. * channel.
  53615. */
  53616. diffuseTexture: BaseTexture;
  53617. /**
  53618. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  53619. */
  53620. specularColor: Color3;
  53621. /**
  53622. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  53623. */
  53624. glossiness: number;
  53625. /**
  53626. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  53627. */
  53628. specularGlossinessTexture: BaseTexture;
  53629. /**
  53630. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  53631. *
  53632. * @param name The material name
  53633. * @param scene The scene the material will be use in.
  53634. */
  53635. constructor(name: string, scene: Scene);
  53636. /**
  53637. * Return the currrent class name of the material.
  53638. */
  53639. getClassName(): string;
  53640. /**
  53641. * Makes a duplicate of the current material.
  53642. * @param name - name to use for the new material.
  53643. */
  53644. clone(name: string): PBRSpecularGlossinessMaterial;
  53645. /**
  53646. * Serialize the material to a parsable JSON object.
  53647. */
  53648. serialize(): any;
  53649. /**
  53650. * Parses a JSON object correponding to the serialize function.
  53651. */
  53652. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  53653. }
  53654. }
  53655. declare module "babylonjs/Materials/PBR/index" {
  53656. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53657. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  53658. export * from "babylonjs/Materials/PBR/pbrMaterial";
  53659. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  53660. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  53661. }
  53662. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  53663. import { Nullable } from "babylonjs/types";
  53664. import { Scene } from "babylonjs/scene";
  53665. import { Matrix } from "babylonjs/Maths/math.vector";
  53666. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53667. /**
  53668. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  53669. * It can help converting any input color in a desired output one. This can then be used to create effects
  53670. * from sepia, black and white to sixties or futuristic rendering...
  53671. *
  53672. * The only supported format is currently 3dl.
  53673. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  53674. */
  53675. export class ColorGradingTexture extends BaseTexture {
  53676. /**
  53677. * The current texture matrix. (will always be identity in color grading texture)
  53678. */
  53679. private _textureMatrix;
  53680. /**
  53681. * The texture URL.
  53682. */
  53683. url: string;
  53684. /**
  53685. * Empty line regex stored for GC.
  53686. */
  53687. private static _noneEmptyLineRegex;
  53688. private _engine;
  53689. /**
  53690. * Instantiates a ColorGradingTexture from the following parameters.
  53691. *
  53692. * @param url The location of the color gradind data (currently only supporting 3dl)
  53693. * @param scene The scene the texture will be used in
  53694. */
  53695. constructor(url: string, scene: Scene);
  53696. /**
  53697. * Returns the texture matrix used in most of the material.
  53698. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  53699. */
  53700. getTextureMatrix(): Matrix;
  53701. /**
  53702. * Occurs when the file being loaded is a .3dl LUT file.
  53703. */
  53704. private load3dlTexture;
  53705. /**
  53706. * Starts the loading process of the texture.
  53707. */
  53708. private loadTexture;
  53709. /**
  53710. * Clones the color gradind texture.
  53711. */
  53712. clone(): ColorGradingTexture;
  53713. /**
  53714. * Called during delayed load for textures.
  53715. */
  53716. delayLoad(): void;
  53717. /**
  53718. * Parses a color grading texture serialized by Babylon.
  53719. * @param parsedTexture The texture information being parsedTexture
  53720. * @param scene The scene to load the texture in
  53721. * @param rootUrl The root url of the data assets to load
  53722. * @return A color gradind texture
  53723. */
  53724. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  53725. /**
  53726. * Serializes the LUT texture to json format.
  53727. */
  53728. serialize(): any;
  53729. }
  53730. }
  53731. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  53732. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53733. import { Scene } from "babylonjs/scene";
  53734. import { Nullable } from "babylonjs/types";
  53735. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53736. /**
  53737. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  53738. */
  53739. export class EquiRectangularCubeTexture extends BaseTexture {
  53740. /** The six faces of the cube. */
  53741. private static _FacesMapping;
  53742. private _noMipmap;
  53743. private _onLoad;
  53744. private _onError;
  53745. /** The size of the cubemap. */
  53746. private _size;
  53747. /** The buffer of the image. */
  53748. private _buffer;
  53749. /** The width of the input image. */
  53750. private _width;
  53751. /** The height of the input image. */
  53752. private _height;
  53753. /** The URL to the image. */
  53754. url: string;
  53755. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  53756. coordinatesMode: number;
  53757. /**
  53758. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  53759. * @param url The location of the image
  53760. * @param scene The scene the texture will be used in
  53761. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  53762. * @param noMipmap Forces to not generate the mipmap if true
  53763. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  53764. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  53765. * @param onLoad — defines a callback called when texture is loaded
  53766. * @param onError — defines a callback called if there is an error
  53767. */
  53768. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  53769. /**
  53770. * Load the image data, by putting the image on a canvas and extracting its buffer.
  53771. */
  53772. private loadImage;
  53773. /**
  53774. * Convert the image buffer into a cubemap and create a CubeTexture.
  53775. */
  53776. private loadTexture;
  53777. /**
  53778. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  53779. * @param buffer The ArrayBuffer that should be converted.
  53780. * @returns The buffer as Float32Array.
  53781. */
  53782. private getFloat32ArrayFromArrayBuffer;
  53783. /**
  53784. * Get the current class name of the texture useful for serialization or dynamic coding.
  53785. * @returns "EquiRectangularCubeTexture"
  53786. */
  53787. getClassName(): string;
  53788. /**
  53789. * Create a clone of the current EquiRectangularCubeTexture and return it.
  53790. * @returns A clone of the current EquiRectangularCubeTexture.
  53791. */
  53792. clone(): EquiRectangularCubeTexture;
  53793. }
  53794. }
  53795. declare module "babylonjs/Misc/tga" {
  53796. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53797. /**
  53798. * Based on jsTGALoader - Javascript loader for TGA file
  53799. * By Vincent Thibault
  53800. * @see http://blog.robrowser.com/javascript-tga-loader.html
  53801. */
  53802. export class TGATools {
  53803. private static _TYPE_INDEXED;
  53804. private static _TYPE_RGB;
  53805. private static _TYPE_GREY;
  53806. private static _TYPE_RLE_INDEXED;
  53807. private static _TYPE_RLE_RGB;
  53808. private static _TYPE_RLE_GREY;
  53809. private static _ORIGIN_MASK;
  53810. private static _ORIGIN_SHIFT;
  53811. private static _ORIGIN_BL;
  53812. private static _ORIGIN_BR;
  53813. private static _ORIGIN_UL;
  53814. private static _ORIGIN_UR;
  53815. /**
  53816. * Gets the header of a TGA file
  53817. * @param data defines the TGA data
  53818. * @returns the header
  53819. */
  53820. static GetTGAHeader(data: Uint8Array): any;
  53821. /**
  53822. * Uploads TGA content to a Babylon Texture
  53823. * @hidden
  53824. */
  53825. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  53826. /** @hidden */
  53827. static _getImageData8bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array;
  53828. /** @hidden */
  53829. static _getImageData16bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array;
  53830. /** @hidden */
  53831. static _getImageData24bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array;
  53832. /** @hidden */
  53833. static _getImageData32bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array;
  53834. /** @hidden */
  53835. static _getImageDataGrey8bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array;
  53836. /** @hidden */
  53837. static _getImageDataGrey16bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array;
  53838. }
  53839. }
  53840. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  53841. import { Nullable } from "babylonjs/types";
  53842. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53843. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  53844. /**
  53845. * Implementation of the TGA Texture Loader.
  53846. * @hidden
  53847. */
  53848. export class _TGATextureLoader implements IInternalTextureLoader {
  53849. /**
  53850. * Defines wether the loader supports cascade loading the different faces.
  53851. */
  53852. readonly supportCascades: boolean;
  53853. /**
  53854. * This returns if the loader support the current file information.
  53855. * @param extension defines the file extension of the file being loaded
  53856. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53857. * @param fallback defines the fallback internal texture if any
  53858. * @param isBase64 defines whether the texture is encoded as a base64
  53859. * @param isBuffer defines whether the texture data are stored as a buffer
  53860. * @returns true if the loader can load the specified file
  53861. */
  53862. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53863. /**
  53864. * Transform the url before loading if required.
  53865. * @param rootUrl the url of the texture
  53866. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53867. * @returns the transformed texture
  53868. */
  53869. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53870. /**
  53871. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53872. * @param rootUrl the url of the texture
  53873. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53874. * @returns the fallback texture
  53875. */
  53876. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53877. /**
  53878. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53879. * @param data contains the texture data
  53880. * @param texture defines the BabylonJS internal texture
  53881. * @param createPolynomials will be true if polynomials have been requested
  53882. * @param onLoad defines the callback to trigger once the texture is ready
  53883. * @param onError defines the callback to trigger in case of error
  53884. */
  53885. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53886. /**
  53887. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53888. * @param data contains the texture data
  53889. * @param texture defines the BabylonJS internal texture
  53890. * @param callback defines the method to call once ready to upload
  53891. */
  53892. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  53893. }
  53894. }
  53895. declare module "babylonjs/Misc/basis" {
  53896. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53897. /**
  53898. * Info about the .basis files
  53899. */
  53900. class BasisFileInfo {
  53901. /**
  53902. * If the file has alpha
  53903. */
  53904. hasAlpha: boolean;
  53905. /**
  53906. * Info about each image of the basis file
  53907. */
  53908. images: Array<{
  53909. levels: Array<{
  53910. width: number;
  53911. height: number;
  53912. transcodedPixels: ArrayBufferView;
  53913. }>;
  53914. }>;
  53915. }
  53916. /**
  53917. * Result of transcoding a basis file
  53918. */
  53919. class TranscodeResult {
  53920. /**
  53921. * Info about the .basis file
  53922. */
  53923. fileInfo: BasisFileInfo;
  53924. /**
  53925. * Format to use when loading the file
  53926. */
  53927. format: number;
  53928. }
  53929. /**
  53930. * Configuration options for the Basis transcoder
  53931. */
  53932. export class BasisTranscodeConfiguration {
  53933. /**
  53934. * Supported compression formats used to determine the supported output format of the transcoder
  53935. */
  53936. supportedCompressionFormats?: {
  53937. /**
  53938. * etc1 compression format
  53939. */
  53940. etc1?: boolean;
  53941. /**
  53942. * s3tc compression format
  53943. */
  53944. s3tc?: boolean;
  53945. /**
  53946. * pvrtc compression format
  53947. */
  53948. pvrtc?: boolean;
  53949. /**
  53950. * etc2 compression format
  53951. */
  53952. etc2?: boolean;
  53953. };
  53954. /**
  53955. * If mipmap levels should be loaded for transcoded images (Default: true)
  53956. */
  53957. loadMipmapLevels?: boolean;
  53958. /**
  53959. * Index of a single image to load (Default: all images)
  53960. */
  53961. loadSingleImage?: number;
  53962. }
  53963. /**
  53964. * Used to load .Basis files
  53965. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  53966. */
  53967. export class BasisTools {
  53968. private static _IgnoreSupportedFormats;
  53969. /**
  53970. * URL to use when loading the basis transcoder
  53971. */
  53972. static JSModuleURL: string;
  53973. /**
  53974. * URL to use when loading the wasm module for the transcoder
  53975. */
  53976. static WasmModuleURL: string;
  53977. /**
  53978. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  53979. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  53980. * @returns internal format corresponding to the Basis format
  53981. */
  53982. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  53983. private static _WorkerPromise;
  53984. private static _Worker;
  53985. private static _actionId;
  53986. private static _CreateWorkerAsync;
  53987. /**
  53988. * Transcodes a loaded image file to compressed pixel data
  53989. * @param imageData image data to transcode
  53990. * @param config configuration options for the transcoding
  53991. * @returns a promise resulting in the transcoded image
  53992. */
  53993. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  53994. /**
  53995. * Loads a texture from the transcode result
  53996. * @param texture texture load to
  53997. * @param transcodeResult the result of transcoding the basis file to load from
  53998. */
  53999. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  54000. }
  54001. }
  54002. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  54003. import { Nullable } from "babylonjs/types";
  54004. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54005. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54006. /**
  54007. * Loader for .basis file format
  54008. */
  54009. export class _BasisTextureLoader implements IInternalTextureLoader {
  54010. /**
  54011. * Defines whether the loader supports cascade loading the different faces.
  54012. */
  54013. readonly supportCascades: boolean;
  54014. /**
  54015. * This returns if the loader support the current file information.
  54016. * @param extension defines the file extension of the file being loaded
  54017. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54018. * @param fallback defines the fallback internal texture if any
  54019. * @param isBase64 defines whether the texture is encoded as a base64
  54020. * @param isBuffer defines whether the texture data are stored as a buffer
  54021. * @returns true if the loader can load the specified file
  54022. */
  54023. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54024. /**
  54025. * Transform the url before loading if required.
  54026. * @param rootUrl the url of the texture
  54027. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54028. * @returns the transformed texture
  54029. */
  54030. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54031. /**
  54032. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54033. * @param rootUrl the url of the texture
  54034. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54035. * @returns the fallback texture
  54036. */
  54037. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54038. /**
  54039. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  54040. * @param data contains the texture data
  54041. * @param texture defines the BabylonJS internal texture
  54042. * @param createPolynomials will be true if polynomials have been requested
  54043. * @param onLoad defines the callback to trigger once the texture is ready
  54044. * @param onError defines the callback to trigger in case of error
  54045. */
  54046. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54047. /**
  54048. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54049. * @param data contains the texture data
  54050. * @param texture defines the BabylonJS internal texture
  54051. * @param callback defines the method to call once ready to upload
  54052. */
  54053. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54054. }
  54055. }
  54056. declare module "babylonjs/Materials/Textures/Loaders/index" {
  54057. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  54058. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  54059. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  54060. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  54061. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  54062. }
  54063. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  54064. import { Scene } from "babylonjs/scene";
  54065. import { Texture } from "babylonjs/Materials/Textures/texture";
  54066. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54067. /**
  54068. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  54069. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54070. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54071. */
  54072. export class CustomProceduralTexture extends ProceduralTexture {
  54073. private _animate;
  54074. private _time;
  54075. private _config;
  54076. private _texturePath;
  54077. /**
  54078. * Instantiates a new Custom Procedural Texture.
  54079. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  54080. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54081. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54082. * @param name Define the name of the texture
  54083. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  54084. * @param size Define the size of the texture to create
  54085. * @param scene Define the scene the texture belongs to
  54086. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  54087. * @param generateMipMaps Define if the texture should creates mip maps or not
  54088. */
  54089. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54090. private _loadJson;
  54091. /**
  54092. * Is the texture ready to be used ? (rendered at least once)
  54093. * @returns true if ready, otherwise, false.
  54094. */
  54095. isReady(): boolean;
  54096. /**
  54097. * Render the texture to its associated render target.
  54098. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  54099. */
  54100. render(useCameraPostProcess?: boolean): void;
  54101. /**
  54102. * Update the list of dependant textures samplers in the shader.
  54103. */
  54104. updateTextures(): void;
  54105. /**
  54106. * Update the uniform values of the procedural texture in the shader.
  54107. */
  54108. updateShaderUniforms(): void;
  54109. /**
  54110. * Define if the texture animates or not.
  54111. */
  54112. animate: boolean;
  54113. }
  54114. }
  54115. declare module "babylonjs/Shaders/noise.fragment" {
  54116. /** @hidden */
  54117. export var noisePixelShader: {
  54118. name: string;
  54119. shader: string;
  54120. };
  54121. }
  54122. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  54123. import { Nullable } from "babylonjs/types";
  54124. import { Scene } from "babylonjs/scene";
  54125. import { Texture } from "babylonjs/Materials/Textures/texture";
  54126. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54127. import "babylonjs/Shaders/noise.fragment";
  54128. /**
  54129. * Class used to generate noise procedural textures
  54130. */
  54131. export class NoiseProceduralTexture extends ProceduralTexture {
  54132. private _time;
  54133. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  54134. brightness: number;
  54135. /** Defines the number of octaves to process */
  54136. octaves: number;
  54137. /** Defines the level of persistence (0.8 by default) */
  54138. persistence: number;
  54139. /** Gets or sets animation speed factor (default is 1) */
  54140. animationSpeedFactor: number;
  54141. /**
  54142. * Creates a new NoiseProceduralTexture
  54143. * @param name defines the name fo the texture
  54144. * @param size defines the size of the texture (default is 256)
  54145. * @param scene defines the hosting scene
  54146. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  54147. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  54148. */
  54149. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54150. private _updateShaderUniforms;
  54151. protected _getDefines(): string;
  54152. /** Generate the current state of the procedural texture */
  54153. render(useCameraPostProcess?: boolean): void;
  54154. /**
  54155. * Serializes this noise procedural texture
  54156. * @returns a serialized noise procedural texture object
  54157. */
  54158. serialize(): any;
  54159. /**
  54160. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  54161. * @param parsedTexture defines parsed texture data
  54162. * @param scene defines the current scene
  54163. * @param rootUrl defines the root URL containing noise procedural texture information
  54164. * @returns a parsed NoiseProceduralTexture
  54165. */
  54166. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  54167. }
  54168. }
  54169. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  54170. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  54171. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  54172. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54173. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  54174. }
  54175. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  54176. import { Nullable } from "babylonjs/types";
  54177. import { Scene } from "babylonjs/scene";
  54178. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54179. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54180. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  54181. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54182. /**
  54183. * Raw cube texture where the raw buffers are passed in
  54184. */
  54185. export class RawCubeTexture extends CubeTexture {
  54186. /**
  54187. * Creates a cube texture where the raw buffers are passed in.
  54188. * @param scene defines the scene the texture is attached to
  54189. * @param data defines the array of data to use to create each face
  54190. * @param size defines the size of the textures
  54191. * @param format defines the format of the data
  54192. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  54193. * @param generateMipMaps defines if the engine should generate the mip levels
  54194. * @param invertY defines if data must be stored with Y axis inverted
  54195. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  54196. * @param compression defines the compression used (null by default)
  54197. */
  54198. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  54199. /**
  54200. * Updates the raw cube texture.
  54201. * @param data defines the data to store
  54202. * @param format defines the data format
  54203. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  54204. * @param invertY defines if data must be stored with Y axis inverted
  54205. * @param compression defines the compression used (null by default)
  54206. * @param level defines which level of the texture to update
  54207. */
  54208. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  54209. /**
  54210. * Updates a raw cube texture with RGBD encoded data.
  54211. * @param data defines the array of data [mipmap][face] to use to create each face
  54212. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  54213. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  54214. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  54215. * @returns a promsie that resolves when the operation is complete
  54216. */
  54217. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  54218. /**
  54219. * Clones the raw cube texture.
  54220. * @return a new cube texture
  54221. */
  54222. clone(): CubeTexture;
  54223. /** @hidden */
  54224. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  54225. }
  54226. }
  54227. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  54228. import { Scene } from "babylonjs/scene";
  54229. import { Texture } from "babylonjs/Materials/Textures/texture";
  54230. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54231. /**
  54232. * Class used to store 3D textures containing user data
  54233. */
  54234. export class RawTexture3D extends Texture {
  54235. /** Gets or sets the texture format to use */
  54236. format: number;
  54237. private _engine;
  54238. /**
  54239. * Create a new RawTexture3D
  54240. * @param data defines the data of the texture
  54241. * @param width defines the width of the texture
  54242. * @param height defines the height of the texture
  54243. * @param depth defines the depth of the texture
  54244. * @param format defines the texture format to use
  54245. * @param scene defines the hosting scene
  54246. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  54247. * @param invertY defines if texture must be stored with Y axis inverted
  54248. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  54249. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  54250. */
  54251. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  54252. /** Gets or sets the texture format to use */
  54253. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  54254. /**
  54255. * Update the texture with new data
  54256. * @param data defines the data to store in the texture
  54257. */
  54258. update(data: ArrayBufferView): void;
  54259. }
  54260. }
  54261. declare module "babylonjs/Materials/Textures/refractionTexture" {
  54262. import { Scene } from "babylonjs/scene";
  54263. import { Plane } from "babylonjs/Maths/math.plane";
  54264. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54265. /**
  54266. * Creates a refraction texture used by refraction channel of the standard material.
  54267. * It is like a mirror but to see through a material.
  54268. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54269. */
  54270. export class RefractionTexture extends RenderTargetTexture {
  54271. /**
  54272. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  54273. * It is possible to directly set the refractionPlane by directly using a Plane(a, b, c, d) where a, b and c give the plane normal vector (a, b, c) and d is a scalar displacement from the refractionPlane to the origin. However in all but the very simplest of situations it is more straight forward to set it to the refractor as stated in the doc.
  54274. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54275. */
  54276. refractionPlane: Plane;
  54277. /**
  54278. * Define how deep under the surface we should see.
  54279. */
  54280. depth: number;
  54281. /**
  54282. * Creates a refraction texture used by refraction channel of the standard material.
  54283. * It is like a mirror but to see through a material.
  54284. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54285. * @param name Define the texture name
  54286. * @param size Define the size of the underlying texture
  54287. * @param scene Define the scene the refraction belongs to
  54288. * @param generateMipMaps Define if we need to generate mips level for the refraction
  54289. */
  54290. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  54291. /**
  54292. * Clone the refraction texture.
  54293. * @returns the cloned texture
  54294. */
  54295. clone(): RefractionTexture;
  54296. /**
  54297. * Serialize the texture to a JSON representation you could use in Parse later on
  54298. * @returns the serialized JSON representation
  54299. */
  54300. serialize(): any;
  54301. }
  54302. }
  54303. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  54304. import { Nullable } from "babylonjs/types";
  54305. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54306. import { Matrix } from "babylonjs/Maths/math.vector";
  54307. import { Engine } from "babylonjs/Engines/engine";
  54308. import { Scene } from "babylonjs/scene";
  54309. /**
  54310. * Defines the options related to the creation of an HtmlElementTexture
  54311. */
  54312. export interface IHtmlElementTextureOptions {
  54313. /**
  54314. * Defines wether mip maps should be created or not.
  54315. */
  54316. generateMipMaps?: boolean;
  54317. /**
  54318. * Defines the sampling mode of the texture.
  54319. */
  54320. samplingMode?: number;
  54321. /**
  54322. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  54323. */
  54324. engine: Nullable<Engine>;
  54325. /**
  54326. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  54327. */
  54328. scene: Nullable<Scene>;
  54329. }
  54330. /**
  54331. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  54332. * To be as efficient as possible depending on your constraints nothing aside the first upload
  54333. * is automatically managed.
  54334. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  54335. * in your application.
  54336. *
  54337. * As the update is not automatic, you need to call them manually.
  54338. */
  54339. export class HtmlElementTexture extends BaseTexture {
  54340. /**
  54341. * The texture URL.
  54342. */
  54343. element: HTMLVideoElement | HTMLCanvasElement;
  54344. private static readonly DefaultOptions;
  54345. private _textureMatrix;
  54346. private _engine;
  54347. private _isVideo;
  54348. private _generateMipMaps;
  54349. private _samplingMode;
  54350. /**
  54351. * Instantiates a HtmlElementTexture from the following parameters.
  54352. *
  54353. * @param name Defines the name of the texture
  54354. * @param element Defines the video or canvas the texture is filled with
  54355. * @param options Defines the other none mandatory texture creation options
  54356. */
  54357. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  54358. private _createInternalTexture;
  54359. /**
  54360. * Returns the texture matrix used in most of the material.
  54361. */
  54362. getTextureMatrix(): Matrix;
  54363. /**
  54364. * Updates the content of the texture.
  54365. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  54366. */
  54367. update(invertY?: Nullable<boolean>): void;
  54368. }
  54369. }
  54370. declare module "babylonjs/Materials/Textures/index" {
  54371. export * from "babylonjs/Materials/Textures/baseTexture";
  54372. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  54373. export * from "babylonjs/Materials/Textures/cubeTexture";
  54374. export * from "babylonjs/Materials/Textures/dynamicTexture";
  54375. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  54376. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  54377. export * from "babylonjs/Materials/Textures/internalTexture";
  54378. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  54379. export * from "babylonjs/Materials/Textures/Loaders/index";
  54380. export * from "babylonjs/Materials/Textures/mirrorTexture";
  54381. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  54382. export * from "babylonjs/Materials/Textures/Procedurals/index";
  54383. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  54384. export * from "babylonjs/Materials/Textures/rawTexture";
  54385. export * from "babylonjs/Materials/Textures/rawTexture3D";
  54386. export * from "babylonjs/Materials/Textures/refractionTexture";
  54387. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  54388. export * from "babylonjs/Materials/Textures/texture";
  54389. export * from "babylonjs/Materials/Textures/videoTexture";
  54390. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  54391. }
  54392. declare module "babylonjs/Materials/Node/nodeMaterialBlockTargets" {
  54393. /**
  54394. * Enum used to define the target of a block
  54395. */
  54396. export enum NodeMaterialBlockTargets {
  54397. /** Vertex shader */
  54398. Vertex = 1,
  54399. /** Fragment shader */
  54400. Fragment = 2,
  54401. /** Neutral */
  54402. Neutral = 4,
  54403. /** Vertex and Fragment */
  54404. VertexAndFragment = 3
  54405. }
  54406. }
  54407. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes" {
  54408. /**
  54409. * Defines the kind of connection point for node based material
  54410. */
  54411. export enum NodeMaterialBlockConnectionPointTypes {
  54412. /** Float */
  54413. Float = 1,
  54414. /** Int */
  54415. Int = 2,
  54416. /** Vector2 */
  54417. Vector2 = 4,
  54418. /** Vector3 */
  54419. Vector3 = 8,
  54420. /** Vector4 */
  54421. Vector4 = 16,
  54422. /** Color3 */
  54423. Color3 = 32,
  54424. /** Color4 */
  54425. Color4 = 64,
  54426. /** Matrix */
  54427. Matrix = 128,
  54428. /** Detect type based on connection */
  54429. AutoDetect = 1024,
  54430. /** Output type that will be defined by input type */
  54431. BasedOnInput = 2048
  54432. }
  54433. }
  54434. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  54435. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54436. /**
  54437. * Root class for all node material optimizers
  54438. */
  54439. export class NodeMaterialOptimizer {
  54440. /**
  54441. * Function used to optimize a NodeMaterial graph
  54442. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  54443. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  54444. */
  54445. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  54446. }
  54447. }
  54448. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  54449. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54450. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54451. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54452. import { Scene } from "babylonjs/scene";
  54453. /**
  54454. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  54455. */
  54456. export class TransformBlock extends NodeMaterialBlock {
  54457. /**
  54458. * Defines the value to use to complement W value to transform it to a Vector4
  54459. */
  54460. complementW: number;
  54461. /**
  54462. * Defines the value to use to complement z value to transform it to a Vector4
  54463. */
  54464. complementZ: number;
  54465. /**
  54466. * Creates a new TransformBlock
  54467. * @param name defines the block name
  54468. */
  54469. constructor(name: string);
  54470. /**
  54471. * Gets the current class name
  54472. * @returns the class name
  54473. */
  54474. getClassName(): string;
  54475. /**
  54476. * Gets the vector input
  54477. */
  54478. readonly vector: NodeMaterialConnectionPoint;
  54479. /**
  54480. * Gets the output component
  54481. */
  54482. readonly output: NodeMaterialConnectionPoint;
  54483. /**
  54484. * Gets the matrix transform input
  54485. */
  54486. readonly transform: NodeMaterialConnectionPoint;
  54487. protected _buildBlock(state: NodeMaterialBuildState): this;
  54488. serialize(): any;
  54489. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54490. protected _dumpPropertiesCode(): string;
  54491. }
  54492. }
  54493. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  54494. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54495. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54496. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54497. /**
  54498. * Block used to output the vertex position
  54499. */
  54500. export class VertexOutputBlock extends NodeMaterialBlock {
  54501. /**
  54502. * Creates a new VertexOutputBlock
  54503. * @param name defines the block name
  54504. */
  54505. constructor(name: string);
  54506. /**
  54507. * Gets the current class name
  54508. * @returns the class name
  54509. */
  54510. getClassName(): string;
  54511. /**
  54512. * Gets the vector input component
  54513. */
  54514. readonly vector: NodeMaterialConnectionPoint;
  54515. protected _buildBlock(state: NodeMaterialBuildState): this;
  54516. }
  54517. }
  54518. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  54519. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54520. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54521. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54522. /**
  54523. * Block used to output the final color
  54524. */
  54525. export class FragmentOutputBlock extends NodeMaterialBlock {
  54526. /**
  54527. * Create a new FragmentOutputBlock
  54528. * @param name defines the block name
  54529. */
  54530. constructor(name: string);
  54531. /**
  54532. * Gets the current class name
  54533. * @returns the class name
  54534. */
  54535. getClassName(): string;
  54536. /**
  54537. * Gets the rgba input component
  54538. */
  54539. readonly rgba: NodeMaterialConnectionPoint;
  54540. /**
  54541. * Gets the rgb input component
  54542. */
  54543. readonly rgb: NodeMaterialConnectionPoint;
  54544. /**
  54545. * Gets the a input component
  54546. */
  54547. readonly a: NodeMaterialConnectionPoint;
  54548. protected _buildBlock(state: NodeMaterialBuildState): this;
  54549. }
  54550. }
  54551. declare module "babylonjs/Materials/Node/nodeMaterialSystemValues" {
  54552. /**
  54553. * Enum used to define system values e.g. values automatically provided by the system
  54554. */
  54555. export enum NodeMaterialSystemValues {
  54556. /** World */
  54557. World = 1,
  54558. /** View */
  54559. View = 2,
  54560. /** Projection */
  54561. Projection = 3,
  54562. /** ViewProjection */
  54563. ViewProjection = 4,
  54564. /** WorldView */
  54565. WorldView = 5,
  54566. /** WorldViewProjection */
  54567. WorldViewProjection = 6,
  54568. /** CameraPosition */
  54569. CameraPosition = 7,
  54570. /** Fog Color */
  54571. FogColor = 8
  54572. }
  54573. }
  54574. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  54575. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54576. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54577. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54578. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54579. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54580. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54581. import { Effect } from "babylonjs/Materials/effect";
  54582. import { Mesh } from "babylonjs/Meshes/mesh";
  54583. import { Nullable } from "babylonjs/types";
  54584. import { Scene } from "babylonjs/scene";
  54585. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  54586. /**
  54587. * Block used to read a reflection texture from a sampler
  54588. */
  54589. export class ReflectionTextureBlock extends NodeMaterialBlock {
  54590. private _define3DName;
  54591. private _defineCubicName;
  54592. private _defineExplicitName;
  54593. private _defineProjectionName;
  54594. private _defineLocalCubicName;
  54595. private _defineSphericalName;
  54596. private _definePlanarName;
  54597. private _defineEquirectangularName;
  54598. private _defineMirroredEquirectangularFixedName;
  54599. private _defineEquirectangularFixedName;
  54600. private _defineSkyboxName;
  54601. private _cubeSamplerName;
  54602. private _2DSamplerName;
  54603. private _positionUVWName;
  54604. private _directionWName;
  54605. private _reflectionCoordsName;
  54606. private _reflection2DCoordsName;
  54607. private _reflectionColorName;
  54608. private _reflectionMatrixName;
  54609. /**
  54610. * Gets or sets the texture associated with the node
  54611. */
  54612. texture: Nullable<BaseTexture>;
  54613. /**
  54614. * Create a new TextureBlock
  54615. * @param name defines the block name
  54616. */
  54617. constructor(name: string);
  54618. /**
  54619. * Gets the current class name
  54620. * @returns the class name
  54621. */
  54622. getClassName(): string;
  54623. /**
  54624. * Gets the world position input component
  54625. */
  54626. readonly position: NodeMaterialConnectionPoint;
  54627. /**
  54628. * Gets the world position input component
  54629. */
  54630. readonly worldPosition: NodeMaterialConnectionPoint;
  54631. /**
  54632. * Gets the world normal input component
  54633. */
  54634. readonly worldNormal: NodeMaterialConnectionPoint;
  54635. /**
  54636. * Gets the world input component
  54637. */
  54638. readonly world: NodeMaterialConnectionPoint;
  54639. /**
  54640. * Gets the camera (or eye) position component
  54641. */
  54642. readonly cameraPosition: NodeMaterialConnectionPoint;
  54643. /**
  54644. * Gets the view input component
  54645. */
  54646. readonly view: NodeMaterialConnectionPoint;
  54647. /**
  54648. * Gets the rgb output component
  54649. */
  54650. readonly rgb: NodeMaterialConnectionPoint;
  54651. /**
  54652. * Gets the r output component
  54653. */
  54654. readonly r: NodeMaterialConnectionPoint;
  54655. /**
  54656. * Gets the g output component
  54657. */
  54658. readonly g: NodeMaterialConnectionPoint;
  54659. /**
  54660. * Gets the b output component
  54661. */
  54662. readonly b: NodeMaterialConnectionPoint;
  54663. autoConfigure(material: NodeMaterial): void;
  54664. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54665. isReady(): boolean;
  54666. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54667. private _injectVertexCode;
  54668. private _writeOutput;
  54669. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54670. serialize(): any;
  54671. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54672. }
  54673. }
  54674. declare module "babylonjs/Materials/Node/nodeMaterial" {
  54675. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54676. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  54677. import { Scene } from "babylonjs/scene";
  54678. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54679. import { Matrix } from "babylonjs/Maths/math.vector";
  54680. import { Mesh } from "babylonjs/Meshes/mesh";
  54681. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54682. import { Observable } from "babylonjs/Misc/observable";
  54683. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54684. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  54685. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  54686. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  54687. import { Nullable } from "babylonjs/types";
  54688. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  54689. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  54690. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  54691. /**
  54692. * Interface used to configure the node material editor
  54693. */
  54694. export interface INodeMaterialEditorOptions {
  54695. /** Define the URl to load node editor script */
  54696. editorURL?: string;
  54697. }
  54698. /** @hidden */
  54699. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  54700. /** BONES */
  54701. NUM_BONE_INFLUENCERS: number;
  54702. BonesPerMesh: number;
  54703. BONETEXTURE: boolean;
  54704. /** MORPH TARGETS */
  54705. MORPHTARGETS: boolean;
  54706. MORPHTARGETS_NORMAL: boolean;
  54707. MORPHTARGETS_TANGENT: boolean;
  54708. MORPHTARGETS_UV: boolean;
  54709. NUM_MORPH_INFLUENCERS: number;
  54710. /** IMAGE PROCESSING */
  54711. IMAGEPROCESSING: boolean;
  54712. VIGNETTE: boolean;
  54713. VIGNETTEBLENDMODEMULTIPLY: boolean;
  54714. VIGNETTEBLENDMODEOPAQUE: boolean;
  54715. TONEMAPPING: boolean;
  54716. TONEMAPPING_ACES: boolean;
  54717. CONTRAST: boolean;
  54718. EXPOSURE: boolean;
  54719. COLORCURVES: boolean;
  54720. COLORGRADING: boolean;
  54721. COLORGRADING3D: boolean;
  54722. SAMPLER3DGREENDEPTH: boolean;
  54723. SAMPLER3DBGRMAP: boolean;
  54724. IMAGEPROCESSINGPOSTPROCESS: boolean;
  54725. /** MISC. */
  54726. BUMPDIRECTUV: number;
  54727. constructor();
  54728. setValue(name: string, value: boolean): void;
  54729. }
  54730. /**
  54731. * Class used to configure NodeMaterial
  54732. */
  54733. export interface INodeMaterialOptions {
  54734. /**
  54735. * Defines if blocks should emit comments
  54736. */
  54737. emitComments: boolean;
  54738. }
  54739. /**
  54740. * Class used to create a node based material built by assembling shader blocks
  54741. */
  54742. export class NodeMaterial extends PushMaterial {
  54743. private static _BuildIdGenerator;
  54744. private _options;
  54745. private _vertexCompilationState;
  54746. private _fragmentCompilationState;
  54747. private _sharedData;
  54748. private _buildId;
  54749. private _buildWasSuccessful;
  54750. private _cachedWorldViewMatrix;
  54751. private _cachedWorldViewProjectionMatrix;
  54752. private _optimizers;
  54753. private _animationFrame;
  54754. /** Define the URl to load node editor script */
  54755. static EditorURL: string;
  54756. private BJSNODEMATERIALEDITOR;
  54757. /** Get the inspector from bundle or global */
  54758. private _getGlobalNodeMaterialEditor;
  54759. /**
  54760. * 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)
  54761. */
  54762. ignoreAlpha: boolean;
  54763. /**
  54764. * Defines the maximum number of lights that can be used in the material
  54765. */
  54766. maxSimultaneousLights: number;
  54767. /**
  54768. * Observable raised when the material is built
  54769. */
  54770. onBuildObservable: Observable<NodeMaterial>;
  54771. /**
  54772. * Gets or sets the root nodes of the material vertex shader
  54773. */
  54774. _vertexOutputNodes: NodeMaterialBlock[];
  54775. /**
  54776. * Gets or sets the root nodes of the material fragment (pixel) shader
  54777. */
  54778. _fragmentOutputNodes: NodeMaterialBlock[];
  54779. /** Gets or sets options to control the node material overall behavior */
  54780. options: INodeMaterialOptions;
  54781. /**
  54782. * Default configuration related to image processing available in the standard Material.
  54783. */
  54784. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  54785. /**
  54786. * Gets the image processing configuration used either in this material.
  54787. */
  54788. /**
  54789. * Sets the Default image processing configuration used either in the this material.
  54790. *
  54791. * If sets to null, the scene one is in use.
  54792. */
  54793. imageProcessingConfiguration: ImageProcessingConfiguration;
  54794. /**
  54795. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  54796. */
  54797. attachedBlocks: NodeMaterialBlock[];
  54798. /**
  54799. * Create a new node based material
  54800. * @param name defines the material name
  54801. * @param scene defines the hosting scene
  54802. * @param options defines creation option
  54803. */
  54804. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  54805. /**
  54806. * Gets the current class name of the material e.g. "NodeMaterial"
  54807. * @returns the class name
  54808. */
  54809. getClassName(): string;
  54810. /**
  54811. * Keep track of the image processing observer to allow dispose and replace.
  54812. */
  54813. private _imageProcessingObserver;
  54814. /**
  54815. * Attaches a new image processing configuration to the Standard Material.
  54816. * @param configuration
  54817. */
  54818. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  54819. /**
  54820. * Get a block by its name
  54821. * @param name defines the name of the block to retrieve
  54822. * @returns the required block or null if not found
  54823. */
  54824. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  54825. /**
  54826. * Get a block by its name
  54827. * @param predicate defines the predicate used to find the good candidate
  54828. * @returns the required block or null if not found
  54829. */
  54830. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  54831. /**
  54832. * Get an input block by its name
  54833. * @param predicate defines the predicate used to find the good candidate
  54834. * @returns the required input block or null if not found
  54835. */
  54836. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  54837. /**
  54838. * Gets the list of input blocks attached to this material
  54839. * @returns an array of InputBlocks
  54840. */
  54841. getInputBlocks(): InputBlock[];
  54842. /**
  54843. * Adds a new optimizer to the list of optimizers
  54844. * @param optimizer defines the optimizers to add
  54845. * @returns the current material
  54846. */
  54847. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  54848. /**
  54849. * Remove an optimizer from the list of optimizers
  54850. * @param optimizer defines the optimizers to remove
  54851. * @returns the current material
  54852. */
  54853. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  54854. /**
  54855. * Add a new block to the list of output nodes
  54856. * @param node defines the node to add
  54857. * @returns the current material
  54858. */
  54859. addOutputNode(node: NodeMaterialBlock): this;
  54860. /**
  54861. * Remove a block from the list of root nodes
  54862. * @param node defines the node to remove
  54863. * @returns the current material
  54864. */
  54865. removeOutputNode(node: NodeMaterialBlock): this;
  54866. private _addVertexOutputNode;
  54867. private _removeVertexOutputNode;
  54868. private _addFragmentOutputNode;
  54869. private _removeFragmentOutputNode;
  54870. /**
  54871. * Specifies if the material will require alpha blending
  54872. * @returns a boolean specifying if alpha blending is needed
  54873. */
  54874. needAlphaBlending(): boolean;
  54875. /**
  54876. * Specifies if this material should be rendered in alpha test mode
  54877. * @returns a boolean specifying if an alpha test is needed.
  54878. */
  54879. needAlphaTesting(): boolean;
  54880. private _initializeBlock;
  54881. private _resetDualBlocks;
  54882. /**
  54883. * Build the material and generates the inner effect
  54884. * @param verbose defines if the build should log activity
  54885. */
  54886. build(verbose?: boolean): void;
  54887. /**
  54888. * Runs an otpimization phase to try to improve the shader code
  54889. */
  54890. optimize(): void;
  54891. private _prepareDefinesForAttributes;
  54892. /**
  54893. * Get if the submesh is ready to be used and all its information available.
  54894. * Child classes can use it to update shaders
  54895. * @param mesh defines the mesh to check
  54896. * @param subMesh defines which submesh to check
  54897. * @param useInstances specifies that instances should be used
  54898. * @returns a boolean indicating that the submesh is ready or not
  54899. */
  54900. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  54901. /**
  54902. * Get a string representing the shaders built by the current node graph
  54903. */
  54904. readonly compiledShaders: string;
  54905. /**
  54906. * Binds the world matrix to the material
  54907. * @param world defines the world transformation matrix
  54908. */
  54909. bindOnlyWorldMatrix(world: Matrix): void;
  54910. /**
  54911. * Binds the submesh to this material by preparing the effect and shader to draw
  54912. * @param world defines the world transformation matrix
  54913. * @param mesh defines the mesh containing the submesh
  54914. * @param subMesh defines the submesh to bind the material to
  54915. */
  54916. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  54917. /**
  54918. * Gets the active textures from the material
  54919. * @returns an array of textures
  54920. */
  54921. getActiveTextures(): BaseTexture[];
  54922. /**
  54923. * Gets the list of texture blocks
  54924. * @returns an array of texture blocks
  54925. */
  54926. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  54927. /**
  54928. * Specifies if the material uses a texture
  54929. * @param texture defines the texture to check against the material
  54930. * @returns a boolean specifying if the material uses the texture
  54931. */
  54932. hasTexture(texture: BaseTexture): boolean;
  54933. /**
  54934. * Disposes the material
  54935. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  54936. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  54937. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  54938. */
  54939. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  54940. /** Creates the node editor window. */
  54941. private _createNodeEditor;
  54942. /**
  54943. * Launch the node material editor
  54944. * @param config Define the configuration of the editor
  54945. * @return a promise fulfilled when the node editor is visible
  54946. */
  54947. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  54948. /**
  54949. * Clear the current material
  54950. */
  54951. clear(): void;
  54952. /**
  54953. * Clear the current material and set it to a default state
  54954. */
  54955. setToDefault(): void;
  54956. /**
  54957. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  54958. * @param url defines the url to load from
  54959. * @returns a promise that will fullfil when the material is fully loaded
  54960. */
  54961. loadAsync(url: string): Promise<unknown>;
  54962. private _gatherBlocks;
  54963. /**
  54964. * Generate a string containing the code declaration required to create an equivalent of this material
  54965. * @returns a string
  54966. */
  54967. generateCode(): string;
  54968. /**
  54969. * Serializes this material in a JSON representation
  54970. * @returns the serialized material object
  54971. */
  54972. serialize(): any;
  54973. private _restoreConnections;
  54974. /**
  54975. * Clear the current graph and load a new one from a serialization object
  54976. * @param source defines the JSON representation of the material
  54977. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  54978. */
  54979. loadFromSerialization(source: any, rootUrl?: string): void;
  54980. /**
  54981. * Creates a node material from parsed material data
  54982. * @param source defines the JSON representation of the material
  54983. * @param scene defines the hosting scene
  54984. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  54985. * @returns a new node material
  54986. */
  54987. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  54988. /**
  54989. * Creates a new node material set to default basic configuration
  54990. * @param name defines the name of the material
  54991. * @param scene defines the hosting scene
  54992. * @returns a new NodeMaterial
  54993. */
  54994. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  54995. }
  54996. }
  54997. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  54998. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54999. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55000. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  55001. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55002. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55003. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55004. import { Effect } from "babylonjs/Materials/effect";
  55005. import { Mesh } from "babylonjs/Meshes/mesh";
  55006. import { Nullable } from "babylonjs/types";
  55007. import { Texture } from "babylonjs/Materials/Textures/texture";
  55008. import { Scene } from "babylonjs/scene";
  55009. /**
  55010. * Block used to read a texture from a sampler
  55011. */
  55012. export class TextureBlock extends NodeMaterialBlock {
  55013. private _defineName;
  55014. private _samplerName;
  55015. private _transformedUVName;
  55016. private _textureTransformName;
  55017. private _textureInfoName;
  55018. private _mainUVName;
  55019. private _mainUVDefineName;
  55020. /**
  55021. * Gets or sets the texture associated with the node
  55022. */
  55023. texture: Nullable<Texture>;
  55024. /**
  55025. * Create a new TextureBlock
  55026. * @param name defines the block name
  55027. */
  55028. constructor(name: string);
  55029. /**
  55030. * Gets the current class name
  55031. * @returns the class name
  55032. */
  55033. getClassName(): string;
  55034. /**
  55035. * Gets the uv input component
  55036. */
  55037. readonly uv: NodeMaterialConnectionPoint;
  55038. /**
  55039. * Gets the rgba output component
  55040. */
  55041. readonly rgba: NodeMaterialConnectionPoint;
  55042. /**
  55043. * Gets the rgb output component
  55044. */
  55045. readonly rgb: NodeMaterialConnectionPoint;
  55046. /**
  55047. * Gets the r output component
  55048. */
  55049. readonly r: NodeMaterialConnectionPoint;
  55050. /**
  55051. * Gets the g output component
  55052. */
  55053. readonly g: NodeMaterialConnectionPoint;
  55054. /**
  55055. * Gets the b output component
  55056. */
  55057. readonly b: NodeMaterialConnectionPoint;
  55058. /**
  55059. * Gets the a output component
  55060. */
  55061. readonly a: NodeMaterialConnectionPoint;
  55062. readonly target: NodeMaterialBlockTargets;
  55063. autoConfigure(material: NodeMaterial): void;
  55064. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55065. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55066. isReady(): boolean;
  55067. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55068. private readonly _isMixed;
  55069. private _injectVertexCode;
  55070. private _writeOutput;
  55071. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55072. protected _dumpPropertiesCode(): string;
  55073. serialize(): any;
  55074. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55075. }
  55076. }
  55077. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  55078. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55079. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55080. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55081. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55082. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  55083. import { Scene } from "babylonjs/scene";
  55084. /**
  55085. * Class used to store shared data between 2 NodeMaterialBuildState
  55086. */
  55087. export class NodeMaterialBuildStateSharedData {
  55088. /**
  55089. * Gets the list of emitted varyings
  55090. */
  55091. temps: string[];
  55092. /**
  55093. * Gets the list of emitted varyings
  55094. */
  55095. varyings: string[];
  55096. /**
  55097. * Gets the varying declaration string
  55098. */
  55099. varyingDeclaration: string;
  55100. /**
  55101. * Input blocks
  55102. */
  55103. inputBlocks: InputBlock[];
  55104. /**
  55105. * Input blocks
  55106. */
  55107. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  55108. /**
  55109. * Bindable blocks (Blocks that need to set data to the effect)
  55110. */
  55111. bindableBlocks: NodeMaterialBlock[];
  55112. /**
  55113. * List of blocks that can provide a compilation fallback
  55114. */
  55115. blocksWithFallbacks: NodeMaterialBlock[];
  55116. /**
  55117. * List of blocks that can provide a define update
  55118. */
  55119. blocksWithDefines: NodeMaterialBlock[];
  55120. /**
  55121. * List of blocks that can provide a repeatable content
  55122. */
  55123. repeatableContentBlocks: NodeMaterialBlock[];
  55124. /**
  55125. * List of blocks that can provide a dynamic list of uniforms
  55126. */
  55127. dynamicUniformBlocks: NodeMaterialBlock[];
  55128. /**
  55129. * List of blocks that can block the isReady function for the material
  55130. */
  55131. blockingBlocks: NodeMaterialBlock[];
  55132. /**
  55133. * Gets the list of animated inputs
  55134. */
  55135. animatedInputs: InputBlock[];
  55136. /**
  55137. * Build Id used to avoid multiple recompilations
  55138. */
  55139. buildId: number;
  55140. /** List of emitted variables */
  55141. variableNames: {
  55142. [key: string]: number;
  55143. };
  55144. /** List of emitted defines */
  55145. defineNames: {
  55146. [key: string]: number;
  55147. };
  55148. /** Should emit comments? */
  55149. emitComments: boolean;
  55150. /** Emit build activity */
  55151. verbose: boolean;
  55152. /** Gets or sets the hosting scene */
  55153. scene: Scene;
  55154. /**
  55155. * Gets the compilation hints emitted at compilation time
  55156. */
  55157. hints: {
  55158. needWorldViewMatrix: boolean;
  55159. needWorldViewProjectionMatrix: boolean;
  55160. needAlphaBlending: boolean;
  55161. needAlphaTesting: boolean;
  55162. };
  55163. /**
  55164. * List of compilation checks
  55165. */
  55166. checks: {
  55167. emitVertex: boolean;
  55168. emitFragment: boolean;
  55169. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  55170. };
  55171. /** Creates a new shared data */
  55172. constructor();
  55173. /**
  55174. * Emits console errors and exceptions if there is a failing check
  55175. */
  55176. emitErrors(): void;
  55177. }
  55178. }
  55179. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  55180. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  55181. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  55182. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  55183. /**
  55184. * Class used to store node based material build state
  55185. */
  55186. export class NodeMaterialBuildState {
  55187. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  55188. supportUniformBuffers: boolean;
  55189. /**
  55190. * Gets the list of emitted attributes
  55191. */
  55192. attributes: string[];
  55193. /**
  55194. * Gets the list of emitted uniforms
  55195. */
  55196. uniforms: string[];
  55197. /**
  55198. * Gets the list of emitted uniform buffers
  55199. */
  55200. uniformBuffers: string[];
  55201. /**
  55202. * Gets the list of emitted samplers
  55203. */
  55204. samplers: string[];
  55205. /**
  55206. * Gets the list of emitted functions
  55207. */
  55208. functions: {
  55209. [key: string]: string;
  55210. };
  55211. /**
  55212. * Gets the list of emitted extensions
  55213. */
  55214. extensions: {
  55215. [key: string]: string;
  55216. };
  55217. /**
  55218. * Gets the target of the compilation state
  55219. */
  55220. target: NodeMaterialBlockTargets;
  55221. /**
  55222. * Gets the list of emitted counters
  55223. */
  55224. counters: {
  55225. [key: string]: number;
  55226. };
  55227. /**
  55228. * Shared data between multiple NodeMaterialBuildState instances
  55229. */
  55230. sharedData: NodeMaterialBuildStateSharedData;
  55231. /** @hidden */
  55232. _vertexState: NodeMaterialBuildState;
  55233. /** @hidden */
  55234. _attributeDeclaration: string;
  55235. /** @hidden */
  55236. _uniformDeclaration: string;
  55237. /** @hidden */
  55238. _samplerDeclaration: string;
  55239. /** @hidden */
  55240. _varyingTransfer: string;
  55241. private _repeatableContentAnchorIndex;
  55242. /** @hidden */
  55243. _builtCompilationString: string;
  55244. /**
  55245. * Gets the emitted compilation strings
  55246. */
  55247. compilationString: string;
  55248. /**
  55249. * Finalize the compilation strings
  55250. * @param state defines the current compilation state
  55251. */
  55252. finalize(state: NodeMaterialBuildState): void;
  55253. /** @hidden */
  55254. readonly _repeatableContentAnchor: string;
  55255. /** @hidden */
  55256. _getFreeVariableName(prefix: string): string;
  55257. /** @hidden */
  55258. _getFreeDefineName(prefix: string): string;
  55259. /** @hidden */
  55260. _excludeVariableName(name: string): void;
  55261. /** @hidden */
  55262. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  55263. /** @hidden */
  55264. _emitExtension(name: string, extension: string): void;
  55265. /** @hidden */
  55266. _emitFunction(name: string, code: string, comments: string): void;
  55267. /** @hidden */
  55268. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  55269. replaceStrings?: {
  55270. search: RegExp;
  55271. replace: string;
  55272. }[];
  55273. repeatKey?: string;
  55274. }): string;
  55275. /** @hidden */
  55276. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  55277. repeatKey?: string;
  55278. removeAttributes?: boolean;
  55279. removeUniforms?: boolean;
  55280. removeVaryings?: boolean;
  55281. removeIfDef?: boolean;
  55282. replaceStrings?: {
  55283. search: RegExp;
  55284. replace: string;
  55285. }[];
  55286. }, storeKey?: string): void;
  55287. /** @hidden */
  55288. _registerTempVariable(name: string): boolean;
  55289. /** @hidden */
  55290. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  55291. /** @hidden */
  55292. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  55293. }
  55294. }
  55295. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  55296. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  55297. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55298. import { Nullable } from "babylonjs/types";
  55299. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55300. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  55301. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  55302. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55303. import { Mesh } from "babylonjs/Meshes/mesh";
  55304. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55305. import { Scene } from "babylonjs/scene";
  55306. /**
  55307. * Defines a block that can be used inside a node based material
  55308. */
  55309. export class NodeMaterialBlock {
  55310. private _buildId;
  55311. private _buildTarget;
  55312. private _target;
  55313. private _isFinalMerger;
  55314. private _isInput;
  55315. /** @hidden */
  55316. _codeVariableName: string;
  55317. /** @hidden */
  55318. _inputs: NodeMaterialConnectionPoint[];
  55319. /** @hidden */
  55320. _outputs: NodeMaterialConnectionPoint[];
  55321. /** @hidden */
  55322. _preparationId: number;
  55323. /**
  55324. * Gets or sets the name of the block
  55325. */
  55326. name: string;
  55327. /**
  55328. * Gets or sets the unique id of the node
  55329. */
  55330. uniqueId: number;
  55331. /**
  55332. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  55333. */
  55334. readonly isFinalMerger: boolean;
  55335. /**
  55336. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  55337. */
  55338. readonly isInput: boolean;
  55339. /**
  55340. * Gets or sets the build Id
  55341. */
  55342. buildId: number;
  55343. /**
  55344. * Gets or sets the target of the block
  55345. */
  55346. target: NodeMaterialBlockTargets;
  55347. /**
  55348. * Gets the list of input points
  55349. */
  55350. readonly inputs: NodeMaterialConnectionPoint[];
  55351. /** Gets the list of output points */
  55352. readonly outputs: NodeMaterialConnectionPoint[];
  55353. /**
  55354. * Find an input by its name
  55355. * @param name defines the name of the input to look for
  55356. * @returns the input or null if not found
  55357. */
  55358. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  55359. /**
  55360. * Find an output by its name
  55361. * @param name defines the name of the outputto look for
  55362. * @returns the output or null if not found
  55363. */
  55364. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  55365. /**
  55366. * Creates a new NodeMaterialBlock
  55367. * @param name defines the block name
  55368. * @param target defines the target of that block (Vertex by default)
  55369. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  55370. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  55371. */
  55372. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  55373. /**
  55374. * Initialize the block and prepare the context for build
  55375. * @param state defines the state that will be used for the build
  55376. */
  55377. initialize(state: NodeMaterialBuildState): void;
  55378. /**
  55379. * Bind data to effect. Will only be called for blocks with isBindable === true
  55380. * @param effect defines the effect to bind data to
  55381. * @param nodeMaterial defines the hosting NodeMaterial
  55382. * @param mesh defines the mesh that will be rendered
  55383. */
  55384. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55385. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  55386. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  55387. protected _writeFloat(value: number): string;
  55388. /**
  55389. * Gets the current class name e.g. "NodeMaterialBlock"
  55390. * @returns the class name
  55391. */
  55392. getClassName(): string;
  55393. /**
  55394. * Register a new input. Must be called inside a block constructor
  55395. * @param name defines the connection point name
  55396. * @param type defines the connection point type
  55397. * @param isOptional defines a boolean indicating that this input can be omitted
  55398. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  55399. * @returns the current block
  55400. */
  55401. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  55402. /**
  55403. * Register a new output. Must be called inside a block constructor
  55404. * @param name defines the connection point name
  55405. * @param type defines the connection point type
  55406. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  55407. * @returns the current block
  55408. */
  55409. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  55410. /**
  55411. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  55412. * @param forOutput defines an optional connection point to check compatibility with
  55413. * @returns the first available input or null
  55414. */
  55415. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  55416. /**
  55417. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  55418. * @param forBlock defines an optional block to check compatibility with
  55419. * @returns the first available input or null
  55420. */
  55421. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  55422. /**
  55423. * Gets the sibling of the given output
  55424. * @param current defines the current output
  55425. * @returns the next output in the list or null
  55426. */
  55427. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  55428. /**
  55429. * Connect current block with another block
  55430. * @param other defines the block to connect with
  55431. * @param options define the various options to help pick the right connections
  55432. * @returns the current block
  55433. */
  55434. connectTo(other: NodeMaterialBlock, options?: {
  55435. input?: string;
  55436. output?: string;
  55437. outputSwizzle?: string;
  55438. }): this | undefined;
  55439. protected _buildBlock(state: NodeMaterialBuildState): void;
  55440. /**
  55441. * Add uniforms, samplers and uniform buffers at compilation time
  55442. * @param state defines the state to update
  55443. * @param nodeMaterial defines the node material requesting the update
  55444. * @param defines defines the material defines to update
  55445. */
  55446. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55447. /**
  55448. * Add potential fallbacks if shader compilation fails
  55449. * @param mesh defines the mesh to be rendered
  55450. * @param fallbacks defines the current prioritized list of fallbacks
  55451. */
  55452. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  55453. /**
  55454. * Initialize defines for shader compilation
  55455. * @param mesh defines the mesh to be rendered
  55456. * @param nodeMaterial defines the node material requesting the update
  55457. * @param defines defines the material defines to update
  55458. * @param useInstances specifies that instances should be used
  55459. */
  55460. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55461. /**
  55462. * Update defines for shader compilation
  55463. * @param mesh defines the mesh to be rendered
  55464. * @param nodeMaterial defines the node material requesting the update
  55465. * @param defines defines the material defines to update
  55466. * @param useInstances specifies that instances should be used
  55467. */
  55468. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55469. /**
  55470. * Lets the block try to connect some inputs automatically
  55471. * @param material defines the hosting NodeMaterial
  55472. */
  55473. autoConfigure(material: NodeMaterial): void;
  55474. /**
  55475. * Function called when a block is declared as repeatable content generator
  55476. * @param vertexShaderState defines the current compilation state for the vertex shader
  55477. * @param fragmentShaderState defines the current compilation state for the fragment shader
  55478. * @param mesh defines the mesh to be rendered
  55479. * @param defines defines the material defines to update
  55480. */
  55481. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  55482. /**
  55483. * Checks if the block is ready
  55484. * @param mesh defines the mesh to be rendered
  55485. * @param nodeMaterial defines the node material requesting the update
  55486. * @param defines defines the material defines to update
  55487. * @param useInstances specifies that instances should be used
  55488. * @returns true if the block is ready
  55489. */
  55490. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  55491. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  55492. private _processBuild;
  55493. /**
  55494. * Compile the current node and generate the shader code
  55495. * @param state defines the current compilation state (uniforms, samplers, current string)
  55496. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  55497. * @returns true if already built
  55498. */
  55499. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  55500. protected _inputRename(name: string): string;
  55501. protected _outputRename(name: string): string;
  55502. protected _dumpPropertiesCode(): string;
  55503. /** @hidden */
  55504. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  55505. /**
  55506. * Clone the current block to a new identical block
  55507. * @param scene defines the hosting scene
  55508. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55509. * @returns a copy of the current block
  55510. */
  55511. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  55512. /**
  55513. * Serializes this block in a JSON representation
  55514. * @returns the serialized block object
  55515. */
  55516. serialize(): any;
  55517. /** @hidden */
  55518. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55519. }
  55520. }
  55521. declare module "babylonjs/Materials/Node/NodeMaterialBlockConnectionPointMode" {
  55522. /**
  55523. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  55524. */
  55525. export enum NodeMaterialBlockConnectionPointMode {
  55526. /** Value is an uniform */
  55527. Uniform = 0,
  55528. /** Value is a mesh attribute */
  55529. Attribute = 1,
  55530. /** Value is a varying between vertex and fragment shaders */
  55531. Varying = 2,
  55532. /** Mode is undefined */
  55533. Undefined = 3
  55534. }
  55535. }
  55536. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  55537. /**
  55538. * Enum defining the type of animations supported by InputBlock
  55539. */
  55540. export enum AnimatedInputBlockTypes {
  55541. /** No animation */
  55542. None = 0,
  55543. /** Time based animation. Will only work for floats */
  55544. Time = 1
  55545. }
  55546. }
  55547. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  55548. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55549. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  55550. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/nodeMaterialSystemValues";
  55551. import { Nullable } from "babylonjs/types";
  55552. import { Effect } from "babylonjs/Materials/effect";
  55553. import { Matrix } from "babylonjs/Maths/math.vector";
  55554. import { Scene } from "babylonjs/scene";
  55555. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55556. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55557. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  55558. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  55559. /**
  55560. * Block used to expose an input value
  55561. */
  55562. export class InputBlock extends NodeMaterialBlock {
  55563. private _mode;
  55564. private _associatedVariableName;
  55565. private _storedValue;
  55566. private _valueCallback;
  55567. private _type;
  55568. private _animationType;
  55569. /** Gets or set a value used to limit the range of float values */
  55570. min: number;
  55571. /** Gets or set a value used to limit the range of float values */
  55572. max: number;
  55573. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  55574. matrixMode: number;
  55575. /** @hidden */
  55576. _systemValue: Nullable<NodeMaterialSystemValues>;
  55577. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  55578. visibleInInspector: boolean;
  55579. /**
  55580. * Gets or sets the connection point type (default is float)
  55581. */
  55582. readonly type: NodeMaterialBlockConnectionPointTypes;
  55583. /**
  55584. * Creates a new InputBlock
  55585. * @param name defines the block name
  55586. * @param target defines the target of that block (Vertex by default)
  55587. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  55588. */
  55589. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  55590. /**
  55591. * Gets the output component
  55592. */
  55593. readonly output: NodeMaterialConnectionPoint;
  55594. /**
  55595. * Set the source of this connection point to a vertex attribute
  55596. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  55597. * @returns the current connection point
  55598. */
  55599. setAsAttribute(attributeName?: string): InputBlock;
  55600. /**
  55601. * Set the source of this connection point to a system value
  55602. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  55603. * @returns the current connection point
  55604. */
  55605. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  55606. /**
  55607. * Gets or sets the value of that point.
  55608. * Please note that this value will be ignored if valueCallback is defined
  55609. */
  55610. value: any;
  55611. /**
  55612. * Gets or sets a callback used to get the value of that point.
  55613. * Please note that setting this value will force the connection point to ignore the value property
  55614. */
  55615. valueCallback: () => any;
  55616. /**
  55617. * Gets or sets the associated variable name in the shader
  55618. */
  55619. associatedVariableName: string;
  55620. /** Gets or sets the type of animation applied to the input */
  55621. animationType: AnimatedInputBlockTypes;
  55622. /**
  55623. * Gets a boolean indicating that this connection point not defined yet
  55624. */
  55625. readonly isUndefined: boolean;
  55626. /**
  55627. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  55628. * In this case the connection point name must be the name of the uniform to use.
  55629. * Can only be set on inputs
  55630. */
  55631. isUniform: boolean;
  55632. /**
  55633. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  55634. * In this case the connection point name must be the name of the attribute to use
  55635. * Can only be set on inputs
  55636. */
  55637. isAttribute: boolean;
  55638. /**
  55639. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  55640. * Can only be set on exit points
  55641. */
  55642. isVarying: boolean;
  55643. /**
  55644. * Gets a boolean indicating that the current connection point is a system value
  55645. */
  55646. readonly isSystemValue: boolean;
  55647. /**
  55648. * Gets or sets the current well known value or null if not defined as a system value
  55649. */
  55650. systemValue: Nullable<NodeMaterialSystemValues>;
  55651. /**
  55652. * Gets the current class name
  55653. * @returns the class name
  55654. */
  55655. getClassName(): string;
  55656. /**
  55657. * Animate the input if animationType !== None
  55658. * @param scene defines the rendering scene
  55659. */
  55660. animate(scene: Scene): void;
  55661. private _emitDefine;
  55662. initialize(state: NodeMaterialBuildState): void;
  55663. /**
  55664. * Set the input block to its default value (based on its type)
  55665. */
  55666. setDefaultValue(): void;
  55667. protected _dumpPropertiesCode(): string;
  55668. private _emit;
  55669. /** @hidden */
  55670. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  55671. /** @hidden */
  55672. _transmit(effect: Effect, scene: Scene): void;
  55673. protected _buildBlock(state: NodeMaterialBuildState): void;
  55674. serialize(): any;
  55675. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55676. }
  55677. }
  55678. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  55679. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  55680. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  55681. import { Nullable } from "babylonjs/types";
  55682. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55683. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55684. /**
  55685. * Defines a connection point for a block
  55686. */
  55687. export class NodeMaterialConnectionPoint {
  55688. /** @hidden */
  55689. _ownerBlock: NodeMaterialBlock;
  55690. /** @hidden */
  55691. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  55692. private _endpoints;
  55693. private _associatedVariableName;
  55694. /** @hidden */
  55695. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  55696. /** @hidden */
  55697. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  55698. private _type;
  55699. /** @hidden */
  55700. _enforceAssociatedVariableName: boolean;
  55701. /**
  55702. * Gets or sets the additional types supported byt this connection point
  55703. */
  55704. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  55705. /**
  55706. * Gets or sets the associated variable name in the shader
  55707. */
  55708. associatedVariableName: string;
  55709. /**
  55710. * Gets or sets the connection point type (default is float)
  55711. */
  55712. type: NodeMaterialBlockConnectionPointTypes;
  55713. /**
  55714. * Gets or sets the connection point name
  55715. */
  55716. name: string;
  55717. /**
  55718. * Gets or sets a boolean indicating that this connection point can be omitted
  55719. */
  55720. isOptional: boolean;
  55721. /**
  55722. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  55723. */
  55724. define: string;
  55725. /** Gets or sets the target of that connection point */
  55726. target: NodeMaterialBlockTargets;
  55727. /**
  55728. * Gets a boolean indicating that the current point is connected
  55729. */
  55730. readonly isConnected: boolean;
  55731. /**
  55732. * Gets a boolean indicating that the current point is connected to an input block
  55733. */
  55734. readonly isConnectedToInputBlock: boolean;
  55735. /**
  55736. * Gets a the connected input block (if any)
  55737. */
  55738. readonly connectInputBlock: Nullable<InputBlock>;
  55739. /** Get the other side of the connection (if any) */
  55740. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  55741. /** Get the block that owns this connection point */
  55742. readonly ownerBlock: NodeMaterialBlock;
  55743. /** Get the block connected on the other side of this connection (if any) */
  55744. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  55745. /** Get the block connected on the endpoints of this connection (if any) */
  55746. readonly connectedBlocks: Array<NodeMaterialBlock>;
  55747. /** Gets the list of connected endpoints */
  55748. readonly endpoints: NodeMaterialConnectionPoint[];
  55749. /** Gets a boolean indicating if that output point is connected to at least one input */
  55750. readonly hasEndpoints: boolean;
  55751. /**
  55752. * Creates a new connection point
  55753. * @param name defines the connection point name
  55754. * @param ownerBlock defines the block hosting this connection point
  55755. */
  55756. constructor(name: string, ownerBlock: NodeMaterialBlock);
  55757. /**
  55758. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  55759. * @returns the class name
  55760. */
  55761. getClassName(): string;
  55762. /**
  55763. * Gets an boolean indicating if the current point can be connected to another point
  55764. * @param connectionPoint defines the other connection point
  55765. * @returns true if the connection is possible
  55766. */
  55767. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  55768. /**
  55769. * Connect this point to another connection point
  55770. * @param connectionPoint defines the other connection point
  55771. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  55772. * @returns the current connection point
  55773. */
  55774. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  55775. /**
  55776. * Disconnect this point from one of his endpoint
  55777. * @param endpoint defines the other connection point
  55778. * @returns the current connection point
  55779. */
  55780. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  55781. /**
  55782. * Serializes this point in a JSON representation
  55783. * @returns the serialized point object
  55784. */
  55785. serialize(): any;
  55786. }
  55787. }
  55788. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  55789. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55790. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55791. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55792. import { Mesh } from "babylonjs/Meshes/mesh";
  55793. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  55794. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55795. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55796. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55797. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55798. /**
  55799. * Block used to add support for vertex skinning (bones)
  55800. */
  55801. export class BonesBlock extends NodeMaterialBlock {
  55802. /**
  55803. * Creates a new BonesBlock
  55804. * @param name defines the block name
  55805. */
  55806. constructor(name: string);
  55807. /**
  55808. * Initialize the block and prepare the context for build
  55809. * @param state defines the state that will be used for the build
  55810. */
  55811. initialize(state: NodeMaterialBuildState): void;
  55812. /**
  55813. * Gets the current class name
  55814. * @returns the class name
  55815. */
  55816. getClassName(): string;
  55817. /**
  55818. * Gets the matrix indices input component
  55819. */
  55820. readonly matricesIndices: NodeMaterialConnectionPoint;
  55821. /**
  55822. * Gets the matrix weights input component
  55823. */
  55824. readonly matricesWeights: NodeMaterialConnectionPoint;
  55825. /**
  55826. * Gets the extra matrix indices input component
  55827. */
  55828. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  55829. /**
  55830. * Gets the extra matrix weights input component
  55831. */
  55832. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  55833. /**
  55834. * Gets the world input component
  55835. */
  55836. readonly world: NodeMaterialConnectionPoint;
  55837. /**
  55838. * Gets the output component
  55839. */
  55840. readonly output: NodeMaterialConnectionPoint;
  55841. autoConfigure(material: NodeMaterial): void;
  55842. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  55843. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55844. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55845. protected _buildBlock(state: NodeMaterialBuildState): this;
  55846. }
  55847. }
  55848. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  55849. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55850. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55851. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55852. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55853. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55854. /**
  55855. * Block used to add support for instances
  55856. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  55857. */
  55858. export class InstancesBlock extends NodeMaterialBlock {
  55859. /**
  55860. * Creates a new InstancesBlock
  55861. * @param name defines the block name
  55862. */
  55863. constructor(name: string);
  55864. /**
  55865. * Gets the current class name
  55866. * @returns the class name
  55867. */
  55868. getClassName(): string;
  55869. /**
  55870. * Gets the first world row input component
  55871. */
  55872. readonly world0: NodeMaterialConnectionPoint;
  55873. /**
  55874. * Gets the second world row input component
  55875. */
  55876. readonly world1: NodeMaterialConnectionPoint;
  55877. /**
  55878. * Gets the third world row input component
  55879. */
  55880. readonly world2: NodeMaterialConnectionPoint;
  55881. /**
  55882. * Gets the forth world row input component
  55883. */
  55884. readonly world3: NodeMaterialConnectionPoint;
  55885. /**
  55886. * Gets the world input component
  55887. */
  55888. readonly world: NodeMaterialConnectionPoint;
  55889. /**
  55890. * Gets the output component
  55891. */
  55892. readonly output: NodeMaterialConnectionPoint;
  55893. autoConfigure(material: NodeMaterial): void;
  55894. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55895. protected _buildBlock(state: NodeMaterialBuildState): this;
  55896. }
  55897. }
  55898. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  55899. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55900. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55901. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55902. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55903. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55904. import { Effect } from "babylonjs/Materials/effect";
  55905. import { Mesh } from "babylonjs/Meshes/mesh";
  55906. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  55907. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  55908. /**
  55909. * Block used to add morph targets support to vertex shader
  55910. */
  55911. export class MorphTargetsBlock extends NodeMaterialBlock {
  55912. private _repeatableContentAnchor;
  55913. private _repeatebleContentGenerated;
  55914. /**
  55915. * Create a new MorphTargetsBlock
  55916. * @param name defines the block name
  55917. */
  55918. constructor(name: string);
  55919. /**
  55920. * Gets the current class name
  55921. * @returns the class name
  55922. */
  55923. getClassName(): string;
  55924. /**
  55925. * Gets the position input component
  55926. */
  55927. readonly position: NodeMaterialConnectionPoint;
  55928. /**
  55929. * Gets the normal input component
  55930. */
  55931. readonly normal: NodeMaterialConnectionPoint;
  55932. /**
  55933. * Gets the tangent input component
  55934. */
  55935. readonly tangent: NodeMaterialConnectionPoint;
  55936. /**
  55937. * Gets the tangent input component
  55938. */
  55939. readonly uv: NodeMaterialConnectionPoint;
  55940. /**
  55941. * Gets the position output component
  55942. */
  55943. readonly positionOutput: NodeMaterialConnectionPoint;
  55944. /**
  55945. * Gets the normal output component
  55946. */
  55947. readonly normalOutput: NodeMaterialConnectionPoint;
  55948. /**
  55949. * Gets the tangent output component
  55950. */
  55951. readonly tangentOutput: NodeMaterialConnectionPoint;
  55952. /**
  55953. * Gets the tangent output component
  55954. */
  55955. readonly uvOutput: NodeMaterialConnectionPoint;
  55956. initialize(state: NodeMaterialBuildState): void;
  55957. autoConfigure(material: NodeMaterial): void;
  55958. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55959. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55960. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  55961. protected _buildBlock(state: NodeMaterialBuildState): this;
  55962. }
  55963. }
  55964. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  55965. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55966. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55967. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55968. import { Nullable } from "babylonjs/types";
  55969. import { Scene } from "babylonjs/scene";
  55970. import { Effect } from "babylonjs/Materials/effect";
  55971. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  55972. import { Mesh } from "babylonjs/Meshes/mesh";
  55973. import { Light } from "babylonjs/Lights/light";
  55974. /**
  55975. * Block used to get data information from a light
  55976. */
  55977. export class LightInformationBlock extends NodeMaterialBlock {
  55978. private _lightDataDefineName;
  55979. private _lightColorDefineName;
  55980. /**
  55981. * Gets or sets the light associated with this block
  55982. */
  55983. light: Nullable<Light>;
  55984. /**
  55985. * Creates a new LightInformationBlock
  55986. * @param name defines the block name
  55987. */
  55988. constructor(name: string);
  55989. /**
  55990. * Gets the current class name
  55991. * @returns the class name
  55992. */
  55993. getClassName(): string;
  55994. /**
  55995. * Gets the world position input component
  55996. */
  55997. readonly worldPosition: NodeMaterialConnectionPoint;
  55998. /**
  55999. * Gets the direction output component
  56000. */
  56001. readonly direction: NodeMaterialConnectionPoint;
  56002. /**
  56003. * Gets the direction output component
  56004. */
  56005. readonly color: NodeMaterialConnectionPoint;
  56006. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56007. protected _buildBlock(state: NodeMaterialBuildState): this;
  56008. serialize(): any;
  56009. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56010. }
  56011. }
  56012. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  56013. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  56014. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  56015. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  56016. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  56017. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  56018. }
  56019. declare module "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock" {
  56020. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56021. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56022. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56023. import { Scene } from "babylonjs/scene";
  56024. /**
  56025. * Block used to add an alpha test in the fragment shader
  56026. */
  56027. export class AlphaTestBlock extends NodeMaterialBlock {
  56028. /**
  56029. * Gets or sets the alpha value where alpha testing happens
  56030. */
  56031. alphaCutOff: number;
  56032. /**
  56033. * Create a new AlphaTestBlock
  56034. * @param name defines the block name
  56035. */
  56036. constructor(name: string);
  56037. /**
  56038. * Gets the current class name
  56039. * @returns the class name
  56040. */
  56041. getClassName(): string;
  56042. /**
  56043. * Gets the color input component
  56044. */
  56045. readonly color: NodeMaterialConnectionPoint;
  56046. /**
  56047. * Gets the alpha input component
  56048. */
  56049. readonly alpha: NodeMaterialConnectionPoint;
  56050. protected _buildBlock(state: NodeMaterialBuildState): this;
  56051. protected _dumpPropertiesCode(): string;
  56052. serialize(): any;
  56053. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56054. }
  56055. }
  56056. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  56057. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56058. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56059. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56060. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56061. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56062. import { Effect } from "babylonjs/Materials/effect";
  56063. import { Mesh } from "babylonjs/Meshes/mesh";
  56064. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56065. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  56066. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  56067. /**
  56068. * Block used to add image processing support to fragment shader
  56069. */
  56070. export class ImageProcessingBlock extends NodeMaterialBlock {
  56071. /**
  56072. * Create a new ImageProcessingBlock
  56073. * @param name defines the block name
  56074. */
  56075. constructor(name: string);
  56076. /**
  56077. * Gets the current class name
  56078. * @returns the class name
  56079. */
  56080. getClassName(): string;
  56081. /**
  56082. * Gets the color input component
  56083. */
  56084. readonly color: NodeMaterialConnectionPoint;
  56085. /**
  56086. * Gets the output component
  56087. */
  56088. readonly output: NodeMaterialConnectionPoint;
  56089. /**
  56090. * Initialize the block and prepare the context for build
  56091. * @param state defines the state that will be used for the build
  56092. */
  56093. initialize(state: NodeMaterialBuildState): void;
  56094. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  56095. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56096. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56097. protected _buildBlock(state: NodeMaterialBuildState): this;
  56098. }
  56099. }
  56100. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  56101. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56102. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56103. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56104. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56105. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56106. import { Effect } from "babylonjs/Materials/effect";
  56107. import { Mesh } from "babylonjs/Meshes/mesh";
  56108. import { Scene } from "babylonjs/scene";
  56109. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  56110. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  56111. /**
  56112. * Block used to pertub normals based on a normal map
  56113. */
  56114. export class PerturbNormalBlock extends NodeMaterialBlock {
  56115. private _tangentSpaceParameterName;
  56116. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  56117. invertX: boolean;
  56118. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  56119. invertY: boolean;
  56120. /**
  56121. * Create a new PerturbNormalBlock
  56122. * @param name defines the block name
  56123. */
  56124. constructor(name: string);
  56125. /**
  56126. * Gets the current class name
  56127. * @returns the class name
  56128. */
  56129. getClassName(): string;
  56130. /**
  56131. * Gets the world position input component
  56132. */
  56133. readonly worldPosition: NodeMaterialConnectionPoint;
  56134. /**
  56135. * Gets the world normal input component
  56136. */
  56137. readonly worldNormal: NodeMaterialConnectionPoint;
  56138. /**
  56139. * Gets the uv input component
  56140. */
  56141. readonly uv: NodeMaterialConnectionPoint;
  56142. /**
  56143. * Gets the normal map color input component
  56144. */
  56145. readonly normalMapColor: NodeMaterialConnectionPoint;
  56146. /**
  56147. * Gets the strength input component
  56148. */
  56149. readonly strength: NodeMaterialConnectionPoint;
  56150. /**
  56151. * Gets the output component
  56152. */
  56153. readonly output: NodeMaterialConnectionPoint;
  56154. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56155. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56156. autoConfigure(material: NodeMaterial): void;
  56157. protected _buildBlock(state: NodeMaterialBuildState): this;
  56158. protected _dumpPropertiesCode(): string;
  56159. serialize(): any;
  56160. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56161. }
  56162. }
  56163. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  56164. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  56165. export * from "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock";
  56166. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  56167. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  56168. }
  56169. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  56170. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56171. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56172. import { Mesh } from "babylonjs/Meshes/mesh";
  56173. import { Effect } from "babylonjs/Materials/effect";
  56174. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56175. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56176. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56177. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  56178. /**
  56179. * Block used to add support for scene fog
  56180. */
  56181. export class FogBlock extends NodeMaterialBlock {
  56182. private _fogDistanceName;
  56183. private _fogParameters;
  56184. /**
  56185. * Create a new FogBlock
  56186. * @param name defines the block name
  56187. */
  56188. constructor(name: string);
  56189. /**
  56190. * Gets the current class name
  56191. * @returns the class name
  56192. */
  56193. getClassName(): string;
  56194. /**
  56195. * Gets the world position input component
  56196. */
  56197. readonly worldPosition: NodeMaterialConnectionPoint;
  56198. /**
  56199. * Gets the view input component
  56200. */
  56201. readonly view: NodeMaterialConnectionPoint;
  56202. /**
  56203. * Gets the color input component
  56204. */
  56205. readonly input: NodeMaterialConnectionPoint;
  56206. /**
  56207. * Gets the fog color input component
  56208. */
  56209. readonly fogColor: NodeMaterialConnectionPoint;
  56210. /**
  56211. * Gets the output component
  56212. */
  56213. readonly output: NodeMaterialConnectionPoint;
  56214. autoConfigure(material: NodeMaterial): void;
  56215. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56216. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56217. protected _buildBlock(state: NodeMaterialBuildState): this;
  56218. }
  56219. }
  56220. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  56221. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56222. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56223. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56224. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56225. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56226. import { Effect } from "babylonjs/Materials/effect";
  56227. import { Mesh } from "babylonjs/Meshes/mesh";
  56228. import { Light } from "babylonjs/Lights/light";
  56229. import { Nullable } from "babylonjs/types";
  56230. import { Scene } from "babylonjs/scene";
  56231. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56232. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56233. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  56234. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56235. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  56236. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  56237. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  56238. /**
  56239. * Block used to add light in the fragment shader
  56240. */
  56241. export class LightBlock extends NodeMaterialBlock {
  56242. private _lightId;
  56243. /**
  56244. * Gets or sets the light associated with this block
  56245. */
  56246. light: Nullable<Light>;
  56247. /**
  56248. * Create a new LightBlock
  56249. * @param name defines the block name
  56250. */
  56251. constructor(name: string);
  56252. /**
  56253. * Gets the current class name
  56254. * @returns the class name
  56255. */
  56256. getClassName(): string;
  56257. /**
  56258. * Gets the world position input component
  56259. */
  56260. readonly worldPosition: NodeMaterialConnectionPoint;
  56261. /**
  56262. * Gets the world normal input component
  56263. */
  56264. readonly worldNormal: NodeMaterialConnectionPoint;
  56265. /**
  56266. * Gets the camera (or eye) position component
  56267. */
  56268. readonly cameraPosition: NodeMaterialConnectionPoint;
  56269. /**
  56270. * Gets the diffuse output component
  56271. */
  56272. readonly diffuseOutput: NodeMaterialConnectionPoint;
  56273. /**
  56274. * Gets the specular output component
  56275. */
  56276. readonly specularOutput: NodeMaterialConnectionPoint;
  56277. autoConfigure(material: NodeMaterial): void;
  56278. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56279. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56280. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56281. private _injectVertexCode;
  56282. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56283. serialize(): any;
  56284. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56285. }
  56286. }
  56287. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  56288. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  56289. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  56290. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  56291. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  56292. }
  56293. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  56294. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56295. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  56296. }
  56297. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  56298. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56299. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56300. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56301. /**
  56302. * Block used to multiply 2 values
  56303. */
  56304. export class MultiplyBlock extends NodeMaterialBlock {
  56305. /**
  56306. * Creates a new MultiplyBlock
  56307. * @param name defines the block name
  56308. */
  56309. constructor(name: string);
  56310. /**
  56311. * Gets the current class name
  56312. * @returns the class name
  56313. */
  56314. getClassName(): string;
  56315. /**
  56316. * Gets the left operand input component
  56317. */
  56318. readonly left: NodeMaterialConnectionPoint;
  56319. /**
  56320. * Gets the right operand input component
  56321. */
  56322. readonly right: NodeMaterialConnectionPoint;
  56323. /**
  56324. * Gets the output component
  56325. */
  56326. readonly output: NodeMaterialConnectionPoint;
  56327. protected _buildBlock(state: NodeMaterialBuildState): this;
  56328. }
  56329. }
  56330. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  56331. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56332. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56333. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56334. /**
  56335. * Block used to add 2 vectors
  56336. */
  56337. export class AddBlock extends NodeMaterialBlock {
  56338. /**
  56339. * Creates a new AddBlock
  56340. * @param name defines the block name
  56341. */
  56342. constructor(name: string);
  56343. /**
  56344. * Gets the current class name
  56345. * @returns the class name
  56346. */
  56347. getClassName(): string;
  56348. /**
  56349. * Gets the left operand input component
  56350. */
  56351. readonly left: NodeMaterialConnectionPoint;
  56352. /**
  56353. * Gets the right operand input component
  56354. */
  56355. readonly right: NodeMaterialConnectionPoint;
  56356. /**
  56357. * Gets the output component
  56358. */
  56359. readonly output: NodeMaterialConnectionPoint;
  56360. protected _buildBlock(state: NodeMaterialBuildState): this;
  56361. }
  56362. }
  56363. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  56364. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56365. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56366. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56367. /**
  56368. * Block used to scale a vector by a float
  56369. */
  56370. export class ScaleBlock extends NodeMaterialBlock {
  56371. /**
  56372. * Creates a new ScaleBlock
  56373. * @param name defines the block name
  56374. */
  56375. constructor(name: string);
  56376. /**
  56377. * Gets the current class name
  56378. * @returns the class name
  56379. */
  56380. getClassName(): string;
  56381. /**
  56382. * Gets the input component
  56383. */
  56384. readonly input: NodeMaterialConnectionPoint;
  56385. /**
  56386. * Gets the factor input component
  56387. */
  56388. readonly factor: NodeMaterialConnectionPoint;
  56389. /**
  56390. * Gets the output component
  56391. */
  56392. readonly output: NodeMaterialConnectionPoint;
  56393. protected _buildBlock(state: NodeMaterialBuildState): this;
  56394. }
  56395. }
  56396. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  56397. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56398. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56399. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56400. import { Scene } from "babylonjs/scene";
  56401. /**
  56402. * Block used to clamp a float
  56403. */
  56404. export class ClampBlock extends NodeMaterialBlock {
  56405. /** Gets or sets the minimum range */
  56406. minimum: number;
  56407. /** Gets or sets the maximum range */
  56408. maximum: number;
  56409. /**
  56410. * Creates a new ClampBlock
  56411. * @param name defines the block name
  56412. */
  56413. constructor(name: string);
  56414. /**
  56415. * Gets the current class name
  56416. * @returns the class name
  56417. */
  56418. getClassName(): string;
  56419. /**
  56420. * Gets the value input component
  56421. */
  56422. readonly value: NodeMaterialConnectionPoint;
  56423. /**
  56424. * Gets the output component
  56425. */
  56426. readonly output: NodeMaterialConnectionPoint;
  56427. protected _buildBlock(state: NodeMaterialBuildState): this;
  56428. protected _dumpPropertiesCode(): string;
  56429. serialize(): any;
  56430. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56431. }
  56432. }
  56433. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  56434. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56435. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56436. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56437. /**
  56438. * Block used to apply a cross product between 2 vectors
  56439. */
  56440. export class CrossBlock extends NodeMaterialBlock {
  56441. /**
  56442. * Creates a new CrossBlock
  56443. * @param name defines the block name
  56444. */
  56445. constructor(name: string);
  56446. /**
  56447. * Gets the current class name
  56448. * @returns the class name
  56449. */
  56450. getClassName(): string;
  56451. /**
  56452. * Gets the left operand input component
  56453. */
  56454. readonly left: NodeMaterialConnectionPoint;
  56455. /**
  56456. * Gets the right operand input component
  56457. */
  56458. readonly right: NodeMaterialConnectionPoint;
  56459. /**
  56460. * Gets the output component
  56461. */
  56462. readonly output: NodeMaterialConnectionPoint;
  56463. protected _buildBlock(state: NodeMaterialBuildState): this;
  56464. }
  56465. }
  56466. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  56467. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56468. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56469. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56470. /**
  56471. * Block used to apply a dot product between 2 vectors
  56472. */
  56473. export class DotBlock extends NodeMaterialBlock {
  56474. /**
  56475. * Creates a new DotBlock
  56476. * @param name defines the block name
  56477. */
  56478. constructor(name: string);
  56479. /**
  56480. * Gets the current class name
  56481. * @returns the class name
  56482. */
  56483. getClassName(): string;
  56484. /**
  56485. * Gets the left operand input component
  56486. */
  56487. readonly left: NodeMaterialConnectionPoint;
  56488. /**
  56489. * Gets the right operand input component
  56490. */
  56491. readonly right: NodeMaterialConnectionPoint;
  56492. /**
  56493. * Gets the output component
  56494. */
  56495. readonly output: NodeMaterialConnectionPoint;
  56496. protected _buildBlock(state: NodeMaterialBuildState): this;
  56497. }
  56498. }
  56499. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  56500. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56501. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56502. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56503. import { Vector2 } from "babylonjs/Maths/math.vector";
  56504. import { Scene } from "babylonjs/scene";
  56505. /**
  56506. * Block used to remap a float from a range to a new one
  56507. */
  56508. export class RemapBlock extends NodeMaterialBlock {
  56509. /**
  56510. * Gets or sets the source range
  56511. */
  56512. sourceRange: Vector2;
  56513. /**
  56514. * Gets or sets the target range
  56515. */
  56516. targetRange: Vector2;
  56517. /**
  56518. * Creates a new RemapBlock
  56519. * @param name defines the block name
  56520. */
  56521. constructor(name: string);
  56522. /**
  56523. * Gets the current class name
  56524. * @returns the class name
  56525. */
  56526. getClassName(): string;
  56527. /**
  56528. * Gets the input component
  56529. */
  56530. readonly input: NodeMaterialConnectionPoint;
  56531. /**
  56532. * Gets the source min input component
  56533. */
  56534. readonly sourceMin: NodeMaterialConnectionPoint;
  56535. /**
  56536. * Gets the source max input component
  56537. */
  56538. readonly sourceMax: NodeMaterialConnectionPoint;
  56539. /**
  56540. * Gets the target min input component
  56541. */
  56542. readonly targetMin: NodeMaterialConnectionPoint;
  56543. /**
  56544. * Gets the target max input component
  56545. */
  56546. readonly targetMax: NodeMaterialConnectionPoint;
  56547. /**
  56548. * Gets the output component
  56549. */
  56550. readonly output: NodeMaterialConnectionPoint;
  56551. protected _buildBlock(state: NodeMaterialBuildState): this;
  56552. protected _dumpPropertiesCode(): string;
  56553. serialize(): any;
  56554. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56555. }
  56556. }
  56557. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  56558. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56559. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56560. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56561. /**
  56562. * Block used to normalize a vector
  56563. */
  56564. export class NormalizeBlock extends NodeMaterialBlock {
  56565. /**
  56566. * Creates a new NormalizeBlock
  56567. * @param name defines the block name
  56568. */
  56569. constructor(name: string);
  56570. /**
  56571. * Gets the current class name
  56572. * @returns the class name
  56573. */
  56574. getClassName(): string;
  56575. /**
  56576. * Gets the input component
  56577. */
  56578. readonly input: NodeMaterialConnectionPoint;
  56579. /**
  56580. * Gets the output component
  56581. */
  56582. readonly output: NodeMaterialConnectionPoint;
  56583. protected _buildBlock(state: NodeMaterialBuildState): this;
  56584. }
  56585. }
  56586. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  56587. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56588. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56589. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56590. import { Scene } from "babylonjs/scene";
  56591. /**
  56592. * Operations supported by the Trigonometry block
  56593. */
  56594. export enum TrigonometryBlockOperations {
  56595. /** Cos */
  56596. Cos = 0,
  56597. /** Sin */
  56598. Sin = 1,
  56599. /** Abs */
  56600. Abs = 2,
  56601. /** Exp */
  56602. Exp = 3,
  56603. /** Exp2 */
  56604. Exp2 = 4,
  56605. /** Round */
  56606. Round = 5,
  56607. /** Floor */
  56608. Floor = 6,
  56609. /** Ceiling */
  56610. Ceiling = 7,
  56611. /** Square root */
  56612. Sqrt = 8
  56613. }
  56614. /**
  56615. * Block used to apply trigonometry operation to floats
  56616. */
  56617. export class TrigonometryBlock extends NodeMaterialBlock {
  56618. /**
  56619. * Gets or sets the operation applied by the block
  56620. */
  56621. operation: TrigonometryBlockOperations;
  56622. /**
  56623. * Creates a new TrigonometryBlock
  56624. * @param name defines the block name
  56625. */
  56626. constructor(name: string);
  56627. /**
  56628. * Gets the current class name
  56629. * @returns the class name
  56630. */
  56631. getClassName(): string;
  56632. /**
  56633. * Gets the input component
  56634. */
  56635. readonly input: NodeMaterialConnectionPoint;
  56636. /**
  56637. * Gets the output component
  56638. */
  56639. readonly output: NodeMaterialConnectionPoint;
  56640. protected _buildBlock(state: NodeMaterialBuildState): this;
  56641. serialize(): any;
  56642. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56643. }
  56644. }
  56645. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  56646. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56647. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56648. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56649. /**
  56650. * Block used to create a Color3/4 out of individual inputs (one for each component)
  56651. */
  56652. export class ColorMergerBlock extends NodeMaterialBlock {
  56653. /**
  56654. * Create a new ColorMergerBlock
  56655. * @param name defines the block name
  56656. */
  56657. constructor(name: string);
  56658. /**
  56659. * Gets the current class name
  56660. * @returns the class name
  56661. */
  56662. getClassName(): string;
  56663. /**
  56664. * Gets the r component (input)
  56665. */
  56666. readonly r: NodeMaterialConnectionPoint;
  56667. /**
  56668. * Gets the g component (input)
  56669. */
  56670. readonly g: NodeMaterialConnectionPoint;
  56671. /**
  56672. * Gets the b component (input)
  56673. */
  56674. readonly b: NodeMaterialConnectionPoint;
  56675. /**
  56676. * Gets the a component (input)
  56677. */
  56678. readonly a: NodeMaterialConnectionPoint;
  56679. /**
  56680. * Gets the rgba component (output)
  56681. */
  56682. readonly rgba: NodeMaterialConnectionPoint;
  56683. /**
  56684. * Gets the rgb component (output)
  56685. */
  56686. readonly rgb: NodeMaterialConnectionPoint;
  56687. protected _buildBlock(state: NodeMaterialBuildState): this;
  56688. }
  56689. }
  56690. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  56691. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56692. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56693. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56694. /**
  56695. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  56696. */
  56697. export class VectorMergerBlock extends NodeMaterialBlock {
  56698. /**
  56699. * Create a new VectorMergerBlock
  56700. * @param name defines the block name
  56701. */
  56702. constructor(name: string);
  56703. /**
  56704. * Gets the current class name
  56705. * @returns the class name
  56706. */
  56707. getClassName(): string;
  56708. /**
  56709. * Gets the x component (input)
  56710. */
  56711. readonly x: NodeMaterialConnectionPoint;
  56712. /**
  56713. * Gets the y component (input)
  56714. */
  56715. readonly y: NodeMaterialConnectionPoint;
  56716. /**
  56717. * Gets the z component (input)
  56718. */
  56719. readonly z: NodeMaterialConnectionPoint;
  56720. /**
  56721. * Gets the w component (input)
  56722. */
  56723. readonly w: NodeMaterialConnectionPoint;
  56724. /**
  56725. * Gets the xyzw component (output)
  56726. */
  56727. readonly xyzw: NodeMaterialConnectionPoint;
  56728. /**
  56729. * Gets the xyz component (output)
  56730. */
  56731. readonly xyz: NodeMaterialConnectionPoint;
  56732. /**
  56733. * Gets the xy component (output)
  56734. */
  56735. readonly xy: NodeMaterialConnectionPoint;
  56736. protected _buildBlock(state: NodeMaterialBuildState): this;
  56737. }
  56738. }
  56739. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  56740. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56741. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56742. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56743. /**
  56744. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  56745. */
  56746. export class ColorSplitterBlock extends NodeMaterialBlock {
  56747. /**
  56748. * Create a new ColorSplitterBlock
  56749. * @param name defines the block name
  56750. */
  56751. constructor(name: string);
  56752. /**
  56753. * Gets the current class name
  56754. * @returns the class name
  56755. */
  56756. getClassName(): string;
  56757. /**
  56758. * Gets the rgba component (input)
  56759. */
  56760. readonly rgba: NodeMaterialConnectionPoint;
  56761. /**
  56762. * Gets the rgb component (input)
  56763. */
  56764. readonly rgbIn: NodeMaterialConnectionPoint;
  56765. /**
  56766. * Gets the rgb component (output)
  56767. */
  56768. readonly rgbOut: NodeMaterialConnectionPoint;
  56769. /**
  56770. * Gets the r component (output)
  56771. */
  56772. readonly r: NodeMaterialConnectionPoint;
  56773. /**
  56774. * Gets the g component (output)
  56775. */
  56776. readonly g: NodeMaterialConnectionPoint;
  56777. /**
  56778. * Gets the b component (output)
  56779. */
  56780. readonly b: NodeMaterialConnectionPoint;
  56781. /**
  56782. * Gets the a component (output)
  56783. */
  56784. readonly a: NodeMaterialConnectionPoint;
  56785. protected _inputRename(name: string): string;
  56786. protected _outputRename(name: string): string;
  56787. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56788. }
  56789. }
  56790. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  56791. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56792. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56793. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56794. /**
  56795. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  56796. */
  56797. export class VectorSplitterBlock extends NodeMaterialBlock {
  56798. /**
  56799. * Create a new VectorSplitterBlock
  56800. * @param name defines the block name
  56801. */
  56802. constructor(name: string);
  56803. /**
  56804. * Gets the current class name
  56805. * @returns the class name
  56806. */
  56807. getClassName(): string;
  56808. /**
  56809. * Gets the xyzw component (input)
  56810. */
  56811. readonly xyzw: NodeMaterialConnectionPoint;
  56812. /**
  56813. * Gets the xyz component (input)
  56814. */
  56815. readonly xyzIn: NodeMaterialConnectionPoint;
  56816. /**
  56817. * Gets the xy component (input)
  56818. */
  56819. readonly xyIn: NodeMaterialConnectionPoint;
  56820. /**
  56821. * Gets the xyz component (output)
  56822. */
  56823. readonly xyzOut: NodeMaterialConnectionPoint;
  56824. /**
  56825. * Gets the xy component (output)
  56826. */
  56827. readonly xyOut: NodeMaterialConnectionPoint;
  56828. /**
  56829. * Gets the x component (output)
  56830. */
  56831. readonly x: NodeMaterialConnectionPoint;
  56832. /**
  56833. * Gets the y component (output)
  56834. */
  56835. readonly y: NodeMaterialConnectionPoint;
  56836. /**
  56837. * Gets the z component (output)
  56838. */
  56839. readonly z: NodeMaterialConnectionPoint;
  56840. /**
  56841. * Gets the w component (output)
  56842. */
  56843. readonly w: NodeMaterialConnectionPoint;
  56844. protected _inputRename(name: string): string;
  56845. protected _outputRename(name: string): string;
  56846. protected _buildBlock(state: NodeMaterialBuildState): this;
  56847. }
  56848. }
  56849. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  56850. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56851. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56852. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56853. /**
  56854. * Block used to lerp 2 values
  56855. */
  56856. export class LerpBlock extends NodeMaterialBlock {
  56857. /**
  56858. * Creates a new LerpBlock
  56859. * @param name defines the block name
  56860. */
  56861. constructor(name: string);
  56862. /**
  56863. * Gets the current class name
  56864. * @returns the class name
  56865. */
  56866. getClassName(): string;
  56867. /**
  56868. * Gets the left operand input component
  56869. */
  56870. readonly left: NodeMaterialConnectionPoint;
  56871. /**
  56872. * Gets the right operand input component
  56873. */
  56874. readonly right: NodeMaterialConnectionPoint;
  56875. /**
  56876. * Gets the gradient operand input component
  56877. */
  56878. readonly gradient: NodeMaterialConnectionPoint;
  56879. /**
  56880. * Gets the output component
  56881. */
  56882. readonly output: NodeMaterialConnectionPoint;
  56883. protected _buildBlock(state: NodeMaterialBuildState): this;
  56884. }
  56885. }
  56886. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  56887. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56888. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56889. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56890. /**
  56891. * Block used to divide 2 vectors
  56892. */
  56893. export class DivideBlock extends NodeMaterialBlock {
  56894. /**
  56895. * Creates a new DivideBlock
  56896. * @param name defines the block name
  56897. */
  56898. constructor(name: string);
  56899. /**
  56900. * Gets the current class name
  56901. * @returns the class name
  56902. */
  56903. getClassName(): string;
  56904. /**
  56905. * Gets the left operand input component
  56906. */
  56907. readonly left: NodeMaterialConnectionPoint;
  56908. /**
  56909. * Gets the right operand input component
  56910. */
  56911. readonly right: NodeMaterialConnectionPoint;
  56912. /**
  56913. * Gets the output component
  56914. */
  56915. readonly output: NodeMaterialConnectionPoint;
  56916. protected _buildBlock(state: NodeMaterialBuildState): this;
  56917. }
  56918. }
  56919. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  56920. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56921. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56922. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56923. /**
  56924. * Block used to subtract 2 vectors
  56925. */
  56926. export class SubtractBlock extends NodeMaterialBlock {
  56927. /**
  56928. * Creates a new SubtractBlock
  56929. * @param name defines the block name
  56930. */
  56931. constructor(name: string);
  56932. /**
  56933. * Gets the current class name
  56934. * @returns the class name
  56935. */
  56936. getClassName(): string;
  56937. /**
  56938. * Gets the left operand input component
  56939. */
  56940. readonly left: NodeMaterialConnectionPoint;
  56941. /**
  56942. * Gets the right operand input component
  56943. */
  56944. readonly right: NodeMaterialConnectionPoint;
  56945. /**
  56946. * Gets the output component
  56947. */
  56948. readonly output: NodeMaterialConnectionPoint;
  56949. protected _buildBlock(state: NodeMaterialBuildState): this;
  56950. }
  56951. }
  56952. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  56953. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56954. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56955. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56956. /**
  56957. * Block used to step a value
  56958. */
  56959. export class StepBlock extends NodeMaterialBlock {
  56960. /**
  56961. * Creates a new AddBlock
  56962. * @param name defines the block name
  56963. */
  56964. constructor(name: string);
  56965. /**
  56966. * Gets the current class name
  56967. * @returns the class name
  56968. */
  56969. getClassName(): string;
  56970. /**
  56971. * Gets the value operand input component
  56972. */
  56973. readonly value: NodeMaterialConnectionPoint;
  56974. /**
  56975. * Gets the edge operand input component
  56976. */
  56977. readonly edge: NodeMaterialConnectionPoint;
  56978. /**
  56979. * Gets the output component
  56980. */
  56981. readonly output: NodeMaterialConnectionPoint;
  56982. protected _buildBlock(state: NodeMaterialBuildState): this;
  56983. }
  56984. }
  56985. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  56986. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56987. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56988. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56989. /**
  56990. * Block used to get the opposite (1 - x) of a value
  56991. */
  56992. export class OneMinusBlock extends NodeMaterialBlock {
  56993. /**
  56994. * Creates a new OneMinusBlock
  56995. * @param name defines the block name
  56996. */
  56997. constructor(name: string);
  56998. /**
  56999. * Gets the current class name
  57000. * @returns the class name
  57001. */
  57002. getClassName(): string;
  57003. /**
  57004. * Gets the input component
  57005. */
  57006. readonly input: NodeMaterialConnectionPoint;
  57007. /**
  57008. * Gets the output component
  57009. */
  57010. readonly output: NodeMaterialConnectionPoint;
  57011. protected _buildBlock(state: NodeMaterialBuildState): this;
  57012. }
  57013. }
  57014. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  57015. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57016. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57017. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57018. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  57019. /**
  57020. * Block used to get the view direction
  57021. */
  57022. export class ViewDirectionBlock extends NodeMaterialBlock {
  57023. /**
  57024. * Creates a new ViewDirectionBlock
  57025. * @param name defines the block name
  57026. */
  57027. constructor(name: string);
  57028. /**
  57029. * Gets the current class name
  57030. * @returns the class name
  57031. */
  57032. getClassName(): string;
  57033. /**
  57034. * Gets the world position component
  57035. */
  57036. readonly worldPosition: NodeMaterialConnectionPoint;
  57037. /**
  57038. * Gets the camera position component
  57039. */
  57040. readonly cameraPosition: NodeMaterialConnectionPoint;
  57041. /**
  57042. * Gets the output component
  57043. */
  57044. readonly output: NodeMaterialConnectionPoint;
  57045. autoConfigure(material: NodeMaterial): void;
  57046. protected _buildBlock(state: NodeMaterialBuildState): this;
  57047. }
  57048. }
  57049. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  57050. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57051. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57052. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57053. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  57054. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  57055. /**
  57056. * Block used to compute fresnel value
  57057. */
  57058. export class FresnelBlock extends NodeMaterialBlock {
  57059. /**
  57060. * Create a new FresnelBlock
  57061. * @param name defines the block name
  57062. */
  57063. constructor(name: string);
  57064. /**
  57065. * Gets the current class name
  57066. * @returns the class name
  57067. */
  57068. getClassName(): string;
  57069. /**
  57070. * Gets the world normal input component
  57071. */
  57072. readonly worldNormal: NodeMaterialConnectionPoint;
  57073. /**
  57074. * Gets the view direction input component
  57075. */
  57076. readonly viewDirection: NodeMaterialConnectionPoint;
  57077. /**
  57078. * Gets the bias input component
  57079. */
  57080. readonly bias: NodeMaterialConnectionPoint;
  57081. /**
  57082. * Gets the camera (or eye) position component
  57083. */
  57084. readonly power: NodeMaterialConnectionPoint;
  57085. /**
  57086. * Gets the fresnel output component
  57087. */
  57088. readonly fresnel: NodeMaterialConnectionPoint;
  57089. autoConfigure(material: NodeMaterial): void;
  57090. protected _buildBlock(state: NodeMaterialBuildState): this;
  57091. }
  57092. }
  57093. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  57094. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57095. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57096. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57097. /**
  57098. * Block used to get the max of 2 values
  57099. */
  57100. export class MaxBlock extends NodeMaterialBlock {
  57101. /**
  57102. * Creates a new MaxBlock
  57103. * @param name defines the block name
  57104. */
  57105. constructor(name: string);
  57106. /**
  57107. * Gets the current class name
  57108. * @returns the class name
  57109. */
  57110. getClassName(): string;
  57111. /**
  57112. * Gets the left operand input component
  57113. */
  57114. readonly left: NodeMaterialConnectionPoint;
  57115. /**
  57116. * Gets the right operand input component
  57117. */
  57118. readonly right: NodeMaterialConnectionPoint;
  57119. /**
  57120. * Gets the output component
  57121. */
  57122. readonly output: NodeMaterialConnectionPoint;
  57123. protected _buildBlock(state: NodeMaterialBuildState): this;
  57124. }
  57125. }
  57126. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  57127. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57128. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57129. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57130. /**
  57131. * Block used to get the min of 2 values
  57132. */
  57133. export class MinBlock extends NodeMaterialBlock {
  57134. /**
  57135. * Creates a new MinBlock
  57136. * @param name defines the block name
  57137. */
  57138. constructor(name: string);
  57139. /**
  57140. * Gets the current class name
  57141. * @returns the class name
  57142. */
  57143. getClassName(): string;
  57144. /**
  57145. * Gets the left operand input component
  57146. */
  57147. readonly left: NodeMaterialConnectionPoint;
  57148. /**
  57149. * Gets the right operand input component
  57150. */
  57151. readonly right: NodeMaterialConnectionPoint;
  57152. /**
  57153. * Gets the output component
  57154. */
  57155. readonly output: NodeMaterialConnectionPoint;
  57156. protected _buildBlock(state: NodeMaterialBuildState): this;
  57157. }
  57158. }
  57159. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  57160. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57161. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57162. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57163. /**
  57164. * Block used to get the distance between 2 values
  57165. */
  57166. export class DistanceBlock extends NodeMaterialBlock {
  57167. /**
  57168. * Creates a new DistanceBlock
  57169. * @param name defines the block name
  57170. */
  57171. constructor(name: string);
  57172. /**
  57173. * Gets the current class name
  57174. * @returns the class name
  57175. */
  57176. getClassName(): string;
  57177. /**
  57178. * Gets the left operand input component
  57179. */
  57180. readonly left: NodeMaterialConnectionPoint;
  57181. /**
  57182. * Gets the right operand input component
  57183. */
  57184. readonly right: NodeMaterialConnectionPoint;
  57185. /**
  57186. * Gets the output component
  57187. */
  57188. readonly output: NodeMaterialConnectionPoint;
  57189. protected _buildBlock(state: NodeMaterialBuildState): this;
  57190. }
  57191. }
  57192. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  57193. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57194. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57195. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57196. /**
  57197. * Block used to get the length of a vector
  57198. */
  57199. export class LengthBlock extends NodeMaterialBlock {
  57200. /**
  57201. * Creates a new LengthBlock
  57202. * @param name defines the block name
  57203. */
  57204. constructor(name: string);
  57205. /**
  57206. * Gets the current class name
  57207. * @returns the class name
  57208. */
  57209. getClassName(): string;
  57210. /**
  57211. * Gets the value input component
  57212. */
  57213. readonly value: NodeMaterialConnectionPoint;
  57214. /**
  57215. * Gets the output component
  57216. */
  57217. readonly output: NodeMaterialConnectionPoint;
  57218. protected _buildBlock(state: NodeMaterialBuildState): this;
  57219. }
  57220. }
  57221. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  57222. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57223. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57224. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57225. /**
  57226. * Block used to get negative version of a value (i.e. x * -1)
  57227. */
  57228. export class NegateBlock extends NodeMaterialBlock {
  57229. /**
  57230. * Creates a new NegateBlock
  57231. * @param name defines the block name
  57232. */
  57233. constructor(name: string);
  57234. /**
  57235. * Gets the current class name
  57236. * @returns the class name
  57237. */
  57238. getClassName(): string;
  57239. /**
  57240. * Gets the value input component
  57241. */
  57242. readonly value: NodeMaterialConnectionPoint;
  57243. /**
  57244. * Gets the output component
  57245. */
  57246. readonly output: NodeMaterialConnectionPoint;
  57247. protected _buildBlock(state: NodeMaterialBuildState): this;
  57248. }
  57249. }
  57250. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  57251. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57252. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57253. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57254. /**
  57255. * Block used to get the value of the first parameter raised to the power of the second
  57256. */
  57257. export class PowBlock extends NodeMaterialBlock {
  57258. /**
  57259. * Creates a new PowBlock
  57260. * @param name defines the block name
  57261. */
  57262. constructor(name: string);
  57263. /**
  57264. * Gets the current class name
  57265. * @returns the class name
  57266. */
  57267. getClassName(): string;
  57268. /**
  57269. * Gets the value operand input component
  57270. */
  57271. readonly value: NodeMaterialConnectionPoint;
  57272. /**
  57273. * Gets the power operand input component
  57274. */
  57275. readonly power: NodeMaterialConnectionPoint;
  57276. /**
  57277. * Gets the output component
  57278. */
  57279. readonly output: NodeMaterialConnectionPoint;
  57280. protected _buildBlock(state: NodeMaterialBuildState): this;
  57281. }
  57282. }
  57283. declare module "babylonjs/Materials/Node/Blocks/index" {
  57284. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  57285. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  57286. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  57287. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  57288. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  57289. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  57290. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  57291. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  57292. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  57293. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  57294. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  57295. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  57296. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  57297. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  57298. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  57299. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  57300. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  57301. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  57302. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  57303. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  57304. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  57305. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  57306. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  57307. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  57308. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  57309. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  57310. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  57311. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  57312. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  57313. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  57314. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  57315. }
  57316. declare module "babylonjs/Materials/Node/Optimizers/index" {
  57317. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  57318. }
  57319. declare module "babylonjs/Materials/Node/index" {
  57320. export * from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  57321. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  57322. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57323. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  57324. export * from "babylonjs/Materials/Node/nodeMaterial";
  57325. export * from "babylonjs/Materials/Node/nodeMaterialSystemValues";
  57326. export * from "babylonjs/Materials/Node/Blocks/index";
  57327. export * from "babylonjs/Materials/Node/Optimizers/index";
  57328. }
  57329. declare module "babylonjs/Materials/effectRenderer" {
  57330. import { Nullable } from "babylonjs/types";
  57331. import { Texture } from "babylonjs/Materials/Textures/texture";
  57332. import { Engine } from "babylonjs/Engines/engine";
  57333. import { Viewport } from "babylonjs/Maths/math.viewport";
  57334. import { Observable } from "babylonjs/Misc/observable";
  57335. import { Effect } from "babylonjs/Materials/effect";
  57336. import "babylonjs/Shaders/postprocess.vertex";
  57337. /**
  57338. * Effect Render Options
  57339. */
  57340. export interface IEffectRendererOptions {
  57341. /**
  57342. * Defines the vertices positions.
  57343. */
  57344. positions?: number[];
  57345. /**
  57346. * Defines the indices.
  57347. */
  57348. indices?: number[];
  57349. }
  57350. /**
  57351. * Helper class to render one or more effects
  57352. */
  57353. export class EffectRenderer {
  57354. private engine;
  57355. private static _DefaultOptions;
  57356. private _vertexBuffers;
  57357. private _indexBuffer;
  57358. private _ringBufferIndex;
  57359. private _ringScreenBuffer;
  57360. private _fullscreenViewport;
  57361. private _getNextFrameBuffer;
  57362. /**
  57363. * Creates an effect renderer
  57364. * @param engine the engine to use for rendering
  57365. * @param options defines the options of the effect renderer
  57366. */
  57367. constructor(engine: Engine, options?: IEffectRendererOptions);
  57368. /**
  57369. * Sets the current viewport in normalized coordinates 0-1
  57370. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  57371. */
  57372. setViewport(viewport?: Viewport): void;
  57373. /**
  57374. * Binds the embedded attributes buffer to the effect.
  57375. * @param effect Defines the effect to bind the attributes for
  57376. */
  57377. bindBuffers(effect: Effect): void;
  57378. /**
  57379. * Sets the current effect wrapper to use during draw.
  57380. * The effect needs to be ready before calling this api.
  57381. * This also sets the default full screen position attribute.
  57382. * @param effectWrapper Defines the effect to draw with
  57383. */
  57384. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  57385. /**
  57386. * Draws a full screen quad.
  57387. */
  57388. draw(): void;
  57389. /**
  57390. * renders one or more effects to a specified texture
  57391. * @param effectWrappers list of effects to renderer
  57392. * @param outputTexture texture to draw to, if null it will render to the screen
  57393. */
  57394. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  57395. /**
  57396. * Disposes of the effect renderer
  57397. */
  57398. dispose(): void;
  57399. }
  57400. /**
  57401. * Options to create an EffectWrapper
  57402. */
  57403. interface EffectWrapperCreationOptions {
  57404. /**
  57405. * Engine to use to create the effect
  57406. */
  57407. engine: Engine;
  57408. /**
  57409. * Fragment shader for the effect
  57410. */
  57411. fragmentShader: string;
  57412. /**
  57413. * Vertex shader for the effect
  57414. */
  57415. vertexShader?: string;
  57416. /**
  57417. * Attributes to use in the shader
  57418. */
  57419. attributeNames?: Array<string>;
  57420. /**
  57421. * Uniforms to use in the shader
  57422. */
  57423. uniformNames?: Array<string>;
  57424. /**
  57425. * Texture sampler names to use in the shader
  57426. */
  57427. samplerNames?: Array<string>;
  57428. /**
  57429. * The friendly name of the effect displayed in Spector.
  57430. */
  57431. name?: string;
  57432. }
  57433. /**
  57434. * Wraps an effect to be used for rendering
  57435. */
  57436. export class EffectWrapper {
  57437. /**
  57438. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  57439. */
  57440. onApplyObservable: Observable<{}>;
  57441. /**
  57442. * The underlying effect
  57443. */
  57444. effect: Effect;
  57445. /**
  57446. * Creates an effect to be renderer
  57447. * @param creationOptions options to create the effect
  57448. */
  57449. constructor(creationOptions: EffectWrapperCreationOptions);
  57450. /**
  57451. * Disposes of the effect wrapper
  57452. */
  57453. dispose(): void;
  57454. }
  57455. }
  57456. declare module "babylonjs/Materials/index" {
  57457. export * from "babylonjs/Materials/Background/index";
  57458. export * from "babylonjs/Materials/colorCurves";
  57459. export * from "babylonjs/Materials/effect";
  57460. export * from "babylonjs/Materials/fresnelParameters";
  57461. export * from "babylonjs/Materials/imageProcessingConfiguration";
  57462. export * from "babylonjs/Materials/material";
  57463. export * from "babylonjs/Materials/materialDefines";
  57464. export * from "babylonjs/Materials/materialHelper";
  57465. export * from "babylonjs/Materials/multiMaterial";
  57466. export * from "babylonjs/Materials/PBR/index";
  57467. export * from "babylonjs/Materials/pushMaterial";
  57468. export * from "babylonjs/Materials/shaderMaterial";
  57469. export * from "babylonjs/Materials/standardMaterial";
  57470. export * from "babylonjs/Materials/Textures/index";
  57471. export * from "babylonjs/Materials/uniformBuffer";
  57472. export * from "babylonjs/Materials/materialFlags";
  57473. export * from "babylonjs/Materials/Node/index";
  57474. export * from "babylonjs/Materials/effectRenderer";
  57475. }
  57476. declare module "babylonjs/Maths/index" {
  57477. export * from "babylonjs/Maths/math.scalar";
  57478. export * from "babylonjs/Maths/math";
  57479. export * from "babylonjs/Maths/sphericalPolynomial";
  57480. }
  57481. declare module "babylonjs/Misc/workerPool" {
  57482. import { IDisposable } from "babylonjs/scene";
  57483. /**
  57484. * Helper class to push actions to a pool of workers.
  57485. */
  57486. export class WorkerPool implements IDisposable {
  57487. private _workerInfos;
  57488. private _pendingActions;
  57489. /**
  57490. * Constructor
  57491. * @param workers Array of workers to use for actions
  57492. */
  57493. constructor(workers: Array<Worker>);
  57494. /**
  57495. * Terminates all workers and clears any pending actions.
  57496. */
  57497. dispose(): void;
  57498. /**
  57499. * Pushes an action to the worker pool. If all the workers are active, the action will be
  57500. * pended until a worker has completed its action.
  57501. * @param action The action to perform. Call onComplete when the action is complete.
  57502. */
  57503. push(action: (worker: Worker, onComplete: () => void) => void): void;
  57504. private _execute;
  57505. }
  57506. }
  57507. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  57508. import { IDisposable } from "babylonjs/scene";
  57509. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  57510. /**
  57511. * Configuration for Draco compression
  57512. */
  57513. export interface IDracoCompressionConfiguration {
  57514. /**
  57515. * Configuration for the decoder.
  57516. */
  57517. decoder: {
  57518. /**
  57519. * The url to the WebAssembly module.
  57520. */
  57521. wasmUrl?: string;
  57522. /**
  57523. * The url to the WebAssembly binary.
  57524. */
  57525. wasmBinaryUrl?: string;
  57526. /**
  57527. * The url to the fallback JavaScript module.
  57528. */
  57529. fallbackUrl?: string;
  57530. };
  57531. }
  57532. /**
  57533. * Draco compression (https://google.github.io/draco/)
  57534. *
  57535. * This class wraps the Draco module.
  57536. *
  57537. * **Encoder**
  57538. *
  57539. * The encoder is not currently implemented.
  57540. *
  57541. * **Decoder**
  57542. *
  57543. * 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.
  57544. *
  57545. * To update the configuration, use the following code:
  57546. * ```javascript
  57547. * DracoCompression.Configuration = {
  57548. * decoder: {
  57549. * wasmUrl: "<url to the WebAssembly library>",
  57550. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  57551. * fallbackUrl: "<url to the fallback JavaScript library>",
  57552. * }
  57553. * };
  57554. * ```
  57555. *
  57556. * 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.
  57557. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  57558. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  57559. *
  57560. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  57561. * ```javascript
  57562. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  57563. * ```
  57564. *
  57565. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  57566. */
  57567. export class DracoCompression implements IDisposable {
  57568. private _workerPoolPromise?;
  57569. private _decoderModulePromise?;
  57570. /**
  57571. * The configuration. Defaults to the following urls:
  57572. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  57573. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  57574. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  57575. */
  57576. static Configuration: IDracoCompressionConfiguration;
  57577. /**
  57578. * Returns true if the decoder configuration is available.
  57579. */
  57580. static readonly DecoderAvailable: boolean;
  57581. /**
  57582. * Default number of workers to create when creating the draco compression object.
  57583. */
  57584. static DefaultNumWorkers: number;
  57585. private static GetDefaultNumWorkers;
  57586. private static _Default;
  57587. /**
  57588. * Default instance for the draco compression object.
  57589. */
  57590. static readonly Default: DracoCompression;
  57591. /**
  57592. * Constructor
  57593. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  57594. */
  57595. constructor(numWorkers?: number);
  57596. /**
  57597. * Stop all async operations and release resources.
  57598. */
  57599. dispose(): void;
  57600. /**
  57601. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  57602. * @returns a promise that resolves when ready
  57603. */
  57604. whenReadyAsync(): Promise<void>;
  57605. /**
  57606. * Decode Draco compressed mesh data to vertex data.
  57607. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  57608. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  57609. * @returns A promise that resolves with the decoded vertex data
  57610. */
  57611. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  57612. [kind: string]: number;
  57613. }): Promise<VertexData>;
  57614. }
  57615. }
  57616. declare module "babylonjs/Meshes/Compression/index" {
  57617. export * from "babylonjs/Meshes/Compression/dracoCompression";
  57618. }
  57619. declare module "babylonjs/Meshes/csg" {
  57620. import { Nullable } from "babylonjs/types";
  57621. import { Scene } from "babylonjs/scene";
  57622. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57623. import { Mesh } from "babylonjs/Meshes/mesh";
  57624. import { Material } from "babylonjs/Materials/material";
  57625. /**
  57626. * Class for building Constructive Solid Geometry
  57627. */
  57628. export class CSG {
  57629. private polygons;
  57630. /**
  57631. * The world matrix
  57632. */
  57633. matrix: Matrix;
  57634. /**
  57635. * Stores the position
  57636. */
  57637. position: Vector3;
  57638. /**
  57639. * Stores the rotation
  57640. */
  57641. rotation: Vector3;
  57642. /**
  57643. * Stores the rotation quaternion
  57644. */
  57645. rotationQuaternion: Nullable<Quaternion>;
  57646. /**
  57647. * Stores the scaling vector
  57648. */
  57649. scaling: Vector3;
  57650. /**
  57651. * Convert the Mesh to CSG
  57652. * @param mesh The Mesh to convert to CSG
  57653. * @returns A new CSG from the Mesh
  57654. */
  57655. static FromMesh(mesh: Mesh): CSG;
  57656. /**
  57657. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  57658. * @param polygons Polygons used to construct a CSG solid
  57659. */
  57660. private static FromPolygons;
  57661. /**
  57662. * Clones, or makes a deep copy, of the CSG
  57663. * @returns A new CSG
  57664. */
  57665. clone(): CSG;
  57666. /**
  57667. * Unions this CSG with another CSG
  57668. * @param csg The CSG to union against this CSG
  57669. * @returns The unioned CSG
  57670. */
  57671. union(csg: CSG): CSG;
  57672. /**
  57673. * Unions this CSG with another CSG in place
  57674. * @param csg The CSG to union against this CSG
  57675. */
  57676. unionInPlace(csg: CSG): void;
  57677. /**
  57678. * Subtracts this CSG with another CSG
  57679. * @param csg The CSG to subtract against this CSG
  57680. * @returns A new CSG
  57681. */
  57682. subtract(csg: CSG): CSG;
  57683. /**
  57684. * Subtracts this CSG with another CSG in place
  57685. * @param csg The CSG to subtact against this CSG
  57686. */
  57687. subtractInPlace(csg: CSG): void;
  57688. /**
  57689. * Intersect this CSG with another CSG
  57690. * @param csg The CSG to intersect against this CSG
  57691. * @returns A new CSG
  57692. */
  57693. intersect(csg: CSG): CSG;
  57694. /**
  57695. * Intersects this CSG with another CSG in place
  57696. * @param csg The CSG to intersect against this CSG
  57697. */
  57698. intersectInPlace(csg: CSG): void;
  57699. /**
  57700. * Return a new CSG solid with solid and empty space switched. This solid is
  57701. * not modified.
  57702. * @returns A new CSG solid with solid and empty space switched
  57703. */
  57704. inverse(): CSG;
  57705. /**
  57706. * Inverses the CSG in place
  57707. */
  57708. inverseInPlace(): void;
  57709. /**
  57710. * This is used to keep meshes transformations so they can be restored
  57711. * when we build back a Babylon Mesh
  57712. * NB : All CSG operations are performed in world coordinates
  57713. * @param csg The CSG to copy the transform attributes from
  57714. * @returns This CSG
  57715. */
  57716. copyTransformAttributes(csg: CSG): CSG;
  57717. /**
  57718. * Build Raw mesh from CSG
  57719. * Coordinates here are in world space
  57720. * @param name The name of the mesh geometry
  57721. * @param scene The Scene
  57722. * @param keepSubMeshes Specifies if the submeshes should be kept
  57723. * @returns A new Mesh
  57724. */
  57725. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  57726. /**
  57727. * Build Mesh from CSG taking material and transforms into account
  57728. * @param name The name of the Mesh
  57729. * @param material The material of the Mesh
  57730. * @param scene The Scene
  57731. * @param keepSubMeshes Specifies if submeshes should be kept
  57732. * @returns The new Mesh
  57733. */
  57734. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  57735. }
  57736. }
  57737. declare module "babylonjs/Meshes/trailMesh" {
  57738. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57739. import { Mesh } from "babylonjs/Meshes/mesh";
  57740. import { Scene } from "babylonjs/scene";
  57741. /**
  57742. * Class used to create a trail following a mesh
  57743. */
  57744. export class TrailMesh extends Mesh {
  57745. private _generator;
  57746. private _autoStart;
  57747. private _running;
  57748. private _diameter;
  57749. private _length;
  57750. private _sectionPolygonPointsCount;
  57751. private _sectionVectors;
  57752. private _sectionNormalVectors;
  57753. private _beforeRenderObserver;
  57754. /**
  57755. * @constructor
  57756. * @param name The value used by scene.getMeshByName() to do a lookup.
  57757. * @param generator The mesh to generate a trail.
  57758. * @param scene The scene to add this mesh to.
  57759. * @param diameter Diameter of trailing mesh. Default is 1.
  57760. * @param length Length of trailing mesh. Default is 60.
  57761. * @param autoStart Automatically start trailing mesh. Default true.
  57762. */
  57763. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  57764. /**
  57765. * "TrailMesh"
  57766. * @returns "TrailMesh"
  57767. */
  57768. getClassName(): string;
  57769. private _createMesh;
  57770. /**
  57771. * Start trailing mesh.
  57772. */
  57773. start(): void;
  57774. /**
  57775. * Stop trailing mesh.
  57776. */
  57777. stop(): void;
  57778. /**
  57779. * Update trailing mesh geometry.
  57780. */
  57781. update(): void;
  57782. /**
  57783. * Returns a new TrailMesh object.
  57784. * @param name is a string, the name given to the new mesh
  57785. * @param newGenerator use new generator object for cloned trail mesh
  57786. * @returns a new mesh
  57787. */
  57788. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  57789. /**
  57790. * Serializes this trail mesh
  57791. * @param serializationObject object to write serialization to
  57792. */
  57793. serialize(serializationObject: any): void;
  57794. /**
  57795. * Parses a serialized trail mesh
  57796. * @param parsedMesh the serialized mesh
  57797. * @param scene the scene to create the trail mesh in
  57798. * @returns the created trail mesh
  57799. */
  57800. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  57801. }
  57802. }
  57803. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  57804. import { Nullable } from "babylonjs/types";
  57805. import { Scene } from "babylonjs/scene";
  57806. import { Vector4 } from "babylonjs/Maths/math.vector";
  57807. import { Color4 } from "babylonjs/Maths/math.color";
  57808. import { Mesh } from "babylonjs/Meshes/mesh";
  57809. /**
  57810. * Class containing static functions to help procedurally build meshes
  57811. */
  57812. export class TiledBoxBuilder {
  57813. /**
  57814. * Creates a box mesh
  57815. * 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)
  57816. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57817. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57818. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57819. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57820. * @param name defines the name of the mesh
  57821. * @param options defines the options used to create the mesh
  57822. * @param scene defines the hosting scene
  57823. * @returns the box mesh
  57824. */
  57825. static CreateTiledBox(name: string, options: {
  57826. pattern?: number;
  57827. width?: number;
  57828. height?: number;
  57829. depth?: number;
  57830. tileSize?: number;
  57831. tileWidth?: number;
  57832. tileHeight?: number;
  57833. alignHorizontal?: number;
  57834. alignVertical?: number;
  57835. faceUV?: Vector4[];
  57836. faceColors?: Color4[];
  57837. sideOrientation?: number;
  57838. updatable?: boolean;
  57839. }, scene?: Nullable<Scene>): Mesh;
  57840. }
  57841. }
  57842. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  57843. import { Vector4 } from "babylonjs/Maths/math.vector";
  57844. import { Mesh } from "babylonjs/Meshes/mesh";
  57845. /**
  57846. * Class containing static functions to help procedurally build meshes
  57847. */
  57848. export class TorusKnotBuilder {
  57849. /**
  57850. * Creates a torus knot mesh
  57851. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  57852. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  57853. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  57854. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  57855. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57856. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57857. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57858. * @param name defines the name of the mesh
  57859. * @param options defines the options used to create the mesh
  57860. * @param scene defines the hosting scene
  57861. * @returns the torus knot mesh
  57862. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  57863. */
  57864. static CreateTorusKnot(name: string, options: {
  57865. radius?: number;
  57866. tube?: number;
  57867. radialSegments?: number;
  57868. tubularSegments?: number;
  57869. p?: number;
  57870. q?: number;
  57871. updatable?: boolean;
  57872. sideOrientation?: number;
  57873. frontUVs?: Vector4;
  57874. backUVs?: Vector4;
  57875. }, scene: any): Mesh;
  57876. }
  57877. }
  57878. declare module "babylonjs/Meshes/polygonMesh" {
  57879. import { Scene } from "babylonjs/scene";
  57880. import { Vector2 } from "babylonjs/Maths/math.vector";
  57881. import { Mesh } from "babylonjs/Meshes/mesh";
  57882. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  57883. import { Path2 } from "babylonjs/Maths/math.path";
  57884. /**
  57885. * Polygon
  57886. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  57887. */
  57888. export class Polygon {
  57889. /**
  57890. * Creates a rectangle
  57891. * @param xmin bottom X coord
  57892. * @param ymin bottom Y coord
  57893. * @param xmax top X coord
  57894. * @param ymax top Y coord
  57895. * @returns points that make the resulting rectation
  57896. */
  57897. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  57898. /**
  57899. * Creates a circle
  57900. * @param radius radius of circle
  57901. * @param cx scale in x
  57902. * @param cy scale in y
  57903. * @param numberOfSides number of sides that make up the circle
  57904. * @returns points that make the resulting circle
  57905. */
  57906. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  57907. /**
  57908. * Creates a polygon from input string
  57909. * @param input Input polygon data
  57910. * @returns the parsed points
  57911. */
  57912. static Parse(input: string): Vector2[];
  57913. /**
  57914. * Starts building a polygon from x and y coordinates
  57915. * @param x x coordinate
  57916. * @param y y coordinate
  57917. * @returns the started path2
  57918. */
  57919. static StartingAt(x: number, y: number): Path2;
  57920. }
  57921. /**
  57922. * Builds a polygon
  57923. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  57924. */
  57925. export class PolygonMeshBuilder {
  57926. private _points;
  57927. private _outlinepoints;
  57928. private _holes;
  57929. private _name;
  57930. private _scene;
  57931. private _epoints;
  57932. private _eholes;
  57933. private _addToepoint;
  57934. /**
  57935. * Babylon reference to the earcut plugin.
  57936. */
  57937. bjsEarcut: any;
  57938. /**
  57939. * Creates a PolygonMeshBuilder
  57940. * @param name name of the builder
  57941. * @param contours Path of the polygon
  57942. * @param scene scene to add to when creating the mesh
  57943. * @param earcutInjection can be used to inject your own earcut reference
  57944. */
  57945. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  57946. /**
  57947. * Adds a whole within the polygon
  57948. * @param hole Array of points defining the hole
  57949. * @returns this
  57950. */
  57951. addHole(hole: Vector2[]): PolygonMeshBuilder;
  57952. /**
  57953. * Creates the polygon
  57954. * @param updatable If the mesh should be updatable
  57955. * @param depth The depth of the mesh created
  57956. * @returns the created mesh
  57957. */
  57958. build(updatable?: boolean, depth?: number): Mesh;
  57959. /**
  57960. * Creates the polygon
  57961. * @param depth The depth of the mesh created
  57962. * @returns the created VertexData
  57963. */
  57964. buildVertexData(depth?: number): VertexData;
  57965. /**
  57966. * Adds a side to the polygon
  57967. * @param positions points that make the polygon
  57968. * @param normals normals of the polygon
  57969. * @param uvs uvs of the polygon
  57970. * @param indices indices of the polygon
  57971. * @param bounds bounds of the polygon
  57972. * @param points points of the polygon
  57973. * @param depth depth of the polygon
  57974. * @param flip flip of the polygon
  57975. */
  57976. private addSide;
  57977. }
  57978. }
  57979. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  57980. import { Scene } from "babylonjs/scene";
  57981. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  57982. import { Color4 } from "babylonjs/Maths/math.color";
  57983. import { Mesh } from "babylonjs/Meshes/mesh";
  57984. import { Nullable } from "babylonjs/types";
  57985. /**
  57986. * Class containing static functions to help procedurally build meshes
  57987. */
  57988. export class PolygonBuilder {
  57989. /**
  57990. * Creates a polygon mesh
  57991. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  57992. * * 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
  57993. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  57994. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57995. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  57996. * * Remember you can only change the shape positions, not their number when updating a polygon
  57997. * @param name defines the name of the mesh
  57998. * @param options defines the options used to create the mesh
  57999. * @param scene defines the hosting scene
  58000. * @param earcutInjection can be used to inject your own earcut reference
  58001. * @returns the polygon mesh
  58002. */
  58003. static CreatePolygon(name: string, options: {
  58004. shape: Vector3[];
  58005. holes?: Vector3[][];
  58006. depth?: number;
  58007. faceUV?: Vector4[];
  58008. faceColors?: Color4[];
  58009. updatable?: boolean;
  58010. sideOrientation?: number;
  58011. frontUVs?: Vector4;
  58012. backUVs?: Vector4;
  58013. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58014. /**
  58015. * Creates an extruded polygon mesh, with depth in the Y direction.
  58016. * * 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)
  58017. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58018. * @param name defines the name of the mesh
  58019. * @param options defines the options used to create the mesh
  58020. * @param scene defines the hosting scene
  58021. * @param earcutInjection can be used to inject your own earcut reference
  58022. * @returns the polygon mesh
  58023. */
  58024. static ExtrudePolygon(name: string, options: {
  58025. shape: Vector3[];
  58026. holes?: Vector3[][];
  58027. depth?: number;
  58028. faceUV?: Vector4[];
  58029. faceColors?: Color4[];
  58030. updatable?: boolean;
  58031. sideOrientation?: number;
  58032. frontUVs?: Vector4;
  58033. backUVs?: Vector4;
  58034. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58035. }
  58036. }
  58037. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  58038. import { Scene } from "babylonjs/scene";
  58039. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  58040. import { Mesh } from "babylonjs/Meshes/mesh";
  58041. import { Nullable } from "babylonjs/types";
  58042. /**
  58043. * Class containing static functions to help procedurally build meshes
  58044. */
  58045. export class LatheBuilder {
  58046. /**
  58047. * Creates lathe mesh.
  58048. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  58049. * * 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
  58050. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  58051. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  58052. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  58053. * * 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
  58054. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  58055. * * 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
  58056. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58057. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58058. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58059. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58060. * @param name defines the name of the mesh
  58061. * @param options defines the options used to create the mesh
  58062. * @param scene defines the hosting scene
  58063. * @returns the lathe mesh
  58064. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  58065. */
  58066. static CreateLathe(name: string, options: {
  58067. shape: Vector3[];
  58068. radius?: number;
  58069. tessellation?: number;
  58070. clip?: number;
  58071. arc?: number;
  58072. closed?: boolean;
  58073. updatable?: boolean;
  58074. sideOrientation?: number;
  58075. frontUVs?: Vector4;
  58076. backUVs?: Vector4;
  58077. cap?: number;
  58078. invertUV?: boolean;
  58079. }, scene?: Nullable<Scene>): Mesh;
  58080. }
  58081. }
  58082. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  58083. import { Nullable } from "babylonjs/types";
  58084. import { Scene } from "babylonjs/scene";
  58085. import { Vector4 } from "babylonjs/Maths/math.vector";
  58086. import { Mesh } from "babylonjs/Meshes/mesh";
  58087. /**
  58088. * Class containing static functions to help procedurally build meshes
  58089. */
  58090. export class TiledPlaneBuilder {
  58091. /**
  58092. * Creates a tiled plane mesh
  58093. * * The parameter `pattern` will, depending on value, do nothing or
  58094. * * * flip (reflect about central vertical) alternate tiles across and up
  58095. * * * flip every tile on alternate rows
  58096. * * * rotate (180 degs) alternate tiles across and up
  58097. * * * rotate every tile on alternate rows
  58098. * * * flip and rotate alternate tiles across and up
  58099. * * * flip and rotate every tile on alternate rows
  58100. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  58101. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  58102. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58103. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  58104. * * 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)
  58105. * * 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)
  58106. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  58107. * @param name defines the name of the mesh
  58108. * @param options defines the options used to create the mesh
  58109. * @param scene defines the hosting scene
  58110. * @returns the box mesh
  58111. */
  58112. static CreateTiledPlane(name: string, options: {
  58113. pattern?: number;
  58114. tileSize?: number;
  58115. tileWidth?: number;
  58116. tileHeight?: number;
  58117. size?: number;
  58118. width?: number;
  58119. height?: number;
  58120. alignHorizontal?: number;
  58121. alignVertical?: number;
  58122. sideOrientation?: number;
  58123. frontUVs?: Vector4;
  58124. backUVs?: Vector4;
  58125. updatable?: boolean;
  58126. }, scene?: Nullable<Scene>): Mesh;
  58127. }
  58128. }
  58129. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  58130. import { Nullable } from "babylonjs/types";
  58131. import { Scene } from "babylonjs/scene";
  58132. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  58133. import { Mesh } from "babylonjs/Meshes/mesh";
  58134. /**
  58135. * Class containing static functions to help procedurally build meshes
  58136. */
  58137. export class TubeBuilder {
  58138. /**
  58139. * Creates a tube mesh.
  58140. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58141. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  58142. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  58143. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  58144. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  58145. * * 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)
  58146. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  58147. * * 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
  58148. * * 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
  58149. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58150. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58151. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58152. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58153. * @param name defines the name of the mesh
  58154. * @param options defines the options used to create the mesh
  58155. * @param scene defines the hosting scene
  58156. * @returns the tube mesh
  58157. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58158. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  58159. */
  58160. static CreateTube(name: string, options: {
  58161. path: Vector3[];
  58162. radius?: number;
  58163. tessellation?: number;
  58164. radiusFunction?: {
  58165. (i: number, distance: number): number;
  58166. };
  58167. cap?: number;
  58168. arc?: number;
  58169. updatable?: boolean;
  58170. sideOrientation?: number;
  58171. frontUVs?: Vector4;
  58172. backUVs?: Vector4;
  58173. instance?: Mesh;
  58174. invertUV?: boolean;
  58175. }, scene?: Nullable<Scene>): Mesh;
  58176. }
  58177. }
  58178. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  58179. import { Scene } from "babylonjs/scene";
  58180. import { Vector4 } from "babylonjs/Maths/math.vector";
  58181. import { Mesh } from "babylonjs/Meshes/mesh";
  58182. import { Nullable } from "babylonjs/types";
  58183. /**
  58184. * Class containing static functions to help procedurally build meshes
  58185. */
  58186. export class IcoSphereBuilder {
  58187. /**
  58188. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  58189. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  58190. * * 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`)
  58191. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  58192. * * 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
  58193. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58194. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58195. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58196. * @param name defines the name of the mesh
  58197. * @param options defines the options used to create the mesh
  58198. * @param scene defines the hosting scene
  58199. * @returns the icosahedron mesh
  58200. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  58201. */
  58202. static CreateIcoSphere(name: string, options: {
  58203. radius?: number;
  58204. radiusX?: number;
  58205. radiusY?: number;
  58206. radiusZ?: number;
  58207. flat?: boolean;
  58208. subdivisions?: number;
  58209. sideOrientation?: number;
  58210. frontUVs?: Vector4;
  58211. backUVs?: Vector4;
  58212. updatable?: boolean;
  58213. }, scene?: Nullable<Scene>): Mesh;
  58214. }
  58215. }
  58216. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  58217. import { Vector3 } from "babylonjs/Maths/math.vector";
  58218. import { Mesh } from "babylonjs/Meshes/mesh";
  58219. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58220. /**
  58221. * Class containing static functions to help procedurally build meshes
  58222. */
  58223. export class DecalBuilder {
  58224. /**
  58225. * Creates a decal mesh.
  58226. * 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
  58227. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  58228. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  58229. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  58230. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  58231. * @param name defines the name of the mesh
  58232. * @param sourceMesh defines the mesh where the decal must be applied
  58233. * @param options defines the options used to create the mesh
  58234. * @param scene defines the hosting scene
  58235. * @returns the decal mesh
  58236. * @see https://doc.babylonjs.com/how_to/decals
  58237. */
  58238. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  58239. position?: Vector3;
  58240. normal?: Vector3;
  58241. size?: Vector3;
  58242. angle?: number;
  58243. }): Mesh;
  58244. }
  58245. }
  58246. declare module "babylonjs/Meshes/meshBuilder" {
  58247. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  58248. import { Nullable } from "babylonjs/types";
  58249. import { Scene } from "babylonjs/scene";
  58250. import { Mesh } from "babylonjs/Meshes/mesh";
  58251. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  58252. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  58253. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58254. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  58255. import { Plane } from "babylonjs/Maths/math.plane";
  58256. /**
  58257. * Class containing static functions to help procedurally build meshes
  58258. */
  58259. export class MeshBuilder {
  58260. /**
  58261. * Creates a box mesh
  58262. * * The parameter `size` sets the size (float) of each box side (default 1)
  58263. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  58264. * * 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)
  58265. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58266. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58267. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58268. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58269. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  58270. * @param name defines the name of the mesh
  58271. * @param options defines the options used to create the mesh
  58272. * @param scene defines the hosting scene
  58273. * @returns the box mesh
  58274. */
  58275. static CreateBox(name: string, options: {
  58276. size?: number;
  58277. width?: number;
  58278. height?: number;
  58279. depth?: number;
  58280. faceUV?: Vector4[];
  58281. faceColors?: Color4[];
  58282. sideOrientation?: number;
  58283. frontUVs?: Vector4;
  58284. backUVs?: Vector4;
  58285. updatable?: boolean;
  58286. }, scene?: Nullable<Scene>): Mesh;
  58287. /**
  58288. * Creates a tiled box mesh
  58289. * * faceTiles sets the pattern, tile size and number of tiles for a face
  58290. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58291. * @param name defines the name of the mesh
  58292. * @param options defines the options used to create the mesh
  58293. * @param scene defines the hosting scene
  58294. * @returns the tiled box mesh
  58295. */
  58296. static CreateTiledBox(name: string, options: {
  58297. pattern?: number;
  58298. size?: number;
  58299. width?: number;
  58300. height?: number;
  58301. depth: number;
  58302. tileSize?: number;
  58303. tileWidth?: number;
  58304. tileHeight?: number;
  58305. faceUV?: Vector4[];
  58306. faceColors?: Color4[];
  58307. alignHorizontal?: number;
  58308. alignVertical?: number;
  58309. sideOrientation?: number;
  58310. updatable?: boolean;
  58311. }, scene?: Nullable<Scene>): Mesh;
  58312. /**
  58313. * Creates a sphere mesh
  58314. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  58315. * * 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`)
  58316. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  58317. * * 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
  58318. * * 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)
  58319. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58320. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58321. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58322. * @param name defines the name of the mesh
  58323. * @param options defines the options used to create the mesh
  58324. * @param scene defines the hosting scene
  58325. * @returns the sphere mesh
  58326. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  58327. */
  58328. static CreateSphere(name: string, options: {
  58329. segments?: number;
  58330. diameter?: number;
  58331. diameterX?: number;
  58332. diameterY?: number;
  58333. diameterZ?: number;
  58334. arc?: number;
  58335. slice?: number;
  58336. sideOrientation?: number;
  58337. frontUVs?: Vector4;
  58338. backUVs?: Vector4;
  58339. updatable?: boolean;
  58340. }, scene?: Nullable<Scene>): Mesh;
  58341. /**
  58342. * Creates a plane polygonal mesh. By default, this is a disc
  58343. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  58344. * * 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
  58345. * * 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
  58346. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58347. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58348. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58349. * @param name defines the name of the mesh
  58350. * @param options defines the options used to create the mesh
  58351. * @param scene defines the hosting scene
  58352. * @returns the plane polygonal mesh
  58353. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  58354. */
  58355. static CreateDisc(name: string, options: {
  58356. radius?: number;
  58357. tessellation?: number;
  58358. arc?: number;
  58359. updatable?: boolean;
  58360. sideOrientation?: number;
  58361. frontUVs?: Vector4;
  58362. backUVs?: Vector4;
  58363. }, scene?: Nullable<Scene>): Mesh;
  58364. /**
  58365. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  58366. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  58367. * * 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`)
  58368. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  58369. * * 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
  58370. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58371. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58372. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58373. * @param name defines the name of the mesh
  58374. * @param options defines the options used to create the mesh
  58375. * @param scene defines the hosting scene
  58376. * @returns the icosahedron mesh
  58377. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  58378. */
  58379. static CreateIcoSphere(name: string, options: {
  58380. radius?: number;
  58381. radiusX?: number;
  58382. radiusY?: number;
  58383. radiusZ?: number;
  58384. flat?: boolean;
  58385. subdivisions?: number;
  58386. sideOrientation?: number;
  58387. frontUVs?: Vector4;
  58388. backUVs?: Vector4;
  58389. updatable?: boolean;
  58390. }, scene?: Nullable<Scene>): Mesh;
  58391. /**
  58392. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58393. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  58394. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  58395. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  58396. * * 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
  58397. * * 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
  58398. * * 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
  58399. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58400. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58401. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58402. * * 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
  58403. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  58404. * * 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
  58405. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  58406. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58407. * @param name defines the name of the mesh
  58408. * @param options defines the options used to create the mesh
  58409. * @param scene defines the hosting scene
  58410. * @returns the ribbon mesh
  58411. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  58412. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58413. */
  58414. static CreateRibbon(name: string, options: {
  58415. pathArray: Vector3[][];
  58416. closeArray?: boolean;
  58417. closePath?: boolean;
  58418. offset?: number;
  58419. updatable?: boolean;
  58420. sideOrientation?: number;
  58421. frontUVs?: Vector4;
  58422. backUVs?: Vector4;
  58423. instance?: Mesh;
  58424. invertUV?: boolean;
  58425. uvs?: Vector2[];
  58426. colors?: Color4[];
  58427. }, scene?: Nullable<Scene>): Mesh;
  58428. /**
  58429. * Creates a cylinder or a cone mesh
  58430. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  58431. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  58432. * * 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.
  58433. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  58434. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  58435. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  58436. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  58437. * * 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).
  58438. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  58439. * * 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).
  58440. * * 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
  58441. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  58442. * * 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
  58443. * * 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.
  58444. * * If `enclose` is false, a ring surface is one element.
  58445. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  58446. * * 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
  58447. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58448. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58449. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58450. * @param name defines the name of the mesh
  58451. * @param options defines the options used to create the mesh
  58452. * @param scene defines the hosting scene
  58453. * @returns the cylinder mesh
  58454. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  58455. */
  58456. static CreateCylinder(name: string, options: {
  58457. height?: number;
  58458. diameterTop?: number;
  58459. diameterBottom?: number;
  58460. diameter?: number;
  58461. tessellation?: number;
  58462. subdivisions?: number;
  58463. arc?: number;
  58464. faceColors?: Color4[];
  58465. faceUV?: Vector4[];
  58466. updatable?: boolean;
  58467. hasRings?: boolean;
  58468. enclose?: boolean;
  58469. cap?: number;
  58470. sideOrientation?: number;
  58471. frontUVs?: Vector4;
  58472. backUVs?: Vector4;
  58473. }, scene?: Nullable<Scene>): Mesh;
  58474. /**
  58475. * Creates a torus mesh
  58476. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  58477. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  58478. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  58479. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58480. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58481. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58482. * @param name defines the name of the mesh
  58483. * @param options defines the options used to create the mesh
  58484. * @param scene defines the hosting scene
  58485. * @returns the torus mesh
  58486. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  58487. */
  58488. static CreateTorus(name: string, options: {
  58489. diameter?: number;
  58490. thickness?: number;
  58491. tessellation?: number;
  58492. updatable?: boolean;
  58493. sideOrientation?: number;
  58494. frontUVs?: Vector4;
  58495. backUVs?: Vector4;
  58496. }, scene?: Nullable<Scene>): Mesh;
  58497. /**
  58498. * Creates a torus knot mesh
  58499. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  58500. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  58501. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  58502. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  58503. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58504. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58505. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58506. * @param name defines the name of the mesh
  58507. * @param options defines the options used to create the mesh
  58508. * @param scene defines the hosting scene
  58509. * @returns the torus knot mesh
  58510. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  58511. */
  58512. static CreateTorusKnot(name: string, options: {
  58513. radius?: number;
  58514. tube?: number;
  58515. radialSegments?: number;
  58516. tubularSegments?: number;
  58517. p?: number;
  58518. q?: number;
  58519. updatable?: boolean;
  58520. sideOrientation?: number;
  58521. frontUVs?: Vector4;
  58522. backUVs?: Vector4;
  58523. }, scene?: Nullable<Scene>): Mesh;
  58524. /**
  58525. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  58526. * * 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
  58527. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  58528. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  58529. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  58530. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  58531. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  58532. * * 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
  58533. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  58534. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58535. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  58536. * @param name defines the name of the new line system
  58537. * @param options defines the options used to create the line system
  58538. * @param scene defines the hosting scene
  58539. * @returns a new line system mesh
  58540. */
  58541. static CreateLineSystem(name: string, options: {
  58542. lines: Vector3[][];
  58543. updatable?: boolean;
  58544. instance?: Nullable<LinesMesh>;
  58545. colors?: Nullable<Color4[][]>;
  58546. useVertexAlpha?: boolean;
  58547. }, scene: Nullable<Scene>): LinesMesh;
  58548. /**
  58549. * Creates a line mesh
  58550. * 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
  58551. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  58552. * * The parameter `points` is an array successive Vector3
  58553. * * 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
  58554. * * The optional parameter `colors` is an array of successive Color4, one per line point
  58555. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  58556. * * When updating an instance, remember that only point positions can change, not the number of points
  58557. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58558. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  58559. * @param name defines the name of the new line system
  58560. * @param options defines the options used to create the line system
  58561. * @param scene defines the hosting scene
  58562. * @returns a new line mesh
  58563. */
  58564. static CreateLines(name: string, options: {
  58565. points: Vector3[];
  58566. updatable?: boolean;
  58567. instance?: Nullable<LinesMesh>;
  58568. colors?: Color4[];
  58569. useVertexAlpha?: boolean;
  58570. }, scene?: Nullable<Scene>): LinesMesh;
  58571. /**
  58572. * Creates a dashed line mesh
  58573. * * 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
  58574. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  58575. * * The parameter `points` is an array successive Vector3
  58576. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  58577. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  58578. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  58579. * * 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
  58580. * * When updating an instance, remember that only point positions can change, not the number of points
  58581. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58582. * @param name defines the name of the mesh
  58583. * @param options defines the options used to create the mesh
  58584. * @param scene defines the hosting scene
  58585. * @returns the dashed line mesh
  58586. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  58587. */
  58588. static CreateDashedLines(name: string, options: {
  58589. points: Vector3[];
  58590. dashSize?: number;
  58591. gapSize?: number;
  58592. dashNb?: number;
  58593. updatable?: boolean;
  58594. instance?: LinesMesh;
  58595. }, scene?: Nullable<Scene>): LinesMesh;
  58596. /**
  58597. * 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.
  58598. * * 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.
  58599. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58600. * * 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.
  58601. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  58602. * * 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
  58603. * * 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
  58604. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  58605. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58606. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58607. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  58608. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58609. * @param name defines the name of the mesh
  58610. * @param options defines the options used to create the mesh
  58611. * @param scene defines the hosting scene
  58612. * @returns the extruded shape mesh
  58613. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58614. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58615. */
  58616. static ExtrudeShape(name: string, options: {
  58617. shape: Vector3[];
  58618. path: Vector3[];
  58619. scale?: number;
  58620. rotation?: number;
  58621. cap?: number;
  58622. updatable?: boolean;
  58623. sideOrientation?: number;
  58624. frontUVs?: Vector4;
  58625. backUVs?: Vector4;
  58626. instance?: Mesh;
  58627. invertUV?: boolean;
  58628. }, scene?: Nullable<Scene>): Mesh;
  58629. /**
  58630. * Creates an custom extruded shape mesh.
  58631. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  58632. * * 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.
  58633. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58634. * * 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
  58635. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  58636. * * 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
  58637. * * It must returns a float value that will be the scale value applied to the shape on each path point
  58638. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  58639. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  58640. * * 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
  58641. * * 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
  58642. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  58643. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58644. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58645. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58646. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58647. * @param name defines the name of the mesh
  58648. * @param options defines the options used to create the mesh
  58649. * @param scene defines the hosting scene
  58650. * @returns the custom extruded shape mesh
  58651. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  58652. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58653. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58654. */
  58655. static ExtrudeShapeCustom(name: string, options: {
  58656. shape: Vector3[];
  58657. path: Vector3[];
  58658. scaleFunction?: any;
  58659. rotationFunction?: any;
  58660. ribbonCloseArray?: boolean;
  58661. ribbonClosePath?: boolean;
  58662. cap?: number;
  58663. updatable?: boolean;
  58664. sideOrientation?: number;
  58665. frontUVs?: Vector4;
  58666. backUVs?: Vector4;
  58667. instance?: Mesh;
  58668. invertUV?: boolean;
  58669. }, scene?: Nullable<Scene>): Mesh;
  58670. /**
  58671. * Creates lathe mesh.
  58672. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  58673. * * 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
  58674. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  58675. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  58676. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  58677. * * 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
  58678. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  58679. * * 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
  58680. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58681. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58682. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58683. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58684. * @param name defines the name of the mesh
  58685. * @param options defines the options used to create the mesh
  58686. * @param scene defines the hosting scene
  58687. * @returns the lathe mesh
  58688. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  58689. */
  58690. static CreateLathe(name: string, options: {
  58691. shape: Vector3[];
  58692. radius?: number;
  58693. tessellation?: number;
  58694. clip?: number;
  58695. arc?: number;
  58696. closed?: boolean;
  58697. updatable?: boolean;
  58698. sideOrientation?: number;
  58699. frontUVs?: Vector4;
  58700. backUVs?: Vector4;
  58701. cap?: number;
  58702. invertUV?: boolean;
  58703. }, scene?: Nullable<Scene>): Mesh;
  58704. /**
  58705. * Creates a tiled plane mesh
  58706. * * You can set a limited pattern arrangement with the tiles
  58707. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58708. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58709. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58710. * @param name defines the name of the mesh
  58711. * @param options defines the options used to create the mesh
  58712. * @param scene defines the hosting scene
  58713. * @returns the plane mesh
  58714. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  58715. */
  58716. static CreateTiledPlane(name: string, options: {
  58717. pattern?: number;
  58718. tileSize?: number;
  58719. tileWidth?: number;
  58720. tileHeight?: number;
  58721. size?: number;
  58722. width?: number;
  58723. height?: number;
  58724. alignHorizontal?: number;
  58725. alignVertical?: number;
  58726. sideOrientation?: number;
  58727. frontUVs?: Vector4;
  58728. backUVs?: Vector4;
  58729. updatable?: boolean;
  58730. }, scene?: Nullable<Scene>): Mesh;
  58731. /**
  58732. * Creates a plane mesh
  58733. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  58734. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  58735. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  58736. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58737. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58738. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58739. * @param name defines the name of the mesh
  58740. * @param options defines the options used to create the mesh
  58741. * @param scene defines the hosting scene
  58742. * @returns the plane mesh
  58743. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  58744. */
  58745. static CreatePlane(name: string, options: {
  58746. size?: number;
  58747. width?: number;
  58748. height?: number;
  58749. sideOrientation?: number;
  58750. frontUVs?: Vector4;
  58751. backUVs?: Vector4;
  58752. updatable?: boolean;
  58753. sourcePlane?: Plane;
  58754. }, scene?: Nullable<Scene>): Mesh;
  58755. /**
  58756. * Creates a ground mesh
  58757. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  58758. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  58759. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58760. * @param name defines the name of the mesh
  58761. * @param options defines the options used to create the mesh
  58762. * @param scene defines the hosting scene
  58763. * @returns the ground mesh
  58764. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  58765. */
  58766. static CreateGround(name: string, options: {
  58767. width?: number;
  58768. height?: number;
  58769. subdivisions?: number;
  58770. subdivisionsX?: number;
  58771. subdivisionsY?: number;
  58772. updatable?: boolean;
  58773. }, scene?: Nullable<Scene>): Mesh;
  58774. /**
  58775. * Creates a tiled ground mesh
  58776. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  58777. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  58778. * * 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
  58779. * * 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
  58780. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58781. * @param name defines the name of the mesh
  58782. * @param options defines the options used to create the mesh
  58783. * @param scene defines the hosting scene
  58784. * @returns the tiled ground mesh
  58785. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  58786. */
  58787. static CreateTiledGround(name: string, options: {
  58788. xmin: number;
  58789. zmin: number;
  58790. xmax: number;
  58791. zmax: number;
  58792. subdivisions?: {
  58793. w: number;
  58794. h: number;
  58795. };
  58796. precision?: {
  58797. w: number;
  58798. h: number;
  58799. };
  58800. updatable?: boolean;
  58801. }, scene?: Nullable<Scene>): Mesh;
  58802. /**
  58803. * Creates a ground mesh from a height map
  58804. * * The parameter `url` sets the URL of the height map image resource.
  58805. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  58806. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  58807. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  58808. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  58809. * * 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.
  58810. * * 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).
  58811. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  58812. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58813. * @param name defines the name of the mesh
  58814. * @param url defines the url to the height map
  58815. * @param options defines the options used to create the mesh
  58816. * @param scene defines the hosting scene
  58817. * @returns the ground mesh
  58818. * @see https://doc.babylonjs.com/babylon101/height_map
  58819. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  58820. */
  58821. static CreateGroundFromHeightMap(name: string, url: string, options: {
  58822. width?: number;
  58823. height?: number;
  58824. subdivisions?: number;
  58825. minHeight?: number;
  58826. maxHeight?: number;
  58827. colorFilter?: Color3;
  58828. alphaFilter?: number;
  58829. updatable?: boolean;
  58830. onReady?: (mesh: GroundMesh) => void;
  58831. }, scene?: Nullable<Scene>): GroundMesh;
  58832. /**
  58833. * Creates a polygon mesh
  58834. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  58835. * * 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
  58836. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  58837. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58838. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  58839. * * Remember you can only change the shape positions, not their number when updating a polygon
  58840. * @param name defines the name of the mesh
  58841. * @param options defines the options used to create the mesh
  58842. * @param scene defines the hosting scene
  58843. * @param earcutInjection can be used to inject your own earcut reference
  58844. * @returns the polygon mesh
  58845. */
  58846. static CreatePolygon(name: string, options: {
  58847. shape: Vector3[];
  58848. holes?: Vector3[][];
  58849. depth?: number;
  58850. faceUV?: Vector4[];
  58851. faceColors?: Color4[];
  58852. updatable?: boolean;
  58853. sideOrientation?: number;
  58854. frontUVs?: Vector4;
  58855. backUVs?: Vector4;
  58856. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58857. /**
  58858. * Creates an extruded polygon mesh, with depth in the Y direction.
  58859. * * 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)
  58860. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58861. * @param name defines the name of the mesh
  58862. * @param options defines the options used to create the mesh
  58863. * @param scene defines the hosting scene
  58864. * @param earcutInjection can be used to inject your own earcut reference
  58865. * @returns the polygon mesh
  58866. */
  58867. static ExtrudePolygon(name: string, options: {
  58868. shape: Vector3[];
  58869. holes?: Vector3[][];
  58870. depth?: number;
  58871. faceUV?: Vector4[];
  58872. faceColors?: Color4[];
  58873. updatable?: boolean;
  58874. sideOrientation?: number;
  58875. frontUVs?: Vector4;
  58876. backUVs?: Vector4;
  58877. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58878. /**
  58879. * Creates a tube mesh.
  58880. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58881. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  58882. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  58883. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  58884. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  58885. * * 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)
  58886. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  58887. * * 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
  58888. * * 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
  58889. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58890. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58891. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58892. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58893. * @param name defines the name of the mesh
  58894. * @param options defines the options used to create the mesh
  58895. * @param scene defines the hosting scene
  58896. * @returns the tube mesh
  58897. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58898. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  58899. */
  58900. static CreateTube(name: string, options: {
  58901. path: Vector3[];
  58902. radius?: number;
  58903. tessellation?: number;
  58904. radiusFunction?: {
  58905. (i: number, distance: number): number;
  58906. };
  58907. cap?: number;
  58908. arc?: number;
  58909. updatable?: boolean;
  58910. sideOrientation?: number;
  58911. frontUVs?: Vector4;
  58912. backUVs?: Vector4;
  58913. instance?: Mesh;
  58914. invertUV?: boolean;
  58915. }, scene?: Nullable<Scene>): Mesh;
  58916. /**
  58917. * Creates a polyhedron mesh
  58918. * * 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
  58919. * * The parameter `size` (positive float, default 1) sets the polygon size
  58920. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  58921. * * 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`
  58922. * * 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
  58923. * * 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)`)
  58924. * * 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
  58925. * * 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
  58926. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58927. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58928. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58929. * @param name defines the name of the mesh
  58930. * @param options defines the options used to create the mesh
  58931. * @param scene defines the hosting scene
  58932. * @returns the polyhedron mesh
  58933. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  58934. */
  58935. static CreatePolyhedron(name: string, options: {
  58936. type?: number;
  58937. size?: number;
  58938. sizeX?: number;
  58939. sizeY?: number;
  58940. sizeZ?: number;
  58941. custom?: any;
  58942. faceUV?: Vector4[];
  58943. faceColors?: Color4[];
  58944. flat?: boolean;
  58945. updatable?: boolean;
  58946. sideOrientation?: number;
  58947. frontUVs?: Vector4;
  58948. backUVs?: Vector4;
  58949. }, scene?: Nullable<Scene>): Mesh;
  58950. /**
  58951. * Creates a decal mesh.
  58952. * 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
  58953. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  58954. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  58955. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  58956. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  58957. * @param name defines the name of the mesh
  58958. * @param sourceMesh defines the mesh where the decal must be applied
  58959. * @param options defines the options used to create the mesh
  58960. * @param scene defines the hosting scene
  58961. * @returns the decal mesh
  58962. * @see https://doc.babylonjs.com/how_to/decals
  58963. */
  58964. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  58965. position?: Vector3;
  58966. normal?: Vector3;
  58967. size?: Vector3;
  58968. angle?: number;
  58969. }): Mesh;
  58970. }
  58971. }
  58972. declare module "babylonjs/Meshes/meshSimplification" {
  58973. import { Mesh } from "babylonjs/Meshes/mesh";
  58974. /**
  58975. * A simplifier interface for future simplification implementations
  58976. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58977. */
  58978. export interface ISimplifier {
  58979. /**
  58980. * Simplification of a given mesh according to the given settings.
  58981. * Since this requires computation, it is assumed that the function runs async.
  58982. * @param settings The settings of the simplification, including quality and distance
  58983. * @param successCallback A callback that will be called after the mesh was simplified.
  58984. * @param errorCallback in case of an error, this callback will be called. optional.
  58985. */
  58986. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  58987. }
  58988. /**
  58989. * Expected simplification settings.
  58990. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  58991. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  58992. */
  58993. export interface ISimplificationSettings {
  58994. /**
  58995. * Gets or sets the expected quality
  58996. */
  58997. quality: number;
  58998. /**
  58999. * Gets or sets the distance when this optimized version should be used
  59000. */
  59001. distance: number;
  59002. /**
  59003. * Gets an already optimized mesh
  59004. */
  59005. optimizeMesh?: boolean;
  59006. }
  59007. /**
  59008. * Class used to specify simplification options
  59009. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59010. */
  59011. export class SimplificationSettings implements ISimplificationSettings {
  59012. /** expected quality */
  59013. quality: number;
  59014. /** distance when this optimized version should be used */
  59015. distance: number;
  59016. /** already optimized mesh */
  59017. optimizeMesh?: boolean | undefined;
  59018. /**
  59019. * Creates a SimplificationSettings
  59020. * @param quality expected quality
  59021. * @param distance distance when this optimized version should be used
  59022. * @param optimizeMesh already optimized mesh
  59023. */
  59024. constructor(
  59025. /** expected quality */
  59026. quality: number,
  59027. /** distance when this optimized version should be used */
  59028. distance: number,
  59029. /** already optimized mesh */
  59030. optimizeMesh?: boolean | undefined);
  59031. }
  59032. /**
  59033. * Interface used to define a simplification task
  59034. */
  59035. export interface ISimplificationTask {
  59036. /**
  59037. * Array of settings
  59038. */
  59039. settings: Array<ISimplificationSettings>;
  59040. /**
  59041. * Simplification type
  59042. */
  59043. simplificationType: SimplificationType;
  59044. /**
  59045. * Mesh to simplify
  59046. */
  59047. mesh: Mesh;
  59048. /**
  59049. * Callback called on success
  59050. */
  59051. successCallback?: () => void;
  59052. /**
  59053. * Defines if parallel processing can be used
  59054. */
  59055. parallelProcessing: boolean;
  59056. }
  59057. /**
  59058. * Queue used to order the simplification tasks
  59059. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59060. */
  59061. export class SimplificationQueue {
  59062. private _simplificationArray;
  59063. /**
  59064. * Gets a boolean indicating that the process is still running
  59065. */
  59066. running: boolean;
  59067. /**
  59068. * Creates a new queue
  59069. */
  59070. constructor();
  59071. /**
  59072. * Adds a new simplification task
  59073. * @param task defines a task to add
  59074. */
  59075. addTask(task: ISimplificationTask): void;
  59076. /**
  59077. * Execute next task
  59078. */
  59079. executeNext(): void;
  59080. /**
  59081. * Execute a simplification task
  59082. * @param task defines the task to run
  59083. */
  59084. runSimplification(task: ISimplificationTask): void;
  59085. private getSimplifier;
  59086. }
  59087. /**
  59088. * The implemented types of simplification
  59089. * At the moment only Quadratic Error Decimation is implemented
  59090. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59091. */
  59092. export enum SimplificationType {
  59093. /** Quadratic error decimation */
  59094. QUADRATIC = 0
  59095. }
  59096. }
  59097. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  59098. import { Scene } from "babylonjs/scene";
  59099. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  59100. import { ISceneComponent } from "babylonjs/sceneComponent";
  59101. module "babylonjs/scene" {
  59102. interface Scene {
  59103. /** @hidden (Backing field) */
  59104. _simplificationQueue: SimplificationQueue;
  59105. /**
  59106. * Gets or sets the simplification queue attached to the scene
  59107. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59108. */
  59109. simplificationQueue: SimplificationQueue;
  59110. }
  59111. }
  59112. module "babylonjs/Meshes/mesh" {
  59113. interface Mesh {
  59114. /**
  59115. * Simplify the mesh according to the given array of settings.
  59116. * Function will return immediately and will simplify async
  59117. * @param settings a collection of simplification settings
  59118. * @param parallelProcessing should all levels calculate parallel or one after the other
  59119. * @param simplificationType the type of simplification to run
  59120. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  59121. * @returns the current mesh
  59122. */
  59123. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  59124. }
  59125. }
  59126. /**
  59127. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  59128. * created in a scene
  59129. */
  59130. export class SimplicationQueueSceneComponent implements ISceneComponent {
  59131. /**
  59132. * The component name helpfull to identify the component in the list of scene components.
  59133. */
  59134. readonly name: string;
  59135. /**
  59136. * The scene the component belongs to.
  59137. */
  59138. scene: Scene;
  59139. /**
  59140. * Creates a new instance of the component for the given scene
  59141. * @param scene Defines the scene to register the component in
  59142. */
  59143. constructor(scene: Scene);
  59144. /**
  59145. * Registers the component in a given scene
  59146. */
  59147. register(): void;
  59148. /**
  59149. * Rebuilds the elements related to this component in case of
  59150. * context lost for instance.
  59151. */
  59152. rebuild(): void;
  59153. /**
  59154. * Disposes the component and the associated ressources
  59155. */
  59156. dispose(): void;
  59157. private _beforeCameraUpdate;
  59158. }
  59159. }
  59160. declare module "babylonjs/Meshes/Builders/index" {
  59161. export * from "babylonjs/Meshes/Builders/boxBuilder";
  59162. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  59163. export * from "babylonjs/Meshes/Builders/discBuilder";
  59164. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  59165. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  59166. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  59167. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  59168. export * from "babylonjs/Meshes/Builders/torusBuilder";
  59169. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  59170. export * from "babylonjs/Meshes/Builders/linesBuilder";
  59171. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  59172. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  59173. export * from "babylonjs/Meshes/Builders/latheBuilder";
  59174. export * from "babylonjs/Meshes/Builders/planeBuilder";
  59175. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  59176. export * from "babylonjs/Meshes/Builders/groundBuilder";
  59177. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  59178. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  59179. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  59180. export * from "babylonjs/Meshes/Builders/decalBuilder";
  59181. }
  59182. declare module "babylonjs/Meshes/index" {
  59183. export * from "babylonjs/Meshes/abstractMesh";
  59184. export * from "babylonjs/Meshes/buffer";
  59185. export * from "babylonjs/Meshes/Compression/index";
  59186. export * from "babylonjs/Meshes/csg";
  59187. export * from "babylonjs/Meshes/geometry";
  59188. export * from "babylonjs/Meshes/groundMesh";
  59189. export * from "babylonjs/Meshes/trailMesh";
  59190. export * from "babylonjs/Meshes/instancedMesh";
  59191. export * from "babylonjs/Meshes/linesMesh";
  59192. export * from "babylonjs/Meshes/mesh";
  59193. export * from "babylonjs/Meshes/mesh.vertexData";
  59194. export * from "babylonjs/Meshes/meshBuilder";
  59195. export * from "babylonjs/Meshes/meshSimplification";
  59196. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  59197. export * from "babylonjs/Meshes/polygonMesh";
  59198. export * from "babylonjs/Meshes/subMesh";
  59199. export * from "babylonjs/Meshes/meshLODLevel";
  59200. export * from "babylonjs/Meshes/transformNode";
  59201. export * from "babylonjs/Meshes/Builders/index";
  59202. export * from "babylonjs/Meshes/dataBuffer";
  59203. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  59204. }
  59205. declare module "babylonjs/Morph/index" {
  59206. export * from "babylonjs/Morph/morphTarget";
  59207. export * from "babylonjs/Morph/morphTargetManager";
  59208. }
  59209. declare module "babylonjs/Navigation/INavigationEngine" {
  59210. import { TransformNode } from "babylonjs/Meshes/transformNode";
  59211. import { Vector3 } from "babylonjs/Maths/math";
  59212. import { Mesh } from "babylonjs/Meshes/mesh";
  59213. import { Scene } from "babylonjs/scene";
  59214. /**
  59215. * Navigation plugin interface to add navigation constrained by a navigation mesh
  59216. */
  59217. export interface INavigationEnginePlugin {
  59218. /**
  59219. * plugin name
  59220. */
  59221. name: string;
  59222. /**
  59223. * Creates a navigation mesh
  59224. * @param meshes array of all the geometry used to compute the navigatio mesh
  59225. * @param parameters bunch of parameters used to filter geometry
  59226. */
  59227. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  59228. /**
  59229. * Create a navigation mesh debug mesh
  59230. * @param scene is where the mesh will be added
  59231. * @returns debug display mesh
  59232. */
  59233. createDebugNavMesh(scene: Scene): Mesh;
  59234. /**
  59235. * Get a navigation mesh constrained position, closest to the parameter position
  59236. * @param position world position
  59237. * @returns the closest point to position constrained by the navigation mesh
  59238. */
  59239. getClosestPoint(position: Vector3): Vector3;
  59240. /**
  59241. * Get a navigation mesh constrained position, within a particular radius
  59242. * @param position world position
  59243. * @param maxRadius the maximum distance to the constrained world position
  59244. * @returns the closest point to position constrained by the navigation mesh
  59245. */
  59246. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  59247. /**
  59248. * Compute the final position from a segment made of destination-position
  59249. * @param position world position
  59250. * @param destination world position
  59251. * @returns the resulting point along the navmesh
  59252. */
  59253. moveAlong(position: Vector3, destination: Vector3): Vector3;
  59254. /**
  59255. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  59256. * @param start world position
  59257. * @param end world position
  59258. * @returns array containing world position composing the path
  59259. */
  59260. computePath(start: Vector3, end: Vector3): Vector3[];
  59261. /**
  59262. * If this plugin is supported
  59263. * @returns true if plugin is supported
  59264. */
  59265. isSupported(): boolean;
  59266. /**
  59267. * Create a new Crowd so you can add agents
  59268. * @param maxAgents the maximum agent count in the crowd
  59269. * @param maxAgentRadius the maximum radius an agent can have
  59270. * @param scene to attach the crowd to
  59271. * @returns the crowd you can add agents to
  59272. */
  59273. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  59274. /**
  59275. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59276. * The queries will try to find a solution within those bounds
  59277. * default is (1,1,1)
  59278. * @param extent x,y,z value that define the extent around the queries point of reference
  59279. */
  59280. setDefaultQueryExtent(extent: Vector3): void;
  59281. /**
  59282. * Get the Bounding box extent specified by setDefaultQueryExtent
  59283. * @returns the box extent values
  59284. */
  59285. getDefaultQueryExtent(): Vector3;
  59286. /**
  59287. * Release all resources
  59288. */
  59289. dispose(): void;
  59290. }
  59291. /**
  59292. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  59293. */
  59294. export interface ICrowd {
  59295. /**
  59296. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  59297. * You can attach anything to that node. The node position is updated in the scene update tick.
  59298. * @param pos world position that will be constrained by the navigation mesh
  59299. * @param parameters agent parameters
  59300. * @param transform hooked to the agent that will be update by the scene
  59301. * @returns agent index
  59302. */
  59303. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  59304. /**
  59305. * Returns the agent position in world space
  59306. * @param index agent index returned by addAgent
  59307. * @returns world space position
  59308. */
  59309. getAgentPosition(index: number): Vector3;
  59310. /**
  59311. * Gets the agent velocity in world space
  59312. * @param index agent index returned by addAgent
  59313. * @returns world space velocity
  59314. */
  59315. getAgentVelocity(index: number): Vector3;
  59316. /**
  59317. * remove a particular agent previously created
  59318. * @param index agent index returned by addAgent
  59319. */
  59320. removeAgent(index: number): void;
  59321. /**
  59322. * get the list of all agents attached to this crowd
  59323. * @returns list of agent indices
  59324. */
  59325. getAgents(): number[];
  59326. /**
  59327. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  59328. * @param deltaTime in seconds
  59329. */
  59330. update(deltaTime: number): void;
  59331. /**
  59332. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  59333. * @param index agent index returned by addAgent
  59334. * @param destination targeted world position
  59335. */
  59336. agentGoto(index: number, destination: Vector3): void;
  59337. /**
  59338. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59339. * The queries will try to find a solution within those bounds
  59340. * default is (1,1,1)
  59341. * @param extent x,y,z value that define the extent around the queries point of reference
  59342. */
  59343. setDefaultQueryExtent(extent: Vector3): void;
  59344. /**
  59345. * Get the Bounding box extent specified by setDefaultQueryExtent
  59346. * @returns the box extent values
  59347. */
  59348. getDefaultQueryExtent(): Vector3;
  59349. /**
  59350. * Release all resources
  59351. */
  59352. dispose(): void;
  59353. }
  59354. /**
  59355. * Configures an agent
  59356. */
  59357. export interface IAgentParameters {
  59358. /**
  59359. * Agent radius. [Limit: >= 0]
  59360. */
  59361. radius: number;
  59362. /**
  59363. * Agent height. [Limit: > 0]
  59364. */
  59365. height: number;
  59366. /**
  59367. * Maximum allowed acceleration. [Limit: >= 0]
  59368. */
  59369. maxAcceleration: number;
  59370. /**
  59371. * Maximum allowed speed. [Limit: >= 0]
  59372. */
  59373. maxSpeed: number;
  59374. /**
  59375. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  59376. */
  59377. collisionQueryRange: number;
  59378. /**
  59379. * The path visibility optimization range. [Limit: > 0]
  59380. */
  59381. pathOptimizationRange: number;
  59382. /**
  59383. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  59384. */
  59385. separationWeight: number;
  59386. }
  59387. /**
  59388. * Configures the navigation mesh creation
  59389. */
  59390. export interface INavMeshParameters {
  59391. /**
  59392. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  59393. */
  59394. cs: number;
  59395. /**
  59396. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  59397. */
  59398. ch: number;
  59399. /**
  59400. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  59401. */
  59402. walkableSlopeAngle: number;
  59403. /**
  59404. * Minimum floor to 'ceiling' height that will still allow the floor area to
  59405. * be considered walkable. [Limit: >= 3] [Units: vx]
  59406. */
  59407. walkableHeight: number;
  59408. /**
  59409. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  59410. */
  59411. walkableClimb: number;
  59412. /**
  59413. * The distance to erode/shrink the walkable area of the heightfield away from
  59414. * obstructions. [Limit: >=0] [Units: vx]
  59415. */
  59416. walkableRadius: number;
  59417. /**
  59418. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  59419. */
  59420. maxEdgeLen: number;
  59421. /**
  59422. * The maximum distance a simplfied contour's border edges should deviate
  59423. * the original raw contour. [Limit: >=0] [Units: vx]
  59424. */
  59425. maxSimplificationError: number;
  59426. /**
  59427. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  59428. */
  59429. minRegionArea: number;
  59430. /**
  59431. * Any regions with a span count smaller than this value will, if possible,
  59432. * be merged with larger regions. [Limit: >=0] [Units: vx]
  59433. */
  59434. mergeRegionArea: number;
  59435. /**
  59436. * The maximum number of vertices allowed for polygons generated during the
  59437. * contour to polygon conversion process. [Limit: >= 3]
  59438. */
  59439. maxVertsPerPoly: number;
  59440. /**
  59441. * Sets the sampling distance to use when generating the detail mesh.
  59442. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  59443. */
  59444. detailSampleDist: number;
  59445. /**
  59446. * The maximum distance the detail mesh surface should deviate from heightfield
  59447. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  59448. */
  59449. detailSampleMaxError: number;
  59450. }
  59451. }
  59452. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  59453. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  59454. import { Mesh } from "babylonjs/Meshes/mesh";
  59455. import { Scene } from "babylonjs/scene";
  59456. import { Vector3 } from "babylonjs/Maths/math";
  59457. import { TransformNode } from "babylonjs/Meshes/transformNode";
  59458. /**
  59459. * RecastJS navigation plugin
  59460. */
  59461. export class RecastJSPlugin implements INavigationEnginePlugin {
  59462. /**
  59463. * Reference to the Recast library
  59464. */
  59465. bjsRECAST: any;
  59466. /**
  59467. * plugin name
  59468. */
  59469. name: string;
  59470. /**
  59471. * the first navmesh created. We might extend this to support multiple navmeshes
  59472. */
  59473. navMesh: any;
  59474. /**
  59475. * Initializes the recastJS plugin
  59476. * @param recastInjection can be used to inject your own recast reference
  59477. */
  59478. constructor(recastInjection?: any);
  59479. /**
  59480. * Creates a navigation mesh
  59481. * @param meshes array of all the geometry used to compute the navigatio mesh
  59482. * @param parameters bunch of parameters used to filter geometry
  59483. */
  59484. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  59485. /**
  59486. * Create a navigation mesh debug mesh
  59487. * @param scene is where the mesh will be added
  59488. * @returns debug display mesh
  59489. */
  59490. createDebugNavMesh(scene: Scene): Mesh;
  59491. /**
  59492. * Get a navigation mesh constrained position, closest to the parameter position
  59493. * @param position world position
  59494. * @returns the closest point to position constrained by the navigation mesh
  59495. */
  59496. getClosestPoint(position: Vector3): Vector3;
  59497. /**
  59498. * Get a navigation mesh constrained position, within a particular radius
  59499. * @param position world position
  59500. * @param maxRadius the maximum distance to the constrained world position
  59501. * @returns the closest point to position constrained by the navigation mesh
  59502. */
  59503. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  59504. /**
  59505. * Compute the final position from a segment made of destination-position
  59506. * @param position world position
  59507. * @param destination world position
  59508. * @returns the resulting point along the navmesh
  59509. */
  59510. moveAlong(position: Vector3, destination: Vector3): Vector3;
  59511. /**
  59512. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  59513. * @param start world position
  59514. * @param end world position
  59515. * @returns array containing world position composing the path
  59516. */
  59517. computePath(start: Vector3, end: Vector3): Vector3[];
  59518. /**
  59519. * Create a new Crowd so you can add agents
  59520. * @param maxAgents the maximum agent count in the crowd
  59521. * @param maxAgentRadius the maximum radius an agent can have
  59522. * @param scene to attach the crowd to
  59523. * @returns the crowd you can add agents to
  59524. */
  59525. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  59526. /**
  59527. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59528. * The queries will try to find a solution within those bounds
  59529. * default is (1,1,1)
  59530. * @param extent x,y,z value that define the extent around the queries point of reference
  59531. */
  59532. setDefaultQueryExtent(extent: Vector3): void;
  59533. /**
  59534. * Get the Bounding box extent specified by setDefaultQueryExtent
  59535. * @returns the box extent values
  59536. */
  59537. getDefaultQueryExtent(): Vector3;
  59538. /**
  59539. * Disposes
  59540. */
  59541. dispose(): void;
  59542. /**
  59543. * If this plugin is supported
  59544. * @returns true if plugin is supported
  59545. */
  59546. isSupported(): boolean;
  59547. }
  59548. /**
  59549. * Recast detour crowd implementation
  59550. */
  59551. export class RecastJSCrowd implements ICrowd {
  59552. /**
  59553. * Recast/detour plugin
  59554. */
  59555. bjsRECASTPlugin: RecastJSPlugin;
  59556. /**
  59557. * Link to the detour crowd
  59558. */
  59559. recastCrowd: any;
  59560. /**
  59561. * One transform per agent
  59562. */
  59563. transforms: TransformNode[];
  59564. /**
  59565. * All agents created
  59566. */
  59567. agents: number[];
  59568. /**
  59569. * Link to the scene is kept to unregister the crowd from the scene
  59570. */
  59571. private _scene;
  59572. /**
  59573. * Observer for crowd updates
  59574. */
  59575. private _onBeforeAnimationsObserver;
  59576. /**
  59577. * Constructor
  59578. * @param plugin recastJS plugin
  59579. * @param maxAgents the maximum agent count in the crowd
  59580. * @param maxAgentRadius the maximum radius an agent can have
  59581. * @param scene to attach the crowd to
  59582. * @returns the crowd you can add agents to
  59583. */
  59584. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  59585. /**
  59586. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  59587. * You can attach anything to that node. The node position is updated in the scene update tick.
  59588. * @param pos world position that will be constrained by the navigation mesh
  59589. * @param parameters agent parameters
  59590. * @param transform hooked to the agent that will be update by the scene
  59591. * @returns agent index
  59592. */
  59593. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  59594. /**
  59595. * Returns the agent position in world space
  59596. * @param index agent index returned by addAgent
  59597. * @returns world space position
  59598. */
  59599. getAgentPosition(index: number): Vector3;
  59600. /**
  59601. * Returns the agent velocity in world space
  59602. * @param index agent index returned by addAgent
  59603. * @returns world space velocity
  59604. */
  59605. getAgentVelocity(index: number): Vector3;
  59606. /**
  59607. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  59608. * @param index agent index returned by addAgent
  59609. * @param destination targeted world position
  59610. */
  59611. agentGoto(index: number, destination: Vector3): void;
  59612. /**
  59613. * remove a particular agent previously created
  59614. * @param index agent index returned by addAgent
  59615. */
  59616. removeAgent(index: number): void;
  59617. /**
  59618. * get the list of all agents attached to this crowd
  59619. * @returns list of agent indices
  59620. */
  59621. getAgents(): number[];
  59622. /**
  59623. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  59624. * @param deltaTime in seconds
  59625. */
  59626. update(deltaTime: number): void;
  59627. /**
  59628. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59629. * The queries will try to find a solution within those bounds
  59630. * default is (1,1,1)
  59631. * @param extent x,y,z value that define the extent around the queries point of reference
  59632. */
  59633. setDefaultQueryExtent(extent: Vector3): void;
  59634. /**
  59635. * Get the Bounding box extent specified by setDefaultQueryExtent
  59636. * @returns the box extent values
  59637. */
  59638. getDefaultQueryExtent(): Vector3;
  59639. /**
  59640. * Release all resources
  59641. */
  59642. dispose(): void;
  59643. }
  59644. }
  59645. declare module "babylonjs/Navigation/Plugins/index" {
  59646. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  59647. }
  59648. declare module "babylonjs/Navigation/index" {
  59649. export * from "babylonjs/Navigation/INavigationEngine";
  59650. export * from "babylonjs/Navigation/Plugins/index";
  59651. }
  59652. declare module "babylonjs/Offline/database" {
  59653. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  59654. /**
  59655. * Class used to enable access to IndexedDB
  59656. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  59657. */
  59658. export class Database implements IOfflineProvider {
  59659. private _callbackManifestChecked;
  59660. private _currentSceneUrl;
  59661. private _db;
  59662. private _enableSceneOffline;
  59663. private _enableTexturesOffline;
  59664. private _manifestVersionFound;
  59665. private _mustUpdateRessources;
  59666. private _hasReachedQuota;
  59667. private _isSupported;
  59668. private _idbFactory;
  59669. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  59670. private static IsUASupportingBlobStorage;
  59671. /**
  59672. * Gets a boolean indicating if Database storate is enabled (off by default)
  59673. */
  59674. static IDBStorageEnabled: boolean;
  59675. /**
  59676. * Gets a boolean indicating if scene must be saved in the database
  59677. */
  59678. readonly enableSceneOffline: boolean;
  59679. /**
  59680. * Gets a boolean indicating if textures must be saved in the database
  59681. */
  59682. readonly enableTexturesOffline: boolean;
  59683. /**
  59684. * Creates a new Database
  59685. * @param urlToScene defines the url to load the scene
  59686. * @param callbackManifestChecked defines the callback to use when manifest is checked
  59687. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  59688. */
  59689. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  59690. private static _ParseURL;
  59691. private static _ReturnFullUrlLocation;
  59692. private _checkManifestFile;
  59693. /**
  59694. * Open the database and make it available
  59695. * @param successCallback defines the callback to call on success
  59696. * @param errorCallback defines the callback to call on error
  59697. */
  59698. open(successCallback: () => void, errorCallback: () => void): void;
  59699. /**
  59700. * Loads an image from the database
  59701. * @param url defines the url to load from
  59702. * @param image defines the target DOM image
  59703. */
  59704. loadImage(url: string, image: HTMLImageElement): void;
  59705. private _loadImageFromDBAsync;
  59706. private _saveImageIntoDBAsync;
  59707. private _checkVersionFromDB;
  59708. private _loadVersionFromDBAsync;
  59709. private _saveVersionIntoDBAsync;
  59710. /**
  59711. * Loads a file from database
  59712. * @param url defines the URL to load from
  59713. * @param sceneLoaded defines a callback to call on success
  59714. * @param progressCallBack defines a callback to call when progress changed
  59715. * @param errorCallback defines a callback to call on error
  59716. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  59717. */
  59718. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  59719. private _loadFileAsync;
  59720. private _saveFileAsync;
  59721. /**
  59722. * Validates if xhr data is correct
  59723. * @param xhr defines the request to validate
  59724. * @param dataType defines the expected data type
  59725. * @returns true if data is correct
  59726. */
  59727. private static _ValidateXHRData;
  59728. }
  59729. }
  59730. declare module "babylonjs/Offline/index" {
  59731. export * from "babylonjs/Offline/database";
  59732. export * from "babylonjs/Offline/IOfflineProvider";
  59733. }
  59734. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  59735. /** @hidden */
  59736. export var gpuUpdateParticlesPixelShader: {
  59737. name: string;
  59738. shader: string;
  59739. };
  59740. }
  59741. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  59742. /** @hidden */
  59743. export var gpuUpdateParticlesVertexShader: {
  59744. name: string;
  59745. shader: string;
  59746. };
  59747. }
  59748. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  59749. /** @hidden */
  59750. export var clipPlaneFragmentDeclaration2: {
  59751. name: string;
  59752. shader: string;
  59753. };
  59754. }
  59755. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  59756. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  59757. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  59758. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59759. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  59760. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  59761. /** @hidden */
  59762. export var gpuRenderParticlesPixelShader: {
  59763. name: string;
  59764. shader: string;
  59765. };
  59766. }
  59767. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  59768. /** @hidden */
  59769. export var clipPlaneVertexDeclaration2: {
  59770. name: string;
  59771. shader: string;
  59772. };
  59773. }
  59774. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  59775. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  59776. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  59777. /** @hidden */
  59778. export var gpuRenderParticlesVertexShader: {
  59779. name: string;
  59780. shader: string;
  59781. };
  59782. }
  59783. declare module "babylonjs/Particles/gpuParticleSystem" {
  59784. import { Nullable } from "babylonjs/types";
  59785. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  59786. import { Observable } from "babylonjs/Misc/observable";
  59787. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  59788. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  59789. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  59790. import { Scene, IDisposable } from "babylonjs/scene";
  59791. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  59792. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  59793. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  59794. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  59795. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  59796. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  59797. /**
  59798. * This represents a GPU particle system in Babylon
  59799. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  59800. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  59801. */
  59802. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  59803. /**
  59804. * The layer mask we are rendering the particles through.
  59805. */
  59806. layerMask: number;
  59807. private _capacity;
  59808. private _activeCount;
  59809. private _currentActiveCount;
  59810. private _accumulatedCount;
  59811. private _renderEffect;
  59812. private _updateEffect;
  59813. private _buffer0;
  59814. private _buffer1;
  59815. private _spriteBuffer;
  59816. private _updateVAO;
  59817. private _renderVAO;
  59818. private _targetIndex;
  59819. private _sourceBuffer;
  59820. private _targetBuffer;
  59821. private _engine;
  59822. private _currentRenderId;
  59823. private _started;
  59824. private _stopped;
  59825. private _timeDelta;
  59826. private _randomTexture;
  59827. private _randomTexture2;
  59828. private _attributesStrideSize;
  59829. private _updateEffectOptions;
  59830. private _randomTextureSize;
  59831. private _actualFrame;
  59832. private readonly _rawTextureWidth;
  59833. /**
  59834. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  59835. */
  59836. static readonly IsSupported: boolean;
  59837. /**
  59838. * An event triggered when the system is disposed.
  59839. */
  59840. onDisposeObservable: Observable<GPUParticleSystem>;
  59841. /**
  59842. * Gets the maximum number of particles active at the same time.
  59843. * @returns The max number of active particles.
  59844. */
  59845. getCapacity(): number;
  59846. /**
  59847. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  59848. * to override the particles.
  59849. */
  59850. forceDepthWrite: boolean;
  59851. /**
  59852. * Gets or set the number of active particles
  59853. */
  59854. activeParticleCount: number;
  59855. private _preWarmDone;
  59856. /**
  59857. * Is this system ready to be used/rendered
  59858. * @return true if the system is ready
  59859. */
  59860. isReady(): boolean;
  59861. /**
  59862. * Gets if the system has been started. (Note: this will still be true after stop is called)
  59863. * @returns True if it has been started, otherwise false.
  59864. */
  59865. isStarted(): boolean;
  59866. /**
  59867. * Starts the particle system and begins to emit
  59868. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  59869. */
  59870. start(delay?: number): void;
  59871. /**
  59872. * Stops the particle system.
  59873. */
  59874. stop(): void;
  59875. /**
  59876. * Remove all active particles
  59877. */
  59878. reset(): void;
  59879. /**
  59880. * Returns the string "GPUParticleSystem"
  59881. * @returns a string containing the class name
  59882. */
  59883. getClassName(): string;
  59884. private _colorGradientsTexture;
  59885. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  59886. /**
  59887. * Adds a new color gradient
  59888. * @param gradient defines the gradient to use (between 0 and 1)
  59889. * @param color1 defines the color to affect to the specified gradient
  59890. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  59891. * @returns the current particle system
  59892. */
  59893. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  59894. /**
  59895. * Remove a specific color gradient
  59896. * @param gradient defines the gradient to remove
  59897. * @returns the current particle system
  59898. */
  59899. removeColorGradient(gradient: number): GPUParticleSystem;
  59900. private _angularSpeedGradientsTexture;
  59901. private _sizeGradientsTexture;
  59902. private _velocityGradientsTexture;
  59903. private _limitVelocityGradientsTexture;
  59904. private _dragGradientsTexture;
  59905. private _addFactorGradient;
  59906. /**
  59907. * Adds a new size gradient
  59908. * @param gradient defines the gradient to use (between 0 and 1)
  59909. * @param factor defines the size factor to affect to the specified gradient
  59910. * @returns the current particle system
  59911. */
  59912. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  59913. /**
  59914. * Remove a specific size gradient
  59915. * @param gradient defines the gradient to remove
  59916. * @returns the current particle system
  59917. */
  59918. removeSizeGradient(gradient: number): GPUParticleSystem;
  59919. /**
  59920. * Adds a new angular speed gradient
  59921. * @param gradient defines the gradient to use (between 0 and 1)
  59922. * @param factor defines the angular speed to affect to the specified gradient
  59923. * @returns the current particle system
  59924. */
  59925. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  59926. /**
  59927. * Remove a specific angular speed gradient
  59928. * @param gradient defines the gradient to remove
  59929. * @returns the current particle system
  59930. */
  59931. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  59932. /**
  59933. * Adds a new velocity gradient
  59934. * @param gradient defines the gradient to use (between 0 and 1)
  59935. * @param factor defines the velocity to affect to the specified gradient
  59936. * @returns the current particle system
  59937. */
  59938. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  59939. /**
  59940. * Remove a specific velocity gradient
  59941. * @param gradient defines the gradient to remove
  59942. * @returns the current particle system
  59943. */
  59944. removeVelocityGradient(gradient: number): GPUParticleSystem;
  59945. /**
  59946. * Adds a new limit velocity gradient
  59947. * @param gradient defines the gradient to use (between 0 and 1)
  59948. * @param factor defines the limit velocity value to affect to the specified gradient
  59949. * @returns the current particle system
  59950. */
  59951. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  59952. /**
  59953. * Remove a specific limit velocity gradient
  59954. * @param gradient defines the gradient to remove
  59955. * @returns the current particle system
  59956. */
  59957. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  59958. /**
  59959. * Adds a new drag gradient
  59960. * @param gradient defines the gradient to use (between 0 and 1)
  59961. * @param factor defines the drag value to affect to the specified gradient
  59962. * @returns the current particle system
  59963. */
  59964. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  59965. /**
  59966. * Remove a specific drag gradient
  59967. * @param gradient defines the gradient to remove
  59968. * @returns the current particle system
  59969. */
  59970. removeDragGradient(gradient: number): GPUParticleSystem;
  59971. /**
  59972. * Not supported by GPUParticleSystem
  59973. * @param gradient defines the gradient to use (between 0 and 1)
  59974. * @param factor defines the emit rate value to affect to the specified gradient
  59975. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  59976. * @returns the current particle system
  59977. */
  59978. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  59979. /**
  59980. * Not supported by GPUParticleSystem
  59981. * @param gradient defines the gradient to remove
  59982. * @returns the current particle system
  59983. */
  59984. removeEmitRateGradient(gradient: number): IParticleSystem;
  59985. /**
  59986. * Not supported by GPUParticleSystem
  59987. * @param gradient defines the gradient to use (between 0 and 1)
  59988. * @param factor defines the start size value to affect to the specified gradient
  59989. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  59990. * @returns the current particle system
  59991. */
  59992. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  59993. /**
  59994. * Not supported by GPUParticleSystem
  59995. * @param gradient defines the gradient to remove
  59996. * @returns the current particle system
  59997. */
  59998. removeStartSizeGradient(gradient: number): IParticleSystem;
  59999. /**
  60000. * Not supported by GPUParticleSystem
  60001. * @param gradient defines the gradient to use (between 0 and 1)
  60002. * @param min defines the color remap minimal range
  60003. * @param max defines the color remap maximal range
  60004. * @returns the current particle system
  60005. */
  60006. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  60007. /**
  60008. * Not supported by GPUParticleSystem
  60009. * @param gradient defines the gradient to remove
  60010. * @returns the current particle system
  60011. */
  60012. removeColorRemapGradient(): IParticleSystem;
  60013. /**
  60014. * Not supported by GPUParticleSystem
  60015. * @param gradient defines the gradient to use (between 0 and 1)
  60016. * @param min defines the alpha remap minimal range
  60017. * @param max defines the alpha remap maximal range
  60018. * @returns the current particle system
  60019. */
  60020. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  60021. /**
  60022. * Not supported by GPUParticleSystem
  60023. * @param gradient defines the gradient to remove
  60024. * @returns the current particle system
  60025. */
  60026. removeAlphaRemapGradient(): IParticleSystem;
  60027. /**
  60028. * Not supported by GPUParticleSystem
  60029. * @param gradient defines the gradient to use (between 0 and 1)
  60030. * @param color defines the color to affect to the specified gradient
  60031. * @returns the current particle system
  60032. */
  60033. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  60034. /**
  60035. * Not supported by GPUParticleSystem
  60036. * @param gradient defines the gradient to remove
  60037. * @returns the current particle system
  60038. */
  60039. removeRampGradient(): IParticleSystem;
  60040. /**
  60041. * Not supported by GPUParticleSystem
  60042. * @returns the list of ramp gradients
  60043. */
  60044. getRampGradients(): Nullable<Array<Color3Gradient>>;
  60045. /**
  60046. * Not supported by GPUParticleSystem
  60047. * Gets or sets a boolean indicating that ramp gradients must be used
  60048. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  60049. */
  60050. useRampGradients: boolean;
  60051. /**
  60052. * Not supported by GPUParticleSystem
  60053. * @param gradient defines the gradient to use (between 0 and 1)
  60054. * @param factor defines the life time factor to affect to the specified gradient
  60055. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  60056. * @returns the current particle system
  60057. */
  60058. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  60059. /**
  60060. * Not supported by GPUParticleSystem
  60061. * @param gradient defines the gradient to remove
  60062. * @returns the current particle system
  60063. */
  60064. removeLifeTimeGradient(gradient: number): IParticleSystem;
  60065. /**
  60066. * Instantiates a GPU particle system.
  60067. * 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.
  60068. * @param name The name of the particle system
  60069. * @param options The options used to create the system
  60070. * @param scene The scene the particle system belongs to
  60071. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  60072. */
  60073. constructor(name: string, options: Partial<{
  60074. capacity: number;
  60075. randomTextureSize: number;
  60076. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  60077. protected _reset(): void;
  60078. private _createUpdateVAO;
  60079. private _createRenderVAO;
  60080. private _initialize;
  60081. /** @hidden */
  60082. _recreateUpdateEffect(): void;
  60083. /** @hidden */
  60084. _recreateRenderEffect(): void;
  60085. /**
  60086. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  60087. * @param preWarm defines if we are in the pre-warmimg phase
  60088. */
  60089. animate(preWarm?: boolean): void;
  60090. private _createFactorGradientTexture;
  60091. private _createSizeGradientTexture;
  60092. private _createAngularSpeedGradientTexture;
  60093. private _createVelocityGradientTexture;
  60094. private _createLimitVelocityGradientTexture;
  60095. private _createDragGradientTexture;
  60096. private _createColorGradientTexture;
  60097. /**
  60098. * Renders the particle system in its current state
  60099. * @param preWarm defines if the system should only update the particles but not render them
  60100. * @returns the current number of particles
  60101. */
  60102. render(preWarm?: boolean): number;
  60103. /**
  60104. * Rebuilds the particle system
  60105. */
  60106. rebuild(): void;
  60107. private _releaseBuffers;
  60108. private _releaseVAOs;
  60109. /**
  60110. * Disposes the particle system and free the associated resources
  60111. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  60112. */
  60113. dispose(disposeTexture?: boolean): void;
  60114. /**
  60115. * Clones the particle system.
  60116. * @param name The name of the cloned object
  60117. * @param newEmitter The new emitter to use
  60118. * @returns the cloned particle system
  60119. */
  60120. clone(name: string, newEmitter: any): GPUParticleSystem;
  60121. /**
  60122. * Serializes the particle system to a JSON object.
  60123. * @returns the JSON object
  60124. */
  60125. serialize(): any;
  60126. /**
  60127. * Parses a JSON object to create a GPU particle system.
  60128. * @param parsedParticleSystem The JSON object to parse
  60129. * @param scene The scene to create the particle system in
  60130. * @param rootUrl The root url to use to load external dependencies like texture
  60131. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  60132. * @returns the parsed GPU particle system
  60133. */
  60134. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  60135. }
  60136. }
  60137. declare module "babylonjs/Particles/particleSystemSet" {
  60138. import { Nullable } from "babylonjs/types";
  60139. import { Color3 } from "babylonjs/Maths/math.color";
  60140. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60141. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60142. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60143. import { Scene, IDisposable } from "babylonjs/scene";
  60144. /**
  60145. * Represents a set of particle systems working together to create a specific effect
  60146. */
  60147. export class ParticleSystemSet implements IDisposable {
  60148. private _emitterCreationOptions;
  60149. private _emitterNode;
  60150. /**
  60151. * Gets the particle system list
  60152. */
  60153. systems: IParticleSystem[];
  60154. /**
  60155. * Gets the emitter node used with this set
  60156. */
  60157. readonly emitterNode: Nullable<TransformNode>;
  60158. /**
  60159. * Creates a new emitter mesh as a sphere
  60160. * @param options defines the options used to create the sphere
  60161. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  60162. * @param scene defines the hosting scene
  60163. */
  60164. setEmitterAsSphere(options: {
  60165. diameter: number;
  60166. segments: number;
  60167. color: Color3;
  60168. }, renderingGroupId: number, scene: Scene): void;
  60169. /**
  60170. * Starts all particle systems of the set
  60171. * @param emitter defines an optional mesh to use as emitter for the particle systems
  60172. */
  60173. start(emitter?: AbstractMesh): void;
  60174. /**
  60175. * Release all associated resources
  60176. */
  60177. dispose(): void;
  60178. /**
  60179. * Serialize the set into a JSON compatible object
  60180. * @returns a JSON compatible representation of the set
  60181. */
  60182. serialize(): any;
  60183. /**
  60184. * Parse a new ParticleSystemSet from a serialized source
  60185. * @param data defines a JSON compatible representation of the set
  60186. * @param scene defines the hosting scene
  60187. * @param gpu defines if we want GPU particles or CPU particles
  60188. * @returns a new ParticleSystemSet
  60189. */
  60190. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  60191. }
  60192. }
  60193. declare module "babylonjs/Particles/particleHelper" {
  60194. import { Nullable } from "babylonjs/types";
  60195. import { Scene } from "babylonjs/scene";
  60196. import { Vector3 } from "babylonjs/Maths/math.vector";
  60197. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60198. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60199. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  60200. /**
  60201. * This class is made for on one-liner static method to help creating particle system set.
  60202. */
  60203. export class ParticleHelper {
  60204. /**
  60205. * Gets or sets base Assets URL
  60206. */
  60207. static BaseAssetsUrl: string;
  60208. /**
  60209. * Create a default particle system that you can tweak
  60210. * @param emitter defines the emitter to use
  60211. * @param capacity defines the system capacity (default is 500 particles)
  60212. * @param scene defines the hosting scene
  60213. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  60214. * @returns the new Particle system
  60215. */
  60216. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  60217. /**
  60218. * This is the main static method (one-liner) of this helper to create different particle systems
  60219. * @param type This string represents the type to the particle system to create
  60220. * @param scene The scene where the particle system should live
  60221. * @param gpu If the system will use gpu
  60222. * @returns the ParticleSystemSet created
  60223. */
  60224. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  60225. /**
  60226. * Static function used to export a particle system to a ParticleSystemSet variable.
  60227. * Please note that the emitter shape is not exported
  60228. * @param systems defines the particle systems to export
  60229. * @returns the created particle system set
  60230. */
  60231. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  60232. }
  60233. }
  60234. declare module "babylonjs/Particles/particleSystemComponent" {
  60235. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60236. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  60237. import "babylonjs/Shaders/particles.vertex";
  60238. module "babylonjs/Engines/engine" {
  60239. interface Engine {
  60240. /**
  60241. * Create an effect to use with particle systems.
  60242. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  60243. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  60244. * @param uniformsNames defines a list of attribute names
  60245. * @param samplers defines an array of string used to represent textures
  60246. * @param defines defines the string containing the defines to use to compile the shaders
  60247. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  60248. * @param onCompiled defines a function to call when the effect creation is successful
  60249. * @param onError defines a function to call when the effect creation has failed
  60250. * @returns the new Effect
  60251. */
  60252. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  60253. }
  60254. }
  60255. module "babylonjs/Meshes/mesh" {
  60256. interface Mesh {
  60257. /**
  60258. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  60259. * @returns an array of IParticleSystem
  60260. */
  60261. getEmittedParticleSystems(): IParticleSystem[];
  60262. /**
  60263. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  60264. * @returns an array of IParticleSystem
  60265. */
  60266. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  60267. }
  60268. }
  60269. /**
  60270. * @hidden
  60271. */
  60272. export var _IDoNeedToBeInTheBuild: number;
  60273. }
  60274. declare module "babylonjs/Particles/index" {
  60275. export * from "babylonjs/Particles/baseParticleSystem";
  60276. export * from "babylonjs/Particles/EmitterTypes/index";
  60277. export * from "babylonjs/Particles/gpuParticleSystem";
  60278. export * from "babylonjs/Particles/IParticleSystem";
  60279. export * from "babylonjs/Particles/particle";
  60280. export * from "babylonjs/Particles/particleHelper";
  60281. export * from "babylonjs/Particles/particleSystem";
  60282. export * from "babylonjs/Particles/particleSystemComponent";
  60283. export * from "babylonjs/Particles/particleSystemSet";
  60284. export * from "babylonjs/Particles/solidParticle";
  60285. export * from "babylonjs/Particles/solidParticleSystem";
  60286. export * from "babylonjs/Particles/subEmitter";
  60287. }
  60288. declare module "babylonjs/Physics/physicsEngineComponent" {
  60289. import { Nullable } from "babylonjs/types";
  60290. import { Observable, Observer } from "babylonjs/Misc/observable";
  60291. import { Vector3 } from "babylonjs/Maths/math.vector";
  60292. import { Mesh } from "babylonjs/Meshes/mesh";
  60293. import { ISceneComponent } from "babylonjs/sceneComponent";
  60294. import { Scene } from "babylonjs/scene";
  60295. import { Node } from "babylonjs/node";
  60296. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  60297. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  60298. module "babylonjs/scene" {
  60299. interface Scene {
  60300. /** @hidden (Backing field) */
  60301. _physicsEngine: Nullable<IPhysicsEngine>;
  60302. /**
  60303. * Gets the current physics engine
  60304. * @returns a IPhysicsEngine or null if none attached
  60305. */
  60306. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  60307. /**
  60308. * Enables physics to the current scene
  60309. * @param gravity defines the scene's gravity for the physics engine
  60310. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  60311. * @return a boolean indicating if the physics engine was initialized
  60312. */
  60313. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  60314. /**
  60315. * Disables and disposes the physics engine associated with the scene
  60316. */
  60317. disablePhysicsEngine(): void;
  60318. /**
  60319. * Gets a boolean indicating if there is an active physics engine
  60320. * @returns a boolean indicating if there is an active physics engine
  60321. */
  60322. isPhysicsEnabled(): boolean;
  60323. /**
  60324. * Deletes a physics compound impostor
  60325. * @param compound defines the compound to delete
  60326. */
  60327. deleteCompoundImpostor(compound: any): void;
  60328. /**
  60329. * An event triggered when physic simulation is about to be run
  60330. */
  60331. onBeforePhysicsObservable: Observable<Scene>;
  60332. /**
  60333. * An event triggered when physic simulation has been done
  60334. */
  60335. onAfterPhysicsObservable: Observable<Scene>;
  60336. }
  60337. }
  60338. module "babylonjs/Meshes/abstractMesh" {
  60339. interface AbstractMesh {
  60340. /** @hidden */
  60341. _physicsImpostor: Nullable<PhysicsImpostor>;
  60342. /**
  60343. * Gets or sets impostor used for physic simulation
  60344. * @see http://doc.babylonjs.com/features/physics_engine
  60345. */
  60346. physicsImpostor: Nullable<PhysicsImpostor>;
  60347. /**
  60348. * Gets the current physics impostor
  60349. * @see http://doc.babylonjs.com/features/physics_engine
  60350. * @returns a physics impostor or null
  60351. */
  60352. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  60353. /** Apply a physic impulse to the mesh
  60354. * @param force defines the force to apply
  60355. * @param contactPoint defines where to apply the force
  60356. * @returns the current mesh
  60357. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  60358. */
  60359. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  60360. /**
  60361. * Creates a physic joint between two meshes
  60362. * @param otherMesh defines the other mesh to use
  60363. * @param pivot1 defines the pivot to use on this mesh
  60364. * @param pivot2 defines the pivot to use on the other mesh
  60365. * @param options defines additional options (can be plugin dependent)
  60366. * @returns the current mesh
  60367. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  60368. */
  60369. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  60370. /** @hidden */
  60371. _disposePhysicsObserver: Nullable<Observer<Node>>;
  60372. }
  60373. }
  60374. /**
  60375. * Defines the physics engine scene component responsible to manage a physics engine
  60376. */
  60377. export class PhysicsEngineSceneComponent implements ISceneComponent {
  60378. /**
  60379. * The component name helpful to identify the component in the list of scene components.
  60380. */
  60381. readonly name: string;
  60382. /**
  60383. * The scene the component belongs to.
  60384. */
  60385. scene: Scene;
  60386. /**
  60387. * Creates a new instance of the component for the given scene
  60388. * @param scene Defines the scene to register the component in
  60389. */
  60390. constructor(scene: Scene);
  60391. /**
  60392. * Registers the component in a given scene
  60393. */
  60394. register(): void;
  60395. /**
  60396. * Rebuilds the elements related to this component in case of
  60397. * context lost for instance.
  60398. */
  60399. rebuild(): void;
  60400. /**
  60401. * Disposes the component and the associated ressources
  60402. */
  60403. dispose(): void;
  60404. }
  60405. }
  60406. declare module "babylonjs/Physics/physicsHelper" {
  60407. import { Nullable } from "babylonjs/types";
  60408. import { Vector3 } from "babylonjs/Maths/math.vector";
  60409. import { Mesh } from "babylonjs/Meshes/mesh";
  60410. import { Scene } from "babylonjs/scene";
  60411. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  60412. /**
  60413. * A helper for physics simulations
  60414. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60415. */
  60416. export class PhysicsHelper {
  60417. private _scene;
  60418. private _physicsEngine;
  60419. /**
  60420. * Initializes the Physics helper
  60421. * @param scene Babylon.js scene
  60422. */
  60423. constructor(scene: Scene);
  60424. /**
  60425. * Applies a radial explosion impulse
  60426. * @param origin the origin of the explosion
  60427. * @param radiusOrEventOptions the radius or the options of radial explosion
  60428. * @param strength the explosion strength
  60429. * @param falloff possible options: Constant & Linear. Defaults to Constant
  60430. * @returns A physics radial explosion event, or null
  60431. */
  60432. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  60433. /**
  60434. * Applies a radial explosion force
  60435. * @param origin the origin of the explosion
  60436. * @param radiusOrEventOptions the radius or the options of radial explosion
  60437. * @param strength the explosion strength
  60438. * @param falloff possible options: Constant & Linear. Defaults to Constant
  60439. * @returns A physics radial explosion event, or null
  60440. */
  60441. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  60442. /**
  60443. * Creates a gravitational field
  60444. * @param origin the origin of the explosion
  60445. * @param radiusOrEventOptions the radius or the options of radial explosion
  60446. * @param strength the explosion strength
  60447. * @param falloff possible options: Constant & Linear. Defaults to Constant
  60448. * @returns A physics gravitational field event, or null
  60449. */
  60450. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  60451. /**
  60452. * Creates a physics updraft event
  60453. * @param origin the origin of the updraft
  60454. * @param radiusOrEventOptions the radius or the options of the updraft
  60455. * @param strength the strength of the updraft
  60456. * @param height the height of the updraft
  60457. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  60458. * @returns A physics updraft event, or null
  60459. */
  60460. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  60461. /**
  60462. * Creates a physics vortex event
  60463. * @param origin the of the vortex
  60464. * @param radiusOrEventOptions the radius or the options of the vortex
  60465. * @param strength the strength of the vortex
  60466. * @param height the height of the vortex
  60467. * @returns a Physics vortex event, or null
  60468. * A physics vortex event or null
  60469. */
  60470. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  60471. }
  60472. /**
  60473. * Represents a physics radial explosion event
  60474. */
  60475. class PhysicsRadialExplosionEvent {
  60476. private _scene;
  60477. private _options;
  60478. private _sphere;
  60479. private _dataFetched;
  60480. /**
  60481. * Initializes a radial explosioin event
  60482. * @param _scene BabylonJS scene
  60483. * @param _options The options for the vortex event
  60484. */
  60485. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  60486. /**
  60487. * Returns the data related to the radial explosion event (sphere).
  60488. * @returns The radial explosion event data
  60489. */
  60490. getData(): PhysicsRadialExplosionEventData;
  60491. /**
  60492. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  60493. * @param impostor A physics imposter
  60494. * @param origin the origin of the explosion
  60495. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  60496. */
  60497. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  60498. /**
  60499. * Triggers affecterd impostors callbacks
  60500. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  60501. */
  60502. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  60503. /**
  60504. * Disposes the sphere.
  60505. * @param force Specifies if the sphere should be disposed by force
  60506. */
  60507. dispose(force?: boolean): void;
  60508. /*** Helpers ***/
  60509. private _prepareSphere;
  60510. private _intersectsWithSphere;
  60511. }
  60512. /**
  60513. * Represents a gravitational field event
  60514. */
  60515. class PhysicsGravitationalFieldEvent {
  60516. private _physicsHelper;
  60517. private _scene;
  60518. private _origin;
  60519. private _options;
  60520. private _tickCallback;
  60521. private _sphere;
  60522. private _dataFetched;
  60523. /**
  60524. * Initializes the physics gravitational field event
  60525. * @param _physicsHelper A physics helper
  60526. * @param _scene BabylonJS scene
  60527. * @param _origin The origin position of the gravitational field event
  60528. * @param _options The options for the vortex event
  60529. */
  60530. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  60531. /**
  60532. * Returns the data related to the gravitational field event (sphere).
  60533. * @returns A gravitational field event
  60534. */
  60535. getData(): PhysicsGravitationalFieldEventData;
  60536. /**
  60537. * Enables the gravitational field.
  60538. */
  60539. enable(): void;
  60540. /**
  60541. * Disables the gravitational field.
  60542. */
  60543. disable(): void;
  60544. /**
  60545. * Disposes the sphere.
  60546. * @param force The force to dispose from the gravitational field event
  60547. */
  60548. dispose(force?: boolean): void;
  60549. private _tick;
  60550. }
  60551. /**
  60552. * Represents a physics updraft event
  60553. */
  60554. class PhysicsUpdraftEvent {
  60555. private _scene;
  60556. private _origin;
  60557. private _options;
  60558. private _physicsEngine;
  60559. private _originTop;
  60560. private _originDirection;
  60561. private _tickCallback;
  60562. private _cylinder;
  60563. private _cylinderPosition;
  60564. private _dataFetched;
  60565. /**
  60566. * Initializes the physics updraft event
  60567. * @param _scene BabylonJS scene
  60568. * @param _origin The origin position of the updraft
  60569. * @param _options The options for the updraft event
  60570. */
  60571. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  60572. /**
  60573. * Returns the data related to the updraft event (cylinder).
  60574. * @returns A physics updraft event
  60575. */
  60576. getData(): PhysicsUpdraftEventData;
  60577. /**
  60578. * Enables the updraft.
  60579. */
  60580. enable(): void;
  60581. /**
  60582. * Disables the updraft.
  60583. */
  60584. disable(): void;
  60585. /**
  60586. * Disposes the cylinder.
  60587. * @param force Specifies if the updraft should be disposed by force
  60588. */
  60589. dispose(force?: boolean): void;
  60590. private getImpostorHitData;
  60591. private _tick;
  60592. /*** Helpers ***/
  60593. private _prepareCylinder;
  60594. private _intersectsWithCylinder;
  60595. }
  60596. /**
  60597. * Represents a physics vortex event
  60598. */
  60599. class PhysicsVortexEvent {
  60600. private _scene;
  60601. private _origin;
  60602. private _options;
  60603. private _physicsEngine;
  60604. private _originTop;
  60605. private _tickCallback;
  60606. private _cylinder;
  60607. private _cylinderPosition;
  60608. private _dataFetched;
  60609. /**
  60610. * Initializes the physics vortex event
  60611. * @param _scene The BabylonJS scene
  60612. * @param _origin The origin position of the vortex
  60613. * @param _options The options for the vortex event
  60614. */
  60615. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  60616. /**
  60617. * Returns the data related to the vortex event (cylinder).
  60618. * @returns The physics vortex event data
  60619. */
  60620. getData(): PhysicsVortexEventData;
  60621. /**
  60622. * Enables the vortex.
  60623. */
  60624. enable(): void;
  60625. /**
  60626. * Disables the cortex.
  60627. */
  60628. disable(): void;
  60629. /**
  60630. * Disposes the sphere.
  60631. * @param force
  60632. */
  60633. dispose(force?: boolean): void;
  60634. private getImpostorHitData;
  60635. private _tick;
  60636. /*** Helpers ***/
  60637. private _prepareCylinder;
  60638. private _intersectsWithCylinder;
  60639. }
  60640. /**
  60641. * Options fot the radial explosion event
  60642. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60643. */
  60644. export class PhysicsRadialExplosionEventOptions {
  60645. /**
  60646. * The radius of the sphere for the radial explosion.
  60647. */
  60648. radius: number;
  60649. /**
  60650. * The strenth of the explosion.
  60651. */
  60652. strength: number;
  60653. /**
  60654. * The strenght of the force in correspondence to the distance of the affected object
  60655. */
  60656. falloff: PhysicsRadialImpulseFalloff;
  60657. /**
  60658. * Sphere options for the radial explosion.
  60659. */
  60660. sphere: {
  60661. segments: number;
  60662. diameter: number;
  60663. };
  60664. /**
  60665. * Sphere options for the radial explosion.
  60666. */
  60667. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  60668. }
  60669. /**
  60670. * Options fot the updraft event
  60671. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60672. */
  60673. export class PhysicsUpdraftEventOptions {
  60674. /**
  60675. * The radius of the cylinder for the vortex
  60676. */
  60677. radius: number;
  60678. /**
  60679. * The strenth of the updraft.
  60680. */
  60681. strength: number;
  60682. /**
  60683. * The height of the cylinder for the updraft.
  60684. */
  60685. height: number;
  60686. /**
  60687. * The mode for the the updraft.
  60688. */
  60689. updraftMode: PhysicsUpdraftMode;
  60690. }
  60691. /**
  60692. * Options fot the vortex event
  60693. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60694. */
  60695. export class PhysicsVortexEventOptions {
  60696. /**
  60697. * The radius of the cylinder for the vortex
  60698. */
  60699. radius: number;
  60700. /**
  60701. * The strenth of the vortex.
  60702. */
  60703. strength: number;
  60704. /**
  60705. * The height of the cylinder for the vortex.
  60706. */
  60707. height: number;
  60708. /**
  60709. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  60710. */
  60711. centripetalForceThreshold: number;
  60712. /**
  60713. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  60714. */
  60715. centripetalForceMultiplier: number;
  60716. /**
  60717. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  60718. */
  60719. centrifugalForceMultiplier: number;
  60720. /**
  60721. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  60722. */
  60723. updraftForceMultiplier: number;
  60724. }
  60725. /**
  60726. * The strenght of the force in correspondence to the distance of the affected object
  60727. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60728. */
  60729. export enum PhysicsRadialImpulseFalloff {
  60730. /** Defines that impulse is constant in strength across it's whole radius */
  60731. Constant = 0,
  60732. /** Defines that impulse gets weaker if it's further from the origin */
  60733. Linear = 1
  60734. }
  60735. /**
  60736. * The strength of the force in correspondence to the distance of the affected object
  60737. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60738. */
  60739. export enum PhysicsUpdraftMode {
  60740. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  60741. Center = 0,
  60742. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  60743. Perpendicular = 1
  60744. }
  60745. /**
  60746. * Interface for a physics hit data
  60747. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60748. */
  60749. export interface PhysicsHitData {
  60750. /**
  60751. * The force applied at the contact point
  60752. */
  60753. force: Vector3;
  60754. /**
  60755. * The contact point
  60756. */
  60757. contactPoint: Vector3;
  60758. /**
  60759. * The distance from the origin to the contact point
  60760. */
  60761. distanceFromOrigin: number;
  60762. }
  60763. /**
  60764. * Interface for radial explosion event data
  60765. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60766. */
  60767. export interface PhysicsRadialExplosionEventData {
  60768. /**
  60769. * A sphere used for the radial explosion event
  60770. */
  60771. sphere: Mesh;
  60772. }
  60773. /**
  60774. * Interface for gravitational field event data
  60775. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60776. */
  60777. export interface PhysicsGravitationalFieldEventData {
  60778. /**
  60779. * A sphere mesh used for the gravitational field event
  60780. */
  60781. sphere: Mesh;
  60782. }
  60783. /**
  60784. * Interface for updraft event data
  60785. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60786. */
  60787. export interface PhysicsUpdraftEventData {
  60788. /**
  60789. * A cylinder used for the updraft event
  60790. */
  60791. cylinder: Mesh;
  60792. }
  60793. /**
  60794. * Interface for vortex event data
  60795. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60796. */
  60797. export interface PhysicsVortexEventData {
  60798. /**
  60799. * A cylinder used for the vortex event
  60800. */
  60801. cylinder: Mesh;
  60802. }
  60803. /**
  60804. * Interface for an affected physics impostor
  60805. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60806. */
  60807. export interface PhysicsAffectedImpostorWithData {
  60808. /**
  60809. * The impostor affected by the effect
  60810. */
  60811. impostor: PhysicsImpostor;
  60812. /**
  60813. * The data about the hit/horce from the explosion
  60814. */
  60815. hitData: PhysicsHitData;
  60816. }
  60817. }
  60818. declare module "babylonjs/Physics/Plugins/index" {
  60819. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  60820. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  60821. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  60822. }
  60823. declare module "babylonjs/Physics/index" {
  60824. export * from "babylonjs/Physics/IPhysicsEngine";
  60825. export * from "babylonjs/Physics/physicsEngine";
  60826. export * from "babylonjs/Physics/physicsEngineComponent";
  60827. export * from "babylonjs/Physics/physicsHelper";
  60828. export * from "babylonjs/Physics/physicsImpostor";
  60829. export * from "babylonjs/Physics/physicsJoint";
  60830. export * from "babylonjs/Physics/Plugins/index";
  60831. }
  60832. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  60833. /** @hidden */
  60834. export var blackAndWhitePixelShader: {
  60835. name: string;
  60836. shader: string;
  60837. };
  60838. }
  60839. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  60840. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60841. import { Camera } from "babylonjs/Cameras/camera";
  60842. import { Engine } from "babylonjs/Engines/engine";
  60843. import "babylonjs/Shaders/blackAndWhite.fragment";
  60844. /**
  60845. * Post process used to render in black and white
  60846. */
  60847. export class BlackAndWhitePostProcess extends PostProcess {
  60848. /**
  60849. * Linear about to convert he result to black and white (default: 1)
  60850. */
  60851. degree: number;
  60852. /**
  60853. * Creates a black and white post process
  60854. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  60855. * @param name The name of the effect.
  60856. * @param options The required width/height ratio to downsize to before computing the render pass.
  60857. * @param camera The camera to apply the render pass to.
  60858. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60859. * @param engine The engine which the post process will be applied. (default: current engine)
  60860. * @param reusable If the post process can be reused on the same frame. (default: false)
  60861. */
  60862. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60863. }
  60864. }
  60865. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  60866. import { Nullable } from "babylonjs/types";
  60867. import { Camera } from "babylonjs/Cameras/camera";
  60868. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60869. import { Engine } from "babylonjs/Engines/engine";
  60870. /**
  60871. * This represents a set of one or more post processes in Babylon.
  60872. * A post process can be used to apply a shader to a texture after it is rendered.
  60873. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60874. */
  60875. export class PostProcessRenderEffect {
  60876. private _postProcesses;
  60877. private _getPostProcesses;
  60878. private _singleInstance;
  60879. private _cameras;
  60880. private _indicesForCamera;
  60881. /**
  60882. * Name of the effect
  60883. * @hidden
  60884. */
  60885. _name: string;
  60886. /**
  60887. * Instantiates a post process render effect.
  60888. * A post process can be used to apply a shader to a texture after it is rendered.
  60889. * @param engine The engine the effect is tied to
  60890. * @param name The name of the effect
  60891. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  60892. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  60893. */
  60894. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  60895. /**
  60896. * Checks if all the post processes in the effect are supported.
  60897. */
  60898. readonly isSupported: boolean;
  60899. /**
  60900. * Updates the current state of the effect
  60901. * @hidden
  60902. */
  60903. _update(): void;
  60904. /**
  60905. * Attaches the effect on cameras
  60906. * @param cameras The camera to attach to.
  60907. * @hidden
  60908. */
  60909. _attachCameras(cameras: Camera): void;
  60910. /**
  60911. * Attaches the effect on cameras
  60912. * @param cameras The camera to attach to.
  60913. * @hidden
  60914. */
  60915. _attachCameras(cameras: Camera[]): void;
  60916. /**
  60917. * Detaches the effect on cameras
  60918. * @param cameras The camera to detatch from.
  60919. * @hidden
  60920. */
  60921. _detachCameras(cameras: Camera): void;
  60922. /**
  60923. * Detatches the effect on cameras
  60924. * @param cameras The camera to detatch from.
  60925. * @hidden
  60926. */
  60927. _detachCameras(cameras: Camera[]): void;
  60928. /**
  60929. * Enables the effect on given cameras
  60930. * @param cameras The camera to enable.
  60931. * @hidden
  60932. */
  60933. _enable(cameras: Camera): void;
  60934. /**
  60935. * Enables the effect on given cameras
  60936. * @param cameras The camera to enable.
  60937. * @hidden
  60938. */
  60939. _enable(cameras: Nullable<Camera[]>): void;
  60940. /**
  60941. * Disables the effect on the given cameras
  60942. * @param cameras The camera to disable.
  60943. * @hidden
  60944. */
  60945. _disable(cameras: Camera): void;
  60946. /**
  60947. * Disables the effect on the given cameras
  60948. * @param cameras The camera to disable.
  60949. * @hidden
  60950. */
  60951. _disable(cameras: Nullable<Camera[]>): void;
  60952. /**
  60953. * Gets a list of the post processes contained in the effect.
  60954. * @param camera The camera to get the post processes on.
  60955. * @returns The list of the post processes in the effect.
  60956. */
  60957. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  60958. }
  60959. }
  60960. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  60961. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60962. /** @hidden */
  60963. export var extractHighlightsPixelShader: {
  60964. name: string;
  60965. shader: string;
  60966. };
  60967. }
  60968. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  60969. import { Nullable } from "babylonjs/types";
  60970. import { Camera } from "babylonjs/Cameras/camera";
  60971. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60972. import { Engine } from "babylonjs/Engines/engine";
  60973. import "babylonjs/Shaders/extractHighlights.fragment";
  60974. /**
  60975. * 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.
  60976. */
  60977. export class ExtractHighlightsPostProcess extends PostProcess {
  60978. /**
  60979. * The luminance threshold, pixels below this value will be set to black.
  60980. */
  60981. threshold: number;
  60982. /** @hidden */
  60983. _exposure: number;
  60984. /**
  60985. * Post process which has the input texture to be used when performing highlight extraction
  60986. * @hidden
  60987. */
  60988. _inputPostProcess: Nullable<PostProcess>;
  60989. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60990. }
  60991. }
  60992. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  60993. /** @hidden */
  60994. export var bloomMergePixelShader: {
  60995. name: string;
  60996. shader: string;
  60997. };
  60998. }
  60999. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  61000. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61001. import { Nullable } from "babylonjs/types";
  61002. import { Engine } from "babylonjs/Engines/engine";
  61003. import { Camera } from "babylonjs/Cameras/camera";
  61004. import "babylonjs/Shaders/bloomMerge.fragment";
  61005. /**
  61006. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  61007. */
  61008. export class BloomMergePostProcess extends PostProcess {
  61009. /** Weight of the bloom to be added to the original input. */
  61010. weight: number;
  61011. /**
  61012. * Creates a new instance of @see BloomMergePostProcess
  61013. * @param name The name of the effect.
  61014. * @param originalFromInput Post process which's input will be used for the merge.
  61015. * @param blurred Blurred highlights post process which's output will be used.
  61016. * @param weight Weight of the bloom to be added to the original input.
  61017. * @param options The required width/height ratio to downsize to before computing the render pass.
  61018. * @param camera The camera to apply the render pass to.
  61019. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61020. * @param engine The engine which the post process will be applied. (default: current engine)
  61021. * @param reusable If the post process can be reused on the same frame. (default: false)
  61022. * @param textureType Type of textures used when performing the post process. (default: 0)
  61023. * @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)
  61024. */
  61025. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  61026. /** Weight of the bloom to be added to the original input. */
  61027. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61028. }
  61029. }
  61030. declare module "babylonjs/PostProcesses/bloomEffect" {
  61031. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  61032. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61033. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  61034. import { Camera } from "babylonjs/Cameras/camera";
  61035. import { Scene } from "babylonjs/scene";
  61036. /**
  61037. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  61038. */
  61039. export class BloomEffect extends PostProcessRenderEffect {
  61040. private bloomScale;
  61041. /**
  61042. * @hidden Internal
  61043. */
  61044. _effects: Array<PostProcess>;
  61045. /**
  61046. * @hidden Internal
  61047. */
  61048. _downscale: ExtractHighlightsPostProcess;
  61049. private _blurX;
  61050. private _blurY;
  61051. private _merge;
  61052. /**
  61053. * The luminance threshold to find bright areas of the image to bloom.
  61054. */
  61055. threshold: number;
  61056. /**
  61057. * The strength of the bloom.
  61058. */
  61059. weight: number;
  61060. /**
  61061. * Specifies the size of the bloom blur kernel, relative to the final output size
  61062. */
  61063. kernel: number;
  61064. /**
  61065. * Creates a new instance of @see BloomEffect
  61066. * @param scene The scene the effect belongs to.
  61067. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  61068. * @param bloomKernel The size of the kernel to be used when applying the blur.
  61069. * @param bloomWeight The the strength of bloom.
  61070. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  61071. * @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)
  61072. */
  61073. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  61074. /**
  61075. * Disposes each of the internal effects for a given camera.
  61076. * @param camera The camera to dispose the effect on.
  61077. */
  61078. disposeEffects(camera: Camera): void;
  61079. /**
  61080. * @hidden Internal
  61081. */
  61082. _updateEffects(): void;
  61083. /**
  61084. * Internal
  61085. * @returns if all the contained post processes are ready.
  61086. * @hidden
  61087. */
  61088. _isReady(): boolean;
  61089. }
  61090. }
  61091. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  61092. /** @hidden */
  61093. export var chromaticAberrationPixelShader: {
  61094. name: string;
  61095. shader: string;
  61096. };
  61097. }
  61098. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  61099. import { Vector2 } from "babylonjs/Maths/math.vector";
  61100. import { Nullable } from "babylonjs/types";
  61101. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61102. import { Camera } from "babylonjs/Cameras/camera";
  61103. import { Engine } from "babylonjs/Engines/engine";
  61104. import "babylonjs/Shaders/chromaticAberration.fragment";
  61105. /**
  61106. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  61107. */
  61108. export class ChromaticAberrationPostProcess extends PostProcess {
  61109. /**
  61110. * The amount of seperation of rgb channels (default: 30)
  61111. */
  61112. aberrationAmount: number;
  61113. /**
  61114. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  61115. */
  61116. radialIntensity: number;
  61117. /**
  61118. * 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))
  61119. */
  61120. direction: Vector2;
  61121. /**
  61122. * 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))
  61123. */
  61124. centerPosition: Vector2;
  61125. /**
  61126. * Creates a new instance ChromaticAberrationPostProcess
  61127. * @param name The name of the effect.
  61128. * @param screenWidth The width of the screen to apply the effect on.
  61129. * @param screenHeight The height of the screen to apply the effect on.
  61130. * @param options The required width/height ratio to downsize to before computing the render pass.
  61131. * @param camera The camera to apply the render pass to.
  61132. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61133. * @param engine The engine which the post process will be applied. (default: current engine)
  61134. * @param reusable If the post process can be reused on the same frame. (default: false)
  61135. * @param textureType Type of textures used when performing the post process. (default: 0)
  61136. * @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)
  61137. */
  61138. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61139. }
  61140. }
  61141. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  61142. /** @hidden */
  61143. export var circleOfConfusionPixelShader: {
  61144. name: string;
  61145. shader: string;
  61146. };
  61147. }
  61148. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  61149. import { Nullable } from "babylonjs/types";
  61150. import { Engine } from "babylonjs/Engines/engine";
  61151. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61152. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61153. import { Camera } from "babylonjs/Cameras/camera";
  61154. import "babylonjs/Shaders/circleOfConfusion.fragment";
  61155. /**
  61156. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  61157. */
  61158. export class CircleOfConfusionPostProcess extends PostProcess {
  61159. /**
  61160. * 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.
  61161. */
  61162. lensSize: number;
  61163. /**
  61164. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  61165. */
  61166. fStop: number;
  61167. /**
  61168. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  61169. */
  61170. focusDistance: number;
  61171. /**
  61172. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  61173. */
  61174. focalLength: number;
  61175. private _depthTexture;
  61176. /**
  61177. * Creates a new instance CircleOfConfusionPostProcess
  61178. * @param name The name of the effect.
  61179. * @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.
  61180. * @param options The required width/height ratio to downsize to before computing the render pass.
  61181. * @param camera The camera to apply the render pass to.
  61182. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61183. * @param engine The engine which the post process will be applied. (default: current engine)
  61184. * @param reusable If the post process can be reused on the same frame. (default: false)
  61185. * @param textureType Type of textures used when performing the post process. (default: 0)
  61186. * @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)
  61187. */
  61188. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61189. /**
  61190. * 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.
  61191. */
  61192. depthTexture: RenderTargetTexture;
  61193. }
  61194. }
  61195. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  61196. /** @hidden */
  61197. export var colorCorrectionPixelShader: {
  61198. name: string;
  61199. shader: string;
  61200. };
  61201. }
  61202. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  61203. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61204. import { Engine } from "babylonjs/Engines/engine";
  61205. import { Camera } from "babylonjs/Cameras/camera";
  61206. import "babylonjs/Shaders/colorCorrection.fragment";
  61207. /**
  61208. *
  61209. * This post-process allows the modification of rendered colors by using
  61210. * a 'look-up table' (LUT). This effect is also called Color Grading.
  61211. *
  61212. * The object needs to be provided an url to a texture containing the color
  61213. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  61214. * Use an image editing software to tweak the LUT to match your needs.
  61215. *
  61216. * For an example of a color LUT, see here:
  61217. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  61218. * For explanations on color grading, see here:
  61219. * @see http://udn.epicgames.com/Three/ColorGrading.html
  61220. *
  61221. */
  61222. export class ColorCorrectionPostProcess extends PostProcess {
  61223. private _colorTableTexture;
  61224. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61225. }
  61226. }
  61227. declare module "babylonjs/Shaders/convolution.fragment" {
  61228. /** @hidden */
  61229. export var convolutionPixelShader: {
  61230. name: string;
  61231. shader: string;
  61232. };
  61233. }
  61234. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  61235. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61236. import { Nullable } from "babylonjs/types";
  61237. import { Camera } from "babylonjs/Cameras/camera";
  61238. import { Engine } from "babylonjs/Engines/engine";
  61239. import "babylonjs/Shaders/convolution.fragment";
  61240. /**
  61241. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  61242. * input texture to perform effects such as edge detection or sharpening
  61243. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  61244. */
  61245. export class ConvolutionPostProcess extends PostProcess {
  61246. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  61247. kernel: number[];
  61248. /**
  61249. * Creates a new instance ConvolutionPostProcess
  61250. * @param name The name of the effect.
  61251. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  61252. * @param options The required width/height ratio to downsize to before computing the render pass.
  61253. * @param camera The camera to apply the render pass to.
  61254. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61255. * @param engine The engine which the post process will be applied. (default: current engine)
  61256. * @param reusable If the post process can be reused on the same frame. (default: false)
  61257. * @param textureType Type of textures used when performing the post process. (default: 0)
  61258. */
  61259. constructor(name: string,
  61260. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  61261. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  61262. /**
  61263. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61264. */
  61265. static EdgeDetect0Kernel: number[];
  61266. /**
  61267. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61268. */
  61269. static EdgeDetect1Kernel: number[];
  61270. /**
  61271. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61272. */
  61273. static EdgeDetect2Kernel: number[];
  61274. /**
  61275. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61276. */
  61277. static SharpenKernel: number[];
  61278. /**
  61279. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61280. */
  61281. static EmbossKernel: number[];
  61282. /**
  61283. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61284. */
  61285. static GaussianKernel: number[];
  61286. }
  61287. }
  61288. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  61289. import { Nullable } from "babylonjs/types";
  61290. import { Vector2 } from "babylonjs/Maths/math.vector";
  61291. import { Camera } from "babylonjs/Cameras/camera";
  61292. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61293. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  61294. import { Engine } from "babylonjs/Engines/engine";
  61295. import { Scene } from "babylonjs/scene";
  61296. /**
  61297. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  61298. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  61299. * based on samples that have a large difference in distance than the center pixel.
  61300. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  61301. */
  61302. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  61303. direction: Vector2;
  61304. /**
  61305. * Creates a new instance CircleOfConfusionPostProcess
  61306. * @param name The name of the effect.
  61307. * @param scene The scene the effect belongs to.
  61308. * @param direction The direction the blur should be applied.
  61309. * @param kernel The size of the kernel used to blur.
  61310. * @param options The required width/height ratio to downsize to before computing the render pass.
  61311. * @param camera The camera to apply the render pass to.
  61312. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  61313. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  61314. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61315. * @param engine The engine which the post process will be applied. (default: current engine)
  61316. * @param reusable If the post process can be reused on the same frame. (default: false)
  61317. * @param textureType Type of textures used when performing the post process. (default: 0)
  61318. * @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)
  61319. */
  61320. 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);
  61321. }
  61322. }
  61323. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  61324. /** @hidden */
  61325. export var depthOfFieldMergePixelShader: {
  61326. name: string;
  61327. shader: string;
  61328. };
  61329. }
  61330. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  61331. import { Nullable } from "babylonjs/types";
  61332. import { Camera } from "babylonjs/Cameras/camera";
  61333. import { Effect } from "babylonjs/Materials/effect";
  61334. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61335. import { Engine } from "babylonjs/Engines/engine";
  61336. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  61337. /**
  61338. * Options to be set when merging outputs from the default pipeline.
  61339. */
  61340. export class DepthOfFieldMergePostProcessOptions {
  61341. /**
  61342. * The original image to merge on top of
  61343. */
  61344. originalFromInput: PostProcess;
  61345. /**
  61346. * Parameters to perform the merge of the depth of field effect
  61347. */
  61348. depthOfField?: {
  61349. circleOfConfusion: PostProcess;
  61350. blurSteps: Array<PostProcess>;
  61351. };
  61352. /**
  61353. * Parameters to perform the merge of bloom effect
  61354. */
  61355. bloom?: {
  61356. blurred: PostProcess;
  61357. weight: number;
  61358. };
  61359. }
  61360. /**
  61361. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  61362. */
  61363. export class DepthOfFieldMergePostProcess extends PostProcess {
  61364. private blurSteps;
  61365. /**
  61366. * Creates a new instance of DepthOfFieldMergePostProcess
  61367. * @param name The name of the effect.
  61368. * @param originalFromInput Post process which's input will be used for the merge.
  61369. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  61370. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  61371. * @param options The required width/height ratio to downsize to before computing the render pass.
  61372. * @param camera The camera to apply the render pass to.
  61373. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61374. * @param engine The engine which the post process will be applied. (default: current engine)
  61375. * @param reusable If the post process can be reused on the same frame. (default: false)
  61376. * @param textureType Type of textures used when performing the post process. (default: 0)
  61377. * @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)
  61378. */
  61379. 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);
  61380. /**
  61381. * Updates the effect with the current post process compile time values and recompiles the shader.
  61382. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  61383. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  61384. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  61385. * @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
  61386. * @param onCompiled Called when the shader has been compiled.
  61387. * @param onError Called if there is an error when compiling a shader.
  61388. */
  61389. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  61390. }
  61391. }
  61392. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  61393. import { Nullable } from "babylonjs/types";
  61394. import { Camera } from "babylonjs/Cameras/camera";
  61395. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61396. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61397. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  61398. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  61399. import { Scene } from "babylonjs/scene";
  61400. /**
  61401. * Specifies the level of max blur that should be applied when using the depth of field effect
  61402. */
  61403. export enum DepthOfFieldEffectBlurLevel {
  61404. /**
  61405. * Subtle blur
  61406. */
  61407. Low = 0,
  61408. /**
  61409. * Medium blur
  61410. */
  61411. Medium = 1,
  61412. /**
  61413. * Large blur
  61414. */
  61415. High = 2
  61416. }
  61417. /**
  61418. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  61419. */
  61420. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  61421. private _circleOfConfusion;
  61422. /**
  61423. * @hidden Internal, blurs from high to low
  61424. */
  61425. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  61426. private _depthOfFieldBlurY;
  61427. private _dofMerge;
  61428. /**
  61429. * @hidden Internal post processes in depth of field effect
  61430. */
  61431. _effects: Array<PostProcess>;
  61432. /**
  61433. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  61434. */
  61435. focalLength: number;
  61436. /**
  61437. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  61438. */
  61439. fStop: number;
  61440. /**
  61441. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  61442. */
  61443. focusDistance: number;
  61444. /**
  61445. * 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.
  61446. */
  61447. lensSize: number;
  61448. /**
  61449. * Creates a new instance DepthOfFieldEffect
  61450. * @param scene The scene the effect belongs to.
  61451. * @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.
  61452. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  61453. * @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)
  61454. */
  61455. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  61456. /**
  61457. * Get the current class name of the current effet
  61458. * @returns "DepthOfFieldEffect"
  61459. */
  61460. getClassName(): string;
  61461. /**
  61462. * 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.
  61463. */
  61464. depthTexture: RenderTargetTexture;
  61465. /**
  61466. * Disposes each of the internal effects for a given camera.
  61467. * @param camera The camera to dispose the effect on.
  61468. */
  61469. disposeEffects(camera: Camera): void;
  61470. /**
  61471. * @hidden Internal
  61472. */
  61473. _updateEffects(): void;
  61474. /**
  61475. * Internal
  61476. * @returns if all the contained post processes are ready.
  61477. * @hidden
  61478. */
  61479. _isReady(): boolean;
  61480. }
  61481. }
  61482. declare module "babylonjs/Shaders/displayPass.fragment" {
  61483. /** @hidden */
  61484. export var displayPassPixelShader: {
  61485. name: string;
  61486. shader: string;
  61487. };
  61488. }
  61489. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  61490. import { Nullable } from "babylonjs/types";
  61491. import { Camera } from "babylonjs/Cameras/camera";
  61492. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61493. import { Engine } from "babylonjs/Engines/engine";
  61494. import "babylonjs/Shaders/displayPass.fragment";
  61495. /**
  61496. * DisplayPassPostProcess which produces an output the same as it's input
  61497. */
  61498. export class DisplayPassPostProcess extends PostProcess {
  61499. /**
  61500. * Creates the DisplayPassPostProcess
  61501. * @param name The name of the effect.
  61502. * @param options The required width/height ratio to downsize to before computing the render pass.
  61503. * @param camera The camera to apply the render pass to.
  61504. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61505. * @param engine The engine which the post process will be applied. (default: current engine)
  61506. * @param reusable If the post process can be reused on the same frame. (default: false)
  61507. */
  61508. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61509. }
  61510. }
  61511. declare module "babylonjs/Shaders/filter.fragment" {
  61512. /** @hidden */
  61513. export var filterPixelShader: {
  61514. name: string;
  61515. shader: string;
  61516. };
  61517. }
  61518. declare module "babylonjs/PostProcesses/filterPostProcess" {
  61519. import { Nullable } from "babylonjs/types";
  61520. import { Matrix } from "babylonjs/Maths/math.vector";
  61521. import { Camera } from "babylonjs/Cameras/camera";
  61522. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61523. import { Engine } from "babylonjs/Engines/engine";
  61524. import "babylonjs/Shaders/filter.fragment";
  61525. /**
  61526. * Applies a kernel filter to the image
  61527. */
  61528. export class FilterPostProcess extends PostProcess {
  61529. /** The matrix to be applied to the image */
  61530. kernelMatrix: Matrix;
  61531. /**
  61532. *
  61533. * @param name The name of the effect.
  61534. * @param kernelMatrix The matrix to be applied to the image
  61535. * @param options The required width/height ratio to downsize to before computing the render pass.
  61536. * @param camera The camera to apply the render pass to.
  61537. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61538. * @param engine The engine which the post process will be applied. (default: current engine)
  61539. * @param reusable If the post process can be reused on the same frame. (default: false)
  61540. */
  61541. constructor(name: string,
  61542. /** The matrix to be applied to the image */
  61543. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61544. }
  61545. }
  61546. declare module "babylonjs/Shaders/fxaa.fragment" {
  61547. /** @hidden */
  61548. export var fxaaPixelShader: {
  61549. name: string;
  61550. shader: string;
  61551. };
  61552. }
  61553. declare module "babylonjs/Shaders/fxaa.vertex" {
  61554. /** @hidden */
  61555. export var fxaaVertexShader: {
  61556. name: string;
  61557. shader: string;
  61558. };
  61559. }
  61560. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  61561. import { Nullable } from "babylonjs/types";
  61562. import { Camera } from "babylonjs/Cameras/camera";
  61563. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61564. import { Engine } from "babylonjs/Engines/engine";
  61565. import "babylonjs/Shaders/fxaa.fragment";
  61566. import "babylonjs/Shaders/fxaa.vertex";
  61567. /**
  61568. * Fxaa post process
  61569. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  61570. */
  61571. export class FxaaPostProcess extends PostProcess {
  61572. /** @hidden */
  61573. texelWidth: number;
  61574. /** @hidden */
  61575. texelHeight: number;
  61576. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  61577. private _getDefines;
  61578. }
  61579. }
  61580. declare module "babylonjs/Shaders/grain.fragment" {
  61581. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61582. /** @hidden */
  61583. export var grainPixelShader: {
  61584. name: string;
  61585. shader: string;
  61586. };
  61587. }
  61588. declare module "babylonjs/PostProcesses/grainPostProcess" {
  61589. import { Nullable } from "babylonjs/types";
  61590. import { Camera } from "babylonjs/Cameras/camera";
  61591. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61592. import { Engine } from "babylonjs/Engines/engine";
  61593. import "babylonjs/Shaders/grain.fragment";
  61594. /**
  61595. * The GrainPostProcess adds noise to the image at mid luminance levels
  61596. */
  61597. export class GrainPostProcess extends PostProcess {
  61598. /**
  61599. * The intensity of the grain added (default: 30)
  61600. */
  61601. intensity: number;
  61602. /**
  61603. * If the grain should be randomized on every frame
  61604. */
  61605. animated: boolean;
  61606. /**
  61607. * Creates a new instance of @see GrainPostProcess
  61608. * @param name The name of the effect.
  61609. * @param options The required width/height ratio to downsize to before computing the render pass.
  61610. * @param camera The camera to apply the render pass to.
  61611. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61612. * @param engine The engine which the post process will be applied. (default: current engine)
  61613. * @param reusable If the post process can be reused on the same frame. (default: false)
  61614. * @param textureType Type of textures used when performing the post process. (default: 0)
  61615. * @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)
  61616. */
  61617. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61618. }
  61619. }
  61620. declare module "babylonjs/Shaders/highlights.fragment" {
  61621. /** @hidden */
  61622. export var highlightsPixelShader: {
  61623. name: string;
  61624. shader: string;
  61625. };
  61626. }
  61627. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  61628. import { Nullable } from "babylonjs/types";
  61629. import { Camera } from "babylonjs/Cameras/camera";
  61630. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61631. import { Engine } from "babylonjs/Engines/engine";
  61632. import "babylonjs/Shaders/highlights.fragment";
  61633. /**
  61634. * Extracts highlights from the image
  61635. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  61636. */
  61637. export class HighlightsPostProcess extends PostProcess {
  61638. /**
  61639. * Extracts highlights from the image
  61640. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  61641. * @param name The name of the effect.
  61642. * @param options The required width/height ratio to downsize to before computing the render pass.
  61643. * @param camera The camera to apply the render pass to.
  61644. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61645. * @param engine The engine which the post process will be applied. (default: current engine)
  61646. * @param reusable If the post process can be reused on the same frame. (default: false)
  61647. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  61648. */
  61649. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  61650. }
  61651. }
  61652. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  61653. /** @hidden */
  61654. export var mrtFragmentDeclaration: {
  61655. name: string;
  61656. shader: string;
  61657. };
  61658. }
  61659. declare module "babylonjs/Shaders/geometry.fragment" {
  61660. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  61661. /** @hidden */
  61662. export var geometryPixelShader: {
  61663. name: string;
  61664. shader: string;
  61665. };
  61666. }
  61667. declare module "babylonjs/Shaders/geometry.vertex" {
  61668. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  61669. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  61670. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  61671. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  61672. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  61673. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  61674. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  61675. /** @hidden */
  61676. export var geometryVertexShader: {
  61677. name: string;
  61678. shader: string;
  61679. };
  61680. }
  61681. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  61682. import { Matrix } from "babylonjs/Maths/math.vector";
  61683. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61684. import { Mesh } from "babylonjs/Meshes/mesh";
  61685. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  61686. import { Effect } from "babylonjs/Materials/effect";
  61687. import { Scene } from "babylonjs/scene";
  61688. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61689. import "babylonjs/Shaders/geometry.fragment";
  61690. import "babylonjs/Shaders/geometry.vertex";
  61691. /** @hidden */
  61692. interface ISavedTransformationMatrix {
  61693. world: Matrix;
  61694. viewProjection: Matrix;
  61695. }
  61696. /**
  61697. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  61698. */
  61699. export class GeometryBufferRenderer {
  61700. /**
  61701. * Constant used to retrieve the position texture index in the G-Buffer textures array
  61702. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  61703. */
  61704. static readonly POSITION_TEXTURE_TYPE: number;
  61705. /**
  61706. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  61707. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  61708. */
  61709. static readonly VELOCITY_TEXTURE_TYPE: number;
  61710. /**
  61711. * Dictionary used to store the previous transformation matrices of each rendered mesh
  61712. * in order to compute objects velocities when enableVelocity is set to "true"
  61713. * @hidden
  61714. */
  61715. _previousTransformationMatrices: {
  61716. [index: number]: ISavedTransformationMatrix;
  61717. };
  61718. /**
  61719. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  61720. * in order to compute objects velocities when enableVelocity is set to "true"
  61721. * @hidden
  61722. */
  61723. _previousBonesTransformationMatrices: {
  61724. [index: number]: Float32Array;
  61725. };
  61726. /**
  61727. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  61728. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  61729. */
  61730. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  61731. private _scene;
  61732. private _multiRenderTarget;
  61733. private _ratio;
  61734. private _enablePosition;
  61735. private _enableVelocity;
  61736. private _positionIndex;
  61737. private _velocityIndex;
  61738. protected _effect: Effect;
  61739. protected _cachedDefines: string;
  61740. /**
  61741. * Set the render list (meshes to be rendered) used in the G buffer.
  61742. */
  61743. renderList: Mesh[];
  61744. /**
  61745. * Gets wether or not G buffer are supported by the running hardware.
  61746. * This requires draw buffer supports
  61747. */
  61748. readonly isSupported: boolean;
  61749. /**
  61750. * Returns the index of the given texture type in the G-Buffer textures array
  61751. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  61752. * @returns the index of the given texture type in the G-Buffer textures array
  61753. */
  61754. getTextureIndex(textureType: number): number;
  61755. /**
  61756. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  61757. */
  61758. /**
  61759. * Sets whether or not objects positions are enabled for the G buffer.
  61760. */
  61761. enablePosition: boolean;
  61762. /**
  61763. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  61764. */
  61765. /**
  61766. * Sets wether or not objects velocities are enabled for the G buffer.
  61767. */
  61768. enableVelocity: boolean;
  61769. /**
  61770. * Gets the scene associated with the buffer.
  61771. */
  61772. readonly scene: Scene;
  61773. /**
  61774. * Gets the ratio used by the buffer during its creation.
  61775. * How big is the buffer related to the main canvas.
  61776. */
  61777. readonly ratio: number;
  61778. /** @hidden */
  61779. static _SceneComponentInitialization: (scene: Scene) => void;
  61780. /**
  61781. * Creates a new G Buffer for the scene
  61782. * @param scene The scene the buffer belongs to
  61783. * @param ratio How big is the buffer related to the main canvas.
  61784. */
  61785. constructor(scene: Scene, ratio?: number);
  61786. /**
  61787. * Checks wether everything is ready to render a submesh to the G buffer.
  61788. * @param subMesh the submesh to check readiness for
  61789. * @param useInstances is the mesh drawn using instance or not
  61790. * @returns true if ready otherwise false
  61791. */
  61792. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61793. /**
  61794. * Gets the current underlying G Buffer.
  61795. * @returns the buffer
  61796. */
  61797. getGBuffer(): MultiRenderTarget;
  61798. /**
  61799. * Gets the number of samples used to render the buffer (anti aliasing).
  61800. */
  61801. /**
  61802. * Sets the number of samples used to render the buffer (anti aliasing).
  61803. */
  61804. samples: number;
  61805. /**
  61806. * Disposes the renderer and frees up associated resources.
  61807. */
  61808. dispose(): void;
  61809. protected _createRenderTargets(): void;
  61810. private _copyBonesTransformationMatrices;
  61811. }
  61812. }
  61813. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  61814. import { Nullable } from "babylonjs/types";
  61815. import { Scene } from "babylonjs/scene";
  61816. import { ISceneComponent } from "babylonjs/sceneComponent";
  61817. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  61818. module "babylonjs/scene" {
  61819. interface Scene {
  61820. /** @hidden (Backing field) */
  61821. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  61822. /**
  61823. * Gets or Sets the current geometry buffer associated to the scene.
  61824. */
  61825. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  61826. /**
  61827. * Enables a GeometryBufferRender and associates it with the scene
  61828. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  61829. * @returns the GeometryBufferRenderer
  61830. */
  61831. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  61832. /**
  61833. * Disables the GeometryBufferRender associated with the scene
  61834. */
  61835. disableGeometryBufferRenderer(): void;
  61836. }
  61837. }
  61838. /**
  61839. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  61840. * in several rendering techniques.
  61841. */
  61842. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  61843. /**
  61844. * The component name helpful to identify the component in the list of scene components.
  61845. */
  61846. readonly name: string;
  61847. /**
  61848. * The scene the component belongs to.
  61849. */
  61850. scene: Scene;
  61851. /**
  61852. * Creates a new instance of the component for the given scene
  61853. * @param scene Defines the scene to register the component in
  61854. */
  61855. constructor(scene: Scene);
  61856. /**
  61857. * Registers the component in a given scene
  61858. */
  61859. register(): void;
  61860. /**
  61861. * Rebuilds the elements related to this component in case of
  61862. * context lost for instance.
  61863. */
  61864. rebuild(): void;
  61865. /**
  61866. * Disposes the component and the associated ressources
  61867. */
  61868. dispose(): void;
  61869. private _gatherRenderTargets;
  61870. }
  61871. }
  61872. declare module "babylonjs/Shaders/motionBlur.fragment" {
  61873. /** @hidden */
  61874. export var motionBlurPixelShader: {
  61875. name: string;
  61876. shader: string;
  61877. };
  61878. }
  61879. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  61880. import { Nullable } from "babylonjs/types";
  61881. import { Camera } from "babylonjs/Cameras/camera";
  61882. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61883. import { Scene } from "babylonjs/scene";
  61884. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61885. import "babylonjs/Animations/animatable";
  61886. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  61887. import "babylonjs/Shaders/motionBlur.fragment";
  61888. import { Engine } from "babylonjs/Engines/engine";
  61889. /**
  61890. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  61891. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  61892. * As an example, all you have to do is to create the post-process:
  61893. * var mb = new BABYLON.MotionBlurPostProcess(
  61894. * 'mb', // The name of the effect.
  61895. * scene, // The scene containing the objects to blur according to their velocity.
  61896. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  61897. * camera // The camera to apply the render pass to.
  61898. * );
  61899. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  61900. */
  61901. export class MotionBlurPostProcess extends PostProcess {
  61902. /**
  61903. * Defines how much the image is blurred by the movement. Default value is equal to 1
  61904. */
  61905. motionStrength: number;
  61906. /**
  61907. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  61908. */
  61909. /**
  61910. * Sets the number of iterations to be used for motion blur quality
  61911. */
  61912. motionBlurSamples: number;
  61913. private _motionBlurSamples;
  61914. private _geometryBufferRenderer;
  61915. /**
  61916. * Creates a new instance MotionBlurPostProcess
  61917. * @param name The name of the effect.
  61918. * @param scene The scene containing the objects to blur according to their velocity.
  61919. * @param options The required width/height ratio to downsize to before computing the render pass.
  61920. * @param camera The camera to apply the render pass to.
  61921. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61922. * @param engine The engine which the post process will be applied. (default: current engine)
  61923. * @param reusable If the post process can be reused on the same frame. (default: false)
  61924. * @param textureType Type of textures used when performing the post process. (default: 0)
  61925. * @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)
  61926. */
  61927. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61928. /**
  61929. * Excludes the given skinned mesh from computing bones velocities.
  61930. * 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.
  61931. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  61932. */
  61933. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  61934. /**
  61935. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  61936. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  61937. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  61938. */
  61939. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  61940. /**
  61941. * Disposes the post process.
  61942. * @param camera The camera to dispose the post process on.
  61943. */
  61944. dispose(camera?: Camera): void;
  61945. }
  61946. }
  61947. declare module "babylonjs/Shaders/refraction.fragment" {
  61948. /** @hidden */
  61949. export var refractionPixelShader: {
  61950. name: string;
  61951. shader: string;
  61952. };
  61953. }
  61954. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  61955. import { Color3 } from "babylonjs/Maths/math.color";
  61956. import { Camera } from "babylonjs/Cameras/camera";
  61957. import { Texture } from "babylonjs/Materials/Textures/texture";
  61958. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61959. import { Engine } from "babylonjs/Engines/engine";
  61960. import "babylonjs/Shaders/refraction.fragment";
  61961. /**
  61962. * Post process which applies a refractin texture
  61963. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  61964. */
  61965. export class RefractionPostProcess extends PostProcess {
  61966. /** the base color of the refraction (used to taint the rendering) */
  61967. color: Color3;
  61968. /** simulated refraction depth */
  61969. depth: number;
  61970. /** the coefficient of the base color (0 to remove base color tainting) */
  61971. colorLevel: number;
  61972. private _refTexture;
  61973. private _ownRefractionTexture;
  61974. /**
  61975. * Gets or sets the refraction texture
  61976. * Please note that you are responsible for disposing the texture if you set it manually
  61977. */
  61978. refractionTexture: Texture;
  61979. /**
  61980. * Initializes the RefractionPostProcess
  61981. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  61982. * @param name The name of the effect.
  61983. * @param refractionTextureUrl Url of the refraction texture to use
  61984. * @param color the base color of the refraction (used to taint the rendering)
  61985. * @param depth simulated refraction depth
  61986. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  61987. * @param camera The camera to apply the render pass to.
  61988. * @param options The required width/height ratio to downsize to before computing the render pass.
  61989. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61990. * @param engine The engine which the post process will be applied. (default: current engine)
  61991. * @param reusable If the post process can be reused on the same frame. (default: false)
  61992. */
  61993. constructor(name: string, refractionTextureUrl: string,
  61994. /** the base color of the refraction (used to taint the rendering) */
  61995. color: Color3,
  61996. /** simulated refraction depth */
  61997. depth: number,
  61998. /** the coefficient of the base color (0 to remove base color tainting) */
  61999. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62000. /**
  62001. * Disposes of the post process
  62002. * @param camera Camera to dispose post process on
  62003. */
  62004. dispose(camera: Camera): void;
  62005. }
  62006. }
  62007. declare module "babylonjs/Shaders/sharpen.fragment" {
  62008. /** @hidden */
  62009. export var sharpenPixelShader: {
  62010. name: string;
  62011. shader: string;
  62012. };
  62013. }
  62014. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  62015. import { Nullable } from "babylonjs/types";
  62016. import { Camera } from "babylonjs/Cameras/camera";
  62017. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62018. import "babylonjs/Shaders/sharpen.fragment";
  62019. import { Engine } from "babylonjs/Engines/engine";
  62020. /**
  62021. * The SharpenPostProcess applies a sharpen kernel to every pixel
  62022. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  62023. */
  62024. export class SharpenPostProcess extends PostProcess {
  62025. /**
  62026. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  62027. */
  62028. colorAmount: number;
  62029. /**
  62030. * How much sharpness should be applied (default: 0.3)
  62031. */
  62032. edgeAmount: number;
  62033. /**
  62034. * Creates a new instance ConvolutionPostProcess
  62035. * @param name The name of the effect.
  62036. * @param options The required width/height ratio to downsize to before computing the render pass.
  62037. * @param camera The camera to apply the render pass to.
  62038. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62039. * @param engine The engine which the post process will be applied. (default: current engine)
  62040. * @param reusable If the post process can be reused on the same frame. (default: false)
  62041. * @param textureType Type of textures used when performing the post process. (default: 0)
  62042. * @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)
  62043. */
  62044. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62045. }
  62046. }
  62047. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  62048. import { Nullable } from "babylonjs/types";
  62049. import { Camera } from "babylonjs/Cameras/camera";
  62050. import { Engine } from "babylonjs/Engines/engine";
  62051. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  62052. import { IInspectable } from "babylonjs/Misc/iInspectable";
  62053. /**
  62054. * PostProcessRenderPipeline
  62055. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62056. */
  62057. export class PostProcessRenderPipeline {
  62058. private engine;
  62059. private _renderEffects;
  62060. private _renderEffectsForIsolatedPass;
  62061. /**
  62062. * List of inspectable custom properties (used by the Inspector)
  62063. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  62064. */
  62065. inspectableCustomProperties: IInspectable[];
  62066. /**
  62067. * @hidden
  62068. */
  62069. protected _cameras: Camera[];
  62070. /** @hidden */
  62071. _name: string;
  62072. /**
  62073. * Gets pipeline name
  62074. */
  62075. readonly name: string;
  62076. /**
  62077. * Initializes a PostProcessRenderPipeline
  62078. * @param engine engine to add the pipeline to
  62079. * @param name name of the pipeline
  62080. */
  62081. constructor(engine: Engine, name: string);
  62082. /**
  62083. * Gets the class name
  62084. * @returns "PostProcessRenderPipeline"
  62085. */
  62086. getClassName(): string;
  62087. /**
  62088. * If all the render effects in the pipeline are supported
  62089. */
  62090. readonly isSupported: boolean;
  62091. /**
  62092. * Adds an effect to the pipeline
  62093. * @param renderEffect the effect to add
  62094. */
  62095. addEffect(renderEffect: PostProcessRenderEffect): void;
  62096. /** @hidden */
  62097. _rebuild(): void;
  62098. /** @hidden */
  62099. _enableEffect(renderEffectName: string, cameras: Camera): void;
  62100. /** @hidden */
  62101. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  62102. /** @hidden */
  62103. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  62104. /** @hidden */
  62105. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  62106. /** @hidden */
  62107. _attachCameras(cameras: Camera, unique: boolean): void;
  62108. /** @hidden */
  62109. _attachCameras(cameras: Camera[], unique: boolean): void;
  62110. /** @hidden */
  62111. _detachCameras(cameras: Camera): void;
  62112. /** @hidden */
  62113. _detachCameras(cameras: Nullable<Camera[]>): void;
  62114. /** @hidden */
  62115. _update(): void;
  62116. /** @hidden */
  62117. _reset(): void;
  62118. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  62119. /**
  62120. * Disposes of the pipeline
  62121. */
  62122. dispose(): void;
  62123. }
  62124. }
  62125. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  62126. import { Camera } from "babylonjs/Cameras/camera";
  62127. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62128. /**
  62129. * PostProcessRenderPipelineManager class
  62130. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62131. */
  62132. export class PostProcessRenderPipelineManager {
  62133. private _renderPipelines;
  62134. /**
  62135. * Initializes a PostProcessRenderPipelineManager
  62136. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62137. */
  62138. constructor();
  62139. /**
  62140. * Gets the list of supported render pipelines
  62141. */
  62142. readonly supportedPipelines: PostProcessRenderPipeline[];
  62143. /**
  62144. * Adds a pipeline to the manager
  62145. * @param renderPipeline The pipeline to add
  62146. */
  62147. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  62148. /**
  62149. * Attaches a camera to the pipeline
  62150. * @param renderPipelineName The name of the pipeline to attach to
  62151. * @param cameras the camera to attach
  62152. * @param unique if the camera can be attached multiple times to the pipeline
  62153. */
  62154. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  62155. /**
  62156. * Detaches a camera from the pipeline
  62157. * @param renderPipelineName The name of the pipeline to detach from
  62158. * @param cameras the camera to detach
  62159. */
  62160. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  62161. /**
  62162. * Enables an effect by name on a pipeline
  62163. * @param renderPipelineName the name of the pipeline to enable the effect in
  62164. * @param renderEffectName the name of the effect to enable
  62165. * @param cameras the cameras that the effect should be enabled on
  62166. */
  62167. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  62168. /**
  62169. * Disables an effect by name on a pipeline
  62170. * @param renderPipelineName the name of the pipeline to disable the effect in
  62171. * @param renderEffectName the name of the effect to disable
  62172. * @param cameras the cameras that the effect should be disabled on
  62173. */
  62174. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  62175. /**
  62176. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  62177. */
  62178. update(): void;
  62179. /** @hidden */
  62180. _rebuild(): void;
  62181. /**
  62182. * Disposes of the manager and pipelines
  62183. */
  62184. dispose(): void;
  62185. }
  62186. }
  62187. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  62188. import { ISceneComponent } from "babylonjs/sceneComponent";
  62189. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  62190. import { Scene } from "babylonjs/scene";
  62191. module "babylonjs/scene" {
  62192. interface Scene {
  62193. /** @hidden (Backing field) */
  62194. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  62195. /**
  62196. * Gets the postprocess render pipeline manager
  62197. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62198. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  62199. */
  62200. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  62201. }
  62202. }
  62203. /**
  62204. * Defines the Render Pipeline scene component responsible to rendering pipelines
  62205. */
  62206. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  62207. /**
  62208. * The component name helpfull to identify the component in the list of scene components.
  62209. */
  62210. readonly name: string;
  62211. /**
  62212. * The scene the component belongs to.
  62213. */
  62214. scene: Scene;
  62215. /**
  62216. * Creates a new instance of the component for the given scene
  62217. * @param scene Defines the scene to register the component in
  62218. */
  62219. constructor(scene: Scene);
  62220. /**
  62221. * Registers the component in a given scene
  62222. */
  62223. register(): void;
  62224. /**
  62225. * Rebuilds the elements related to this component in case of
  62226. * context lost for instance.
  62227. */
  62228. rebuild(): void;
  62229. /**
  62230. * Disposes the component and the associated ressources
  62231. */
  62232. dispose(): void;
  62233. private _gatherRenderTargets;
  62234. }
  62235. }
  62236. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  62237. import { Nullable } from "babylonjs/types";
  62238. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  62239. import { Camera } from "babylonjs/Cameras/camera";
  62240. import { IDisposable } from "babylonjs/scene";
  62241. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  62242. import { Scene } from "babylonjs/scene";
  62243. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  62244. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  62245. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  62246. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  62247. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  62248. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62249. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  62250. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  62251. import { Animation } from "babylonjs/Animations/animation";
  62252. /**
  62253. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  62254. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  62255. */
  62256. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  62257. private _scene;
  62258. private _camerasToBeAttached;
  62259. /**
  62260. * ID of the sharpen post process,
  62261. */
  62262. private readonly SharpenPostProcessId;
  62263. /**
  62264. * @ignore
  62265. * ID of the image processing post process;
  62266. */
  62267. readonly ImageProcessingPostProcessId: string;
  62268. /**
  62269. * @ignore
  62270. * ID of the Fast Approximate Anti-Aliasing post process;
  62271. */
  62272. readonly FxaaPostProcessId: string;
  62273. /**
  62274. * ID of the chromatic aberration post process,
  62275. */
  62276. private readonly ChromaticAberrationPostProcessId;
  62277. /**
  62278. * ID of the grain post process
  62279. */
  62280. private readonly GrainPostProcessId;
  62281. /**
  62282. * Sharpen post process which will apply a sharpen convolution to enhance edges
  62283. */
  62284. sharpen: SharpenPostProcess;
  62285. private _sharpenEffect;
  62286. private bloom;
  62287. /**
  62288. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  62289. */
  62290. depthOfField: DepthOfFieldEffect;
  62291. /**
  62292. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  62293. */
  62294. fxaa: FxaaPostProcess;
  62295. /**
  62296. * Image post processing pass used to perform operations such as tone mapping or color grading.
  62297. */
  62298. imageProcessing: ImageProcessingPostProcess;
  62299. /**
  62300. * Chromatic aberration post process which will shift rgb colors in the image
  62301. */
  62302. chromaticAberration: ChromaticAberrationPostProcess;
  62303. private _chromaticAberrationEffect;
  62304. /**
  62305. * Grain post process which add noise to the image
  62306. */
  62307. grain: GrainPostProcess;
  62308. private _grainEffect;
  62309. /**
  62310. * Glow post process which adds a glow to emissive areas of the image
  62311. */
  62312. private _glowLayer;
  62313. /**
  62314. * Animations which can be used to tweak settings over a period of time
  62315. */
  62316. animations: Animation[];
  62317. private _imageProcessingConfigurationObserver;
  62318. private _sharpenEnabled;
  62319. private _bloomEnabled;
  62320. private _depthOfFieldEnabled;
  62321. private _depthOfFieldBlurLevel;
  62322. private _fxaaEnabled;
  62323. private _imageProcessingEnabled;
  62324. private _defaultPipelineTextureType;
  62325. private _bloomScale;
  62326. private _chromaticAberrationEnabled;
  62327. private _grainEnabled;
  62328. private _buildAllowed;
  62329. /**
  62330. * Gets active scene
  62331. */
  62332. readonly scene: Scene;
  62333. /**
  62334. * Enable or disable the sharpen process from the pipeline
  62335. */
  62336. sharpenEnabled: boolean;
  62337. private _resizeObserver;
  62338. private _hardwareScaleLevel;
  62339. private _bloomKernel;
  62340. /**
  62341. * Specifies the size of the bloom blur kernel, relative to the final output size
  62342. */
  62343. bloomKernel: number;
  62344. /**
  62345. * Specifies the weight of the bloom in the final rendering
  62346. */
  62347. private _bloomWeight;
  62348. /**
  62349. * Specifies the luma threshold for the area that will be blurred by the bloom
  62350. */
  62351. private _bloomThreshold;
  62352. private _hdr;
  62353. /**
  62354. * The strength of the bloom.
  62355. */
  62356. bloomWeight: number;
  62357. /**
  62358. * The strength of the bloom.
  62359. */
  62360. bloomThreshold: number;
  62361. /**
  62362. * The scale of the bloom, lower value will provide better performance.
  62363. */
  62364. bloomScale: number;
  62365. /**
  62366. * Enable or disable the bloom from the pipeline
  62367. */
  62368. bloomEnabled: boolean;
  62369. private _rebuildBloom;
  62370. /**
  62371. * If the depth of field is enabled.
  62372. */
  62373. depthOfFieldEnabled: boolean;
  62374. /**
  62375. * Blur level of the depth of field effect. (Higher blur will effect performance)
  62376. */
  62377. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  62378. /**
  62379. * If the anti aliasing is enabled.
  62380. */
  62381. fxaaEnabled: boolean;
  62382. private _samples;
  62383. /**
  62384. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  62385. */
  62386. samples: number;
  62387. /**
  62388. * If image processing is enabled.
  62389. */
  62390. imageProcessingEnabled: boolean;
  62391. /**
  62392. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  62393. */
  62394. glowLayerEnabled: boolean;
  62395. /**
  62396. * Gets the glow layer (or null if not defined)
  62397. */
  62398. readonly glowLayer: Nullable<GlowLayer>;
  62399. /**
  62400. * Enable or disable the chromaticAberration process from the pipeline
  62401. */
  62402. chromaticAberrationEnabled: boolean;
  62403. /**
  62404. * Enable or disable the grain process from the pipeline
  62405. */
  62406. grainEnabled: boolean;
  62407. /**
  62408. * @constructor
  62409. * @param name - The rendering pipeline name (default: "")
  62410. * @param hdr - If high dynamic range textures should be used (default: true)
  62411. * @param scene - The scene linked to this pipeline (default: the last created scene)
  62412. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  62413. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  62414. */
  62415. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  62416. /**
  62417. * Get the class name
  62418. * @returns "DefaultRenderingPipeline"
  62419. */
  62420. getClassName(): string;
  62421. /**
  62422. * Force the compilation of the entire pipeline.
  62423. */
  62424. prepare(): void;
  62425. private _hasCleared;
  62426. private _prevPostProcess;
  62427. private _prevPrevPostProcess;
  62428. private _setAutoClearAndTextureSharing;
  62429. private _depthOfFieldSceneObserver;
  62430. private _buildPipeline;
  62431. private _disposePostProcesses;
  62432. /**
  62433. * Adds a camera to the pipeline
  62434. * @param camera the camera to be added
  62435. */
  62436. addCamera(camera: Camera): void;
  62437. /**
  62438. * Removes a camera from the pipeline
  62439. * @param camera the camera to remove
  62440. */
  62441. removeCamera(camera: Camera): void;
  62442. /**
  62443. * Dispose of the pipeline and stop all post processes
  62444. */
  62445. dispose(): void;
  62446. /**
  62447. * Serialize the rendering pipeline (Used when exporting)
  62448. * @returns the serialized object
  62449. */
  62450. serialize(): any;
  62451. /**
  62452. * Parse the serialized pipeline
  62453. * @param source Source pipeline.
  62454. * @param scene The scene to load the pipeline to.
  62455. * @param rootUrl The URL of the serialized pipeline.
  62456. * @returns An instantiated pipeline from the serialized object.
  62457. */
  62458. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  62459. }
  62460. }
  62461. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  62462. /** @hidden */
  62463. export var lensHighlightsPixelShader: {
  62464. name: string;
  62465. shader: string;
  62466. };
  62467. }
  62468. declare module "babylonjs/Shaders/depthOfField.fragment" {
  62469. /** @hidden */
  62470. export var depthOfFieldPixelShader: {
  62471. name: string;
  62472. shader: string;
  62473. };
  62474. }
  62475. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  62476. import { Camera } from "babylonjs/Cameras/camera";
  62477. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62478. import { Scene } from "babylonjs/scene";
  62479. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  62480. import "babylonjs/Shaders/chromaticAberration.fragment";
  62481. import "babylonjs/Shaders/lensHighlights.fragment";
  62482. import "babylonjs/Shaders/depthOfField.fragment";
  62483. /**
  62484. * BABYLON.JS Chromatic Aberration GLSL Shader
  62485. * Author: Olivier Guyot
  62486. * Separates very slightly R, G and B colors on the edges of the screen
  62487. * Inspired by Francois Tarlier & Martins Upitis
  62488. */
  62489. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  62490. /**
  62491. * @ignore
  62492. * The chromatic aberration PostProcess id in the pipeline
  62493. */
  62494. LensChromaticAberrationEffect: string;
  62495. /**
  62496. * @ignore
  62497. * The highlights enhancing PostProcess id in the pipeline
  62498. */
  62499. HighlightsEnhancingEffect: string;
  62500. /**
  62501. * @ignore
  62502. * The depth-of-field PostProcess id in the pipeline
  62503. */
  62504. LensDepthOfFieldEffect: string;
  62505. private _scene;
  62506. private _depthTexture;
  62507. private _grainTexture;
  62508. private _chromaticAberrationPostProcess;
  62509. private _highlightsPostProcess;
  62510. private _depthOfFieldPostProcess;
  62511. private _edgeBlur;
  62512. private _grainAmount;
  62513. private _chromaticAberration;
  62514. private _distortion;
  62515. private _highlightsGain;
  62516. private _highlightsThreshold;
  62517. private _dofDistance;
  62518. private _dofAperture;
  62519. private _dofDarken;
  62520. private _dofPentagon;
  62521. private _blurNoise;
  62522. /**
  62523. * @constructor
  62524. *
  62525. * Effect parameters are as follow:
  62526. * {
  62527. * chromatic_aberration: number; // from 0 to x (1 for realism)
  62528. * edge_blur: number; // from 0 to x (1 for realism)
  62529. * distortion: number; // from 0 to x (1 for realism)
  62530. * grain_amount: number; // from 0 to 1
  62531. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  62532. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  62533. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  62534. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  62535. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  62536. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  62537. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  62538. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  62539. * }
  62540. * Note: if an effect parameter is unset, effect is disabled
  62541. *
  62542. * @param name The rendering pipeline name
  62543. * @param parameters - An object containing all parameters (see above)
  62544. * @param scene The scene linked to this pipeline
  62545. * @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)
  62546. * @param cameras The array of cameras that the rendering pipeline will be attached to
  62547. */
  62548. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  62549. /**
  62550. * Get the class name
  62551. * @returns "LensRenderingPipeline"
  62552. */
  62553. getClassName(): string;
  62554. /**
  62555. * Gets associated scene
  62556. */
  62557. readonly scene: Scene;
  62558. /**
  62559. * Gets or sets the edge blur
  62560. */
  62561. edgeBlur: number;
  62562. /**
  62563. * Gets or sets the grain amount
  62564. */
  62565. grainAmount: number;
  62566. /**
  62567. * Gets or sets the chromatic aberration amount
  62568. */
  62569. chromaticAberration: number;
  62570. /**
  62571. * Gets or sets the depth of field aperture
  62572. */
  62573. dofAperture: number;
  62574. /**
  62575. * Gets or sets the edge distortion
  62576. */
  62577. edgeDistortion: number;
  62578. /**
  62579. * Gets or sets the depth of field distortion
  62580. */
  62581. dofDistortion: number;
  62582. /**
  62583. * Gets or sets the darken out of focus amount
  62584. */
  62585. darkenOutOfFocus: number;
  62586. /**
  62587. * Gets or sets a boolean indicating if blur noise is enabled
  62588. */
  62589. blurNoise: boolean;
  62590. /**
  62591. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  62592. */
  62593. pentagonBokeh: boolean;
  62594. /**
  62595. * Gets or sets the highlight grain amount
  62596. */
  62597. highlightsGain: number;
  62598. /**
  62599. * Gets or sets the highlight threshold
  62600. */
  62601. highlightsThreshold: number;
  62602. /**
  62603. * Sets the amount of blur at the edges
  62604. * @param amount blur amount
  62605. */
  62606. setEdgeBlur(amount: number): void;
  62607. /**
  62608. * Sets edge blur to 0
  62609. */
  62610. disableEdgeBlur(): void;
  62611. /**
  62612. * Sets the amout of grain
  62613. * @param amount Amount of grain
  62614. */
  62615. setGrainAmount(amount: number): void;
  62616. /**
  62617. * Set grain amount to 0
  62618. */
  62619. disableGrain(): void;
  62620. /**
  62621. * Sets the chromatic aberration amount
  62622. * @param amount amount of chromatic aberration
  62623. */
  62624. setChromaticAberration(amount: number): void;
  62625. /**
  62626. * Sets chromatic aberration amount to 0
  62627. */
  62628. disableChromaticAberration(): void;
  62629. /**
  62630. * Sets the EdgeDistortion amount
  62631. * @param amount amount of EdgeDistortion
  62632. */
  62633. setEdgeDistortion(amount: number): void;
  62634. /**
  62635. * Sets edge distortion to 0
  62636. */
  62637. disableEdgeDistortion(): void;
  62638. /**
  62639. * Sets the FocusDistance amount
  62640. * @param amount amount of FocusDistance
  62641. */
  62642. setFocusDistance(amount: number): void;
  62643. /**
  62644. * Disables depth of field
  62645. */
  62646. disableDepthOfField(): void;
  62647. /**
  62648. * Sets the Aperture amount
  62649. * @param amount amount of Aperture
  62650. */
  62651. setAperture(amount: number): void;
  62652. /**
  62653. * Sets the DarkenOutOfFocus amount
  62654. * @param amount amount of DarkenOutOfFocus
  62655. */
  62656. setDarkenOutOfFocus(amount: number): void;
  62657. private _pentagonBokehIsEnabled;
  62658. /**
  62659. * Creates a pentagon bokeh effect
  62660. */
  62661. enablePentagonBokeh(): void;
  62662. /**
  62663. * Disables the pentagon bokeh effect
  62664. */
  62665. disablePentagonBokeh(): void;
  62666. /**
  62667. * Enables noise blur
  62668. */
  62669. enableNoiseBlur(): void;
  62670. /**
  62671. * Disables noise blur
  62672. */
  62673. disableNoiseBlur(): void;
  62674. /**
  62675. * Sets the HighlightsGain amount
  62676. * @param amount amount of HighlightsGain
  62677. */
  62678. setHighlightsGain(amount: number): void;
  62679. /**
  62680. * Sets the HighlightsThreshold amount
  62681. * @param amount amount of HighlightsThreshold
  62682. */
  62683. setHighlightsThreshold(amount: number): void;
  62684. /**
  62685. * Disables highlights
  62686. */
  62687. disableHighlights(): void;
  62688. /**
  62689. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  62690. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  62691. */
  62692. dispose(disableDepthRender?: boolean): void;
  62693. private _createChromaticAberrationPostProcess;
  62694. private _createHighlightsPostProcess;
  62695. private _createDepthOfFieldPostProcess;
  62696. private _createGrainTexture;
  62697. }
  62698. }
  62699. declare module "babylonjs/Shaders/ssao2.fragment" {
  62700. /** @hidden */
  62701. export var ssao2PixelShader: {
  62702. name: string;
  62703. shader: string;
  62704. };
  62705. }
  62706. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  62707. /** @hidden */
  62708. export var ssaoCombinePixelShader: {
  62709. name: string;
  62710. shader: string;
  62711. };
  62712. }
  62713. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  62714. import { Camera } from "babylonjs/Cameras/camera";
  62715. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62716. import { Scene } from "babylonjs/scene";
  62717. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  62718. import "babylonjs/Shaders/ssao2.fragment";
  62719. import "babylonjs/Shaders/ssaoCombine.fragment";
  62720. /**
  62721. * Render pipeline to produce ssao effect
  62722. */
  62723. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  62724. /**
  62725. * @ignore
  62726. * The PassPostProcess id in the pipeline that contains the original scene color
  62727. */
  62728. SSAOOriginalSceneColorEffect: string;
  62729. /**
  62730. * @ignore
  62731. * The SSAO PostProcess id in the pipeline
  62732. */
  62733. SSAORenderEffect: string;
  62734. /**
  62735. * @ignore
  62736. * The horizontal blur PostProcess id in the pipeline
  62737. */
  62738. SSAOBlurHRenderEffect: string;
  62739. /**
  62740. * @ignore
  62741. * The vertical blur PostProcess id in the pipeline
  62742. */
  62743. SSAOBlurVRenderEffect: string;
  62744. /**
  62745. * @ignore
  62746. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  62747. */
  62748. SSAOCombineRenderEffect: string;
  62749. /**
  62750. * The output strength of the SSAO post-process. Default value is 1.0.
  62751. */
  62752. totalStrength: number;
  62753. /**
  62754. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  62755. */
  62756. maxZ: number;
  62757. /**
  62758. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  62759. */
  62760. minZAspect: number;
  62761. private _samples;
  62762. /**
  62763. * Number of samples used for the SSAO calculations. Default value is 8
  62764. */
  62765. samples: number;
  62766. private _textureSamples;
  62767. /**
  62768. * Number of samples to use for antialiasing
  62769. */
  62770. textureSamples: number;
  62771. /**
  62772. * Ratio object used for SSAO ratio and blur ratio
  62773. */
  62774. private _ratio;
  62775. /**
  62776. * Dynamically generated sphere sampler.
  62777. */
  62778. private _sampleSphere;
  62779. /**
  62780. * Blur filter offsets
  62781. */
  62782. private _samplerOffsets;
  62783. private _expensiveBlur;
  62784. /**
  62785. * If bilateral blur should be used
  62786. */
  62787. expensiveBlur: boolean;
  62788. /**
  62789. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  62790. */
  62791. radius: number;
  62792. /**
  62793. * The base color of the SSAO post-process
  62794. * The final result is "base + ssao" between [0, 1]
  62795. */
  62796. base: number;
  62797. /**
  62798. * Support test.
  62799. */
  62800. static readonly IsSupported: boolean;
  62801. private _scene;
  62802. private _depthTexture;
  62803. private _normalTexture;
  62804. private _randomTexture;
  62805. private _originalColorPostProcess;
  62806. private _ssaoPostProcess;
  62807. private _blurHPostProcess;
  62808. private _blurVPostProcess;
  62809. private _ssaoCombinePostProcess;
  62810. private _firstUpdate;
  62811. /**
  62812. * Gets active scene
  62813. */
  62814. readonly scene: Scene;
  62815. /**
  62816. * @constructor
  62817. * @param name The rendering pipeline name
  62818. * @param scene The scene linked to this pipeline
  62819. * @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 }
  62820. * @param cameras The array of cameras that the rendering pipeline will be attached to
  62821. */
  62822. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  62823. /**
  62824. * Get the class name
  62825. * @returns "SSAO2RenderingPipeline"
  62826. */
  62827. getClassName(): string;
  62828. /**
  62829. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  62830. */
  62831. dispose(disableGeometryBufferRenderer?: boolean): void;
  62832. private _createBlurPostProcess;
  62833. /** @hidden */
  62834. _rebuild(): void;
  62835. private _bits;
  62836. private _radicalInverse_VdC;
  62837. private _hammersley;
  62838. private _hemisphereSample_uniform;
  62839. private _generateHemisphere;
  62840. private _createSSAOPostProcess;
  62841. private _createSSAOCombinePostProcess;
  62842. private _createRandomTexture;
  62843. /**
  62844. * Serialize the rendering pipeline (Used when exporting)
  62845. * @returns the serialized object
  62846. */
  62847. serialize(): any;
  62848. /**
  62849. * Parse the serialized pipeline
  62850. * @param source Source pipeline.
  62851. * @param scene The scene to load the pipeline to.
  62852. * @param rootUrl The URL of the serialized pipeline.
  62853. * @returns An instantiated pipeline from the serialized object.
  62854. */
  62855. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  62856. }
  62857. }
  62858. declare module "babylonjs/Shaders/ssao.fragment" {
  62859. /** @hidden */
  62860. export var ssaoPixelShader: {
  62861. name: string;
  62862. shader: string;
  62863. };
  62864. }
  62865. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  62866. import { Camera } from "babylonjs/Cameras/camera";
  62867. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62868. import { Scene } from "babylonjs/scene";
  62869. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  62870. import "babylonjs/Shaders/ssao.fragment";
  62871. import "babylonjs/Shaders/ssaoCombine.fragment";
  62872. /**
  62873. * Render pipeline to produce ssao effect
  62874. */
  62875. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  62876. /**
  62877. * @ignore
  62878. * The PassPostProcess id in the pipeline that contains the original scene color
  62879. */
  62880. SSAOOriginalSceneColorEffect: string;
  62881. /**
  62882. * @ignore
  62883. * The SSAO PostProcess id in the pipeline
  62884. */
  62885. SSAORenderEffect: string;
  62886. /**
  62887. * @ignore
  62888. * The horizontal blur PostProcess id in the pipeline
  62889. */
  62890. SSAOBlurHRenderEffect: string;
  62891. /**
  62892. * @ignore
  62893. * The vertical blur PostProcess id in the pipeline
  62894. */
  62895. SSAOBlurVRenderEffect: string;
  62896. /**
  62897. * @ignore
  62898. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  62899. */
  62900. SSAOCombineRenderEffect: string;
  62901. /**
  62902. * The output strength of the SSAO post-process. Default value is 1.0.
  62903. */
  62904. totalStrength: number;
  62905. /**
  62906. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  62907. */
  62908. radius: number;
  62909. /**
  62910. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  62911. * Must not be equal to fallOff and superior to fallOff.
  62912. * Default value is 0.0075
  62913. */
  62914. area: number;
  62915. /**
  62916. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  62917. * Must not be equal to area and inferior to area.
  62918. * Default value is 0.000001
  62919. */
  62920. fallOff: number;
  62921. /**
  62922. * The base color of the SSAO post-process
  62923. * The final result is "base + ssao" between [0, 1]
  62924. */
  62925. base: number;
  62926. private _scene;
  62927. private _depthTexture;
  62928. private _randomTexture;
  62929. private _originalColorPostProcess;
  62930. private _ssaoPostProcess;
  62931. private _blurHPostProcess;
  62932. private _blurVPostProcess;
  62933. private _ssaoCombinePostProcess;
  62934. private _firstUpdate;
  62935. /**
  62936. * Gets active scene
  62937. */
  62938. readonly scene: Scene;
  62939. /**
  62940. * @constructor
  62941. * @param name - The rendering pipeline name
  62942. * @param scene - The scene linked to this pipeline
  62943. * @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 }
  62944. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  62945. */
  62946. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  62947. /**
  62948. * Get the class name
  62949. * @returns "SSAORenderingPipeline"
  62950. */
  62951. getClassName(): string;
  62952. /**
  62953. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  62954. */
  62955. dispose(disableDepthRender?: boolean): void;
  62956. private _createBlurPostProcess;
  62957. /** @hidden */
  62958. _rebuild(): void;
  62959. private _createSSAOPostProcess;
  62960. private _createSSAOCombinePostProcess;
  62961. private _createRandomTexture;
  62962. }
  62963. }
  62964. declare module "babylonjs/Shaders/standard.fragment" {
  62965. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  62966. /** @hidden */
  62967. export var standardPixelShader: {
  62968. name: string;
  62969. shader: string;
  62970. };
  62971. }
  62972. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  62973. import { Nullable } from "babylonjs/types";
  62974. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  62975. import { Camera } from "babylonjs/Cameras/camera";
  62976. import { Texture } from "babylonjs/Materials/Textures/texture";
  62977. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62978. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62979. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  62980. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  62981. import { IDisposable } from "babylonjs/scene";
  62982. import { SpotLight } from "babylonjs/Lights/spotLight";
  62983. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  62984. import { Scene } from "babylonjs/scene";
  62985. import { Animation } from "babylonjs/Animations/animation";
  62986. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  62987. import "babylonjs/Shaders/standard.fragment";
  62988. /**
  62989. * Standard rendering pipeline
  62990. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  62991. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  62992. */
  62993. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  62994. /**
  62995. * Public members
  62996. */
  62997. /**
  62998. * Post-process which contains the original scene color before the pipeline applies all the effects
  62999. */
  63000. originalPostProcess: Nullable<PostProcess>;
  63001. /**
  63002. * Post-process used to down scale an image x4
  63003. */
  63004. downSampleX4PostProcess: Nullable<PostProcess>;
  63005. /**
  63006. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  63007. */
  63008. brightPassPostProcess: Nullable<PostProcess>;
  63009. /**
  63010. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  63011. */
  63012. blurHPostProcesses: PostProcess[];
  63013. /**
  63014. * Post-process array storing all the vertical blur post-processes used by the pipeline
  63015. */
  63016. blurVPostProcesses: PostProcess[];
  63017. /**
  63018. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  63019. */
  63020. textureAdderPostProcess: Nullable<PostProcess>;
  63021. /**
  63022. * Post-process used to create volumetric lighting effect
  63023. */
  63024. volumetricLightPostProcess: Nullable<PostProcess>;
  63025. /**
  63026. * Post-process used to smooth the previous volumetric light post-process on the X axis
  63027. */
  63028. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  63029. /**
  63030. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  63031. */
  63032. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  63033. /**
  63034. * Post-process used to merge the volumetric light effect and the real scene color
  63035. */
  63036. volumetricLightMergePostProces: Nullable<PostProcess>;
  63037. /**
  63038. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  63039. */
  63040. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  63041. /**
  63042. * Base post-process used to calculate the average luminance of the final image for HDR
  63043. */
  63044. luminancePostProcess: Nullable<PostProcess>;
  63045. /**
  63046. * Post-processes used to create down sample post-processes in order to get
  63047. * the average luminance of the final image for HDR
  63048. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  63049. */
  63050. luminanceDownSamplePostProcesses: PostProcess[];
  63051. /**
  63052. * Post-process used to create a HDR effect (light adaptation)
  63053. */
  63054. hdrPostProcess: Nullable<PostProcess>;
  63055. /**
  63056. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  63057. */
  63058. textureAdderFinalPostProcess: Nullable<PostProcess>;
  63059. /**
  63060. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  63061. */
  63062. lensFlareFinalPostProcess: Nullable<PostProcess>;
  63063. /**
  63064. * Post-process used to merge the final HDR post-process and the real scene color
  63065. */
  63066. hdrFinalPostProcess: Nullable<PostProcess>;
  63067. /**
  63068. * Post-process used to create a lens flare effect
  63069. */
  63070. lensFlarePostProcess: Nullable<PostProcess>;
  63071. /**
  63072. * Post-process that merges the result of the lens flare post-process and the real scene color
  63073. */
  63074. lensFlareComposePostProcess: Nullable<PostProcess>;
  63075. /**
  63076. * Post-process used to create a motion blur effect
  63077. */
  63078. motionBlurPostProcess: Nullable<PostProcess>;
  63079. /**
  63080. * Post-process used to create a depth of field effect
  63081. */
  63082. depthOfFieldPostProcess: Nullable<PostProcess>;
  63083. /**
  63084. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  63085. */
  63086. fxaaPostProcess: Nullable<FxaaPostProcess>;
  63087. /**
  63088. * Represents the brightness threshold in order to configure the illuminated surfaces
  63089. */
  63090. brightThreshold: number;
  63091. /**
  63092. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  63093. */
  63094. blurWidth: number;
  63095. /**
  63096. * Sets if the blur for highlighted surfaces must be only horizontal
  63097. */
  63098. horizontalBlur: boolean;
  63099. /**
  63100. * Gets the overall exposure used by the pipeline
  63101. */
  63102. /**
  63103. * Sets the overall exposure used by the pipeline
  63104. */
  63105. exposure: number;
  63106. /**
  63107. * Texture used typically to simulate "dirty" on camera lens
  63108. */
  63109. lensTexture: Nullable<Texture>;
  63110. /**
  63111. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  63112. */
  63113. volumetricLightCoefficient: number;
  63114. /**
  63115. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  63116. */
  63117. volumetricLightPower: number;
  63118. /**
  63119. * Used the set the blur intensity to smooth the volumetric lights
  63120. */
  63121. volumetricLightBlurScale: number;
  63122. /**
  63123. * Light (spot or directional) used to generate the volumetric lights rays
  63124. * The source light must have a shadow generate so the pipeline can get its
  63125. * depth map
  63126. */
  63127. sourceLight: Nullable<SpotLight | DirectionalLight>;
  63128. /**
  63129. * For eye adaptation, represents the minimum luminance the eye can see
  63130. */
  63131. hdrMinimumLuminance: number;
  63132. /**
  63133. * For eye adaptation, represents the decrease luminance speed
  63134. */
  63135. hdrDecreaseRate: number;
  63136. /**
  63137. * For eye adaptation, represents the increase luminance speed
  63138. */
  63139. hdrIncreaseRate: number;
  63140. /**
  63141. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  63142. */
  63143. /**
  63144. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  63145. */
  63146. hdrAutoExposure: boolean;
  63147. /**
  63148. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  63149. */
  63150. lensColorTexture: Nullable<Texture>;
  63151. /**
  63152. * The overall strengh for the lens flare effect
  63153. */
  63154. lensFlareStrength: number;
  63155. /**
  63156. * Dispersion coefficient for lens flare ghosts
  63157. */
  63158. lensFlareGhostDispersal: number;
  63159. /**
  63160. * Main lens flare halo width
  63161. */
  63162. lensFlareHaloWidth: number;
  63163. /**
  63164. * Based on the lens distortion effect, defines how much the lens flare result
  63165. * is distorted
  63166. */
  63167. lensFlareDistortionStrength: number;
  63168. /**
  63169. * Configures the blur intensity used for for lens flare (halo)
  63170. */
  63171. lensFlareBlurWidth: number;
  63172. /**
  63173. * Lens star texture must be used to simulate rays on the flares and is available
  63174. * in the documentation
  63175. */
  63176. lensStarTexture: Nullable<Texture>;
  63177. /**
  63178. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  63179. * flare effect by taking account of the dirt texture
  63180. */
  63181. lensFlareDirtTexture: Nullable<Texture>;
  63182. /**
  63183. * Represents the focal length for the depth of field effect
  63184. */
  63185. depthOfFieldDistance: number;
  63186. /**
  63187. * Represents the blur intensity for the blurred part of the depth of field effect
  63188. */
  63189. depthOfFieldBlurWidth: number;
  63190. /**
  63191. * Gets how much the image is blurred by the movement while using the motion blur post-process
  63192. */
  63193. /**
  63194. * Sets how much the image is blurred by the movement while using the motion blur post-process
  63195. */
  63196. motionStrength: number;
  63197. /**
  63198. * Gets wether or not the motion blur post-process is object based or screen based.
  63199. */
  63200. /**
  63201. * Sets wether or not the motion blur post-process should be object based or screen based
  63202. */
  63203. objectBasedMotionBlur: boolean;
  63204. /**
  63205. * List of animations for the pipeline (IAnimatable implementation)
  63206. */
  63207. animations: Animation[];
  63208. /**
  63209. * Private members
  63210. */
  63211. private _scene;
  63212. private _currentDepthOfFieldSource;
  63213. private _basePostProcess;
  63214. private _fixedExposure;
  63215. private _currentExposure;
  63216. private _hdrAutoExposure;
  63217. private _hdrCurrentLuminance;
  63218. private _motionStrength;
  63219. private _isObjectBasedMotionBlur;
  63220. private _floatTextureType;
  63221. private _camerasToBeAttached;
  63222. private _ratio;
  63223. private _bloomEnabled;
  63224. private _depthOfFieldEnabled;
  63225. private _vlsEnabled;
  63226. private _lensFlareEnabled;
  63227. private _hdrEnabled;
  63228. private _motionBlurEnabled;
  63229. private _fxaaEnabled;
  63230. private _motionBlurSamples;
  63231. private _volumetricLightStepsCount;
  63232. private _samples;
  63233. /**
  63234. * @ignore
  63235. * Specifies if the bloom pipeline is enabled
  63236. */
  63237. BloomEnabled: boolean;
  63238. /**
  63239. * @ignore
  63240. * Specifies if the depth of field pipeline is enabed
  63241. */
  63242. DepthOfFieldEnabled: boolean;
  63243. /**
  63244. * @ignore
  63245. * Specifies if the lens flare pipeline is enabed
  63246. */
  63247. LensFlareEnabled: boolean;
  63248. /**
  63249. * @ignore
  63250. * Specifies if the HDR pipeline is enabled
  63251. */
  63252. HDREnabled: boolean;
  63253. /**
  63254. * @ignore
  63255. * Specifies if the volumetric lights scattering effect is enabled
  63256. */
  63257. VLSEnabled: boolean;
  63258. /**
  63259. * @ignore
  63260. * Specifies if the motion blur effect is enabled
  63261. */
  63262. MotionBlurEnabled: boolean;
  63263. /**
  63264. * Specifies if anti-aliasing is enabled
  63265. */
  63266. fxaaEnabled: boolean;
  63267. /**
  63268. * Specifies the number of steps used to calculate the volumetric lights
  63269. * Typically in interval [50, 200]
  63270. */
  63271. volumetricLightStepsCount: number;
  63272. /**
  63273. * Specifies the number of samples used for the motion blur effect
  63274. * Typically in interval [16, 64]
  63275. */
  63276. motionBlurSamples: number;
  63277. /**
  63278. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  63279. */
  63280. samples: number;
  63281. /**
  63282. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  63283. * @constructor
  63284. * @param name The rendering pipeline name
  63285. * @param scene The scene linked to this pipeline
  63286. * @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)
  63287. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  63288. * @param cameras The array of cameras that the rendering pipeline will be attached to
  63289. */
  63290. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  63291. private _buildPipeline;
  63292. private _createDownSampleX4PostProcess;
  63293. private _createBrightPassPostProcess;
  63294. private _createBlurPostProcesses;
  63295. private _createTextureAdderPostProcess;
  63296. private _createVolumetricLightPostProcess;
  63297. private _createLuminancePostProcesses;
  63298. private _createHdrPostProcess;
  63299. private _createLensFlarePostProcess;
  63300. private _createDepthOfFieldPostProcess;
  63301. private _createMotionBlurPostProcess;
  63302. private _getDepthTexture;
  63303. private _disposePostProcesses;
  63304. /**
  63305. * Dispose of the pipeline and stop all post processes
  63306. */
  63307. dispose(): void;
  63308. /**
  63309. * Serialize the rendering pipeline (Used when exporting)
  63310. * @returns the serialized object
  63311. */
  63312. serialize(): any;
  63313. /**
  63314. * Parse the serialized pipeline
  63315. * @param source Source pipeline.
  63316. * @param scene The scene to load the pipeline to.
  63317. * @param rootUrl The URL of the serialized pipeline.
  63318. * @returns An instantiated pipeline from the serialized object.
  63319. */
  63320. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  63321. /**
  63322. * Luminance steps
  63323. */
  63324. static LuminanceSteps: number;
  63325. }
  63326. }
  63327. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  63328. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  63329. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  63330. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  63331. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  63332. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  63333. }
  63334. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  63335. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  63336. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  63337. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63338. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  63339. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63340. }
  63341. declare module "babylonjs/Shaders/tonemap.fragment" {
  63342. /** @hidden */
  63343. export var tonemapPixelShader: {
  63344. name: string;
  63345. shader: string;
  63346. };
  63347. }
  63348. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  63349. import { Camera } from "babylonjs/Cameras/camera";
  63350. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63351. import "babylonjs/Shaders/tonemap.fragment";
  63352. import { Engine } from "babylonjs/Engines/engine";
  63353. /** Defines operator used for tonemapping */
  63354. export enum TonemappingOperator {
  63355. /** Hable */
  63356. Hable = 0,
  63357. /** Reinhard */
  63358. Reinhard = 1,
  63359. /** HejiDawson */
  63360. HejiDawson = 2,
  63361. /** Photographic */
  63362. Photographic = 3
  63363. }
  63364. /**
  63365. * Defines a post process to apply tone mapping
  63366. */
  63367. export class TonemapPostProcess extends PostProcess {
  63368. private _operator;
  63369. /** Defines the required exposure adjustement */
  63370. exposureAdjustment: number;
  63371. /**
  63372. * Creates a new TonemapPostProcess
  63373. * @param name defines the name of the postprocess
  63374. * @param _operator defines the operator to use
  63375. * @param exposureAdjustment defines the required exposure adjustement
  63376. * @param camera defines the camera to use (can be null)
  63377. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  63378. * @param engine defines the hosting engine (can be ignore if camera is set)
  63379. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  63380. */
  63381. constructor(name: string, _operator: TonemappingOperator,
  63382. /** Defines the required exposure adjustement */
  63383. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  63384. }
  63385. }
  63386. declare module "babylonjs/Shaders/depth.vertex" {
  63387. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63388. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63389. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63390. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63391. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63392. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63393. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63394. /** @hidden */
  63395. export var depthVertexShader: {
  63396. name: string;
  63397. shader: string;
  63398. };
  63399. }
  63400. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  63401. /** @hidden */
  63402. export var volumetricLightScatteringPixelShader: {
  63403. name: string;
  63404. shader: string;
  63405. };
  63406. }
  63407. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  63408. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63409. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63410. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63411. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63412. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63413. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63414. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63415. /** @hidden */
  63416. export var volumetricLightScatteringPassVertexShader: {
  63417. name: string;
  63418. shader: string;
  63419. };
  63420. }
  63421. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  63422. /** @hidden */
  63423. export var volumetricLightScatteringPassPixelShader: {
  63424. name: string;
  63425. shader: string;
  63426. };
  63427. }
  63428. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  63429. import { Vector3 } from "babylonjs/Maths/math.vector";
  63430. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63431. import { Mesh } from "babylonjs/Meshes/mesh";
  63432. import { Camera } from "babylonjs/Cameras/camera";
  63433. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63434. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63435. import { Scene } from "babylonjs/scene";
  63436. import "babylonjs/Meshes/Builders/planeBuilder";
  63437. import "babylonjs/Shaders/depth.vertex";
  63438. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  63439. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  63440. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  63441. import { Engine } from "babylonjs/Engines/engine";
  63442. /**
  63443. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  63444. */
  63445. export class VolumetricLightScatteringPostProcess extends PostProcess {
  63446. private _volumetricLightScatteringPass;
  63447. private _volumetricLightScatteringRTT;
  63448. private _viewPort;
  63449. private _screenCoordinates;
  63450. private _cachedDefines;
  63451. /**
  63452. * If not undefined, the mesh position is computed from the attached node position
  63453. */
  63454. attachedNode: {
  63455. position: Vector3;
  63456. };
  63457. /**
  63458. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  63459. */
  63460. customMeshPosition: Vector3;
  63461. /**
  63462. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  63463. */
  63464. useCustomMeshPosition: boolean;
  63465. /**
  63466. * If the post-process should inverse the light scattering direction
  63467. */
  63468. invert: boolean;
  63469. /**
  63470. * The internal mesh used by the post-process
  63471. */
  63472. mesh: Mesh;
  63473. /**
  63474. * @hidden
  63475. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  63476. */
  63477. useDiffuseColor: boolean;
  63478. /**
  63479. * Array containing the excluded meshes not rendered in the internal pass
  63480. */
  63481. excludedMeshes: AbstractMesh[];
  63482. /**
  63483. * Controls the overall intensity of the post-process
  63484. */
  63485. exposure: number;
  63486. /**
  63487. * Dissipates each sample's contribution in range [0, 1]
  63488. */
  63489. decay: number;
  63490. /**
  63491. * Controls the overall intensity of each sample
  63492. */
  63493. weight: number;
  63494. /**
  63495. * Controls the density of each sample
  63496. */
  63497. density: number;
  63498. /**
  63499. * @constructor
  63500. * @param name The post-process name
  63501. * @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)
  63502. * @param camera The camera that the post-process will be attached to
  63503. * @param mesh The mesh used to create the light scattering
  63504. * @param samples The post-process quality, default 100
  63505. * @param samplingModeThe post-process filtering mode
  63506. * @param engine The babylon engine
  63507. * @param reusable If the post-process is reusable
  63508. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  63509. */
  63510. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  63511. /**
  63512. * Returns the string "VolumetricLightScatteringPostProcess"
  63513. * @returns "VolumetricLightScatteringPostProcess"
  63514. */
  63515. getClassName(): string;
  63516. private _isReady;
  63517. /**
  63518. * Sets the new light position for light scattering effect
  63519. * @param position The new custom light position
  63520. */
  63521. setCustomMeshPosition(position: Vector3): void;
  63522. /**
  63523. * Returns the light position for light scattering effect
  63524. * @return Vector3 The custom light position
  63525. */
  63526. getCustomMeshPosition(): Vector3;
  63527. /**
  63528. * Disposes the internal assets and detaches the post-process from the camera
  63529. */
  63530. dispose(camera: Camera): void;
  63531. /**
  63532. * Returns the render target texture used by the post-process
  63533. * @return the render target texture used by the post-process
  63534. */
  63535. getPass(): RenderTargetTexture;
  63536. private _meshExcluded;
  63537. private _createPass;
  63538. private _updateMeshScreenCoordinates;
  63539. /**
  63540. * Creates a default mesh for the Volumeric Light Scattering post-process
  63541. * @param name The mesh name
  63542. * @param scene The scene where to create the mesh
  63543. * @return the default mesh
  63544. */
  63545. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  63546. }
  63547. }
  63548. declare module "babylonjs/PostProcesses/index" {
  63549. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  63550. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  63551. export * from "babylonjs/PostProcesses/bloomEffect";
  63552. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  63553. export * from "babylonjs/PostProcesses/blurPostProcess";
  63554. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  63555. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  63556. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  63557. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  63558. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  63559. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  63560. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  63561. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  63562. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  63563. export * from "babylonjs/PostProcesses/filterPostProcess";
  63564. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  63565. export * from "babylonjs/PostProcesses/grainPostProcess";
  63566. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  63567. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  63568. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  63569. export * from "babylonjs/PostProcesses/passPostProcess";
  63570. export * from "babylonjs/PostProcesses/postProcess";
  63571. export * from "babylonjs/PostProcesses/postProcessManager";
  63572. export * from "babylonjs/PostProcesses/refractionPostProcess";
  63573. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  63574. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  63575. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  63576. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  63577. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  63578. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  63579. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  63580. }
  63581. declare module "babylonjs/Probes/index" {
  63582. export * from "babylonjs/Probes/reflectionProbe";
  63583. }
  63584. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  63585. import { Scene } from "babylonjs/scene";
  63586. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63587. import { SmartArray } from "babylonjs/Misc/smartArray";
  63588. import { ISceneComponent } from "babylonjs/sceneComponent";
  63589. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  63590. import "babylonjs/Meshes/Builders/boxBuilder";
  63591. import "babylonjs/Shaders/color.fragment";
  63592. import "babylonjs/Shaders/color.vertex";
  63593. import { Color3 } from "babylonjs/Maths/math.color";
  63594. module "babylonjs/scene" {
  63595. interface Scene {
  63596. /** @hidden (Backing field) */
  63597. _boundingBoxRenderer: BoundingBoxRenderer;
  63598. /** @hidden (Backing field) */
  63599. _forceShowBoundingBoxes: boolean;
  63600. /**
  63601. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  63602. */
  63603. forceShowBoundingBoxes: boolean;
  63604. /**
  63605. * Gets the bounding box renderer associated with the scene
  63606. * @returns a BoundingBoxRenderer
  63607. */
  63608. getBoundingBoxRenderer(): BoundingBoxRenderer;
  63609. }
  63610. }
  63611. module "babylonjs/Meshes/abstractMesh" {
  63612. interface AbstractMesh {
  63613. /** @hidden (Backing field) */
  63614. _showBoundingBox: boolean;
  63615. /**
  63616. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  63617. */
  63618. showBoundingBox: boolean;
  63619. }
  63620. }
  63621. /**
  63622. * Component responsible of rendering the bounding box of the meshes in a scene.
  63623. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  63624. */
  63625. export class BoundingBoxRenderer implements ISceneComponent {
  63626. /**
  63627. * The component name helpfull to identify the component in the list of scene components.
  63628. */
  63629. readonly name: string;
  63630. /**
  63631. * The scene the component belongs to.
  63632. */
  63633. scene: Scene;
  63634. /**
  63635. * Color of the bounding box lines placed in front of an object
  63636. */
  63637. frontColor: Color3;
  63638. /**
  63639. * Color of the bounding box lines placed behind an object
  63640. */
  63641. backColor: Color3;
  63642. /**
  63643. * Defines if the renderer should show the back lines or not
  63644. */
  63645. showBackLines: boolean;
  63646. /**
  63647. * @hidden
  63648. */
  63649. renderList: SmartArray<BoundingBox>;
  63650. private _colorShader;
  63651. private _vertexBuffers;
  63652. private _indexBuffer;
  63653. private _fillIndexBuffer;
  63654. private _fillIndexData;
  63655. /**
  63656. * Instantiates a new bounding box renderer in a scene.
  63657. * @param scene the scene the renderer renders in
  63658. */
  63659. constructor(scene: Scene);
  63660. /**
  63661. * Registers the component in a given scene
  63662. */
  63663. register(): void;
  63664. private _evaluateSubMesh;
  63665. private _activeMesh;
  63666. private _prepareRessources;
  63667. private _createIndexBuffer;
  63668. /**
  63669. * Rebuilds the elements related to this component in case of
  63670. * context lost for instance.
  63671. */
  63672. rebuild(): void;
  63673. /**
  63674. * @hidden
  63675. */
  63676. reset(): void;
  63677. /**
  63678. * Render the bounding boxes of a specific rendering group
  63679. * @param renderingGroupId defines the rendering group to render
  63680. */
  63681. render(renderingGroupId: number): void;
  63682. /**
  63683. * In case of occlusion queries, we can render the occlusion bounding box through this method
  63684. * @param mesh Define the mesh to render the occlusion bounding box for
  63685. */
  63686. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  63687. /**
  63688. * Dispose and release the resources attached to this renderer.
  63689. */
  63690. dispose(): void;
  63691. }
  63692. }
  63693. declare module "babylonjs/Shaders/depth.fragment" {
  63694. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  63695. /** @hidden */
  63696. export var depthPixelShader: {
  63697. name: string;
  63698. shader: string;
  63699. };
  63700. }
  63701. declare module "babylonjs/Rendering/depthRenderer" {
  63702. import { Nullable } from "babylonjs/types";
  63703. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63704. import { Scene } from "babylonjs/scene";
  63705. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63706. import { Camera } from "babylonjs/Cameras/camera";
  63707. import "babylonjs/Shaders/depth.fragment";
  63708. import "babylonjs/Shaders/depth.vertex";
  63709. /**
  63710. * This represents a depth renderer in Babylon.
  63711. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  63712. */
  63713. export class DepthRenderer {
  63714. private _scene;
  63715. private _depthMap;
  63716. private _effect;
  63717. private readonly _storeNonLinearDepth;
  63718. private readonly _clearColor;
  63719. /** Get if the depth renderer is using packed depth or not */
  63720. readonly isPacked: boolean;
  63721. private _cachedDefines;
  63722. private _camera;
  63723. /**
  63724. * Specifiess that the depth renderer will only be used within
  63725. * the camera it is created for.
  63726. * This can help forcing its rendering during the camera processing.
  63727. */
  63728. useOnlyInActiveCamera: boolean;
  63729. /** @hidden */
  63730. static _SceneComponentInitialization: (scene: Scene) => void;
  63731. /**
  63732. * Instantiates a depth renderer
  63733. * @param scene The scene the renderer belongs to
  63734. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  63735. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  63736. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  63737. */
  63738. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  63739. /**
  63740. * Creates the depth rendering effect and checks if the effect is ready.
  63741. * @param subMesh The submesh to be used to render the depth map of
  63742. * @param useInstances If multiple world instances should be used
  63743. * @returns if the depth renderer is ready to render the depth map
  63744. */
  63745. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63746. /**
  63747. * Gets the texture which the depth map will be written to.
  63748. * @returns The depth map texture
  63749. */
  63750. getDepthMap(): RenderTargetTexture;
  63751. /**
  63752. * Disposes of the depth renderer.
  63753. */
  63754. dispose(): void;
  63755. }
  63756. }
  63757. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  63758. import { Nullable } from "babylonjs/types";
  63759. import { Scene } from "babylonjs/scene";
  63760. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  63761. import { Camera } from "babylonjs/Cameras/camera";
  63762. import { ISceneComponent } from "babylonjs/sceneComponent";
  63763. module "babylonjs/scene" {
  63764. interface Scene {
  63765. /** @hidden (Backing field) */
  63766. _depthRenderer: {
  63767. [id: string]: DepthRenderer;
  63768. };
  63769. /**
  63770. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  63771. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  63772. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  63773. * @returns the created depth renderer
  63774. */
  63775. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  63776. /**
  63777. * Disables a depth renderer for a given camera
  63778. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  63779. */
  63780. disableDepthRenderer(camera?: Nullable<Camera>): void;
  63781. }
  63782. }
  63783. /**
  63784. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  63785. * in several rendering techniques.
  63786. */
  63787. export class DepthRendererSceneComponent implements ISceneComponent {
  63788. /**
  63789. * The component name helpfull to identify the component in the list of scene components.
  63790. */
  63791. readonly name: string;
  63792. /**
  63793. * The scene the component belongs to.
  63794. */
  63795. scene: Scene;
  63796. /**
  63797. * Creates a new instance of the component for the given scene
  63798. * @param scene Defines the scene to register the component in
  63799. */
  63800. constructor(scene: Scene);
  63801. /**
  63802. * Registers the component in a given scene
  63803. */
  63804. register(): void;
  63805. /**
  63806. * Rebuilds the elements related to this component in case of
  63807. * context lost for instance.
  63808. */
  63809. rebuild(): void;
  63810. /**
  63811. * Disposes the component and the associated ressources
  63812. */
  63813. dispose(): void;
  63814. private _gatherRenderTargets;
  63815. private _gatherActiveCameraRenderTargets;
  63816. }
  63817. }
  63818. declare module "babylonjs/Shaders/outline.fragment" {
  63819. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  63820. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  63821. /** @hidden */
  63822. export var outlinePixelShader: {
  63823. name: string;
  63824. shader: string;
  63825. };
  63826. }
  63827. declare module "babylonjs/Shaders/outline.vertex" {
  63828. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63829. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63830. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63831. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63832. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  63833. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63834. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63835. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63836. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  63837. /** @hidden */
  63838. export var outlineVertexShader: {
  63839. name: string;
  63840. shader: string;
  63841. };
  63842. }
  63843. declare module "babylonjs/Rendering/outlineRenderer" {
  63844. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63845. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  63846. import { Scene } from "babylonjs/scene";
  63847. import { ISceneComponent } from "babylonjs/sceneComponent";
  63848. import "babylonjs/Shaders/outline.fragment";
  63849. import "babylonjs/Shaders/outline.vertex";
  63850. module "babylonjs/scene" {
  63851. interface Scene {
  63852. /** @hidden */
  63853. _outlineRenderer: OutlineRenderer;
  63854. /**
  63855. * Gets the outline renderer associated with the scene
  63856. * @returns a OutlineRenderer
  63857. */
  63858. getOutlineRenderer(): OutlineRenderer;
  63859. }
  63860. }
  63861. module "babylonjs/Meshes/abstractMesh" {
  63862. interface AbstractMesh {
  63863. /** @hidden (Backing field) */
  63864. _renderOutline: boolean;
  63865. /**
  63866. * Gets or sets a boolean indicating if the outline must be rendered as well
  63867. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  63868. */
  63869. renderOutline: boolean;
  63870. /** @hidden (Backing field) */
  63871. _renderOverlay: boolean;
  63872. /**
  63873. * Gets or sets a boolean indicating if the overlay must be rendered as well
  63874. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  63875. */
  63876. renderOverlay: boolean;
  63877. }
  63878. }
  63879. /**
  63880. * This class is responsible to draw bothe outline/overlay of meshes.
  63881. * It should not be used directly but through the available method on mesh.
  63882. */
  63883. export class OutlineRenderer implements ISceneComponent {
  63884. /**
  63885. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  63886. */
  63887. private static _StencilReference;
  63888. /**
  63889. * The name of the component. Each component must have a unique name.
  63890. */
  63891. name: string;
  63892. /**
  63893. * The scene the component belongs to.
  63894. */
  63895. scene: Scene;
  63896. /**
  63897. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  63898. */
  63899. zOffset: number;
  63900. private _engine;
  63901. private _effect;
  63902. private _cachedDefines;
  63903. private _savedDepthWrite;
  63904. /**
  63905. * Instantiates a new outline renderer. (There could be only one per scene).
  63906. * @param scene Defines the scene it belongs to
  63907. */
  63908. constructor(scene: Scene);
  63909. /**
  63910. * Register the component to one instance of a scene.
  63911. */
  63912. register(): void;
  63913. /**
  63914. * Rebuilds the elements related to this component in case of
  63915. * context lost for instance.
  63916. */
  63917. rebuild(): void;
  63918. /**
  63919. * Disposes the component and the associated ressources.
  63920. */
  63921. dispose(): void;
  63922. /**
  63923. * Renders the outline in the canvas.
  63924. * @param subMesh Defines the sumesh to render
  63925. * @param batch Defines the batch of meshes in case of instances
  63926. * @param useOverlay Defines if the rendering is for the overlay or the outline
  63927. */
  63928. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  63929. /**
  63930. * Returns whether or not the outline renderer is ready for a given submesh.
  63931. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  63932. * @param subMesh Defines the submesh to check readyness for
  63933. * @param useInstances Defines wheter wee are trying to render instances or not
  63934. * @returns true if ready otherwise false
  63935. */
  63936. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63937. private _beforeRenderingMesh;
  63938. private _afterRenderingMesh;
  63939. }
  63940. }
  63941. declare module "babylonjs/Rendering/index" {
  63942. export * from "babylonjs/Rendering/boundingBoxRenderer";
  63943. export * from "babylonjs/Rendering/depthRenderer";
  63944. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  63945. export * from "babylonjs/Rendering/edgesRenderer";
  63946. export * from "babylonjs/Rendering/geometryBufferRenderer";
  63947. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  63948. export * from "babylonjs/Rendering/outlineRenderer";
  63949. export * from "babylonjs/Rendering/renderingGroup";
  63950. export * from "babylonjs/Rendering/renderingManager";
  63951. export * from "babylonjs/Rendering/utilityLayerRenderer";
  63952. }
  63953. declare module "babylonjs/Sprites/spritePackedManager" {
  63954. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  63955. import { Scene } from "babylonjs/scene";
  63956. /**
  63957. * Class used to manage multiple sprites of different sizes on the same spritesheet
  63958. * @see http://doc.babylonjs.com/babylon101/sprites
  63959. */
  63960. export class SpritePackedManager extends SpriteManager {
  63961. /** defines the packed manager's name */
  63962. name: string;
  63963. /**
  63964. * Creates a new sprite manager from a packed sprite sheet
  63965. * @param name defines the manager's name
  63966. * @param imgUrl defines the sprite sheet url
  63967. * @param capacity defines the maximum allowed number of sprites
  63968. * @param scene defines the hosting scene
  63969. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  63970. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  63971. * @param samplingMode defines the smapling mode to use with spritesheet
  63972. * @param fromPacked set to true; do not alter
  63973. */
  63974. constructor(
  63975. /** defines the packed manager's name */
  63976. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  63977. }
  63978. }
  63979. declare module "babylonjs/Sprites/index" {
  63980. export * from "babylonjs/Sprites/sprite";
  63981. export * from "babylonjs/Sprites/spriteManager";
  63982. export * from "babylonjs/Sprites/spritePackedManager";
  63983. export * from "babylonjs/Sprites/spriteSceneComponent";
  63984. }
  63985. declare module "babylonjs/Misc/assetsManager" {
  63986. import { Scene } from "babylonjs/scene";
  63987. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63988. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  63989. import { Skeleton } from "babylonjs/Bones/skeleton";
  63990. import { Observable } from "babylonjs/Misc/observable";
  63991. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63992. import { Texture } from "babylonjs/Materials/Textures/texture";
  63993. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  63994. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  63995. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  63996. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  63997. /**
  63998. * Defines the list of states available for a task inside a AssetsManager
  63999. */
  64000. export enum AssetTaskState {
  64001. /**
  64002. * Initialization
  64003. */
  64004. INIT = 0,
  64005. /**
  64006. * Running
  64007. */
  64008. RUNNING = 1,
  64009. /**
  64010. * Done
  64011. */
  64012. DONE = 2,
  64013. /**
  64014. * Error
  64015. */
  64016. ERROR = 3
  64017. }
  64018. /**
  64019. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  64020. */
  64021. export abstract class AbstractAssetTask {
  64022. /**
  64023. * Task name
  64024. */ name: string;
  64025. /**
  64026. * Callback called when the task is successful
  64027. */
  64028. onSuccess: (task: any) => void;
  64029. /**
  64030. * Callback called when the task is not successful
  64031. */
  64032. onError: (task: any, message?: string, exception?: any) => void;
  64033. /**
  64034. * Creates a new AssetsManager
  64035. * @param name defines the name of the task
  64036. */
  64037. constructor(
  64038. /**
  64039. * Task name
  64040. */ name: string);
  64041. private _isCompleted;
  64042. private _taskState;
  64043. private _errorObject;
  64044. /**
  64045. * Get if the task is completed
  64046. */
  64047. readonly isCompleted: boolean;
  64048. /**
  64049. * Gets the current state of the task
  64050. */
  64051. readonly taskState: AssetTaskState;
  64052. /**
  64053. * Gets the current error object (if task is in error)
  64054. */
  64055. readonly errorObject: {
  64056. message?: string;
  64057. exception?: any;
  64058. };
  64059. /**
  64060. * Internal only
  64061. * @hidden
  64062. */
  64063. _setErrorObject(message?: string, exception?: any): void;
  64064. /**
  64065. * Execute the current task
  64066. * @param scene defines the scene where you want your assets to be loaded
  64067. * @param onSuccess is a callback called when the task is successfully executed
  64068. * @param onError is a callback called if an error occurs
  64069. */
  64070. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64071. /**
  64072. * Execute the current task
  64073. * @param scene defines the scene where you want your assets to be loaded
  64074. * @param onSuccess is a callback called when the task is successfully executed
  64075. * @param onError is a callback called if an error occurs
  64076. */
  64077. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64078. /**
  64079. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  64080. * This can be used with failed tasks that have the reason for failure fixed.
  64081. */
  64082. reset(): void;
  64083. private onErrorCallback;
  64084. private onDoneCallback;
  64085. }
  64086. /**
  64087. * Define the interface used by progress events raised during assets loading
  64088. */
  64089. export interface IAssetsProgressEvent {
  64090. /**
  64091. * Defines the number of remaining tasks to process
  64092. */
  64093. remainingCount: number;
  64094. /**
  64095. * Defines the total number of tasks
  64096. */
  64097. totalCount: number;
  64098. /**
  64099. * Defines the task that was just processed
  64100. */
  64101. task: AbstractAssetTask;
  64102. }
  64103. /**
  64104. * Class used to share progress information about assets loading
  64105. */
  64106. export class AssetsProgressEvent implements IAssetsProgressEvent {
  64107. /**
  64108. * Defines the number of remaining tasks to process
  64109. */
  64110. remainingCount: number;
  64111. /**
  64112. * Defines the total number of tasks
  64113. */
  64114. totalCount: number;
  64115. /**
  64116. * Defines the task that was just processed
  64117. */
  64118. task: AbstractAssetTask;
  64119. /**
  64120. * Creates a AssetsProgressEvent
  64121. * @param remainingCount defines the number of remaining tasks to process
  64122. * @param totalCount defines the total number of tasks
  64123. * @param task defines the task that was just processed
  64124. */
  64125. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  64126. }
  64127. /**
  64128. * Define a task used by AssetsManager to load meshes
  64129. */
  64130. export class MeshAssetTask extends AbstractAssetTask {
  64131. /**
  64132. * Defines the name of the task
  64133. */
  64134. name: string;
  64135. /**
  64136. * Defines the list of mesh's names you want to load
  64137. */
  64138. meshesNames: any;
  64139. /**
  64140. * Defines the root url to use as a base to load your meshes and associated resources
  64141. */
  64142. rootUrl: string;
  64143. /**
  64144. * Defines the filename of the scene to load from
  64145. */
  64146. sceneFilename: string;
  64147. /**
  64148. * Gets the list of loaded meshes
  64149. */
  64150. loadedMeshes: Array<AbstractMesh>;
  64151. /**
  64152. * Gets the list of loaded particle systems
  64153. */
  64154. loadedParticleSystems: Array<IParticleSystem>;
  64155. /**
  64156. * Gets the list of loaded skeletons
  64157. */
  64158. loadedSkeletons: Array<Skeleton>;
  64159. /**
  64160. * Gets the list of loaded animation groups
  64161. */
  64162. loadedAnimationGroups: Array<AnimationGroup>;
  64163. /**
  64164. * Callback called when the task is successful
  64165. */
  64166. onSuccess: (task: MeshAssetTask) => void;
  64167. /**
  64168. * Callback called when the task is successful
  64169. */
  64170. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  64171. /**
  64172. * Creates a new MeshAssetTask
  64173. * @param name defines the name of the task
  64174. * @param meshesNames defines the list of mesh's names you want to load
  64175. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  64176. * @param sceneFilename defines the filename of the scene to load from
  64177. */
  64178. constructor(
  64179. /**
  64180. * Defines the name of the task
  64181. */
  64182. name: string,
  64183. /**
  64184. * Defines the list of mesh's names you want to load
  64185. */
  64186. meshesNames: any,
  64187. /**
  64188. * Defines the root url to use as a base to load your meshes and associated resources
  64189. */
  64190. rootUrl: string,
  64191. /**
  64192. * Defines the filename of the scene to load from
  64193. */
  64194. sceneFilename: string);
  64195. /**
  64196. * Execute the current task
  64197. * @param scene defines the scene where you want your assets to be loaded
  64198. * @param onSuccess is a callback called when the task is successfully executed
  64199. * @param onError is a callback called if an error occurs
  64200. */
  64201. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64202. }
  64203. /**
  64204. * Define a task used by AssetsManager to load text content
  64205. */
  64206. export class TextFileAssetTask extends AbstractAssetTask {
  64207. /**
  64208. * Defines the name of the task
  64209. */
  64210. name: string;
  64211. /**
  64212. * Defines the location of the file to load
  64213. */
  64214. url: string;
  64215. /**
  64216. * Gets the loaded text string
  64217. */
  64218. text: string;
  64219. /**
  64220. * Callback called when the task is successful
  64221. */
  64222. onSuccess: (task: TextFileAssetTask) => void;
  64223. /**
  64224. * Callback called when the task is successful
  64225. */
  64226. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  64227. /**
  64228. * Creates a new TextFileAssetTask object
  64229. * @param name defines the name of the task
  64230. * @param url defines the location of the file to load
  64231. */
  64232. constructor(
  64233. /**
  64234. * Defines the name of the task
  64235. */
  64236. name: string,
  64237. /**
  64238. * Defines the location of the file to load
  64239. */
  64240. url: string);
  64241. /**
  64242. * Execute the current task
  64243. * @param scene defines the scene where you want your assets to be loaded
  64244. * @param onSuccess is a callback called when the task is successfully executed
  64245. * @param onError is a callback called if an error occurs
  64246. */
  64247. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64248. }
  64249. /**
  64250. * Define a task used by AssetsManager to load binary data
  64251. */
  64252. export class BinaryFileAssetTask extends AbstractAssetTask {
  64253. /**
  64254. * Defines the name of the task
  64255. */
  64256. name: string;
  64257. /**
  64258. * Defines the location of the file to load
  64259. */
  64260. url: string;
  64261. /**
  64262. * Gets the lodaded data (as an array buffer)
  64263. */
  64264. data: ArrayBuffer;
  64265. /**
  64266. * Callback called when the task is successful
  64267. */
  64268. onSuccess: (task: BinaryFileAssetTask) => void;
  64269. /**
  64270. * Callback called when the task is successful
  64271. */
  64272. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  64273. /**
  64274. * Creates a new BinaryFileAssetTask object
  64275. * @param name defines the name of the new task
  64276. * @param url defines the location of the file to load
  64277. */
  64278. constructor(
  64279. /**
  64280. * Defines the name of the task
  64281. */
  64282. name: string,
  64283. /**
  64284. * Defines the location of the file to load
  64285. */
  64286. url: string);
  64287. /**
  64288. * Execute the current task
  64289. * @param scene defines the scene where you want your assets to be loaded
  64290. * @param onSuccess is a callback called when the task is successfully executed
  64291. * @param onError is a callback called if an error occurs
  64292. */
  64293. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64294. }
  64295. /**
  64296. * Define a task used by AssetsManager to load images
  64297. */
  64298. export class ImageAssetTask extends AbstractAssetTask {
  64299. /**
  64300. * Defines the name of the task
  64301. */
  64302. name: string;
  64303. /**
  64304. * Defines the location of the image to load
  64305. */
  64306. url: string;
  64307. /**
  64308. * Gets the loaded images
  64309. */
  64310. image: HTMLImageElement;
  64311. /**
  64312. * Callback called when the task is successful
  64313. */
  64314. onSuccess: (task: ImageAssetTask) => void;
  64315. /**
  64316. * Callback called when the task is successful
  64317. */
  64318. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  64319. /**
  64320. * Creates a new ImageAssetTask
  64321. * @param name defines the name of the task
  64322. * @param url defines the location of the image to load
  64323. */
  64324. constructor(
  64325. /**
  64326. * Defines the name of the task
  64327. */
  64328. name: string,
  64329. /**
  64330. * Defines the location of the image to load
  64331. */
  64332. url: string);
  64333. /**
  64334. * Execute the current task
  64335. * @param scene defines the scene where you want your assets to be loaded
  64336. * @param onSuccess is a callback called when the task is successfully executed
  64337. * @param onError is a callback called if an error occurs
  64338. */
  64339. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64340. }
  64341. /**
  64342. * Defines the interface used by texture loading tasks
  64343. */
  64344. export interface ITextureAssetTask<TEX extends BaseTexture> {
  64345. /**
  64346. * Gets the loaded texture
  64347. */
  64348. texture: TEX;
  64349. }
  64350. /**
  64351. * Define a task used by AssetsManager to load 2D textures
  64352. */
  64353. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  64354. /**
  64355. * Defines the name of the task
  64356. */
  64357. name: string;
  64358. /**
  64359. * Defines the location of the file to load
  64360. */
  64361. url: string;
  64362. /**
  64363. * Defines if mipmap should not be generated (default is false)
  64364. */
  64365. noMipmap?: boolean | undefined;
  64366. /**
  64367. * Defines if texture must be inverted on Y axis (default is false)
  64368. */
  64369. invertY?: boolean | undefined;
  64370. /**
  64371. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  64372. */
  64373. samplingMode: number;
  64374. /**
  64375. * Gets the loaded texture
  64376. */
  64377. texture: Texture;
  64378. /**
  64379. * Callback called when the task is successful
  64380. */
  64381. onSuccess: (task: TextureAssetTask) => void;
  64382. /**
  64383. * Callback called when the task is successful
  64384. */
  64385. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  64386. /**
  64387. * Creates a new TextureAssetTask object
  64388. * @param name defines the name of the task
  64389. * @param url defines the location of the file to load
  64390. * @param noMipmap defines if mipmap should not be generated (default is false)
  64391. * @param invertY defines if texture must be inverted on Y axis (default is false)
  64392. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  64393. */
  64394. constructor(
  64395. /**
  64396. * Defines the name of the task
  64397. */
  64398. name: string,
  64399. /**
  64400. * Defines the location of the file to load
  64401. */
  64402. url: string,
  64403. /**
  64404. * Defines if mipmap should not be generated (default is false)
  64405. */
  64406. noMipmap?: boolean | undefined,
  64407. /**
  64408. * Defines if texture must be inverted on Y axis (default is false)
  64409. */
  64410. invertY?: boolean | undefined,
  64411. /**
  64412. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  64413. */
  64414. samplingMode?: number);
  64415. /**
  64416. * Execute the current task
  64417. * @param scene defines the scene where you want your assets to be loaded
  64418. * @param onSuccess is a callback called when the task is successfully executed
  64419. * @param onError is a callback called if an error occurs
  64420. */
  64421. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64422. }
  64423. /**
  64424. * Define a task used by AssetsManager to load cube textures
  64425. */
  64426. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  64427. /**
  64428. * Defines the name of the task
  64429. */
  64430. name: string;
  64431. /**
  64432. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  64433. */
  64434. url: string;
  64435. /**
  64436. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  64437. */
  64438. extensions?: string[] | undefined;
  64439. /**
  64440. * Defines if mipmaps should not be generated (default is false)
  64441. */
  64442. noMipmap?: boolean | undefined;
  64443. /**
  64444. * Defines the explicit list of files (undefined by default)
  64445. */
  64446. files?: string[] | undefined;
  64447. /**
  64448. * Gets the loaded texture
  64449. */
  64450. texture: CubeTexture;
  64451. /**
  64452. * Callback called when the task is successful
  64453. */
  64454. onSuccess: (task: CubeTextureAssetTask) => void;
  64455. /**
  64456. * Callback called when the task is successful
  64457. */
  64458. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  64459. /**
  64460. * Creates a new CubeTextureAssetTask
  64461. * @param name defines the name of the task
  64462. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  64463. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  64464. * @param noMipmap defines if mipmaps should not be generated (default is false)
  64465. * @param files defines the explicit list of files (undefined by default)
  64466. */
  64467. constructor(
  64468. /**
  64469. * Defines the name of the task
  64470. */
  64471. name: string,
  64472. /**
  64473. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  64474. */
  64475. url: string,
  64476. /**
  64477. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  64478. */
  64479. extensions?: string[] | undefined,
  64480. /**
  64481. * Defines if mipmaps should not be generated (default is false)
  64482. */
  64483. noMipmap?: boolean | undefined,
  64484. /**
  64485. * Defines the explicit list of files (undefined by default)
  64486. */
  64487. files?: string[] | undefined);
  64488. /**
  64489. * Execute the current task
  64490. * @param scene defines the scene where you want your assets to be loaded
  64491. * @param onSuccess is a callback called when the task is successfully executed
  64492. * @param onError is a callback called if an error occurs
  64493. */
  64494. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64495. }
  64496. /**
  64497. * Define a task used by AssetsManager to load HDR cube textures
  64498. */
  64499. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  64500. /**
  64501. * Defines the name of the task
  64502. */
  64503. name: string;
  64504. /**
  64505. * Defines the location of the file to load
  64506. */
  64507. url: string;
  64508. /**
  64509. * Defines the desired size (the more it increases the longer the generation will be)
  64510. */
  64511. size: number;
  64512. /**
  64513. * Defines if mipmaps should not be generated (default is false)
  64514. */
  64515. noMipmap: boolean;
  64516. /**
  64517. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  64518. */
  64519. generateHarmonics: boolean;
  64520. /**
  64521. * 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)
  64522. */
  64523. gammaSpace: boolean;
  64524. /**
  64525. * Internal Use Only
  64526. */
  64527. reserved: boolean;
  64528. /**
  64529. * Gets the loaded texture
  64530. */
  64531. texture: HDRCubeTexture;
  64532. /**
  64533. * Callback called when the task is successful
  64534. */
  64535. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  64536. /**
  64537. * Callback called when the task is successful
  64538. */
  64539. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  64540. /**
  64541. * Creates a new HDRCubeTextureAssetTask object
  64542. * @param name defines the name of the task
  64543. * @param url defines the location of the file to load
  64544. * @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.
  64545. * @param noMipmap defines if mipmaps should not be generated (default is false)
  64546. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  64547. * @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)
  64548. * @param reserved Internal use only
  64549. */
  64550. constructor(
  64551. /**
  64552. * Defines the name of the task
  64553. */
  64554. name: string,
  64555. /**
  64556. * Defines the location of the file to load
  64557. */
  64558. url: string,
  64559. /**
  64560. * Defines the desired size (the more it increases the longer the generation will be)
  64561. */
  64562. size: number,
  64563. /**
  64564. * Defines if mipmaps should not be generated (default is false)
  64565. */
  64566. noMipmap?: boolean,
  64567. /**
  64568. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  64569. */
  64570. generateHarmonics?: boolean,
  64571. /**
  64572. * 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)
  64573. */
  64574. gammaSpace?: boolean,
  64575. /**
  64576. * Internal Use Only
  64577. */
  64578. reserved?: boolean);
  64579. /**
  64580. * Execute the current task
  64581. * @param scene defines the scene where you want your assets to be loaded
  64582. * @param onSuccess is a callback called when the task is successfully executed
  64583. * @param onError is a callback called if an error occurs
  64584. */
  64585. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64586. }
  64587. /**
  64588. * Define a task used by AssetsManager to load Equirectangular cube textures
  64589. */
  64590. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  64591. /**
  64592. * Defines the name of the task
  64593. */
  64594. name: string;
  64595. /**
  64596. * Defines the location of the file to load
  64597. */
  64598. url: string;
  64599. /**
  64600. * Defines the desired size (the more it increases the longer the generation will be)
  64601. */
  64602. size: number;
  64603. /**
  64604. * Defines if mipmaps should not be generated (default is false)
  64605. */
  64606. noMipmap: boolean;
  64607. /**
  64608. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  64609. * but the standard material would require them in Gamma space) (default is true)
  64610. */
  64611. gammaSpace: boolean;
  64612. /**
  64613. * Gets the loaded texture
  64614. */
  64615. texture: EquiRectangularCubeTexture;
  64616. /**
  64617. * Callback called when the task is successful
  64618. */
  64619. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  64620. /**
  64621. * Callback called when the task is successful
  64622. */
  64623. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  64624. /**
  64625. * Creates a new EquiRectangularCubeTextureAssetTask object
  64626. * @param name defines the name of the task
  64627. * @param url defines the location of the file to load
  64628. * @param size defines the desired size (the more it increases the longer the generation will be)
  64629. * If the size is omitted this implies you are using a preprocessed cubemap.
  64630. * @param noMipmap defines if mipmaps should not be generated (default is false)
  64631. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  64632. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  64633. * (default is true)
  64634. */
  64635. constructor(
  64636. /**
  64637. * Defines the name of the task
  64638. */
  64639. name: string,
  64640. /**
  64641. * Defines the location of the file to load
  64642. */
  64643. url: string,
  64644. /**
  64645. * Defines the desired size (the more it increases the longer the generation will be)
  64646. */
  64647. size: number,
  64648. /**
  64649. * Defines if mipmaps should not be generated (default is false)
  64650. */
  64651. noMipmap?: boolean,
  64652. /**
  64653. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  64654. * but the standard material would require them in Gamma space) (default is true)
  64655. */
  64656. gammaSpace?: boolean);
  64657. /**
  64658. * Execute the current task
  64659. * @param scene defines the scene where you want your assets to be loaded
  64660. * @param onSuccess is a callback called when the task is successfully executed
  64661. * @param onError is a callback called if an error occurs
  64662. */
  64663. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64664. }
  64665. /**
  64666. * This class can be used to easily import assets into a scene
  64667. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  64668. */
  64669. export class AssetsManager {
  64670. private _scene;
  64671. private _isLoading;
  64672. protected _tasks: AbstractAssetTask[];
  64673. protected _waitingTasksCount: number;
  64674. protected _totalTasksCount: number;
  64675. /**
  64676. * Callback called when all tasks are processed
  64677. */
  64678. onFinish: (tasks: AbstractAssetTask[]) => void;
  64679. /**
  64680. * Callback called when a task is successful
  64681. */
  64682. onTaskSuccess: (task: AbstractAssetTask) => void;
  64683. /**
  64684. * Callback called when a task had an error
  64685. */
  64686. onTaskError: (task: AbstractAssetTask) => void;
  64687. /**
  64688. * Callback called when a task is done (whatever the result is)
  64689. */
  64690. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  64691. /**
  64692. * Observable called when all tasks are processed
  64693. */
  64694. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  64695. /**
  64696. * Observable called when a task had an error
  64697. */
  64698. onTaskErrorObservable: Observable<AbstractAssetTask>;
  64699. /**
  64700. * Observable called when all tasks were executed
  64701. */
  64702. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  64703. /**
  64704. * Observable called when a task is done (whatever the result is)
  64705. */
  64706. onProgressObservable: Observable<IAssetsProgressEvent>;
  64707. /**
  64708. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  64709. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  64710. */
  64711. useDefaultLoadingScreen: boolean;
  64712. /**
  64713. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  64714. * when all assets have been downloaded.
  64715. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  64716. */
  64717. autoHideLoadingUI: boolean;
  64718. /**
  64719. * Creates a new AssetsManager
  64720. * @param scene defines the scene to work on
  64721. */
  64722. constructor(scene: Scene);
  64723. /**
  64724. * Add a MeshAssetTask to the list of active tasks
  64725. * @param taskName defines the name of the new task
  64726. * @param meshesNames defines the name of meshes to load
  64727. * @param rootUrl defines the root url to use to locate files
  64728. * @param sceneFilename defines the filename of the scene file
  64729. * @returns a new MeshAssetTask object
  64730. */
  64731. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  64732. /**
  64733. * Add a TextFileAssetTask to the list of active tasks
  64734. * @param taskName defines the name of the new task
  64735. * @param url defines the url of the file to load
  64736. * @returns a new TextFileAssetTask object
  64737. */
  64738. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  64739. /**
  64740. * Add a BinaryFileAssetTask to the list of active tasks
  64741. * @param taskName defines the name of the new task
  64742. * @param url defines the url of the file to load
  64743. * @returns a new BinaryFileAssetTask object
  64744. */
  64745. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  64746. /**
  64747. * Add a ImageAssetTask to the list of active tasks
  64748. * @param taskName defines the name of the new task
  64749. * @param url defines the url of the file to load
  64750. * @returns a new ImageAssetTask object
  64751. */
  64752. addImageTask(taskName: string, url: string): ImageAssetTask;
  64753. /**
  64754. * Add a TextureAssetTask to the list of active tasks
  64755. * @param taskName defines the name of the new task
  64756. * @param url defines the url of the file to load
  64757. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  64758. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  64759. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  64760. * @returns a new TextureAssetTask object
  64761. */
  64762. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  64763. /**
  64764. * Add a CubeTextureAssetTask to the list of active tasks
  64765. * @param taskName defines the name of the new task
  64766. * @param url defines the url of the file to load
  64767. * @param extensions defines the extension to use to load the cube map (can be null)
  64768. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  64769. * @param files defines the list of files to load (can be null)
  64770. * @returns a new CubeTextureAssetTask object
  64771. */
  64772. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  64773. /**
  64774. *
  64775. * Add a HDRCubeTextureAssetTask to the list of active tasks
  64776. * @param taskName defines the name of the new task
  64777. * @param url defines the url of the file to load
  64778. * @param size defines the size you want for the cubemap (can be null)
  64779. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  64780. * @param generateHarmonics defines if you want to automatically generate (true by default)
  64781. * @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)
  64782. * @param reserved Internal use only
  64783. * @returns a new HDRCubeTextureAssetTask object
  64784. */
  64785. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  64786. /**
  64787. *
  64788. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  64789. * @param taskName defines the name of the new task
  64790. * @param url defines the url of the file to load
  64791. * @param size defines the size you want for the cubemap (can be null)
  64792. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  64793. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  64794. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  64795. * @returns a new EquiRectangularCubeTextureAssetTask object
  64796. */
  64797. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  64798. /**
  64799. * Remove a task from the assets manager.
  64800. * @param task the task to remove
  64801. */
  64802. removeTask(task: AbstractAssetTask): void;
  64803. private _decreaseWaitingTasksCount;
  64804. private _runTask;
  64805. /**
  64806. * Reset the AssetsManager and remove all tasks
  64807. * @return the current instance of the AssetsManager
  64808. */
  64809. reset(): AssetsManager;
  64810. /**
  64811. * Start the loading process
  64812. * @return the current instance of the AssetsManager
  64813. */
  64814. load(): AssetsManager;
  64815. /**
  64816. * Start the loading process as an async operation
  64817. * @return a promise returning the list of failed tasks
  64818. */
  64819. loadAsync(): Promise<void>;
  64820. }
  64821. }
  64822. declare module "babylonjs/Misc/deferred" {
  64823. /**
  64824. * Wrapper class for promise with external resolve and reject.
  64825. */
  64826. export class Deferred<T> {
  64827. /**
  64828. * The promise associated with this deferred object.
  64829. */
  64830. readonly promise: Promise<T>;
  64831. private _resolve;
  64832. private _reject;
  64833. /**
  64834. * The resolve method of the promise associated with this deferred object.
  64835. */
  64836. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  64837. /**
  64838. * The reject method of the promise associated with this deferred object.
  64839. */
  64840. readonly reject: (reason?: any) => void;
  64841. /**
  64842. * Constructor for this deferred object.
  64843. */
  64844. constructor();
  64845. }
  64846. }
  64847. declare module "babylonjs/Misc/meshExploder" {
  64848. import { Mesh } from "babylonjs/Meshes/mesh";
  64849. /**
  64850. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  64851. */
  64852. export class MeshExploder {
  64853. private _centerMesh;
  64854. private _meshes;
  64855. private _meshesOrigins;
  64856. private _toCenterVectors;
  64857. private _scaledDirection;
  64858. private _newPosition;
  64859. private _centerPosition;
  64860. /**
  64861. * Explodes meshes from a center mesh.
  64862. * @param meshes The meshes to explode.
  64863. * @param centerMesh The mesh to be center of explosion.
  64864. */
  64865. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  64866. private _setCenterMesh;
  64867. /**
  64868. * Get class name
  64869. * @returns "MeshExploder"
  64870. */
  64871. getClassName(): string;
  64872. /**
  64873. * "Exploded meshes"
  64874. * @returns Array of meshes with the centerMesh at index 0.
  64875. */
  64876. getMeshes(): Array<Mesh>;
  64877. /**
  64878. * Explodes meshes giving a specific direction
  64879. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  64880. */
  64881. explode(direction?: number): void;
  64882. }
  64883. }
  64884. declare module "babylonjs/Misc/filesInput" {
  64885. import { Engine } from "babylonjs/Engines/engine";
  64886. import { Scene } from "babylonjs/scene";
  64887. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  64888. /**
  64889. * Class used to help managing file picking and drag'n'drop
  64890. */
  64891. export class FilesInput {
  64892. /**
  64893. * List of files ready to be loaded
  64894. */
  64895. static readonly FilesToLoad: {
  64896. [key: string]: File;
  64897. };
  64898. /**
  64899. * Callback called when a file is processed
  64900. */
  64901. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  64902. private _engine;
  64903. private _currentScene;
  64904. private _sceneLoadedCallback;
  64905. private _progressCallback;
  64906. private _additionalRenderLoopLogicCallback;
  64907. private _textureLoadingCallback;
  64908. private _startingProcessingFilesCallback;
  64909. private _onReloadCallback;
  64910. private _errorCallback;
  64911. private _elementToMonitor;
  64912. private _sceneFileToLoad;
  64913. private _filesToLoad;
  64914. /**
  64915. * Creates a new FilesInput
  64916. * @param engine defines the rendering engine
  64917. * @param scene defines the hosting scene
  64918. * @param sceneLoadedCallback callback called when scene is loaded
  64919. * @param progressCallback callback called to track progress
  64920. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  64921. * @param textureLoadingCallback callback called when a texture is loading
  64922. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  64923. * @param onReloadCallback callback called when a reload is requested
  64924. * @param errorCallback callback call if an error occurs
  64925. */
  64926. 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);
  64927. private _dragEnterHandler;
  64928. private _dragOverHandler;
  64929. private _dropHandler;
  64930. /**
  64931. * Calls this function to listen to drag'n'drop events on a specific DOM element
  64932. * @param elementToMonitor defines the DOM element to track
  64933. */
  64934. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  64935. /**
  64936. * Release all associated resources
  64937. */
  64938. dispose(): void;
  64939. private renderFunction;
  64940. private drag;
  64941. private drop;
  64942. private _traverseFolder;
  64943. private _processFiles;
  64944. /**
  64945. * Load files from a drop event
  64946. * @param event defines the drop event to use as source
  64947. */
  64948. loadFiles(event: any): void;
  64949. private _processReload;
  64950. /**
  64951. * Reload the current scene from the loaded files
  64952. */
  64953. reload(): void;
  64954. }
  64955. }
  64956. declare module "babylonjs/Misc/HighDynamicRange/index" {
  64957. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  64958. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  64959. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  64960. }
  64961. declare module "babylonjs/Misc/sceneOptimizer" {
  64962. import { Scene, IDisposable } from "babylonjs/scene";
  64963. import { Observable } from "babylonjs/Misc/observable";
  64964. /**
  64965. * Defines the root class used to create scene optimization to use with SceneOptimizer
  64966. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64967. */
  64968. export class SceneOptimization {
  64969. /**
  64970. * Defines the priority of this optimization (0 by default which means first in the list)
  64971. */
  64972. priority: number;
  64973. /**
  64974. * Gets a string describing the action executed by the current optimization
  64975. * @returns description string
  64976. */
  64977. getDescription(): string;
  64978. /**
  64979. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  64980. * @param scene defines the current scene where to apply this optimization
  64981. * @param optimizer defines the current optimizer
  64982. * @returns true if everything that can be done was applied
  64983. */
  64984. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  64985. /**
  64986. * Creates the SceneOptimization object
  64987. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  64988. * @param desc defines the description associated with the optimization
  64989. */
  64990. constructor(
  64991. /**
  64992. * Defines the priority of this optimization (0 by default which means first in the list)
  64993. */
  64994. priority?: number);
  64995. }
  64996. /**
  64997. * Defines an optimization used to reduce the size of render target textures
  64998. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  64999. */
  65000. export class TextureOptimization extends SceneOptimization {
  65001. /**
  65002. * Defines the priority of this optimization (0 by default which means first in the list)
  65003. */
  65004. priority: number;
  65005. /**
  65006. * 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
  65007. */
  65008. maximumSize: number;
  65009. /**
  65010. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  65011. */
  65012. step: number;
  65013. /**
  65014. * Gets a string describing the action executed by the current optimization
  65015. * @returns description string
  65016. */
  65017. getDescription(): string;
  65018. /**
  65019. * Creates the TextureOptimization object
  65020. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65021. * @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
  65022. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  65023. */
  65024. constructor(
  65025. /**
  65026. * Defines the priority of this optimization (0 by default which means first in the list)
  65027. */
  65028. priority?: number,
  65029. /**
  65030. * 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
  65031. */
  65032. maximumSize?: number,
  65033. /**
  65034. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  65035. */
  65036. step?: number);
  65037. /**
  65038. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65039. * @param scene defines the current scene where to apply this optimization
  65040. * @param optimizer defines the current optimizer
  65041. * @returns true if everything that can be done was applied
  65042. */
  65043. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65044. }
  65045. /**
  65046. * Defines an optimization used to increase or decrease the rendering resolution
  65047. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65048. */
  65049. export class HardwareScalingOptimization extends SceneOptimization {
  65050. /**
  65051. * Defines the priority of this optimization (0 by default which means first in the list)
  65052. */
  65053. priority: number;
  65054. /**
  65055. * Defines the maximum scale to use (2 by default)
  65056. */
  65057. maximumScale: number;
  65058. /**
  65059. * Defines the step to use between two passes (0.5 by default)
  65060. */
  65061. step: number;
  65062. private _currentScale;
  65063. private _directionOffset;
  65064. /**
  65065. * Gets a string describing the action executed by the current optimization
  65066. * @return description string
  65067. */
  65068. getDescription(): string;
  65069. /**
  65070. * Creates the HardwareScalingOptimization object
  65071. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65072. * @param maximumScale defines the maximum scale to use (2 by default)
  65073. * @param step defines the step to use between two passes (0.5 by default)
  65074. */
  65075. constructor(
  65076. /**
  65077. * Defines the priority of this optimization (0 by default which means first in the list)
  65078. */
  65079. priority?: number,
  65080. /**
  65081. * Defines the maximum scale to use (2 by default)
  65082. */
  65083. maximumScale?: number,
  65084. /**
  65085. * Defines the step to use between two passes (0.5 by default)
  65086. */
  65087. step?: number);
  65088. /**
  65089. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65090. * @param scene defines the current scene where to apply this optimization
  65091. * @param optimizer defines the current optimizer
  65092. * @returns true if everything that can be done was applied
  65093. */
  65094. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65095. }
  65096. /**
  65097. * Defines an optimization used to remove shadows
  65098. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65099. */
  65100. export class ShadowsOptimization extends SceneOptimization {
  65101. /**
  65102. * Gets a string describing the action executed by the current optimization
  65103. * @return description string
  65104. */
  65105. getDescription(): string;
  65106. /**
  65107. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65108. * @param scene defines the current scene where to apply this optimization
  65109. * @param optimizer defines the current optimizer
  65110. * @returns true if everything that can be done was applied
  65111. */
  65112. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65113. }
  65114. /**
  65115. * Defines an optimization used to turn post-processes off
  65116. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65117. */
  65118. export class PostProcessesOptimization extends SceneOptimization {
  65119. /**
  65120. * Gets a string describing the action executed by the current optimization
  65121. * @return description string
  65122. */
  65123. getDescription(): string;
  65124. /**
  65125. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65126. * @param scene defines the current scene where to apply this optimization
  65127. * @param optimizer defines the current optimizer
  65128. * @returns true if everything that can be done was applied
  65129. */
  65130. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65131. }
  65132. /**
  65133. * Defines an optimization used to turn lens flares off
  65134. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65135. */
  65136. export class LensFlaresOptimization extends SceneOptimization {
  65137. /**
  65138. * Gets a string describing the action executed by the current optimization
  65139. * @return description string
  65140. */
  65141. getDescription(): string;
  65142. /**
  65143. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65144. * @param scene defines the current scene where to apply this optimization
  65145. * @param optimizer defines the current optimizer
  65146. * @returns true if everything that can be done was applied
  65147. */
  65148. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65149. }
  65150. /**
  65151. * Defines an optimization based on user defined callback.
  65152. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65153. */
  65154. export class CustomOptimization extends SceneOptimization {
  65155. /**
  65156. * Callback called to apply the custom optimization.
  65157. */
  65158. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  65159. /**
  65160. * Callback called to get custom description
  65161. */
  65162. onGetDescription: () => string;
  65163. /**
  65164. * Gets a string describing the action executed by the current optimization
  65165. * @returns description string
  65166. */
  65167. getDescription(): string;
  65168. /**
  65169. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65170. * @param scene defines the current scene where to apply this optimization
  65171. * @param optimizer defines the current optimizer
  65172. * @returns true if everything that can be done was applied
  65173. */
  65174. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65175. }
  65176. /**
  65177. * Defines an optimization used to turn particles off
  65178. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65179. */
  65180. export class ParticlesOptimization extends SceneOptimization {
  65181. /**
  65182. * Gets a string describing the action executed by the current optimization
  65183. * @return description string
  65184. */
  65185. getDescription(): string;
  65186. /**
  65187. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65188. * @param scene defines the current scene where to apply this optimization
  65189. * @param optimizer defines the current optimizer
  65190. * @returns true if everything that can be done was applied
  65191. */
  65192. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65193. }
  65194. /**
  65195. * Defines an optimization used to turn render targets off
  65196. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65197. */
  65198. export class RenderTargetsOptimization extends SceneOptimization {
  65199. /**
  65200. * Gets a string describing the action executed by the current optimization
  65201. * @return description string
  65202. */
  65203. getDescription(): string;
  65204. /**
  65205. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65206. * @param scene defines the current scene where to apply this optimization
  65207. * @param optimizer defines the current optimizer
  65208. * @returns true if everything that can be done was applied
  65209. */
  65210. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65211. }
  65212. /**
  65213. * Defines an optimization used to merge meshes with compatible materials
  65214. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65215. */
  65216. export class MergeMeshesOptimization extends SceneOptimization {
  65217. private static _UpdateSelectionTree;
  65218. /**
  65219. * Gets or sets a boolean which defines if optimization octree has to be updated
  65220. */
  65221. /**
  65222. * Gets or sets a boolean which defines if optimization octree has to be updated
  65223. */
  65224. static UpdateSelectionTree: boolean;
  65225. /**
  65226. * Gets a string describing the action executed by the current optimization
  65227. * @return description string
  65228. */
  65229. getDescription(): string;
  65230. private _canBeMerged;
  65231. /**
  65232. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65233. * @param scene defines the current scene where to apply this optimization
  65234. * @param optimizer defines the current optimizer
  65235. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  65236. * @returns true if everything that can be done was applied
  65237. */
  65238. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  65239. }
  65240. /**
  65241. * Defines a list of options used by SceneOptimizer
  65242. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65243. */
  65244. export class SceneOptimizerOptions {
  65245. /**
  65246. * Defines the target frame rate to reach (60 by default)
  65247. */
  65248. targetFrameRate: number;
  65249. /**
  65250. * Defines the interval between two checkes (2000ms by default)
  65251. */
  65252. trackerDuration: number;
  65253. /**
  65254. * Gets the list of optimizations to apply
  65255. */
  65256. optimizations: SceneOptimization[];
  65257. /**
  65258. * Creates a new list of options used by SceneOptimizer
  65259. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  65260. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  65261. */
  65262. constructor(
  65263. /**
  65264. * Defines the target frame rate to reach (60 by default)
  65265. */
  65266. targetFrameRate?: number,
  65267. /**
  65268. * Defines the interval between two checkes (2000ms by default)
  65269. */
  65270. trackerDuration?: number);
  65271. /**
  65272. * Add a new optimization
  65273. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  65274. * @returns the current SceneOptimizerOptions
  65275. */
  65276. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  65277. /**
  65278. * Add a new custom optimization
  65279. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  65280. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  65281. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65282. * @returns the current SceneOptimizerOptions
  65283. */
  65284. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  65285. /**
  65286. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  65287. * @param targetFrameRate defines the target frame rate (60 by default)
  65288. * @returns a SceneOptimizerOptions object
  65289. */
  65290. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  65291. /**
  65292. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  65293. * @param targetFrameRate defines the target frame rate (60 by default)
  65294. * @returns a SceneOptimizerOptions object
  65295. */
  65296. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  65297. /**
  65298. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  65299. * @param targetFrameRate defines the target frame rate (60 by default)
  65300. * @returns a SceneOptimizerOptions object
  65301. */
  65302. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  65303. }
  65304. /**
  65305. * Class used to run optimizations in order to reach a target frame rate
  65306. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65307. */
  65308. export class SceneOptimizer implements IDisposable {
  65309. private _isRunning;
  65310. private _options;
  65311. private _scene;
  65312. private _currentPriorityLevel;
  65313. private _targetFrameRate;
  65314. private _trackerDuration;
  65315. private _currentFrameRate;
  65316. private _sceneDisposeObserver;
  65317. private _improvementMode;
  65318. /**
  65319. * Defines an observable called when the optimizer reaches the target frame rate
  65320. */
  65321. onSuccessObservable: Observable<SceneOptimizer>;
  65322. /**
  65323. * Defines an observable called when the optimizer enables an optimization
  65324. */
  65325. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  65326. /**
  65327. * Defines an observable called when the optimizer is not able to reach the target frame rate
  65328. */
  65329. onFailureObservable: Observable<SceneOptimizer>;
  65330. /**
  65331. * Gets a boolean indicating if the optimizer is in improvement mode
  65332. */
  65333. readonly isInImprovementMode: boolean;
  65334. /**
  65335. * Gets the current priority level (0 at start)
  65336. */
  65337. readonly currentPriorityLevel: number;
  65338. /**
  65339. * Gets the current frame rate checked by the SceneOptimizer
  65340. */
  65341. readonly currentFrameRate: number;
  65342. /**
  65343. * Gets or sets the current target frame rate (60 by default)
  65344. */
  65345. /**
  65346. * Gets or sets the current target frame rate (60 by default)
  65347. */
  65348. targetFrameRate: number;
  65349. /**
  65350. * Gets or sets the current interval between two checks (every 2000ms by default)
  65351. */
  65352. /**
  65353. * Gets or sets the current interval between two checks (every 2000ms by default)
  65354. */
  65355. trackerDuration: number;
  65356. /**
  65357. * Gets the list of active optimizations
  65358. */
  65359. readonly optimizations: SceneOptimization[];
  65360. /**
  65361. * Creates a new SceneOptimizer
  65362. * @param scene defines the scene to work on
  65363. * @param options defines the options to use with the SceneOptimizer
  65364. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  65365. * @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)
  65366. */
  65367. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  65368. /**
  65369. * Stops the current optimizer
  65370. */
  65371. stop(): void;
  65372. /**
  65373. * Reset the optimizer to initial step (current priority level = 0)
  65374. */
  65375. reset(): void;
  65376. /**
  65377. * Start the optimizer. By default it will try to reach a specific framerate
  65378. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  65379. */
  65380. start(): void;
  65381. private _checkCurrentState;
  65382. /**
  65383. * Release all resources
  65384. */
  65385. dispose(): void;
  65386. /**
  65387. * Helper function to create a SceneOptimizer with one single line of code
  65388. * @param scene defines the scene to work on
  65389. * @param options defines the options to use with the SceneOptimizer
  65390. * @param onSuccess defines a callback to call on success
  65391. * @param onFailure defines a callback to call on failure
  65392. * @returns the new SceneOptimizer object
  65393. */
  65394. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  65395. }
  65396. }
  65397. declare module "babylonjs/Misc/sceneSerializer" {
  65398. import { Scene } from "babylonjs/scene";
  65399. /**
  65400. * Class used to serialize a scene into a string
  65401. */
  65402. export class SceneSerializer {
  65403. /**
  65404. * Clear cache used by a previous serialization
  65405. */
  65406. static ClearCache(): void;
  65407. /**
  65408. * Serialize a scene into a JSON compatible object
  65409. * @param scene defines the scene to serialize
  65410. * @returns a JSON compatible object
  65411. */
  65412. static Serialize(scene: Scene): any;
  65413. /**
  65414. * Serialize a mesh into a JSON compatible object
  65415. * @param toSerialize defines the mesh to serialize
  65416. * @param withParents defines if parents must be serialized as well
  65417. * @param withChildren defines if children must be serialized as well
  65418. * @returns a JSON compatible object
  65419. */
  65420. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  65421. }
  65422. }
  65423. declare module "babylonjs/Misc/textureTools" {
  65424. import { Texture } from "babylonjs/Materials/Textures/texture";
  65425. /**
  65426. * Class used to host texture specific utilities
  65427. */
  65428. export class TextureTools {
  65429. /**
  65430. * Uses the GPU to create a copy texture rescaled at a given size
  65431. * @param texture Texture to copy from
  65432. * @param width defines the desired width
  65433. * @param height defines the desired height
  65434. * @param useBilinearMode defines if bilinear mode has to be used
  65435. * @return the generated texture
  65436. */
  65437. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  65438. }
  65439. }
  65440. declare module "babylonjs/Misc/videoRecorder" {
  65441. import { Nullable } from "babylonjs/types";
  65442. import { Engine } from "babylonjs/Engines/engine";
  65443. /**
  65444. * This represents the different options available for the video capture.
  65445. */
  65446. export interface VideoRecorderOptions {
  65447. /** Defines the mime type of the video. */
  65448. mimeType: string;
  65449. /** Defines the FPS the video should be recorded at. */
  65450. fps: number;
  65451. /** Defines the chunk size for the recording data. */
  65452. recordChunckSize: number;
  65453. /** The audio tracks to attach to the recording. */
  65454. audioTracks?: MediaStreamTrack[];
  65455. }
  65456. /**
  65457. * This can help with recording videos from BabylonJS.
  65458. * This is based on the available WebRTC functionalities of the browser.
  65459. *
  65460. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  65461. */
  65462. export class VideoRecorder {
  65463. private static readonly _defaultOptions;
  65464. /**
  65465. * Returns whether or not the VideoRecorder is available in your browser.
  65466. * @param engine Defines the Babylon Engine.
  65467. * @returns true if supported otherwise false.
  65468. */
  65469. static IsSupported(engine: Engine): boolean;
  65470. private readonly _options;
  65471. private _canvas;
  65472. private _mediaRecorder;
  65473. private _recordedChunks;
  65474. private _fileName;
  65475. private _resolve;
  65476. private _reject;
  65477. /**
  65478. * True when a recording is already in progress.
  65479. */
  65480. readonly isRecording: boolean;
  65481. /**
  65482. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  65483. * @param engine Defines the BabylonJS Engine you wish to record.
  65484. * @param options Defines options that can be used to customize the capture.
  65485. */
  65486. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  65487. /**
  65488. * Stops the current recording before the default capture timeout passed in the startRecording function.
  65489. */
  65490. stopRecording(): void;
  65491. /**
  65492. * Starts recording the canvas for a max duration specified in parameters.
  65493. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  65494. * If null no automatic download will start and you can rely on the promise to get the data back.
  65495. * @param maxDuration Defines the maximum recording time in seconds.
  65496. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  65497. * @return A promise callback at the end of the recording with the video data in Blob.
  65498. */
  65499. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  65500. /**
  65501. * Releases internal resources used during the recording.
  65502. */
  65503. dispose(): void;
  65504. private _handleDataAvailable;
  65505. private _handleError;
  65506. private _handleStop;
  65507. }
  65508. }
  65509. declare module "babylonjs/Misc/screenshotTools" {
  65510. import { Camera } from "babylonjs/Cameras/camera";
  65511. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  65512. import { Engine } from "babylonjs/Engines/engine";
  65513. /**
  65514. * Class containing a set of static utilities functions for screenshots
  65515. */
  65516. export class ScreenshotTools {
  65517. /**
  65518. * Captures a screenshot of the current rendering
  65519. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  65520. * @param engine defines the rendering engine
  65521. * @param camera defines the source camera
  65522. * @param size This parameter can be set to a single number or to an object with the
  65523. * following (optional) properties: precision, width, height. If a single number is passed,
  65524. * it will be used for both width and height. If an object is passed, the screenshot size
  65525. * will be derived from the parameters. The precision property is a multiplier allowing
  65526. * rendering at a higher or lower resolution
  65527. * @param successCallback defines the callback receives a single parameter which contains the
  65528. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  65529. * src parameter of an <img> to display it
  65530. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  65531. * Check your browser for supported MIME types
  65532. */
  65533. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  65534. /**
  65535. * Captures a screenshot of the current rendering
  65536. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  65537. * @param engine defines the rendering engine
  65538. * @param camera defines the source camera
  65539. * @param size This parameter can be set to a single number or to an object with the
  65540. * following (optional) properties: precision, width, height. If a single number is passed,
  65541. * it will be used for both width and height. If an object is passed, the screenshot size
  65542. * will be derived from the parameters. The precision property is a multiplier allowing
  65543. * rendering at a higher or lower resolution
  65544. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  65545. * Check your browser for supported MIME types
  65546. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  65547. * to the src parameter of an <img> to display it
  65548. */
  65549. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  65550. /**
  65551. * Generates an image screenshot from the specified camera.
  65552. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  65553. * @param engine The engine to use for rendering
  65554. * @param camera The camera to use for rendering
  65555. * @param size This parameter can be set to a single number or to an object with the
  65556. * following (optional) properties: precision, width, height. If a single number is passed,
  65557. * it will be used for both width and height. If an object is passed, the screenshot size
  65558. * will be derived from the parameters. The precision property is a multiplier allowing
  65559. * rendering at a higher or lower resolution
  65560. * @param successCallback The callback receives a single parameter which contains the
  65561. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  65562. * src parameter of an <img> to display it
  65563. * @param mimeType The MIME type of the screenshot image (default: image/png).
  65564. * Check your browser for supported MIME types
  65565. * @param samples Texture samples (default: 1)
  65566. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  65567. * @param fileName A name for for the downloaded file.
  65568. */
  65569. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  65570. /**
  65571. * Generates an image screenshot from the specified camera.
  65572. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  65573. * @param engine The engine to use for rendering
  65574. * @param camera The camera to use for rendering
  65575. * @param size This parameter can be set to a single number or to an object with the
  65576. * following (optional) properties: precision, width, height. If a single number is passed,
  65577. * it will be used for both width and height. If an object is passed, the screenshot size
  65578. * will be derived from the parameters. The precision property is a multiplier allowing
  65579. * rendering at a higher or lower resolution
  65580. * @param mimeType The MIME type of the screenshot image (default: image/png).
  65581. * Check your browser for supported MIME types
  65582. * @param samples Texture samples (default: 1)
  65583. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  65584. * @param fileName A name for for the downloaded file.
  65585. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  65586. * to the src parameter of an <img> to display it
  65587. */
  65588. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  65589. /**
  65590. * Gets height and width for screenshot size
  65591. * @private
  65592. */
  65593. private static _getScreenshotSize;
  65594. }
  65595. }
  65596. declare module "babylonjs/Misc/index" {
  65597. export * from "babylonjs/Misc/andOrNotEvaluator";
  65598. export * from "babylonjs/Misc/assetsManager";
  65599. export * from "babylonjs/Misc/dds";
  65600. export * from "babylonjs/Misc/decorators";
  65601. export * from "babylonjs/Misc/deferred";
  65602. export * from "babylonjs/Misc/environmentTextureTools";
  65603. export * from "babylonjs/Misc/meshExploder";
  65604. export * from "babylonjs/Misc/filesInput";
  65605. export * from "babylonjs/Misc/HighDynamicRange/index";
  65606. export * from "babylonjs/Misc/khronosTextureContainer";
  65607. export * from "babylonjs/Misc/observable";
  65608. export * from "babylonjs/Misc/performanceMonitor";
  65609. export * from "babylonjs/Misc/promise";
  65610. export * from "babylonjs/Misc/sceneOptimizer";
  65611. export * from "babylonjs/Misc/sceneSerializer";
  65612. export * from "babylonjs/Misc/smartArray";
  65613. export * from "babylonjs/Misc/stringDictionary";
  65614. export * from "babylonjs/Misc/tags";
  65615. export * from "babylonjs/Misc/textureTools";
  65616. export * from "babylonjs/Misc/tga";
  65617. export * from "babylonjs/Misc/tools";
  65618. export * from "babylonjs/Misc/videoRecorder";
  65619. export * from "babylonjs/Misc/virtualJoystick";
  65620. export * from "babylonjs/Misc/workerPool";
  65621. export * from "babylonjs/Misc/logger";
  65622. export * from "babylonjs/Misc/typeStore";
  65623. export * from "babylonjs/Misc/filesInputStore";
  65624. export * from "babylonjs/Misc/deepCopier";
  65625. export * from "babylonjs/Misc/pivotTools";
  65626. export * from "babylonjs/Misc/precisionDate";
  65627. export * from "babylonjs/Misc/screenshotTools";
  65628. export * from "babylonjs/Misc/typeStore";
  65629. export * from "babylonjs/Misc/webRequest";
  65630. export * from "babylonjs/Misc/iInspectable";
  65631. export * from "babylonjs/Misc/brdfTextureTools";
  65632. export * from "babylonjs/Misc/rgbdTextureTools";
  65633. export * from "babylonjs/Misc/gradients";
  65634. export * from "babylonjs/Misc/perfCounter";
  65635. export * from "babylonjs/Misc/fileRequest";
  65636. export * from "babylonjs/Misc/customAnimationFrameRequester";
  65637. export * from "babylonjs/Misc/retryStrategy";
  65638. export * from "babylonjs/Misc/loadFileError";
  65639. }
  65640. declare module "babylonjs/index" {
  65641. export * from "babylonjs/abstractScene";
  65642. export * from "babylonjs/Actions/index";
  65643. export * from "babylonjs/Animations/index";
  65644. export * from "babylonjs/assetContainer";
  65645. export * from "babylonjs/Audio/index";
  65646. export * from "babylonjs/Behaviors/index";
  65647. export * from "babylonjs/Bones/index";
  65648. export * from "babylonjs/Cameras/index";
  65649. export * from "babylonjs/Collisions/index";
  65650. export * from "babylonjs/Culling/index";
  65651. export * from "babylonjs/Debug/index";
  65652. export * from "babylonjs/Engines/index";
  65653. export * from "babylonjs/Events/index";
  65654. export * from "babylonjs/Gamepads/index";
  65655. export * from "babylonjs/Gizmos/index";
  65656. export * from "babylonjs/Helpers/index";
  65657. export * from "babylonjs/Instrumentation/index";
  65658. export * from "babylonjs/Layers/index";
  65659. export * from "babylonjs/LensFlares/index";
  65660. export * from "babylonjs/Lights/index";
  65661. export * from "babylonjs/Loading/index";
  65662. export * from "babylonjs/Materials/index";
  65663. export * from "babylonjs/Maths/index";
  65664. export * from "babylonjs/Meshes/index";
  65665. export * from "babylonjs/Morph/index";
  65666. export * from "babylonjs/Navigation/index";
  65667. export * from "babylonjs/node";
  65668. export * from "babylonjs/Offline/index";
  65669. export * from "babylonjs/Particles/index";
  65670. export * from "babylonjs/Physics/index";
  65671. export * from "babylonjs/PostProcesses/index";
  65672. export * from "babylonjs/Probes/index";
  65673. export * from "babylonjs/Rendering/index";
  65674. export * from "babylonjs/scene";
  65675. export * from "babylonjs/sceneComponent";
  65676. export * from "babylonjs/Sprites/index";
  65677. export * from "babylonjs/States/index";
  65678. export * from "babylonjs/Misc/index";
  65679. export * from "babylonjs/types";
  65680. }
  65681. declare module "babylonjs/Animations/pathCursor" {
  65682. import { Vector3 } from "babylonjs/Maths/math.vector";
  65683. import { Path2 } from "babylonjs/Maths/math.path";
  65684. /**
  65685. * A cursor which tracks a point on a path
  65686. */
  65687. export class PathCursor {
  65688. private path;
  65689. /**
  65690. * Stores path cursor callbacks for when an onchange event is triggered
  65691. */
  65692. private _onchange;
  65693. /**
  65694. * The value of the path cursor
  65695. */
  65696. value: number;
  65697. /**
  65698. * The animation array of the path cursor
  65699. */
  65700. animations: Animation[];
  65701. /**
  65702. * Initializes the path cursor
  65703. * @param path The path to track
  65704. */
  65705. constructor(path: Path2);
  65706. /**
  65707. * Gets the cursor point on the path
  65708. * @returns A point on the path cursor at the cursor location
  65709. */
  65710. getPoint(): Vector3;
  65711. /**
  65712. * Moves the cursor ahead by the step amount
  65713. * @param step The amount to move the cursor forward
  65714. * @returns This path cursor
  65715. */
  65716. moveAhead(step?: number): PathCursor;
  65717. /**
  65718. * Moves the cursor behind by the step amount
  65719. * @param step The amount to move the cursor back
  65720. * @returns This path cursor
  65721. */
  65722. moveBack(step?: number): PathCursor;
  65723. /**
  65724. * Moves the cursor by the step amount
  65725. * If the step amount is greater than one, an exception is thrown
  65726. * @param step The amount to move the cursor
  65727. * @returns This path cursor
  65728. */
  65729. move(step: number): PathCursor;
  65730. /**
  65731. * Ensures that the value is limited between zero and one
  65732. * @returns This path cursor
  65733. */
  65734. private ensureLimits;
  65735. /**
  65736. * Runs onchange callbacks on change (used by the animation engine)
  65737. * @returns This path cursor
  65738. */
  65739. private raiseOnChange;
  65740. /**
  65741. * Executes a function on change
  65742. * @param f A path cursor onchange callback
  65743. * @returns This path cursor
  65744. */
  65745. onchange(f: (cursor: PathCursor) => void): PathCursor;
  65746. }
  65747. }
  65748. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  65749. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  65750. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  65751. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  65752. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  65753. }
  65754. declare module "babylonjs/Engines/Processors/Expressions/index" {
  65755. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  65756. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  65757. }
  65758. declare module "babylonjs/Engines/Processors/index" {
  65759. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  65760. export * from "babylonjs/Engines/Processors/Expressions/index";
  65761. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  65762. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  65763. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  65764. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  65765. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  65766. export * from "babylonjs/Engines/Processors/shaderProcessor";
  65767. }
  65768. declare module "babylonjs/Legacy/legacy" {
  65769. import * as Babylon from "babylonjs/index";
  65770. export * from "babylonjs/index";
  65771. }
  65772. declare module "babylonjs/Shaders/blur.fragment" {
  65773. /** @hidden */
  65774. export var blurPixelShader: {
  65775. name: string;
  65776. shader: string;
  65777. };
  65778. }
  65779. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  65780. /** @hidden */
  65781. export var pointCloudVertexDeclaration: {
  65782. name: string;
  65783. shader: string;
  65784. };
  65785. }
  65786. declare module "babylonjs" {
  65787. export * from "babylonjs/Legacy/legacy";
  65788. }
  65789. declare module BABYLON {
  65790. /** Alias type for value that can be null */
  65791. export type Nullable<T> = T | null;
  65792. /**
  65793. * Alias type for number that are floats
  65794. * @ignorenaming
  65795. */
  65796. export type float = number;
  65797. /**
  65798. * Alias type for number that are doubles.
  65799. * @ignorenaming
  65800. */
  65801. export type double = number;
  65802. /**
  65803. * Alias type for number that are integer
  65804. * @ignorenaming
  65805. */
  65806. export type int = number;
  65807. /** Alias type for number array or Float32Array */
  65808. export type FloatArray = number[] | Float32Array;
  65809. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  65810. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  65811. /**
  65812. * Alias for types that can be used by a Buffer or VertexBuffer.
  65813. */
  65814. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  65815. /**
  65816. * Alias type for primitive types
  65817. * @ignorenaming
  65818. */
  65819. type Primitive = undefined | null | boolean | string | number | Function;
  65820. /**
  65821. * Type modifier to make all the properties of an object Readonly
  65822. */
  65823. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  65824. /**
  65825. * Type modifier to make all the properties of an object Readonly recursively
  65826. */
  65827. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  65828. /** @hidden */
  65829. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  65830. }
  65831. /** @hidden */
  65832. /** @hidden */
  65833. type DeepImmutableObject<T> = {
  65834. readonly [K in keyof T]: DeepImmutable<T[K]>;
  65835. };
  65836. }
  65837. declare module BABYLON {
  65838. /**
  65839. * A class serves as a medium between the observable and its observers
  65840. */
  65841. export class EventState {
  65842. /**
  65843. * Create a new EventState
  65844. * @param mask defines the mask associated with this state
  65845. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  65846. * @param target defines the original target of the state
  65847. * @param currentTarget defines the current target of the state
  65848. */
  65849. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  65850. /**
  65851. * Initialize the current event state
  65852. * @param mask defines the mask associated with this state
  65853. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  65854. * @param target defines the original target of the state
  65855. * @param currentTarget defines the current target of the state
  65856. * @returns the current event state
  65857. */
  65858. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  65859. /**
  65860. * An Observer can set this property to true to prevent subsequent observers of being notified
  65861. */
  65862. skipNextObservers: boolean;
  65863. /**
  65864. * Get the mask value that were used to trigger the event corresponding to this EventState object
  65865. */
  65866. mask: number;
  65867. /**
  65868. * The object that originally notified the event
  65869. */
  65870. target?: any;
  65871. /**
  65872. * The current object in the bubbling phase
  65873. */
  65874. currentTarget?: any;
  65875. /**
  65876. * This will be populated with the return value of the last function that was executed.
  65877. * If it is the first function in the callback chain it will be the event data.
  65878. */
  65879. lastReturnValue?: any;
  65880. }
  65881. /**
  65882. * Represent an Observer registered to a given Observable object.
  65883. */
  65884. export class Observer<T> {
  65885. /**
  65886. * Defines the callback to call when the observer is notified
  65887. */
  65888. callback: (eventData: T, eventState: EventState) => void;
  65889. /**
  65890. * Defines the mask of the observer (used to filter notifications)
  65891. */
  65892. mask: number;
  65893. /**
  65894. * Defines the current scope used to restore the JS context
  65895. */
  65896. scope: any;
  65897. /** @hidden */
  65898. _willBeUnregistered: boolean;
  65899. /**
  65900. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  65901. */
  65902. unregisterOnNextCall: boolean;
  65903. /**
  65904. * Creates a new observer
  65905. * @param callback defines the callback to call when the observer is notified
  65906. * @param mask defines the mask of the observer (used to filter notifications)
  65907. * @param scope defines the current scope used to restore the JS context
  65908. */
  65909. constructor(
  65910. /**
  65911. * Defines the callback to call when the observer is notified
  65912. */
  65913. callback: (eventData: T, eventState: EventState) => void,
  65914. /**
  65915. * Defines the mask of the observer (used to filter notifications)
  65916. */
  65917. mask: number,
  65918. /**
  65919. * Defines the current scope used to restore the JS context
  65920. */
  65921. scope?: any);
  65922. }
  65923. /**
  65924. * Represent a list of observers registered to multiple Observables object.
  65925. */
  65926. export class MultiObserver<T> {
  65927. private _observers;
  65928. private _observables;
  65929. /**
  65930. * Release associated resources
  65931. */
  65932. dispose(): void;
  65933. /**
  65934. * Raise a callback when one of the observable will notify
  65935. * @param observables defines a list of observables to watch
  65936. * @param callback defines the callback to call on notification
  65937. * @param mask defines the mask used to filter notifications
  65938. * @param scope defines the current scope used to restore the JS context
  65939. * @returns the new MultiObserver
  65940. */
  65941. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  65942. }
  65943. /**
  65944. * The Observable class is a simple implementation of the Observable pattern.
  65945. *
  65946. * 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.
  65947. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  65948. * 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).
  65949. * 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.
  65950. */
  65951. export class Observable<T> {
  65952. private _observers;
  65953. private _eventState;
  65954. private _onObserverAdded;
  65955. /**
  65956. * Gets the list of observers
  65957. */
  65958. readonly observers: Array<Observer<T>>;
  65959. /**
  65960. * Creates a new observable
  65961. * @param onObserverAdded defines a callback to call when a new observer is added
  65962. */
  65963. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  65964. /**
  65965. * Create a new Observer with the specified callback
  65966. * @param callback the callback that will be executed for that Observer
  65967. * @param mask the mask used to filter observers
  65968. * @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.
  65969. * @param scope optional scope for the callback to be called from
  65970. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  65971. * @returns the new observer created for the callback
  65972. */
  65973. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  65974. /**
  65975. * Create a new Observer with the specified callback and unregisters after the next notification
  65976. * @param callback the callback that will be executed for that Observer
  65977. * @returns the new observer created for the callback
  65978. */
  65979. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  65980. /**
  65981. * Remove an Observer from the Observable object
  65982. * @param observer the instance of the Observer to remove
  65983. * @returns false if it doesn't belong to this Observable
  65984. */
  65985. remove(observer: Nullable<Observer<T>>): boolean;
  65986. /**
  65987. * Remove a callback from the Observable object
  65988. * @param callback the callback to remove
  65989. * @param scope optional scope. If used only the callbacks with this scope will be removed
  65990. * @returns false if it doesn't belong to this Observable
  65991. */
  65992. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  65993. private _deferUnregister;
  65994. private _remove;
  65995. /**
  65996. * Moves the observable to the top of the observer list making it get called first when notified
  65997. * @param observer the observer to move
  65998. */
  65999. makeObserverTopPriority(observer: Observer<T>): void;
  66000. /**
  66001. * Moves the observable to the bottom of the observer list making it get called last when notified
  66002. * @param observer the observer to move
  66003. */
  66004. makeObserverBottomPriority(observer: Observer<T>): void;
  66005. /**
  66006. * Notify all Observers by calling their respective callback with the given data
  66007. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  66008. * @param eventData defines the data to send to all observers
  66009. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  66010. * @param target defines the original target of the state
  66011. * @param currentTarget defines the current target of the state
  66012. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  66013. */
  66014. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  66015. /**
  66016. * Calling this will execute each callback, expecting it to be a promise or return a value.
  66017. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  66018. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  66019. * and it is crucial that all callbacks will be executed.
  66020. * The order of the callbacks is kept, callbacks are not executed parallel.
  66021. *
  66022. * @param eventData The data to be sent to each callback
  66023. * @param mask is used to filter observers defaults to -1
  66024. * @param target defines the callback target (see EventState)
  66025. * @param currentTarget defines he current object in the bubbling phase
  66026. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  66027. */
  66028. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  66029. /**
  66030. * Notify a specific observer
  66031. * @param observer defines the observer to notify
  66032. * @param eventData defines the data to be sent to each callback
  66033. * @param mask is used to filter observers defaults to -1
  66034. */
  66035. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  66036. /**
  66037. * Gets a boolean indicating if the observable has at least one observer
  66038. * @returns true is the Observable has at least one Observer registered
  66039. */
  66040. hasObservers(): boolean;
  66041. /**
  66042. * Clear the list of observers
  66043. */
  66044. clear(): void;
  66045. /**
  66046. * Clone the current observable
  66047. * @returns a new observable
  66048. */
  66049. clone(): Observable<T>;
  66050. /**
  66051. * Does this observable handles observer registered with a given mask
  66052. * @param mask defines the mask to be tested
  66053. * @return whether or not one observer registered with the given mask is handeled
  66054. **/
  66055. hasSpecificMask(mask?: number): boolean;
  66056. }
  66057. }
  66058. declare module BABYLON {
  66059. /**
  66060. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  66061. * Babylon.js
  66062. */
  66063. export class DomManagement {
  66064. /**
  66065. * Checks if the window object exists
  66066. * @returns true if the window object exists
  66067. */
  66068. static IsWindowObjectExist(): boolean;
  66069. /**
  66070. * Checks if the navigator object exists
  66071. * @returns true if the navigator object exists
  66072. */
  66073. static IsNavigatorAvailable(): boolean;
  66074. /**
  66075. * Extracts text content from a DOM element hierarchy
  66076. * @param element defines the root element
  66077. * @returns a string
  66078. */
  66079. static GetDOMTextContent(element: HTMLElement): string;
  66080. }
  66081. }
  66082. declare module BABYLON {
  66083. /**
  66084. * Logger used througouht the application to allow configuration of
  66085. * the log level required for the messages.
  66086. */
  66087. export class Logger {
  66088. /**
  66089. * No log
  66090. */
  66091. static readonly NoneLogLevel: number;
  66092. /**
  66093. * Only message logs
  66094. */
  66095. static readonly MessageLogLevel: number;
  66096. /**
  66097. * Only warning logs
  66098. */
  66099. static readonly WarningLogLevel: number;
  66100. /**
  66101. * Only error logs
  66102. */
  66103. static readonly ErrorLogLevel: number;
  66104. /**
  66105. * All logs
  66106. */
  66107. static readonly AllLogLevel: number;
  66108. private static _LogCache;
  66109. /**
  66110. * Gets a value indicating the number of loading errors
  66111. * @ignorenaming
  66112. */
  66113. static errorsCount: number;
  66114. /**
  66115. * Callback called when a new log is added
  66116. */
  66117. static OnNewCacheEntry: (entry: string) => void;
  66118. private static _AddLogEntry;
  66119. private static _FormatMessage;
  66120. private static _LogDisabled;
  66121. private static _LogEnabled;
  66122. private static _WarnDisabled;
  66123. private static _WarnEnabled;
  66124. private static _ErrorDisabled;
  66125. private static _ErrorEnabled;
  66126. /**
  66127. * Log a message to the console
  66128. */
  66129. static Log: (message: string) => void;
  66130. /**
  66131. * Write a warning message to the console
  66132. */
  66133. static Warn: (message: string) => void;
  66134. /**
  66135. * Write an error message to the console
  66136. */
  66137. static Error: (message: string) => void;
  66138. /**
  66139. * Gets current log cache (list of logs)
  66140. */
  66141. static readonly LogCache: string;
  66142. /**
  66143. * Clears the log cache
  66144. */
  66145. static ClearLogCache(): void;
  66146. /**
  66147. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  66148. */
  66149. static LogLevels: number;
  66150. }
  66151. }
  66152. declare module BABYLON {
  66153. /** @hidden */
  66154. export class _TypeStore {
  66155. /** @hidden */
  66156. static RegisteredTypes: {
  66157. [key: string]: Object;
  66158. };
  66159. /** @hidden */
  66160. static GetClass(fqdn: string): any;
  66161. }
  66162. }
  66163. declare module BABYLON {
  66164. /**
  66165. * Class containing a set of static utilities functions for deep copy.
  66166. */
  66167. export class DeepCopier {
  66168. /**
  66169. * Tries to copy an object by duplicating every property
  66170. * @param source defines the source object
  66171. * @param destination defines the target object
  66172. * @param doNotCopyList defines a list of properties to avoid
  66173. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  66174. */
  66175. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  66176. }
  66177. }
  66178. declare module BABYLON {
  66179. /**
  66180. * Class containing a set of static utilities functions for precision date
  66181. */
  66182. export class PrecisionDate {
  66183. /**
  66184. * Gets either window.performance.now() if supported or Date.now() else
  66185. */
  66186. static readonly Now: number;
  66187. }
  66188. }
  66189. declare module BABYLON {
  66190. /** @hidden */
  66191. export class _DevTools {
  66192. static WarnImport(name: string): string;
  66193. }
  66194. }
  66195. declare module BABYLON {
  66196. /**
  66197. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  66198. */
  66199. export class WebRequest {
  66200. private _xhr;
  66201. /**
  66202. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  66203. * i.e. when loading files, where the server/service expects an Authorization header
  66204. */
  66205. static CustomRequestHeaders: {
  66206. [key: string]: string;
  66207. };
  66208. /**
  66209. * Add callback functions in this array to update all the requests before they get sent to the network
  66210. */
  66211. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  66212. private _injectCustomRequestHeaders;
  66213. /**
  66214. * Gets or sets a function to be called when loading progress changes
  66215. */
  66216. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  66217. /**
  66218. * Returns client's state
  66219. */
  66220. readonly readyState: number;
  66221. /**
  66222. * Returns client's status
  66223. */
  66224. readonly status: number;
  66225. /**
  66226. * Returns client's status as a text
  66227. */
  66228. readonly statusText: string;
  66229. /**
  66230. * Returns client's response
  66231. */
  66232. readonly response: any;
  66233. /**
  66234. * Returns client's response url
  66235. */
  66236. readonly responseURL: string;
  66237. /**
  66238. * Returns client's response as text
  66239. */
  66240. readonly responseText: string;
  66241. /**
  66242. * Gets or sets the expected response type
  66243. */
  66244. responseType: XMLHttpRequestResponseType;
  66245. /** @hidden */
  66246. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  66247. /** @hidden */
  66248. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  66249. /**
  66250. * Cancels any network activity
  66251. */
  66252. abort(): void;
  66253. /**
  66254. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  66255. * @param body defines an optional request body
  66256. */
  66257. send(body?: Document | BodyInit | null): void;
  66258. /**
  66259. * Sets the request method, request URL
  66260. * @param method defines the method to use (GET, POST, etc..)
  66261. * @param url defines the url to connect with
  66262. */
  66263. open(method: string, url: string): void;
  66264. }
  66265. }
  66266. declare module BABYLON {
  66267. /**
  66268. * File request interface
  66269. */
  66270. export interface IFileRequest {
  66271. /**
  66272. * Raised when the request is complete (success or error).
  66273. */
  66274. onCompleteObservable: Observable<IFileRequest>;
  66275. /**
  66276. * Aborts the request for a file.
  66277. */
  66278. abort: () => void;
  66279. }
  66280. }
  66281. declare module BABYLON {
  66282. /**
  66283. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  66284. */
  66285. export class PerformanceMonitor {
  66286. private _enabled;
  66287. private _rollingFrameTime;
  66288. private _lastFrameTimeMs;
  66289. /**
  66290. * constructor
  66291. * @param frameSampleSize The number of samples required to saturate the sliding window
  66292. */
  66293. constructor(frameSampleSize?: number);
  66294. /**
  66295. * Samples current frame
  66296. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  66297. */
  66298. sampleFrame(timeMs?: number): void;
  66299. /**
  66300. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  66301. */
  66302. readonly averageFrameTime: number;
  66303. /**
  66304. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  66305. */
  66306. readonly averageFrameTimeVariance: number;
  66307. /**
  66308. * Returns the frame time of the most recent frame
  66309. */
  66310. readonly instantaneousFrameTime: number;
  66311. /**
  66312. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  66313. */
  66314. readonly averageFPS: number;
  66315. /**
  66316. * Returns the average framerate in frames per second using the most recent frame time
  66317. */
  66318. readonly instantaneousFPS: number;
  66319. /**
  66320. * Returns true if enough samples have been taken to completely fill the sliding window
  66321. */
  66322. readonly isSaturated: boolean;
  66323. /**
  66324. * Enables contributions to the sliding window sample set
  66325. */
  66326. enable(): void;
  66327. /**
  66328. * Disables contributions to the sliding window sample set
  66329. * Samples will not be interpolated over the disabled period
  66330. */
  66331. disable(): void;
  66332. /**
  66333. * Returns true if sampling is enabled
  66334. */
  66335. readonly isEnabled: boolean;
  66336. /**
  66337. * Resets performance monitor
  66338. */
  66339. reset(): void;
  66340. }
  66341. /**
  66342. * RollingAverage
  66343. *
  66344. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  66345. */
  66346. export class RollingAverage {
  66347. /**
  66348. * Current average
  66349. */
  66350. average: number;
  66351. /**
  66352. * Current variance
  66353. */
  66354. variance: number;
  66355. protected _samples: Array<number>;
  66356. protected _sampleCount: number;
  66357. protected _pos: number;
  66358. protected _m2: number;
  66359. /**
  66360. * constructor
  66361. * @param length The number of samples required to saturate the sliding window
  66362. */
  66363. constructor(length: number);
  66364. /**
  66365. * Adds a sample to the sample set
  66366. * @param v The sample value
  66367. */
  66368. add(v: number): void;
  66369. /**
  66370. * Returns previously added values or null if outside of history or outside the sliding window domain
  66371. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  66372. * @return Value previously recorded with add() or null if outside of range
  66373. */
  66374. history(i: number): number;
  66375. /**
  66376. * Returns true if enough samples have been taken to completely fill the sliding window
  66377. * @return true if sample-set saturated
  66378. */
  66379. isSaturated(): boolean;
  66380. /**
  66381. * Resets the rolling average (equivalent to 0 samples taken so far)
  66382. */
  66383. reset(): void;
  66384. /**
  66385. * Wraps a value around the sample range boundaries
  66386. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  66387. * @return Wrapped position in sample range
  66388. */
  66389. protected _wrapPosition(i: number): number;
  66390. }
  66391. }
  66392. declare module BABYLON {
  66393. /**
  66394. * This class implement a typical dictionary using a string as key and the generic type T as value.
  66395. * The underlying implementation relies on an associative array to ensure the best performances.
  66396. * The value can be anything including 'null' but except 'undefined'
  66397. */
  66398. export class StringDictionary<T> {
  66399. /**
  66400. * This will clear this dictionary and copy the content from the 'source' one.
  66401. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  66402. * @param source the dictionary to take the content from and copy to this dictionary
  66403. */
  66404. copyFrom(source: StringDictionary<T>): void;
  66405. /**
  66406. * Get a value based from its key
  66407. * @param key the given key to get the matching value from
  66408. * @return the value if found, otherwise undefined is returned
  66409. */
  66410. get(key: string): T | undefined;
  66411. /**
  66412. * Get a value from its key or add it if it doesn't exist.
  66413. * This method will ensure you that a given key/data will be present in the dictionary.
  66414. * @param key the given key to get the matching value from
  66415. * @param factory the factory that will create the value if the key is not present in the dictionary.
  66416. * The factory will only be invoked if there's no data for the given key.
  66417. * @return the value corresponding to the key.
  66418. */
  66419. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  66420. /**
  66421. * Get a value from its key if present in the dictionary otherwise add it
  66422. * @param key the key to get the value from
  66423. * @param val if there's no such key/value pair in the dictionary add it with this value
  66424. * @return the value corresponding to the key
  66425. */
  66426. getOrAdd(key: string, val: T): T;
  66427. /**
  66428. * Check if there's a given key in the dictionary
  66429. * @param key the key to check for
  66430. * @return true if the key is present, false otherwise
  66431. */
  66432. contains(key: string): boolean;
  66433. /**
  66434. * Add a new key and its corresponding value
  66435. * @param key the key to add
  66436. * @param value the value corresponding to the key
  66437. * @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
  66438. */
  66439. add(key: string, value: T): boolean;
  66440. /**
  66441. * Update a specific value associated to a key
  66442. * @param key defines the key to use
  66443. * @param value defines the value to store
  66444. * @returns true if the value was updated (or false if the key was not found)
  66445. */
  66446. set(key: string, value: T): boolean;
  66447. /**
  66448. * Get the element of the given key and remove it from the dictionary
  66449. * @param key defines the key to search
  66450. * @returns the value associated with the key or null if not found
  66451. */
  66452. getAndRemove(key: string): Nullable<T>;
  66453. /**
  66454. * Remove a key/value from the dictionary.
  66455. * @param key the key to remove
  66456. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  66457. */
  66458. remove(key: string): boolean;
  66459. /**
  66460. * Clear the whole content of the dictionary
  66461. */
  66462. clear(): void;
  66463. /**
  66464. * Gets the current count
  66465. */
  66466. readonly count: number;
  66467. /**
  66468. * Execute a callback on each key/val of the dictionary.
  66469. * Note that you can remove any element in this dictionary in the callback implementation
  66470. * @param callback the callback to execute on a given key/value pair
  66471. */
  66472. forEach(callback: (key: string, val: T) => void): void;
  66473. /**
  66474. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  66475. * If the callback returns null or undefined the method will iterate to the next key/value pair
  66476. * Note that you can remove any element in this dictionary in the callback implementation
  66477. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  66478. * @returns the first item
  66479. */
  66480. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  66481. private _count;
  66482. private _data;
  66483. }
  66484. }
  66485. declare module BABYLON {
  66486. /**
  66487. * Class used to store gfx data (like WebGLBuffer)
  66488. */
  66489. export class DataBuffer {
  66490. /**
  66491. * Gets or sets the number of objects referencing this buffer
  66492. */
  66493. references: number;
  66494. /** Gets or sets the size of the underlying buffer */
  66495. capacity: number;
  66496. /**
  66497. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  66498. */
  66499. is32Bits: boolean;
  66500. /**
  66501. * Gets the underlying buffer
  66502. */
  66503. readonly underlyingResource: any;
  66504. }
  66505. }
  66506. declare module BABYLON {
  66507. /**
  66508. * Class used to store data that will be store in GPU memory
  66509. */
  66510. export class Buffer {
  66511. private _engine;
  66512. private _buffer;
  66513. /** @hidden */
  66514. _data: Nullable<DataArray>;
  66515. private _updatable;
  66516. private _instanced;
  66517. /**
  66518. * Gets the byte stride.
  66519. */
  66520. readonly byteStride: number;
  66521. /**
  66522. * Constructor
  66523. * @param engine the engine
  66524. * @param data the data to use for this buffer
  66525. * @param updatable whether the data is updatable
  66526. * @param stride the stride (optional)
  66527. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  66528. * @param instanced whether the buffer is instanced (optional)
  66529. * @param useBytes set to true if the stride in in bytes (optional)
  66530. */
  66531. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  66532. /**
  66533. * Create a new VertexBuffer based on the current buffer
  66534. * @param kind defines the vertex buffer kind (position, normal, etc.)
  66535. * @param offset defines offset in the buffer (0 by default)
  66536. * @param size defines the size in floats of attributes (position is 3 for instance)
  66537. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  66538. * @param instanced defines if the vertex buffer contains indexed data
  66539. * @param useBytes defines if the offset and stride are in bytes
  66540. * @returns the new vertex buffer
  66541. */
  66542. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  66543. /**
  66544. * Gets a boolean indicating if the Buffer is updatable?
  66545. * @returns true if the buffer is updatable
  66546. */
  66547. isUpdatable(): boolean;
  66548. /**
  66549. * Gets current buffer's data
  66550. * @returns a DataArray or null
  66551. */
  66552. getData(): Nullable<DataArray>;
  66553. /**
  66554. * Gets underlying native buffer
  66555. * @returns underlying native buffer
  66556. */
  66557. getBuffer(): Nullable<DataBuffer>;
  66558. /**
  66559. * Gets the stride in float32 units (i.e. byte stride / 4).
  66560. * May not be an integer if the byte stride is not divisible by 4.
  66561. * DEPRECATED. Use byteStride instead.
  66562. * @returns the stride in float32 units
  66563. */
  66564. getStrideSize(): number;
  66565. /**
  66566. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  66567. * @param data defines the data to store
  66568. */
  66569. create(data?: Nullable<DataArray>): void;
  66570. /** @hidden */
  66571. _rebuild(): void;
  66572. /**
  66573. * Update current buffer data
  66574. * @param data defines the data to store
  66575. */
  66576. update(data: DataArray): void;
  66577. /**
  66578. * Updates the data directly.
  66579. * @param data the new data
  66580. * @param offset the new offset
  66581. * @param vertexCount the vertex count (optional)
  66582. * @param useBytes set to true if the offset is in bytes
  66583. */
  66584. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  66585. /**
  66586. * Release all resources
  66587. */
  66588. dispose(): void;
  66589. }
  66590. /**
  66591. * Specialized buffer used to store vertex data
  66592. */
  66593. export class VertexBuffer {
  66594. /** @hidden */
  66595. _buffer: Buffer;
  66596. private _kind;
  66597. private _size;
  66598. private _ownsBuffer;
  66599. private _instanced;
  66600. private _instanceDivisor;
  66601. /**
  66602. * The byte type.
  66603. */
  66604. static readonly BYTE: number;
  66605. /**
  66606. * The unsigned byte type.
  66607. */
  66608. static readonly UNSIGNED_BYTE: number;
  66609. /**
  66610. * The short type.
  66611. */
  66612. static readonly SHORT: number;
  66613. /**
  66614. * The unsigned short type.
  66615. */
  66616. static readonly UNSIGNED_SHORT: number;
  66617. /**
  66618. * The integer type.
  66619. */
  66620. static readonly INT: number;
  66621. /**
  66622. * The unsigned integer type.
  66623. */
  66624. static readonly UNSIGNED_INT: number;
  66625. /**
  66626. * The float type.
  66627. */
  66628. static readonly FLOAT: number;
  66629. /**
  66630. * Gets or sets the instance divisor when in instanced mode
  66631. */
  66632. instanceDivisor: number;
  66633. /**
  66634. * Gets the byte stride.
  66635. */
  66636. readonly byteStride: number;
  66637. /**
  66638. * Gets the byte offset.
  66639. */
  66640. readonly byteOffset: number;
  66641. /**
  66642. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  66643. */
  66644. readonly normalized: boolean;
  66645. /**
  66646. * Gets the data type of each component in the array.
  66647. */
  66648. readonly type: number;
  66649. /**
  66650. * Constructor
  66651. * @param engine the engine
  66652. * @param data the data to use for this vertex buffer
  66653. * @param kind the vertex buffer kind
  66654. * @param updatable whether the data is updatable
  66655. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  66656. * @param stride the stride (optional)
  66657. * @param instanced whether the buffer is instanced (optional)
  66658. * @param offset the offset of the data (optional)
  66659. * @param size the number of components (optional)
  66660. * @param type the type of the component (optional)
  66661. * @param normalized whether the data contains normalized data (optional)
  66662. * @param useBytes set to true if stride and offset are in bytes (optional)
  66663. */
  66664. 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);
  66665. /** @hidden */
  66666. _rebuild(): void;
  66667. /**
  66668. * Returns the kind of the VertexBuffer (string)
  66669. * @returns a string
  66670. */
  66671. getKind(): string;
  66672. /**
  66673. * Gets a boolean indicating if the VertexBuffer is updatable?
  66674. * @returns true if the buffer is updatable
  66675. */
  66676. isUpdatable(): boolean;
  66677. /**
  66678. * Gets current buffer's data
  66679. * @returns a DataArray or null
  66680. */
  66681. getData(): Nullable<DataArray>;
  66682. /**
  66683. * Gets underlying native buffer
  66684. * @returns underlying native buffer
  66685. */
  66686. getBuffer(): Nullable<DataBuffer>;
  66687. /**
  66688. * Gets the stride in float32 units (i.e. byte stride / 4).
  66689. * May not be an integer if the byte stride is not divisible by 4.
  66690. * DEPRECATED. Use byteStride instead.
  66691. * @returns the stride in float32 units
  66692. */
  66693. getStrideSize(): number;
  66694. /**
  66695. * Returns the offset as a multiple of the type byte length.
  66696. * DEPRECATED. Use byteOffset instead.
  66697. * @returns the offset in bytes
  66698. */
  66699. getOffset(): number;
  66700. /**
  66701. * Returns the number of components per vertex attribute (integer)
  66702. * @returns the size in float
  66703. */
  66704. getSize(): number;
  66705. /**
  66706. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  66707. * @returns true if this buffer is instanced
  66708. */
  66709. getIsInstanced(): boolean;
  66710. /**
  66711. * Returns the instancing divisor, zero for non-instanced (integer).
  66712. * @returns a number
  66713. */
  66714. getInstanceDivisor(): number;
  66715. /**
  66716. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  66717. * @param data defines the data to store
  66718. */
  66719. create(data?: DataArray): void;
  66720. /**
  66721. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  66722. * This function will create a new buffer if the current one is not updatable
  66723. * @param data defines the data to store
  66724. */
  66725. update(data: DataArray): void;
  66726. /**
  66727. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  66728. * Returns the directly updated WebGLBuffer.
  66729. * @param data the new data
  66730. * @param offset the new offset
  66731. * @param useBytes set to true if the offset is in bytes
  66732. */
  66733. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  66734. /**
  66735. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  66736. */
  66737. dispose(): void;
  66738. /**
  66739. * Enumerates each value of this vertex buffer as numbers.
  66740. * @param count the number of values to enumerate
  66741. * @param callback the callback function called for each value
  66742. */
  66743. forEach(count: number, callback: (value: number, index: number) => void): void;
  66744. /**
  66745. * Positions
  66746. */
  66747. static readonly PositionKind: string;
  66748. /**
  66749. * Normals
  66750. */
  66751. static readonly NormalKind: string;
  66752. /**
  66753. * Tangents
  66754. */
  66755. static readonly TangentKind: string;
  66756. /**
  66757. * Texture coordinates
  66758. */
  66759. static readonly UVKind: string;
  66760. /**
  66761. * Texture coordinates 2
  66762. */
  66763. static readonly UV2Kind: string;
  66764. /**
  66765. * Texture coordinates 3
  66766. */
  66767. static readonly UV3Kind: string;
  66768. /**
  66769. * Texture coordinates 4
  66770. */
  66771. static readonly UV4Kind: string;
  66772. /**
  66773. * Texture coordinates 5
  66774. */
  66775. static readonly UV5Kind: string;
  66776. /**
  66777. * Texture coordinates 6
  66778. */
  66779. static readonly UV6Kind: string;
  66780. /**
  66781. * Colors
  66782. */
  66783. static readonly ColorKind: string;
  66784. /**
  66785. * Matrix indices (for bones)
  66786. */
  66787. static readonly MatricesIndicesKind: string;
  66788. /**
  66789. * Matrix weights (for bones)
  66790. */
  66791. static readonly MatricesWeightsKind: string;
  66792. /**
  66793. * Additional matrix indices (for bones)
  66794. */
  66795. static readonly MatricesIndicesExtraKind: string;
  66796. /**
  66797. * Additional matrix weights (for bones)
  66798. */
  66799. static readonly MatricesWeightsExtraKind: string;
  66800. /**
  66801. * Deduces the stride given a kind.
  66802. * @param kind The kind string to deduce
  66803. * @returns The deduced stride
  66804. */
  66805. static DeduceStride(kind: string): number;
  66806. /**
  66807. * Gets the byte length of the given type.
  66808. * @param type the type
  66809. * @returns the number of bytes
  66810. */
  66811. static GetTypeByteLength(type: number): number;
  66812. /**
  66813. * Enumerates each value of the given parameters as numbers.
  66814. * @param data the data to enumerate
  66815. * @param byteOffset the byte offset of the data
  66816. * @param byteStride the byte stride of the data
  66817. * @param componentCount the number of components per element
  66818. * @param componentType the type of the component
  66819. * @param count the number of values to enumerate
  66820. * @param normalized whether the data is normalized
  66821. * @param callback the callback function called for each value
  66822. */
  66823. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  66824. private static _GetFloatValue;
  66825. }
  66826. }
  66827. declare module BABYLON {
  66828. /**
  66829. * Scalar computation library
  66830. */
  66831. export class Scalar {
  66832. /**
  66833. * Two pi constants convenient for computation.
  66834. */
  66835. static TwoPi: number;
  66836. /**
  66837. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  66838. * @param a number
  66839. * @param b number
  66840. * @param epsilon (default = 1.401298E-45)
  66841. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  66842. */
  66843. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  66844. /**
  66845. * Returns a string : the upper case translation of the number i to hexadecimal.
  66846. * @param i number
  66847. * @returns the upper case translation of the number i to hexadecimal.
  66848. */
  66849. static ToHex(i: number): string;
  66850. /**
  66851. * Returns -1 if value is negative and +1 is value is positive.
  66852. * @param value the value
  66853. * @returns the value itself if it's equal to zero.
  66854. */
  66855. static Sign(value: number): number;
  66856. /**
  66857. * Returns the value itself if it's between min and max.
  66858. * Returns min if the value is lower than min.
  66859. * Returns max if the value is greater than max.
  66860. * @param value the value to clmap
  66861. * @param min the min value to clamp to (default: 0)
  66862. * @param max the max value to clamp to (default: 1)
  66863. * @returns the clamped value
  66864. */
  66865. static Clamp(value: number, min?: number, max?: number): number;
  66866. /**
  66867. * the log2 of value.
  66868. * @param value the value to compute log2 of
  66869. * @returns the log2 of value.
  66870. */
  66871. static Log2(value: number): number;
  66872. /**
  66873. * Loops the value, so that it is never larger than length and never smaller than 0.
  66874. *
  66875. * This is similar to the modulo operator but it works with floating point numbers.
  66876. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  66877. * With t = 5 and length = 2.5, the result would be 0.0.
  66878. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  66879. * @param value the value
  66880. * @param length the length
  66881. * @returns the looped value
  66882. */
  66883. static Repeat(value: number, length: number): number;
  66884. /**
  66885. * Normalize the value between 0.0 and 1.0 using min and max values
  66886. * @param value value to normalize
  66887. * @param min max to normalize between
  66888. * @param max min to normalize between
  66889. * @returns the normalized value
  66890. */
  66891. static Normalize(value: number, min: number, max: number): number;
  66892. /**
  66893. * Denormalize the value from 0.0 and 1.0 using min and max values
  66894. * @param normalized value to denormalize
  66895. * @param min max to denormalize between
  66896. * @param max min to denormalize between
  66897. * @returns the denormalized value
  66898. */
  66899. static Denormalize(normalized: number, min: number, max: number): number;
  66900. /**
  66901. * Calculates the shortest difference between two given angles given in degrees.
  66902. * @param current current angle in degrees
  66903. * @param target target angle in degrees
  66904. * @returns the delta
  66905. */
  66906. static DeltaAngle(current: number, target: number): number;
  66907. /**
  66908. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  66909. * @param tx value
  66910. * @param length length
  66911. * @returns The returned value will move back and forth between 0 and length
  66912. */
  66913. static PingPong(tx: number, length: number): number;
  66914. /**
  66915. * Interpolates between min and max with smoothing at the limits.
  66916. *
  66917. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  66918. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  66919. * @param from from
  66920. * @param to to
  66921. * @param tx value
  66922. * @returns the smooth stepped value
  66923. */
  66924. static SmoothStep(from: number, to: number, tx: number): number;
  66925. /**
  66926. * Moves a value current towards target.
  66927. *
  66928. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  66929. * Negative values of maxDelta pushes the value away from target.
  66930. * @param current current value
  66931. * @param target target value
  66932. * @param maxDelta max distance to move
  66933. * @returns resulting value
  66934. */
  66935. static MoveTowards(current: number, target: number, maxDelta: number): number;
  66936. /**
  66937. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  66938. *
  66939. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  66940. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  66941. * @param current current value
  66942. * @param target target value
  66943. * @param maxDelta max distance to move
  66944. * @returns resulting angle
  66945. */
  66946. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  66947. /**
  66948. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  66949. * @param start start value
  66950. * @param end target value
  66951. * @param amount amount to lerp between
  66952. * @returns the lerped value
  66953. */
  66954. static Lerp(start: number, end: number, amount: number): number;
  66955. /**
  66956. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  66957. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  66958. * @param start start value
  66959. * @param end target value
  66960. * @param amount amount to lerp between
  66961. * @returns the lerped value
  66962. */
  66963. static LerpAngle(start: number, end: number, amount: number): number;
  66964. /**
  66965. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  66966. * @param a start value
  66967. * @param b target value
  66968. * @param value value between a and b
  66969. * @returns the inverseLerp value
  66970. */
  66971. static InverseLerp(a: number, b: number, value: number): number;
  66972. /**
  66973. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  66974. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  66975. * @param value1 spline value
  66976. * @param tangent1 spline value
  66977. * @param value2 spline value
  66978. * @param tangent2 spline value
  66979. * @param amount input value
  66980. * @returns hermite result
  66981. */
  66982. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  66983. /**
  66984. * Returns a random float number between and min and max values
  66985. * @param min min value of random
  66986. * @param max max value of random
  66987. * @returns random value
  66988. */
  66989. static RandomRange(min: number, max: number): number;
  66990. /**
  66991. * This function returns percentage of a number in a given range.
  66992. *
  66993. * RangeToPercent(40,20,60) will return 0.5 (50%)
  66994. * RangeToPercent(34,0,100) will return 0.34 (34%)
  66995. * @param number to convert to percentage
  66996. * @param min min range
  66997. * @param max max range
  66998. * @returns the percentage
  66999. */
  67000. static RangeToPercent(number: number, min: number, max: number): number;
  67001. /**
  67002. * This function returns number that corresponds to the percentage in a given range.
  67003. *
  67004. * PercentToRange(0.34,0,100) will return 34.
  67005. * @param percent to convert to number
  67006. * @param min min range
  67007. * @param max max range
  67008. * @returns the number
  67009. */
  67010. static PercentToRange(percent: number, min: number, max: number): number;
  67011. /**
  67012. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  67013. * @param angle The angle to normalize in radian.
  67014. * @return The converted angle.
  67015. */
  67016. static NormalizeRadians(angle: number): number;
  67017. }
  67018. }
  67019. declare module BABYLON {
  67020. /**
  67021. * Constant used to convert a value to gamma space
  67022. * @ignorenaming
  67023. */
  67024. export const ToGammaSpace: number;
  67025. /**
  67026. * Constant used to convert a value to linear space
  67027. * @ignorenaming
  67028. */
  67029. export const ToLinearSpace = 2.2;
  67030. /**
  67031. * Constant used to define the minimal number value in Babylon.js
  67032. * @ignorenaming
  67033. */
  67034. let Epsilon: number;
  67035. }
  67036. declare module BABYLON {
  67037. /**
  67038. * Class used to represent a viewport on screen
  67039. */
  67040. export class Viewport {
  67041. /** viewport left coordinate */
  67042. x: number;
  67043. /** viewport top coordinate */
  67044. y: number;
  67045. /**viewport width */
  67046. width: number;
  67047. /** viewport height */
  67048. height: number;
  67049. /**
  67050. * Creates a Viewport object located at (x, y) and sized (width, height)
  67051. * @param x defines viewport left coordinate
  67052. * @param y defines viewport top coordinate
  67053. * @param width defines the viewport width
  67054. * @param height defines the viewport height
  67055. */
  67056. constructor(
  67057. /** viewport left coordinate */
  67058. x: number,
  67059. /** viewport top coordinate */
  67060. y: number,
  67061. /**viewport width */
  67062. width: number,
  67063. /** viewport height */
  67064. height: number);
  67065. /**
  67066. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  67067. * @param renderWidth defines the rendering width
  67068. * @param renderHeight defines the rendering height
  67069. * @returns a new Viewport
  67070. */
  67071. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  67072. /**
  67073. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  67074. * @param renderWidth defines the rendering width
  67075. * @param renderHeight defines the rendering height
  67076. * @param ref defines the target viewport
  67077. * @returns the current viewport
  67078. */
  67079. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  67080. /**
  67081. * Returns a new Viewport copied from the current one
  67082. * @returns a new Viewport
  67083. */
  67084. clone(): Viewport;
  67085. }
  67086. }
  67087. declare module BABYLON {
  67088. /**
  67089. * Class containing a set of static utilities functions for arrays.
  67090. */
  67091. export class ArrayTools {
  67092. /**
  67093. * Returns an array of the given size filled with element built from the given constructor and the paramters
  67094. * @param size the number of element to construct and put in the array
  67095. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  67096. * @returns a new array filled with new objects
  67097. */
  67098. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  67099. }
  67100. }
  67101. declare module BABYLON {
  67102. /**
  67103. * @hidden
  67104. */
  67105. export interface IColor4Like {
  67106. r: float;
  67107. g: float;
  67108. b: float;
  67109. a: float;
  67110. }
  67111. /**
  67112. * @hidden
  67113. */
  67114. export interface IColor3Like {
  67115. r: float;
  67116. g: float;
  67117. b: float;
  67118. }
  67119. /**
  67120. * @hidden
  67121. */
  67122. export interface IVector4Like {
  67123. x: float;
  67124. y: float;
  67125. z: float;
  67126. w: float;
  67127. }
  67128. /**
  67129. * @hidden
  67130. */
  67131. export interface IVector3Like {
  67132. x: float;
  67133. y: float;
  67134. z: float;
  67135. }
  67136. /**
  67137. * @hidden
  67138. */
  67139. export interface IVector2Like {
  67140. x: float;
  67141. y: float;
  67142. }
  67143. /**
  67144. * @hidden
  67145. */
  67146. export interface IMatrixLike {
  67147. toArray(): DeepImmutable<Float32Array>;
  67148. updateFlag: int;
  67149. }
  67150. /**
  67151. * @hidden
  67152. */
  67153. export interface IViewportLike {
  67154. x: float;
  67155. y: float;
  67156. width: float;
  67157. height: float;
  67158. }
  67159. /**
  67160. * @hidden
  67161. */
  67162. export interface IPlaneLike {
  67163. normal: IVector3Like;
  67164. d: float;
  67165. normalize(): void;
  67166. }
  67167. }
  67168. declare module BABYLON {
  67169. /**
  67170. * Class representing a vector containing 2 coordinates
  67171. */
  67172. export class Vector2 {
  67173. /** defines the first coordinate */
  67174. x: number;
  67175. /** defines the second coordinate */
  67176. y: number;
  67177. /**
  67178. * Creates a new Vector2 from the given x and y coordinates
  67179. * @param x defines the first coordinate
  67180. * @param y defines the second coordinate
  67181. */
  67182. constructor(
  67183. /** defines the first coordinate */
  67184. x?: number,
  67185. /** defines the second coordinate */
  67186. y?: number);
  67187. /**
  67188. * Gets a string with the Vector2 coordinates
  67189. * @returns a string with the Vector2 coordinates
  67190. */
  67191. toString(): string;
  67192. /**
  67193. * Gets class name
  67194. * @returns the string "Vector2"
  67195. */
  67196. getClassName(): string;
  67197. /**
  67198. * Gets current vector hash code
  67199. * @returns the Vector2 hash code as a number
  67200. */
  67201. getHashCode(): number;
  67202. /**
  67203. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  67204. * @param array defines the source array
  67205. * @param index defines the offset in source array
  67206. * @returns the current Vector2
  67207. */
  67208. toArray(array: FloatArray, index?: number): Vector2;
  67209. /**
  67210. * Copy the current vector to an array
  67211. * @returns a new array with 2 elements: the Vector2 coordinates.
  67212. */
  67213. asArray(): number[];
  67214. /**
  67215. * Sets the Vector2 coordinates with the given Vector2 coordinates
  67216. * @param source defines the source Vector2
  67217. * @returns the current updated Vector2
  67218. */
  67219. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  67220. /**
  67221. * Sets the Vector2 coordinates with the given floats
  67222. * @param x defines the first coordinate
  67223. * @param y defines the second coordinate
  67224. * @returns the current updated Vector2
  67225. */
  67226. copyFromFloats(x: number, y: number): Vector2;
  67227. /**
  67228. * Sets the Vector2 coordinates with the given floats
  67229. * @param x defines the first coordinate
  67230. * @param y defines the second coordinate
  67231. * @returns the current updated Vector2
  67232. */
  67233. set(x: number, y: number): Vector2;
  67234. /**
  67235. * Add another vector with the current one
  67236. * @param otherVector defines the other vector
  67237. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  67238. */
  67239. add(otherVector: DeepImmutable<Vector2>): Vector2;
  67240. /**
  67241. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  67242. * @param otherVector defines the other vector
  67243. * @param result defines the target vector
  67244. * @returns the unmodified current Vector2
  67245. */
  67246. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67247. /**
  67248. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  67249. * @param otherVector defines the other vector
  67250. * @returns the current updated Vector2
  67251. */
  67252. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67253. /**
  67254. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  67255. * @param otherVector defines the other vector
  67256. * @returns a new Vector2
  67257. */
  67258. addVector3(otherVector: Vector3): Vector2;
  67259. /**
  67260. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  67261. * @param otherVector defines the other vector
  67262. * @returns a new Vector2
  67263. */
  67264. subtract(otherVector: Vector2): Vector2;
  67265. /**
  67266. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  67267. * @param otherVector defines the other vector
  67268. * @param result defines the target vector
  67269. * @returns the unmodified current Vector2
  67270. */
  67271. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67272. /**
  67273. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  67274. * @param otherVector defines the other vector
  67275. * @returns the current updated Vector2
  67276. */
  67277. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67278. /**
  67279. * Multiplies in place the current Vector2 coordinates by the given ones
  67280. * @param otherVector defines the other vector
  67281. * @returns the current updated Vector2
  67282. */
  67283. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67284. /**
  67285. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  67286. * @param otherVector defines the other vector
  67287. * @returns a new Vector2
  67288. */
  67289. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  67290. /**
  67291. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  67292. * @param otherVector defines the other vector
  67293. * @param result defines the target vector
  67294. * @returns the unmodified current Vector2
  67295. */
  67296. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67297. /**
  67298. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  67299. * @param x defines the first coordinate
  67300. * @param y defines the second coordinate
  67301. * @returns a new Vector2
  67302. */
  67303. multiplyByFloats(x: number, y: number): Vector2;
  67304. /**
  67305. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  67306. * @param otherVector defines the other vector
  67307. * @returns a new Vector2
  67308. */
  67309. divide(otherVector: Vector2): Vector2;
  67310. /**
  67311. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  67312. * @param otherVector defines the other vector
  67313. * @param result defines the target vector
  67314. * @returns the unmodified current Vector2
  67315. */
  67316. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67317. /**
  67318. * Divides the current Vector2 coordinates by the given ones
  67319. * @param otherVector defines the other vector
  67320. * @returns the current updated Vector2
  67321. */
  67322. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67323. /**
  67324. * Gets a new Vector2 with current Vector2 negated coordinates
  67325. * @returns a new Vector2
  67326. */
  67327. negate(): Vector2;
  67328. /**
  67329. * Multiply the Vector2 coordinates by scale
  67330. * @param scale defines the scaling factor
  67331. * @returns the current updated Vector2
  67332. */
  67333. scaleInPlace(scale: number): Vector2;
  67334. /**
  67335. * Returns a new Vector2 scaled by "scale" from the current Vector2
  67336. * @param scale defines the scaling factor
  67337. * @returns a new Vector2
  67338. */
  67339. scale(scale: number): Vector2;
  67340. /**
  67341. * Scale the current Vector2 values by a factor to a given Vector2
  67342. * @param scale defines the scale factor
  67343. * @param result defines the Vector2 object where to store the result
  67344. * @returns the unmodified current Vector2
  67345. */
  67346. scaleToRef(scale: number, result: Vector2): Vector2;
  67347. /**
  67348. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  67349. * @param scale defines the scale factor
  67350. * @param result defines the Vector2 object where to store the result
  67351. * @returns the unmodified current Vector2
  67352. */
  67353. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  67354. /**
  67355. * Gets a boolean if two vectors are equals
  67356. * @param otherVector defines the other vector
  67357. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  67358. */
  67359. equals(otherVector: DeepImmutable<Vector2>): boolean;
  67360. /**
  67361. * Gets a boolean if two vectors are equals (using an epsilon value)
  67362. * @param otherVector defines the other vector
  67363. * @param epsilon defines the minimal distance to consider equality
  67364. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  67365. */
  67366. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  67367. /**
  67368. * Gets a new Vector2 from current Vector2 floored values
  67369. * @returns a new Vector2
  67370. */
  67371. floor(): Vector2;
  67372. /**
  67373. * Gets a new Vector2 from current Vector2 floored values
  67374. * @returns a new Vector2
  67375. */
  67376. fract(): Vector2;
  67377. /**
  67378. * Gets the length of the vector
  67379. * @returns the vector length (float)
  67380. */
  67381. length(): number;
  67382. /**
  67383. * Gets the vector squared length
  67384. * @returns the vector squared length (float)
  67385. */
  67386. lengthSquared(): number;
  67387. /**
  67388. * Normalize the vector
  67389. * @returns the current updated Vector2
  67390. */
  67391. normalize(): Vector2;
  67392. /**
  67393. * Gets a new Vector2 copied from the Vector2
  67394. * @returns a new Vector2
  67395. */
  67396. clone(): Vector2;
  67397. /**
  67398. * Gets a new Vector2(0, 0)
  67399. * @returns a new Vector2
  67400. */
  67401. static Zero(): Vector2;
  67402. /**
  67403. * Gets a new Vector2(1, 1)
  67404. * @returns a new Vector2
  67405. */
  67406. static One(): Vector2;
  67407. /**
  67408. * Gets a new Vector2 set from the given index element of the given array
  67409. * @param array defines the data source
  67410. * @param offset defines the offset in the data source
  67411. * @returns a new Vector2
  67412. */
  67413. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  67414. /**
  67415. * Sets "result" from the given index element of the given array
  67416. * @param array defines the data source
  67417. * @param offset defines the offset in the data source
  67418. * @param result defines the target vector
  67419. */
  67420. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  67421. /**
  67422. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  67423. * @param value1 defines 1st point of control
  67424. * @param value2 defines 2nd point of control
  67425. * @param value3 defines 3rd point of control
  67426. * @param value4 defines 4th point of control
  67427. * @param amount defines the interpolation factor
  67428. * @returns a new Vector2
  67429. */
  67430. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  67431. /**
  67432. * 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".
  67433. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  67434. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  67435. * @param value defines the value to clamp
  67436. * @param min defines the lower limit
  67437. * @param max defines the upper limit
  67438. * @returns a new Vector2
  67439. */
  67440. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  67441. /**
  67442. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  67443. * @param value1 defines the 1st control point
  67444. * @param tangent1 defines the outgoing tangent
  67445. * @param value2 defines the 2nd control point
  67446. * @param tangent2 defines the incoming tangent
  67447. * @param amount defines the interpolation factor
  67448. * @returns a new Vector2
  67449. */
  67450. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  67451. /**
  67452. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  67453. * @param start defines the start vector
  67454. * @param end defines the end vector
  67455. * @param amount defines the interpolation factor
  67456. * @returns a new Vector2
  67457. */
  67458. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  67459. /**
  67460. * Gets the dot product of the vector "left" and the vector "right"
  67461. * @param left defines first vector
  67462. * @param right defines second vector
  67463. * @returns the dot product (float)
  67464. */
  67465. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  67466. /**
  67467. * Returns a new Vector2 equal to the normalized given vector
  67468. * @param vector defines the vector to normalize
  67469. * @returns a new Vector2
  67470. */
  67471. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  67472. /**
  67473. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  67474. * @param left defines 1st vector
  67475. * @param right defines 2nd vector
  67476. * @returns a new Vector2
  67477. */
  67478. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  67479. /**
  67480. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  67481. * @param left defines 1st vector
  67482. * @param right defines 2nd vector
  67483. * @returns a new Vector2
  67484. */
  67485. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  67486. /**
  67487. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  67488. * @param vector defines the vector to transform
  67489. * @param transformation defines the matrix to apply
  67490. * @returns a new Vector2
  67491. */
  67492. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  67493. /**
  67494. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  67495. * @param vector defines the vector to transform
  67496. * @param transformation defines the matrix to apply
  67497. * @param result defines the target vector
  67498. */
  67499. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  67500. /**
  67501. * Determines if a given vector is included in a triangle
  67502. * @param p defines the vector to test
  67503. * @param p0 defines 1st triangle point
  67504. * @param p1 defines 2nd triangle point
  67505. * @param p2 defines 3rd triangle point
  67506. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  67507. */
  67508. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  67509. /**
  67510. * Gets the distance between the vectors "value1" and "value2"
  67511. * @param value1 defines first vector
  67512. * @param value2 defines second vector
  67513. * @returns the distance between vectors
  67514. */
  67515. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  67516. /**
  67517. * Returns the squared distance between the vectors "value1" and "value2"
  67518. * @param value1 defines first vector
  67519. * @param value2 defines second vector
  67520. * @returns the squared distance between vectors
  67521. */
  67522. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  67523. /**
  67524. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  67525. * @param value1 defines first vector
  67526. * @param value2 defines second vector
  67527. * @returns a new Vector2
  67528. */
  67529. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  67530. /**
  67531. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  67532. * @param p defines the middle point
  67533. * @param segA defines one point of the segment
  67534. * @param segB defines the other point of the segment
  67535. * @returns the shortest distance
  67536. */
  67537. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  67538. }
  67539. /**
  67540. * Classed used to store (x,y,z) vector representation
  67541. * A Vector3 is the main object used in 3D geometry
  67542. * It can represent etiher the coordinates of a point the space, either a direction
  67543. * Reminder: js uses a left handed forward facing system
  67544. */
  67545. export class Vector3 {
  67546. /**
  67547. * Defines the first coordinates (on X axis)
  67548. */
  67549. x: number;
  67550. /**
  67551. * Defines the second coordinates (on Y axis)
  67552. */
  67553. y: number;
  67554. /**
  67555. * Defines the third coordinates (on Z axis)
  67556. */
  67557. z: number;
  67558. private static _UpReadOnly;
  67559. private static _ZeroReadOnly;
  67560. /**
  67561. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  67562. * @param x defines the first coordinates (on X axis)
  67563. * @param y defines the second coordinates (on Y axis)
  67564. * @param z defines the third coordinates (on Z axis)
  67565. */
  67566. constructor(
  67567. /**
  67568. * Defines the first coordinates (on X axis)
  67569. */
  67570. x?: number,
  67571. /**
  67572. * Defines the second coordinates (on Y axis)
  67573. */
  67574. y?: number,
  67575. /**
  67576. * Defines the third coordinates (on Z axis)
  67577. */
  67578. z?: number);
  67579. /**
  67580. * Creates a string representation of the Vector3
  67581. * @returns a string with the Vector3 coordinates.
  67582. */
  67583. toString(): string;
  67584. /**
  67585. * Gets the class name
  67586. * @returns the string "Vector3"
  67587. */
  67588. getClassName(): string;
  67589. /**
  67590. * Creates the Vector3 hash code
  67591. * @returns a number which tends to be unique between Vector3 instances
  67592. */
  67593. getHashCode(): number;
  67594. /**
  67595. * Creates an array containing three elements : the coordinates of the Vector3
  67596. * @returns a new array of numbers
  67597. */
  67598. asArray(): number[];
  67599. /**
  67600. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  67601. * @param array defines the destination array
  67602. * @param index defines the offset in the destination array
  67603. * @returns the current Vector3
  67604. */
  67605. toArray(array: FloatArray, index?: number): Vector3;
  67606. /**
  67607. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  67608. * @returns a new Quaternion object, computed from the Vector3 coordinates
  67609. */
  67610. toQuaternion(): Quaternion;
  67611. /**
  67612. * Adds the given vector to the current Vector3
  67613. * @param otherVector defines the second operand
  67614. * @returns the current updated Vector3
  67615. */
  67616. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  67617. /**
  67618. * Adds the given coordinates to the current Vector3
  67619. * @param x defines the x coordinate of the operand
  67620. * @param y defines the y coordinate of the operand
  67621. * @param z defines the z coordinate of the operand
  67622. * @returns the current updated Vector3
  67623. */
  67624. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  67625. /**
  67626. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  67627. * @param otherVector defines the second operand
  67628. * @returns the resulting Vector3
  67629. */
  67630. add(otherVector: DeepImmutable<Vector3>): Vector3;
  67631. /**
  67632. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  67633. * @param otherVector defines the second operand
  67634. * @param result defines the Vector3 object where to store the result
  67635. * @returns the current Vector3
  67636. */
  67637. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  67638. /**
  67639. * Subtract the given vector from the current Vector3
  67640. * @param otherVector defines the second operand
  67641. * @returns the current updated Vector3
  67642. */
  67643. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  67644. /**
  67645. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  67646. * @param otherVector defines the second operand
  67647. * @returns the resulting Vector3
  67648. */
  67649. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  67650. /**
  67651. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  67652. * @param otherVector defines the second operand
  67653. * @param result defines the Vector3 object where to store the result
  67654. * @returns the current Vector3
  67655. */
  67656. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  67657. /**
  67658. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  67659. * @param x defines the x coordinate of the operand
  67660. * @param y defines the y coordinate of the operand
  67661. * @param z defines the z coordinate of the operand
  67662. * @returns the resulting Vector3
  67663. */
  67664. subtractFromFloats(x: number, y: number, z: number): Vector3;
  67665. /**
  67666. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  67667. * @param x defines the x coordinate of the operand
  67668. * @param y defines the y coordinate of the operand
  67669. * @param z defines the z coordinate of the operand
  67670. * @param result defines the Vector3 object where to store the result
  67671. * @returns the current Vector3
  67672. */
  67673. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  67674. /**
  67675. * Gets a new Vector3 set with the current Vector3 negated coordinates
  67676. * @returns a new Vector3
  67677. */
  67678. negate(): Vector3;
  67679. /**
  67680. * Multiplies the Vector3 coordinates by the float "scale"
  67681. * @param scale defines the multiplier factor
  67682. * @returns the current updated Vector3
  67683. */
  67684. scaleInPlace(scale: number): Vector3;
  67685. /**
  67686. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  67687. * @param scale defines the multiplier factor
  67688. * @returns a new Vector3
  67689. */
  67690. scale(scale: number): Vector3;
  67691. /**
  67692. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  67693. * @param scale defines the multiplier factor
  67694. * @param result defines the Vector3 object where to store the result
  67695. * @returns the current Vector3
  67696. */
  67697. scaleToRef(scale: number, result: Vector3): Vector3;
  67698. /**
  67699. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  67700. * @param scale defines the scale factor
  67701. * @param result defines the Vector3 object where to store the result
  67702. * @returns the unmodified current Vector3
  67703. */
  67704. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  67705. /**
  67706. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  67707. * @param otherVector defines the second operand
  67708. * @returns true if both vectors are equals
  67709. */
  67710. equals(otherVector: DeepImmutable<Vector3>): boolean;
  67711. /**
  67712. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  67713. * @param otherVector defines the second operand
  67714. * @param epsilon defines the minimal distance to define values as equals
  67715. * @returns true if both vectors are distant less than epsilon
  67716. */
  67717. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  67718. /**
  67719. * Returns true if the current Vector3 coordinates equals the given floats
  67720. * @param x defines the x coordinate of the operand
  67721. * @param y defines the y coordinate of the operand
  67722. * @param z defines the z coordinate of the operand
  67723. * @returns true if both vectors are equals
  67724. */
  67725. equalsToFloats(x: number, y: number, z: number): boolean;
  67726. /**
  67727. * Multiplies the current Vector3 coordinates by the given ones
  67728. * @param otherVector defines the second operand
  67729. * @returns the current updated Vector3
  67730. */
  67731. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  67732. /**
  67733. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  67734. * @param otherVector defines the second operand
  67735. * @returns the new Vector3
  67736. */
  67737. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  67738. /**
  67739. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  67740. * @param otherVector defines the second operand
  67741. * @param result defines the Vector3 object where to store the result
  67742. * @returns the current Vector3
  67743. */
  67744. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  67745. /**
  67746. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  67747. * @param x defines the x coordinate of the operand
  67748. * @param y defines the y coordinate of the operand
  67749. * @param z defines the z coordinate of the operand
  67750. * @returns the new Vector3
  67751. */
  67752. multiplyByFloats(x: number, y: number, z: number): Vector3;
  67753. /**
  67754. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  67755. * @param otherVector defines the second operand
  67756. * @returns the new Vector3
  67757. */
  67758. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  67759. /**
  67760. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  67761. * @param otherVector defines the second operand
  67762. * @param result defines the Vector3 object where to store the result
  67763. * @returns the current Vector3
  67764. */
  67765. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  67766. /**
  67767. * Divides the current Vector3 coordinates by the given ones.
  67768. * @param otherVector defines the second operand
  67769. * @returns the current updated Vector3
  67770. */
  67771. divideInPlace(otherVector: Vector3): Vector3;
  67772. /**
  67773. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  67774. * @param other defines the second operand
  67775. * @returns the current updated Vector3
  67776. */
  67777. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  67778. /**
  67779. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  67780. * @param other defines the second operand
  67781. * @returns the current updated Vector3
  67782. */
  67783. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  67784. /**
  67785. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  67786. * @param x defines the x coordinate of the operand
  67787. * @param y defines the y coordinate of the operand
  67788. * @param z defines the z coordinate of the operand
  67789. * @returns the current updated Vector3
  67790. */
  67791. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  67792. /**
  67793. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  67794. * @param x defines the x coordinate of the operand
  67795. * @param y defines the y coordinate of the operand
  67796. * @param z defines the z coordinate of the operand
  67797. * @returns the current updated Vector3
  67798. */
  67799. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  67800. /**
  67801. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  67802. * Check if is non uniform within a certain amount of decimal places to account for this
  67803. * @param epsilon the amount the values can differ
  67804. * @returns if the the vector is non uniform to a certain number of decimal places
  67805. */
  67806. isNonUniformWithinEpsilon(epsilon: number): boolean;
  67807. /**
  67808. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  67809. */
  67810. readonly isNonUniform: boolean;
  67811. /**
  67812. * Gets a new Vector3 from current Vector3 floored values
  67813. * @returns a new Vector3
  67814. */
  67815. floor(): Vector3;
  67816. /**
  67817. * Gets a new Vector3 from current Vector3 floored values
  67818. * @returns a new Vector3
  67819. */
  67820. fract(): Vector3;
  67821. /**
  67822. * Gets the length of the Vector3
  67823. * @returns the length of the Vector3
  67824. */
  67825. length(): number;
  67826. /**
  67827. * Gets the squared length of the Vector3
  67828. * @returns squared length of the Vector3
  67829. */
  67830. lengthSquared(): number;
  67831. /**
  67832. * Normalize the current Vector3.
  67833. * Please note that this is an in place operation.
  67834. * @returns the current updated Vector3
  67835. */
  67836. normalize(): Vector3;
  67837. /**
  67838. * Reorders the x y z properties of the vector in place
  67839. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  67840. * @returns the current updated vector
  67841. */
  67842. reorderInPlace(order: string): this;
  67843. /**
  67844. * Rotates the vector around 0,0,0 by a quaternion
  67845. * @param quaternion the rotation quaternion
  67846. * @param result vector to store the result
  67847. * @returns the resulting vector
  67848. */
  67849. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  67850. /**
  67851. * Rotates a vector around a given point
  67852. * @param quaternion the rotation quaternion
  67853. * @param point the point to rotate around
  67854. * @param result vector to store the result
  67855. * @returns the resulting vector
  67856. */
  67857. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  67858. /**
  67859. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  67860. * The cross product is then orthogonal to both current and "other"
  67861. * @param other defines the right operand
  67862. * @returns the cross product
  67863. */
  67864. cross(other: Vector3): Vector3;
  67865. /**
  67866. * Normalize the current Vector3 with the given input length.
  67867. * Please note that this is an in place operation.
  67868. * @param len the length of the vector
  67869. * @returns the current updated Vector3
  67870. */
  67871. normalizeFromLength(len: number): Vector3;
  67872. /**
  67873. * Normalize the current Vector3 to a new vector
  67874. * @returns the new Vector3
  67875. */
  67876. normalizeToNew(): Vector3;
  67877. /**
  67878. * Normalize the current Vector3 to the reference
  67879. * @param reference define the Vector3 to update
  67880. * @returns the updated Vector3
  67881. */
  67882. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  67883. /**
  67884. * Creates a new Vector3 copied from the current Vector3
  67885. * @returns the new Vector3
  67886. */
  67887. clone(): Vector3;
  67888. /**
  67889. * Copies the given vector coordinates to the current Vector3 ones
  67890. * @param source defines the source Vector3
  67891. * @returns the current updated Vector3
  67892. */
  67893. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  67894. /**
  67895. * Copies the given floats to the current Vector3 coordinates
  67896. * @param x defines the x coordinate of the operand
  67897. * @param y defines the y coordinate of the operand
  67898. * @param z defines the z coordinate of the operand
  67899. * @returns the current updated Vector3
  67900. */
  67901. copyFromFloats(x: number, y: number, z: number): Vector3;
  67902. /**
  67903. * Copies the given floats to the current Vector3 coordinates
  67904. * @param x defines the x coordinate of the operand
  67905. * @param y defines the y coordinate of the operand
  67906. * @param z defines the z coordinate of the operand
  67907. * @returns the current updated Vector3
  67908. */
  67909. set(x: number, y: number, z: number): Vector3;
  67910. /**
  67911. * Copies the given float to the current Vector3 coordinates
  67912. * @param v defines the x, y and z coordinates of the operand
  67913. * @returns the current updated Vector3
  67914. */
  67915. setAll(v: number): Vector3;
  67916. /**
  67917. * Get the clip factor between two vectors
  67918. * @param vector0 defines the first operand
  67919. * @param vector1 defines the second operand
  67920. * @param axis defines the axis to use
  67921. * @param size defines the size along the axis
  67922. * @returns the clip factor
  67923. */
  67924. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  67925. /**
  67926. * Get angle between two vectors
  67927. * @param vector0 angle between vector0 and vector1
  67928. * @param vector1 angle between vector0 and vector1
  67929. * @param normal direction of the normal
  67930. * @return the angle between vector0 and vector1
  67931. */
  67932. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  67933. /**
  67934. * Returns a new Vector3 set from the index "offset" of the given array
  67935. * @param array defines the source array
  67936. * @param offset defines the offset in the source array
  67937. * @returns the new Vector3
  67938. */
  67939. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  67940. /**
  67941. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  67942. * This function is deprecated. Use FromArray instead
  67943. * @param array defines the source array
  67944. * @param offset defines the offset in the source array
  67945. * @returns the new Vector3
  67946. */
  67947. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  67948. /**
  67949. * Sets the given vector "result" with the element values from the index "offset" of the given array
  67950. * @param array defines the source array
  67951. * @param offset defines the offset in the source array
  67952. * @param result defines the Vector3 where to store the result
  67953. */
  67954. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  67955. /**
  67956. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  67957. * This function is deprecated. Use FromArrayToRef instead.
  67958. * @param array defines the source array
  67959. * @param offset defines the offset in the source array
  67960. * @param result defines the Vector3 where to store the result
  67961. */
  67962. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  67963. /**
  67964. * Sets the given vector "result" with the given floats.
  67965. * @param x defines the x coordinate of the source
  67966. * @param y defines the y coordinate of the source
  67967. * @param z defines the z coordinate of the source
  67968. * @param result defines the Vector3 where to store the result
  67969. */
  67970. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  67971. /**
  67972. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  67973. * @returns a new empty Vector3
  67974. */
  67975. static Zero(): Vector3;
  67976. /**
  67977. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  67978. * @returns a new unit Vector3
  67979. */
  67980. static One(): Vector3;
  67981. /**
  67982. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  67983. * @returns a new up Vector3
  67984. */
  67985. static Up(): Vector3;
  67986. /**
  67987. * Gets a up Vector3 that must not be updated
  67988. */
  67989. static readonly UpReadOnly: DeepImmutable<Vector3>;
  67990. /**
  67991. * Gets a zero Vector3 that must not be updated
  67992. */
  67993. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  67994. /**
  67995. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  67996. * @returns a new down Vector3
  67997. */
  67998. static Down(): Vector3;
  67999. /**
  68000. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  68001. * @returns a new forward Vector3
  68002. */
  68003. static Forward(): Vector3;
  68004. /**
  68005. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  68006. * @returns a new forward Vector3
  68007. */
  68008. static Backward(): Vector3;
  68009. /**
  68010. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  68011. * @returns a new right Vector3
  68012. */
  68013. static Right(): Vector3;
  68014. /**
  68015. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  68016. * @returns a new left Vector3
  68017. */
  68018. static Left(): Vector3;
  68019. /**
  68020. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  68021. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  68022. * @param vector defines the Vector3 to transform
  68023. * @param transformation defines the transformation matrix
  68024. * @returns the transformed Vector3
  68025. */
  68026. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  68027. /**
  68028. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  68029. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  68030. * @param vector defines the Vector3 to transform
  68031. * @param transformation defines the transformation matrix
  68032. * @param result defines the Vector3 where to store the result
  68033. */
  68034. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  68035. /**
  68036. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  68037. * This method computes tranformed coordinates only, not transformed direction vectors
  68038. * @param x define the x coordinate of the source vector
  68039. * @param y define the y coordinate of the source vector
  68040. * @param z define the z coordinate of the source vector
  68041. * @param transformation defines the transformation matrix
  68042. * @param result defines the Vector3 where to store the result
  68043. */
  68044. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  68045. /**
  68046. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  68047. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  68048. * @param vector defines the Vector3 to transform
  68049. * @param transformation defines the transformation matrix
  68050. * @returns the new Vector3
  68051. */
  68052. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  68053. /**
  68054. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  68055. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  68056. * @param vector defines the Vector3 to transform
  68057. * @param transformation defines the transformation matrix
  68058. * @param result defines the Vector3 where to store the result
  68059. */
  68060. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  68061. /**
  68062. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  68063. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  68064. * @param x define the x coordinate of the source vector
  68065. * @param y define the y coordinate of the source vector
  68066. * @param z define the z coordinate of the source vector
  68067. * @param transformation defines the transformation matrix
  68068. * @param result defines the Vector3 where to store the result
  68069. */
  68070. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  68071. /**
  68072. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  68073. * @param value1 defines the first control point
  68074. * @param value2 defines the second control point
  68075. * @param value3 defines the third control point
  68076. * @param value4 defines the fourth control point
  68077. * @param amount defines the amount on the spline to use
  68078. * @returns the new Vector3
  68079. */
  68080. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  68081. /**
  68082. * 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"
  68083. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  68084. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  68085. * @param value defines the current value
  68086. * @param min defines the lower range value
  68087. * @param max defines the upper range value
  68088. * @returns the new Vector3
  68089. */
  68090. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  68091. /**
  68092. * 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"
  68093. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  68094. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  68095. * @param value defines the current value
  68096. * @param min defines the lower range value
  68097. * @param max defines the upper range value
  68098. * @param result defines the Vector3 where to store the result
  68099. */
  68100. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  68101. /**
  68102. * Checks if a given vector is inside a specific range
  68103. * @param v defines the vector to test
  68104. * @param min defines the minimum range
  68105. * @param max defines the maximum range
  68106. */
  68107. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  68108. /**
  68109. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  68110. * @param value1 defines the first control point
  68111. * @param tangent1 defines the first tangent vector
  68112. * @param value2 defines the second control point
  68113. * @param tangent2 defines the second tangent vector
  68114. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  68115. * @returns the new Vector3
  68116. */
  68117. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  68118. /**
  68119. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  68120. * @param start defines the start value
  68121. * @param end defines the end value
  68122. * @param amount max defines amount between both (between 0 and 1)
  68123. * @returns the new Vector3
  68124. */
  68125. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  68126. /**
  68127. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  68128. * @param start defines the start value
  68129. * @param end defines the end value
  68130. * @param amount max defines amount between both (between 0 and 1)
  68131. * @param result defines the Vector3 where to store the result
  68132. */
  68133. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  68134. /**
  68135. * Returns the dot product (float) between the vectors "left" and "right"
  68136. * @param left defines the left operand
  68137. * @param right defines the right operand
  68138. * @returns the dot product
  68139. */
  68140. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  68141. /**
  68142. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  68143. * The cross product is then orthogonal to both "left" and "right"
  68144. * @param left defines the left operand
  68145. * @param right defines the right operand
  68146. * @returns the cross product
  68147. */
  68148. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  68149. /**
  68150. * Sets the given vector "result" with the cross product of "left" and "right"
  68151. * The cross product is then orthogonal to both "left" and "right"
  68152. * @param left defines the left operand
  68153. * @param right defines the right operand
  68154. * @param result defines the Vector3 where to store the result
  68155. */
  68156. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  68157. /**
  68158. * Returns a new Vector3 as the normalization of the given vector
  68159. * @param vector defines the Vector3 to normalize
  68160. * @returns the new Vector3
  68161. */
  68162. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  68163. /**
  68164. * Sets the given vector "result" with the normalization of the given first vector
  68165. * @param vector defines the Vector3 to normalize
  68166. * @param result defines the Vector3 where to store the result
  68167. */
  68168. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  68169. /**
  68170. * Project a Vector3 onto screen space
  68171. * @param vector defines the Vector3 to project
  68172. * @param world defines the world matrix to use
  68173. * @param transform defines the transform (view x projection) matrix to use
  68174. * @param viewport defines the screen viewport to use
  68175. * @returns the new Vector3
  68176. */
  68177. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  68178. /** @hidden */
  68179. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  68180. /**
  68181. * Unproject from screen space to object space
  68182. * @param source defines the screen space Vector3 to use
  68183. * @param viewportWidth defines the current width of the viewport
  68184. * @param viewportHeight defines the current height of the viewport
  68185. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68186. * @param transform defines the transform (view x projection) matrix to use
  68187. * @returns the new Vector3
  68188. */
  68189. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  68190. /**
  68191. * Unproject from screen space to object space
  68192. * @param source defines the screen space Vector3 to use
  68193. * @param viewportWidth defines the current width of the viewport
  68194. * @param viewportHeight defines the current height of the viewport
  68195. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68196. * @param view defines the view matrix to use
  68197. * @param projection defines the projection matrix to use
  68198. * @returns the new Vector3
  68199. */
  68200. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  68201. /**
  68202. * Unproject from screen space to object space
  68203. * @param source defines the screen space Vector3 to use
  68204. * @param viewportWidth defines the current width of the viewport
  68205. * @param viewportHeight defines the current height of the viewport
  68206. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68207. * @param view defines the view matrix to use
  68208. * @param projection defines the projection matrix to use
  68209. * @param result defines the Vector3 where to store the result
  68210. */
  68211. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  68212. /**
  68213. * Unproject from screen space to object space
  68214. * @param sourceX defines the screen space x coordinate to use
  68215. * @param sourceY defines the screen space y coordinate to use
  68216. * @param sourceZ defines the screen space z coordinate to use
  68217. * @param viewportWidth defines the current width of the viewport
  68218. * @param viewportHeight defines the current height of the viewport
  68219. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68220. * @param view defines the view matrix to use
  68221. * @param projection defines the projection matrix to use
  68222. * @param result defines the Vector3 where to store the result
  68223. */
  68224. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  68225. /**
  68226. * Gets the minimal coordinate values between two Vector3
  68227. * @param left defines the first operand
  68228. * @param right defines the second operand
  68229. * @returns the new Vector3
  68230. */
  68231. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  68232. /**
  68233. * Gets the maximal coordinate values between two Vector3
  68234. * @param left defines the first operand
  68235. * @param right defines the second operand
  68236. * @returns the new Vector3
  68237. */
  68238. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  68239. /**
  68240. * Returns the distance between the vectors "value1" and "value2"
  68241. * @param value1 defines the first operand
  68242. * @param value2 defines the second operand
  68243. * @returns the distance
  68244. */
  68245. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  68246. /**
  68247. * Returns the squared distance between the vectors "value1" and "value2"
  68248. * @param value1 defines the first operand
  68249. * @param value2 defines the second operand
  68250. * @returns the squared distance
  68251. */
  68252. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  68253. /**
  68254. * Returns a new Vector3 located at the center between "value1" and "value2"
  68255. * @param value1 defines the first operand
  68256. * @param value2 defines the second operand
  68257. * @returns the new Vector3
  68258. */
  68259. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  68260. /**
  68261. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  68262. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  68263. * to something in order to rotate it from its local system to the given target system
  68264. * Note: axis1, axis2 and axis3 are normalized during this operation
  68265. * @param axis1 defines the first axis
  68266. * @param axis2 defines the second axis
  68267. * @param axis3 defines the third axis
  68268. * @returns a new Vector3
  68269. */
  68270. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  68271. /**
  68272. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  68273. * @param axis1 defines the first axis
  68274. * @param axis2 defines the second axis
  68275. * @param axis3 defines the third axis
  68276. * @param ref defines the Vector3 where to store the result
  68277. */
  68278. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  68279. }
  68280. /**
  68281. * Vector4 class created for EulerAngle class conversion to Quaternion
  68282. */
  68283. export class Vector4 {
  68284. /** x value of the vector */
  68285. x: number;
  68286. /** y value of the vector */
  68287. y: number;
  68288. /** z value of the vector */
  68289. z: number;
  68290. /** w value of the vector */
  68291. w: number;
  68292. /**
  68293. * Creates a Vector4 object from the given floats.
  68294. * @param x x value of the vector
  68295. * @param y y value of the vector
  68296. * @param z z value of the vector
  68297. * @param w w value of the vector
  68298. */
  68299. constructor(
  68300. /** x value of the vector */
  68301. x: number,
  68302. /** y value of the vector */
  68303. y: number,
  68304. /** z value of the vector */
  68305. z: number,
  68306. /** w value of the vector */
  68307. w: number);
  68308. /**
  68309. * Returns the string with the Vector4 coordinates.
  68310. * @returns a string containing all the vector values
  68311. */
  68312. toString(): string;
  68313. /**
  68314. * Returns the string "Vector4".
  68315. * @returns "Vector4"
  68316. */
  68317. getClassName(): string;
  68318. /**
  68319. * Returns the Vector4 hash code.
  68320. * @returns a unique hash code
  68321. */
  68322. getHashCode(): number;
  68323. /**
  68324. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  68325. * @returns the resulting array
  68326. */
  68327. asArray(): number[];
  68328. /**
  68329. * Populates the given array from the given index with the Vector4 coordinates.
  68330. * @param array array to populate
  68331. * @param index index of the array to start at (default: 0)
  68332. * @returns the Vector4.
  68333. */
  68334. toArray(array: FloatArray, index?: number): Vector4;
  68335. /**
  68336. * Adds the given vector to the current Vector4.
  68337. * @param otherVector the vector to add
  68338. * @returns the updated Vector4.
  68339. */
  68340. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  68341. /**
  68342. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  68343. * @param otherVector the vector to add
  68344. * @returns the resulting vector
  68345. */
  68346. add(otherVector: DeepImmutable<Vector4>): Vector4;
  68347. /**
  68348. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  68349. * @param otherVector the vector to add
  68350. * @param result the vector to store the result
  68351. * @returns the current Vector4.
  68352. */
  68353. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68354. /**
  68355. * Subtract in place the given vector from the current Vector4.
  68356. * @param otherVector the vector to subtract
  68357. * @returns the updated Vector4.
  68358. */
  68359. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  68360. /**
  68361. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  68362. * @param otherVector the vector to add
  68363. * @returns the new vector with the result
  68364. */
  68365. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  68366. /**
  68367. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  68368. * @param otherVector the vector to subtract
  68369. * @param result the vector to store the result
  68370. * @returns the current Vector4.
  68371. */
  68372. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68373. /**
  68374. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  68375. */
  68376. /**
  68377. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  68378. * @param x value to subtract
  68379. * @param y value to subtract
  68380. * @param z value to subtract
  68381. * @param w value to subtract
  68382. * @returns new vector containing the result
  68383. */
  68384. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  68385. /**
  68386. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  68387. * @param x value to subtract
  68388. * @param y value to subtract
  68389. * @param z value to subtract
  68390. * @param w value to subtract
  68391. * @param result the vector to store the result in
  68392. * @returns the current Vector4.
  68393. */
  68394. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  68395. /**
  68396. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  68397. * @returns a new vector with the negated values
  68398. */
  68399. negate(): Vector4;
  68400. /**
  68401. * Multiplies the current Vector4 coordinates by scale (float).
  68402. * @param scale the number to scale with
  68403. * @returns the updated Vector4.
  68404. */
  68405. scaleInPlace(scale: number): Vector4;
  68406. /**
  68407. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  68408. * @param scale the number to scale with
  68409. * @returns a new vector with the result
  68410. */
  68411. scale(scale: number): Vector4;
  68412. /**
  68413. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  68414. * @param scale the number to scale with
  68415. * @param result a vector to store the result in
  68416. * @returns the current Vector4.
  68417. */
  68418. scaleToRef(scale: number, result: Vector4): Vector4;
  68419. /**
  68420. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  68421. * @param scale defines the scale factor
  68422. * @param result defines the Vector4 object where to store the result
  68423. * @returns the unmodified current Vector4
  68424. */
  68425. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  68426. /**
  68427. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  68428. * @param otherVector the vector to compare against
  68429. * @returns true if they are equal
  68430. */
  68431. equals(otherVector: DeepImmutable<Vector4>): boolean;
  68432. /**
  68433. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  68434. * @param otherVector vector to compare against
  68435. * @param epsilon (Default: very small number)
  68436. * @returns true if they are equal
  68437. */
  68438. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  68439. /**
  68440. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  68441. * @param x x value to compare against
  68442. * @param y y value to compare against
  68443. * @param z z value to compare against
  68444. * @param w w value to compare against
  68445. * @returns true if equal
  68446. */
  68447. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  68448. /**
  68449. * Multiplies in place the current Vector4 by the given one.
  68450. * @param otherVector vector to multiple with
  68451. * @returns the updated Vector4.
  68452. */
  68453. multiplyInPlace(otherVector: Vector4): Vector4;
  68454. /**
  68455. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  68456. * @param otherVector vector to multiple with
  68457. * @returns resulting new vector
  68458. */
  68459. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  68460. /**
  68461. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  68462. * @param otherVector vector to multiple with
  68463. * @param result vector to store the result
  68464. * @returns the current Vector4.
  68465. */
  68466. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68467. /**
  68468. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  68469. * @param x x value multiply with
  68470. * @param y y value multiply with
  68471. * @param z z value multiply with
  68472. * @param w w value multiply with
  68473. * @returns resulting new vector
  68474. */
  68475. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  68476. /**
  68477. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  68478. * @param otherVector vector to devide with
  68479. * @returns resulting new vector
  68480. */
  68481. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  68482. /**
  68483. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  68484. * @param otherVector vector to devide with
  68485. * @param result vector to store the result
  68486. * @returns the current Vector4.
  68487. */
  68488. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68489. /**
  68490. * Divides the current Vector3 coordinates by the given ones.
  68491. * @param otherVector vector to devide with
  68492. * @returns the updated Vector3.
  68493. */
  68494. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  68495. /**
  68496. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  68497. * @param other defines the second operand
  68498. * @returns the current updated Vector4
  68499. */
  68500. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  68501. /**
  68502. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  68503. * @param other defines the second operand
  68504. * @returns the current updated Vector4
  68505. */
  68506. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  68507. /**
  68508. * Gets a new Vector4 from current Vector4 floored values
  68509. * @returns a new Vector4
  68510. */
  68511. floor(): Vector4;
  68512. /**
  68513. * Gets a new Vector4 from current Vector3 floored values
  68514. * @returns a new Vector4
  68515. */
  68516. fract(): Vector4;
  68517. /**
  68518. * Returns the Vector4 length (float).
  68519. * @returns the length
  68520. */
  68521. length(): number;
  68522. /**
  68523. * Returns the Vector4 squared length (float).
  68524. * @returns the length squared
  68525. */
  68526. lengthSquared(): number;
  68527. /**
  68528. * Normalizes in place the Vector4.
  68529. * @returns the updated Vector4.
  68530. */
  68531. normalize(): Vector4;
  68532. /**
  68533. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  68534. * @returns this converted to a new vector3
  68535. */
  68536. toVector3(): Vector3;
  68537. /**
  68538. * Returns a new Vector4 copied from the current one.
  68539. * @returns the new cloned vector
  68540. */
  68541. clone(): Vector4;
  68542. /**
  68543. * Updates the current Vector4 with the given one coordinates.
  68544. * @param source the source vector to copy from
  68545. * @returns the updated Vector4.
  68546. */
  68547. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  68548. /**
  68549. * Updates the current Vector4 coordinates with the given floats.
  68550. * @param x float to copy from
  68551. * @param y float to copy from
  68552. * @param z float to copy from
  68553. * @param w float to copy from
  68554. * @returns the updated Vector4.
  68555. */
  68556. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  68557. /**
  68558. * Updates the current Vector4 coordinates with the given floats.
  68559. * @param x float to set from
  68560. * @param y float to set from
  68561. * @param z float to set from
  68562. * @param w float to set from
  68563. * @returns the updated Vector4.
  68564. */
  68565. set(x: number, y: number, z: number, w: number): Vector4;
  68566. /**
  68567. * Copies the given float to the current Vector3 coordinates
  68568. * @param v defines the x, y, z and w coordinates of the operand
  68569. * @returns the current updated Vector3
  68570. */
  68571. setAll(v: number): Vector4;
  68572. /**
  68573. * Returns a new Vector4 set from the starting index of the given array.
  68574. * @param array the array to pull values from
  68575. * @param offset the offset into the array to start at
  68576. * @returns the new vector
  68577. */
  68578. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  68579. /**
  68580. * Updates the given vector "result" from the starting index of the given array.
  68581. * @param array the array to pull values from
  68582. * @param offset the offset into the array to start at
  68583. * @param result the vector to store the result in
  68584. */
  68585. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  68586. /**
  68587. * Updates the given vector "result" from the starting index of the given Float32Array.
  68588. * @param array the array to pull values from
  68589. * @param offset the offset into the array to start at
  68590. * @param result the vector to store the result in
  68591. */
  68592. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  68593. /**
  68594. * Updates the given vector "result" coordinates from the given floats.
  68595. * @param x float to set from
  68596. * @param y float to set from
  68597. * @param z float to set from
  68598. * @param w float to set from
  68599. * @param result the vector to the floats in
  68600. */
  68601. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  68602. /**
  68603. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  68604. * @returns the new vector
  68605. */
  68606. static Zero(): Vector4;
  68607. /**
  68608. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  68609. * @returns the new vector
  68610. */
  68611. static One(): Vector4;
  68612. /**
  68613. * Returns a new normalized Vector4 from the given one.
  68614. * @param vector the vector to normalize
  68615. * @returns the vector
  68616. */
  68617. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  68618. /**
  68619. * Updates the given vector "result" from the normalization of the given one.
  68620. * @param vector the vector to normalize
  68621. * @param result the vector to store the result in
  68622. */
  68623. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  68624. /**
  68625. * Returns a vector with the minimum values from the left and right vectors
  68626. * @param left left vector to minimize
  68627. * @param right right vector to minimize
  68628. * @returns a new vector with the minimum of the left and right vector values
  68629. */
  68630. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  68631. /**
  68632. * Returns a vector with the maximum values from the left and right vectors
  68633. * @param left left vector to maximize
  68634. * @param right right vector to maximize
  68635. * @returns a new vector with the maximum of the left and right vector values
  68636. */
  68637. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  68638. /**
  68639. * Returns the distance (float) between the vectors "value1" and "value2".
  68640. * @param value1 value to calulate the distance between
  68641. * @param value2 value to calulate the distance between
  68642. * @return the distance between the two vectors
  68643. */
  68644. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  68645. /**
  68646. * Returns the squared distance (float) between the vectors "value1" and "value2".
  68647. * @param value1 value to calulate the distance between
  68648. * @param value2 value to calulate the distance between
  68649. * @return the distance between the two vectors squared
  68650. */
  68651. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  68652. /**
  68653. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  68654. * @param value1 value to calulate the center between
  68655. * @param value2 value to calulate the center between
  68656. * @return the center between the two vectors
  68657. */
  68658. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  68659. /**
  68660. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  68661. * This methods computes transformed normalized direction vectors only.
  68662. * @param vector the vector to transform
  68663. * @param transformation the transformation matrix to apply
  68664. * @returns the new vector
  68665. */
  68666. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  68667. /**
  68668. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  68669. * This methods computes transformed normalized direction vectors only.
  68670. * @param vector the vector to transform
  68671. * @param transformation the transformation matrix to apply
  68672. * @param result the vector to store the result in
  68673. */
  68674. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  68675. /**
  68676. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  68677. * This methods computes transformed normalized direction vectors only.
  68678. * @param x value to transform
  68679. * @param y value to transform
  68680. * @param z value to transform
  68681. * @param w value to transform
  68682. * @param transformation the transformation matrix to apply
  68683. * @param result the vector to store the results in
  68684. */
  68685. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  68686. /**
  68687. * Creates a new Vector4 from a Vector3
  68688. * @param source defines the source data
  68689. * @param w defines the 4th component (default is 0)
  68690. * @returns a new Vector4
  68691. */
  68692. static FromVector3(source: Vector3, w?: number): Vector4;
  68693. }
  68694. /**
  68695. * Class used to store quaternion data
  68696. * @see https://en.wikipedia.org/wiki/Quaternion
  68697. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  68698. */
  68699. export class Quaternion {
  68700. /** defines the first component (0 by default) */
  68701. x: number;
  68702. /** defines the second component (0 by default) */
  68703. y: number;
  68704. /** defines the third component (0 by default) */
  68705. z: number;
  68706. /** defines the fourth component (1.0 by default) */
  68707. w: number;
  68708. /**
  68709. * Creates a new Quaternion from the given floats
  68710. * @param x defines the first component (0 by default)
  68711. * @param y defines the second component (0 by default)
  68712. * @param z defines the third component (0 by default)
  68713. * @param w defines the fourth component (1.0 by default)
  68714. */
  68715. constructor(
  68716. /** defines the first component (0 by default) */
  68717. x?: number,
  68718. /** defines the second component (0 by default) */
  68719. y?: number,
  68720. /** defines the third component (0 by default) */
  68721. z?: number,
  68722. /** defines the fourth component (1.0 by default) */
  68723. w?: number);
  68724. /**
  68725. * Gets a string representation for the current quaternion
  68726. * @returns a string with the Quaternion coordinates
  68727. */
  68728. toString(): string;
  68729. /**
  68730. * Gets the class name of the quaternion
  68731. * @returns the string "Quaternion"
  68732. */
  68733. getClassName(): string;
  68734. /**
  68735. * Gets a hash code for this quaternion
  68736. * @returns the quaternion hash code
  68737. */
  68738. getHashCode(): number;
  68739. /**
  68740. * Copy the quaternion to an array
  68741. * @returns a new array populated with 4 elements from the quaternion coordinates
  68742. */
  68743. asArray(): number[];
  68744. /**
  68745. * Check if two quaternions are equals
  68746. * @param otherQuaternion defines the second operand
  68747. * @return true if the current quaternion and the given one coordinates are strictly equals
  68748. */
  68749. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  68750. /**
  68751. * Clone the current quaternion
  68752. * @returns a new quaternion copied from the current one
  68753. */
  68754. clone(): Quaternion;
  68755. /**
  68756. * Copy a quaternion to the current one
  68757. * @param other defines the other quaternion
  68758. * @returns the updated current quaternion
  68759. */
  68760. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  68761. /**
  68762. * Updates the current quaternion with the given float coordinates
  68763. * @param x defines the x coordinate
  68764. * @param y defines the y coordinate
  68765. * @param z defines the z coordinate
  68766. * @param w defines the w coordinate
  68767. * @returns the updated current quaternion
  68768. */
  68769. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  68770. /**
  68771. * Updates the current quaternion from the given float coordinates
  68772. * @param x defines the x coordinate
  68773. * @param y defines the y coordinate
  68774. * @param z defines the z coordinate
  68775. * @param w defines the w coordinate
  68776. * @returns the updated current quaternion
  68777. */
  68778. set(x: number, y: number, z: number, w: number): Quaternion;
  68779. /**
  68780. * Adds two quaternions
  68781. * @param other defines the second operand
  68782. * @returns a new quaternion as the addition result of the given one and the current quaternion
  68783. */
  68784. add(other: DeepImmutable<Quaternion>): Quaternion;
  68785. /**
  68786. * Add a quaternion to the current one
  68787. * @param other defines the quaternion to add
  68788. * @returns the current quaternion
  68789. */
  68790. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  68791. /**
  68792. * Subtract two quaternions
  68793. * @param other defines the second operand
  68794. * @returns a new quaternion as the subtraction result of the given one from the current one
  68795. */
  68796. subtract(other: Quaternion): Quaternion;
  68797. /**
  68798. * Multiplies the current quaternion by a scale factor
  68799. * @param value defines the scale factor
  68800. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  68801. */
  68802. scale(value: number): Quaternion;
  68803. /**
  68804. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  68805. * @param scale defines the scale factor
  68806. * @param result defines the Quaternion object where to store the result
  68807. * @returns the unmodified current quaternion
  68808. */
  68809. scaleToRef(scale: number, result: Quaternion): Quaternion;
  68810. /**
  68811. * Multiplies in place the current quaternion by a scale factor
  68812. * @param value defines the scale factor
  68813. * @returns the current modified quaternion
  68814. */
  68815. scaleInPlace(value: number): Quaternion;
  68816. /**
  68817. * Scale the current quaternion values by a factor and add the result to a given quaternion
  68818. * @param scale defines the scale factor
  68819. * @param result defines the Quaternion object where to store the result
  68820. * @returns the unmodified current quaternion
  68821. */
  68822. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  68823. /**
  68824. * Multiplies two quaternions
  68825. * @param q1 defines the second operand
  68826. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  68827. */
  68828. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  68829. /**
  68830. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  68831. * @param q1 defines the second operand
  68832. * @param result defines the target quaternion
  68833. * @returns the current quaternion
  68834. */
  68835. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  68836. /**
  68837. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  68838. * @param q1 defines the second operand
  68839. * @returns the currentupdated quaternion
  68840. */
  68841. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  68842. /**
  68843. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  68844. * @param ref defines the target quaternion
  68845. * @returns the current quaternion
  68846. */
  68847. conjugateToRef(ref: Quaternion): Quaternion;
  68848. /**
  68849. * Conjugates in place (1-q) the current quaternion
  68850. * @returns the current updated quaternion
  68851. */
  68852. conjugateInPlace(): Quaternion;
  68853. /**
  68854. * Conjugates in place (1-q) the current quaternion
  68855. * @returns a new quaternion
  68856. */
  68857. conjugate(): Quaternion;
  68858. /**
  68859. * Gets length of current quaternion
  68860. * @returns the quaternion length (float)
  68861. */
  68862. length(): number;
  68863. /**
  68864. * Normalize in place the current quaternion
  68865. * @returns the current updated quaternion
  68866. */
  68867. normalize(): Quaternion;
  68868. /**
  68869. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  68870. * @param order is a reserved parameter and is ignore for now
  68871. * @returns a new Vector3 containing the Euler angles
  68872. */
  68873. toEulerAngles(order?: string): Vector3;
  68874. /**
  68875. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  68876. * @param result defines the vector which will be filled with the Euler angles
  68877. * @param order is a reserved parameter and is ignore for now
  68878. * @returns the current unchanged quaternion
  68879. */
  68880. toEulerAnglesToRef(result: Vector3): Quaternion;
  68881. /**
  68882. * Updates the given rotation matrix with the current quaternion values
  68883. * @param result defines the target matrix
  68884. * @returns the current unchanged quaternion
  68885. */
  68886. toRotationMatrix(result: Matrix): Quaternion;
  68887. /**
  68888. * Updates the current quaternion from the given rotation matrix values
  68889. * @param matrix defines the source matrix
  68890. * @returns the current updated quaternion
  68891. */
  68892. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  68893. /**
  68894. * Creates a new quaternion from a rotation matrix
  68895. * @param matrix defines the source matrix
  68896. * @returns a new quaternion created from the given rotation matrix values
  68897. */
  68898. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  68899. /**
  68900. * Updates the given quaternion with the given rotation matrix values
  68901. * @param matrix defines the source matrix
  68902. * @param result defines the target quaternion
  68903. */
  68904. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  68905. /**
  68906. * Returns the dot product (float) between the quaternions "left" and "right"
  68907. * @param left defines the left operand
  68908. * @param right defines the right operand
  68909. * @returns the dot product
  68910. */
  68911. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  68912. /**
  68913. * Checks if the two quaternions are close to each other
  68914. * @param quat0 defines the first quaternion to check
  68915. * @param quat1 defines the second quaternion to check
  68916. * @returns true if the two quaternions are close to each other
  68917. */
  68918. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  68919. /**
  68920. * Creates an empty quaternion
  68921. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  68922. */
  68923. static Zero(): Quaternion;
  68924. /**
  68925. * Inverse a given quaternion
  68926. * @param q defines the source quaternion
  68927. * @returns a new quaternion as the inverted current quaternion
  68928. */
  68929. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  68930. /**
  68931. * Inverse a given quaternion
  68932. * @param q defines the source quaternion
  68933. * @param result the quaternion the result will be stored in
  68934. * @returns the result quaternion
  68935. */
  68936. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  68937. /**
  68938. * Creates an identity quaternion
  68939. * @returns the identity quaternion
  68940. */
  68941. static Identity(): Quaternion;
  68942. /**
  68943. * Gets a boolean indicating if the given quaternion is identity
  68944. * @param quaternion defines the quaternion to check
  68945. * @returns true if the quaternion is identity
  68946. */
  68947. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  68948. /**
  68949. * Creates a quaternion from a rotation around an axis
  68950. * @param axis defines the axis to use
  68951. * @param angle defines the angle to use
  68952. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  68953. */
  68954. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  68955. /**
  68956. * Creates a rotation around an axis and stores it into the given quaternion
  68957. * @param axis defines the axis to use
  68958. * @param angle defines the angle to use
  68959. * @param result defines the target quaternion
  68960. * @returns the target quaternion
  68961. */
  68962. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  68963. /**
  68964. * Creates a new quaternion from data stored into an array
  68965. * @param array defines the data source
  68966. * @param offset defines the offset in the source array where the data starts
  68967. * @returns a new quaternion
  68968. */
  68969. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  68970. /**
  68971. * Create a quaternion from Euler rotation angles
  68972. * @param x Pitch
  68973. * @param y Yaw
  68974. * @param z Roll
  68975. * @returns the new Quaternion
  68976. */
  68977. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  68978. /**
  68979. * Updates a quaternion from Euler rotation angles
  68980. * @param x Pitch
  68981. * @param y Yaw
  68982. * @param z Roll
  68983. * @param result the quaternion to store the result
  68984. * @returns the updated quaternion
  68985. */
  68986. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  68987. /**
  68988. * Create a quaternion from Euler rotation vector
  68989. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  68990. * @returns the new Quaternion
  68991. */
  68992. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  68993. /**
  68994. * Updates a quaternion from Euler rotation vector
  68995. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  68996. * @param result the quaternion to store the result
  68997. * @returns the updated quaternion
  68998. */
  68999. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  69000. /**
  69001. * Creates a new quaternion from the given Euler float angles (y, x, z)
  69002. * @param yaw defines the rotation around Y axis
  69003. * @param pitch defines the rotation around X axis
  69004. * @param roll defines the rotation around Z axis
  69005. * @returns the new quaternion
  69006. */
  69007. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  69008. /**
  69009. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  69010. * @param yaw defines the rotation around Y axis
  69011. * @param pitch defines the rotation around X axis
  69012. * @param roll defines the rotation around Z axis
  69013. * @param result defines the target quaternion
  69014. */
  69015. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  69016. /**
  69017. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  69018. * @param alpha defines the rotation around first axis
  69019. * @param beta defines the rotation around second axis
  69020. * @param gamma defines the rotation around third axis
  69021. * @returns the new quaternion
  69022. */
  69023. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  69024. /**
  69025. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  69026. * @param alpha defines the rotation around first axis
  69027. * @param beta defines the rotation around second axis
  69028. * @param gamma defines the rotation around third axis
  69029. * @param result defines the target quaternion
  69030. */
  69031. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  69032. /**
  69033. * 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)
  69034. * @param axis1 defines the first axis
  69035. * @param axis2 defines the second axis
  69036. * @param axis3 defines the third axis
  69037. * @returns the new quaternion
  69038. */
  69039. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  69040. /**
  69041. * 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
  69042. * @param axis1 defines the first axis
  69043. * @param axis2 defines the second axis
  69044. * @param axis3 defines the third axis
  69045. * @param ref defines the target quaternion
  69046. */
  69047. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  69048. /**
  69049. * Interpolates between two quaternions
  69050. * @param left defines first quaternion
  69051. * @param right defines second quaternion
  69052. * @param amount defines the gradient to use
  69053. * @returns the new interpolated quaternion
  69054. */
  69055. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  69056. /**
  69057. * Interpolates between two quaternions and stores it into a target quaternion
  69058. * @param left defines first quaternion
  69059. * @param right defines second quaternion
  69060. * @param amount defines the gradient to use
  69061. * @param result defines the target quaternion
  69062. */
  69063. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  69064. /**
  69065. * Interpolate between two quaternions using Hermite interpolation
  69066. * @param value1 defines first quaternion
  69067. * @param tangent1 defines the incoming tangent
  69068. * @param value2 defines second quaternion
  69069. * @param tangent2 defines the outgoing tangent
  69070. * @param amount defines the target quaternion
  69071. * @returns the new interpolated quaternion
  69072. */
  69073. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  69074. }
  69075. /**
  69076. * Class used to store matrix data (4x4)
  69077. */
  69078. export class Matrix {
  69079. private static _updateFlagSeed;
  69080. private static _identityReadOnly;
  69081. private _isIdentity;
  69082. private _isIdentityDirty;
  69083. private _isIdentity3x2;
  69084. private _isIdentity3x2Dirty;
  69085. /**
  69086. * Gets the update flag of the matrix which is an unique number for the matrix.
  69087. * It will be incremented every time the matrix data change.
  69088. * You can use it to speed the comparison between two versions of the same matrix.
  69089. */
  69090. updateFlag: number;
  69091. private readonly _m;
  69092. /**
  69093. * Gets the internal data of the matrix
  69094. */
  69095. readonly m: DeepImmutable<Float32Array>;
  69096. /** @hidden */
  69097. _markAsUpdated(): void;
  69098. /** @hidden */
  69099. private _updateIdentityStatus;
  69100. /**
  69101. * Creates an empty matrix (filled with zeros)
  69102. */
  69103. constructor();
  69104. /**
  69105. * Check if the current matrix is identity
  69106. * @returns true is the matrix is the identity matrix
  69107. */
  69108. isIdentity(): boolean;
  69109. /**
  69110. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  69111. * @returns true is the matrix is the identity matrix
  69112. */
  69113. isIdentityAs3x2(): boolean;
  69114. /**
  69115. * Gets the determinant of the matrix
  69116. * @returns the matrix determinant
  69117. */
  69118. determinant(): number;
  69119. /**
  69120. * Returns the matrix as a Float32Array
  69121. * @returns the matrix underlying array
  69122. */
  69123. toArray(): DeepImmutable<Float32Array>;
  69124. /**
  69125. * Returns the matrix as a Float32Array
  69126. * @returns the matrix underlying array.
  69127. */
  69128. asArray(): DeepImmutable<Float32Array>;
  69129. /**
  69130. * Inverts the current matrix in place
  69131. * @returns the current inverted matrix
  69132. */
  69133. invert(): Matrix;
  69134. /**
  69135. * Sets all the matrix elements to zero
  69136. * @returns the current matrix
  69137. */
  69138. reset(): Matrix;
  69139. /**
  69140. * Adds the current matrix with a second one
  69141. * @param other defines the matrix to add
  69142. * @returns a new matrix as the addition of the current matrix and the given one
  69143. */
  69144. add(other: DeepImmutable<Matrix>): Matrix;
  69145. /**
  69146. * Sets the given matrix "result" to the addition of the current matrix and the given one
  69147. * @param other defines the matrix to add
  69148. * @param result defines the target matrix
  69149. * @returns the current matrix
  69150. */
  69151. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  69152. /**
  69153. * Adds in place the given matrix to the current matrix
  69154. * @param other defines the second operand
  69155. * @returns the current updated matrix
  69156. */
  69157. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  69158. /**
  69159. * Sets the given matrix to the current inverted Matrix
  69160. * @param other defines the target matrix
  69161. * @returns the unmodified current matrix
  69162. */
  69163. invertToRef(other: Matrix): Matrix;
  69164. /**
  69165. * add a value at the specified position in the current Matrix
  69166. * @param index the index of the value within the matrix. between 0 and 15.
  69167. * @param value the value to be added
  69168. * @returns the current updated matrix
  69169. */
  69170. addAtIndex(index: number, value: number): Matrix;
  69171. /**
  69172. * mutiply the specified position in the current Matrix by a value
  69173. * @param index the index of the value within the matrix. between 0 and 15.
  69174. * @param value the value to be added
  69175. * @returns the current updated matrix
  69176. */
  69177. multiplyAtIndex(index: number, value: number): Matrix;
  69178. /**
  69179. * Inserts the translation vector (using 3 floats) in the current matrix
  69180. * @param x defines the 1st component of the translation
  69181. * @param y defines the 2nd component of the translation
  69182. * @param z defines the 3rd component of the translation
  69183. * @returns the current updated matrix
  69184. */
  69185. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  69186. /**
  69187. * Adds the translation vector (using 3 floats) in the current matrix
  69188. * @param x defines the 1st component of the translation
  69189. * @param y defines the 2nd component of the translation
  69190. * @param z defines the 3rd component of the translation
  69191. * @returns the current updated matrix
  69192. */
  69193. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  69194. /**
  69195. * Inserts the translation vector in the current matrix
  69196. * @param vector3 defines the translation to insert
  69197. * @returns the current updated matrix
  69198. */
  69199. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  69200. /**
  69201. * Gets the translation value of the current matrix
  69202. * @returns a new Vector3 as the extracted translation from the matrix
  69203. */
  69204. getTranslation(): Vector3;
  69205. /**
  69206. * Fill a Vector3 with the extracted translation from the matrix
  69207. * @param result defines the Vector3 where to store the translation
  69208. * @returns the current matrix
  69209. */
  69210. getTranslationToRef(result: Vector3): Matrix;
  69211. /**
  69212. * Remove rotation and scaling part from the matrix
  69213. * @returns the updated matrix
  69214. */
  69215. removeRotationAndScaling(): Matrix;
  69216. /**
  69217. * Multiply two matrices
  69218. * @param other defines the second operand
  69219. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  69220. */
  69221. multiply(other: DeepImmutable<Matrix>): Matrix;
  69222. /**
  69223. * Copy the current matrix from the given one
  69224. * @param other defines the source matrix
  69225. * @returns the current updated matrix
  69226. */
  69227. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  69228. /**
  69229. * Populates the given array from the starting index with the current matrix values
  69230. * @param array defines the target array
  69231. * @param offset defines the offset in the target array where to start storing values
  69232. * @returns the current matrix
  69233. */
  69234. copyToArray(array: Float32Array, offset?: number): Matrix;
  69235. /**
  69236. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  69237. * @param other defines the second operand
  69238. * @param result defines the matrix where to store the multiplication
  69239. * @returns the current matrix
  69240. */
  69241. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  69242. /**
  69243. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  69244. * @param other defines the second operand
  69245. * @param result defines the array where to store the multiplication
  69246. * @param offset defines the offset in the target array where to start storing values
  69247. * @returns the current matrix
  69248. */
  69249. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  69250. /**
  69251. * Check equality between this matrix and a second one
  69252. * @param value defines the second matrix to compare
  69253. * @returns true is the current matrix and the given one values are strictly equal
  69254. */
  69255. equals(value: DeepImmutable<Matrix>): boolean;
  69256. /**
  69257. * Clone the current matrix
  69258. * @returns a new matrix from the current matrix
  69259. */
  69260. clone(): Matrix;
  69261. /**
  69262. * Returns the name of the current matrix class
  69263. * @returns the string "Matrix"
  69264. */
  69265. getClassName(): string;
  69266. /**
  69267. * Gets the hash code of the current matrix
  69268. * @returns the hash code
  69269. */
  69270. getHashCode(): number;
  69271. /**
  69272. * Decomposes the current Matrix into a translation, rotation and scaling components
  69273. * @param scale defines the scale vector3 given as a reference to update
  69274. * @param rotation defines the rotation quaternion given as a reference to update
  69275. * @param translation defines the translation vector3 given as a reference to update
  69276. * @returns true if operation was successful
  69277. */
  69278. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  69279. /**
  69280. * Gets specific row of the matrix
  69281. * @param index defines the number of the row to get
  69282. * @returns the index-th row of the current matrix as a new Vector4
  69283. */
  69284. getRow(index: number): Nullable<Vector4>;
  69285. /**
  69286. * Sets the index-th row of the current matrix to the vector4 values
  69287. * @param index defines the number of the row to set
  69288. * @param row defines the target vector4
  69289. * @returns the updated current matrix
  69290. */
  69291. setRow(index: number, row: Vector4): Matrix;
  69292. /**
  69293. * Compute the transpose of the matrix
  69294. * @returns the new transposed matrix
  69295. */
  69296. transpose(): Matrix;
  69297. /**
  69298. * Compute the transpose of the matrix and store it in a given matrix
  69299. * @param result defines the target matrix
  69300. * @returns the current matrix
  69301. */
  69302. transposeToRef(result: Matrix): Matrix;
  69303. /**
  69304. * Sets the index-th row of the current matrix with the given 4 x float values
  69305. * @param index defines the row index
  69306. * @param x defines the x component to set
  69307. * @param y defines the y component to set
  69308. * @param z defines the z component to set
  69309. * @param w defines the w component to set
  69310. * @returns the updated current matrix
  69311. */
  69312. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  69313. /**
  69314. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  69315. * @param scale defines the scale factor
  69316. * @returns a new matrix
  69317. */
  69318. scale(scale: number): Matrix;
  69319. /**
  69320. * Scale the current matrix values by a factor to a given result matrix
  69321. * @param scale defines the scale factor
  69322. * @param result defines the matrix to store the result
  69323. * @returns the current matrix
  69324. */
  69325. scaleToRef(scale: number, result: Matrix): Matrix;
  69326. /**
  69327. * Scale the current matrix values by a factor and add the result to a given matrix
  69328. * @param scale defines the scale factor
  69329. * @param result defines the Matrix to store the result
  69330. * @returns the current matrix
  69331. */
  69332. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  69333. /**
  69334. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  69335. * @param ref matrix to store the result
  69336. */
  69337. toNormalMatrix(ref: Matrix): void;
  69338. /**
  69339. * Gets only rotation part of the current matrix
  69340. * @returns a new matrix sets to the extracted rotation matrix from the current one
  69341. */
  69342. getRotationMatrix(): Matrix;
  69343. /**
  69344. * Extracts the rotation matrix from the current one and sets it as the given "result"
  69345. * @param result defines the target matrix to store data to
  69346. * @returns the current matrix
  69347. */
  69348. getRotationMatrixToRef(result: Matrix): Matrix;
  69349. /**
  69350. * Toggles model matrix from being right handed to left handed in place and vice versa
  69351. */
  69352. toggleModelMatrixHandInPlace(): void;
  69353. /**
  69354. * Toggles projection matrix from being right handed to left handed in place and vice versa
  69355. */
  69356. toggleProjectionMatrixHandInPlace(): void;
  69357. /**
  69358. * Creates a matrix from an array
  69359. * @param array defines the source array
  69360. * @param offset defines an offset in the source array
  69361. * @returns a new Matrix set from the starting index of the given array
  69362. */
  69363. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  69364. /**
  69365. * Copy the content of an array into a given matrix
  69366. * @param array defines the source array
  69367. * @param offset defines an offset in the source array
  69368. * @param result defines the target matrix
  69369. */
  69370. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  69371. /**
  69372. * Stores an array into a matrix after having multiplied each component by a given factor
  69373. * @param array defines the source array
  69374. * @param offset defines the offset in the source array
  69375. * @param scale defines the scaling factor
  69376. * @param result defines the target matrix
  69377. */
  69378. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  69379. /**
  69380. * Gets an identity matrix that must not be updated
  69381. */
  69382. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  69383. /**
  69384. * Stores a list of values (16) inside a given matrix
  69385. * @param initialM11 defines 1st value of 1st row
  69386. * @param initialM12 defines 2nd value of 1st row
  69387. * @param initialM13 defines 3rd value of 1st row
  69388. * @param initialM14 defines 4th value of 1st row
  69389. * @param initialM21 defines 1st value of 2nd row
  69390. * @param initialM22 defines 2nd value of 2nd row
  69391. * @param initialM23 defines 3rd value of 2nd row
  69392. * @param initialM24 defines 4th value of 2nd row
  69393. * @param initialM31 defines 1st value of 3rd row
  69394. * @param initialM32 defines 2nd value of 3rd row
  69395. * @param initialM33 defines 3rd value of 3rd row
  69396. * @param initialM34 defines 4th value of 3rd row
  69397. * @param initialM41 defines 1st value of 4th row
  69398. * @param initialM42 defines 2nd value of 4th row
  69399. * @param initialM43 defines 3rd value of 4th row
  69400. * @param initialM44 defines 4th value of 4th row
  69401. * @param result defines the target matrix
  69402. */
  69403. 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;
  69404. /**
  69405. * Creates new matrix from a list of values (16)
  69406. * @param initialM11 defines 1st value of 1st row
  69407. * @param initialM12 defines 2nd value of 1st row
  69408. * @param initialM13 defines 3rd value of 1st row
  69409. * @param initialM14 defines 4th value of 1st row
  69410. * @param initialM21 defines 1st value of 2nd row
  69411. * @param initialM22 defines 2nd value of 2nd row
  69412. * @param initialM23 defines 3rd value of 2nd row
  69413. * @param initialM24 defines 4th value of 2nd row
  69414. * @param initialM31 defines 1st value of 3rd row
  69415. * @param initialM32 defines 2nd value of 3rd row
  69416. * @param initialM33 defines 3rd value of 3rd row
  69417. * @param initialM34 defines 4th value of 3rd row
  69418. * @param initialM41 defines 1st value of 4th row
  69419. * @param initialM42 defines 2nd value of 4th row
  69420. * @param initialM43 defines 3rd value of 4th row
  69421. * @param initialM44 defines 4th value of 4th row
  69422. * @returns the new matrix
  69423. */
  69424. 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;
  69425. /**
  69426. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  69427. * @param scale defines the scale vector3
  69428. * @param rotation defines the rotation quaternion
  69429. * @param translation defines the translation vector3
  69430. * @returns a new matrix
  69431. */
  69432. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  69433. /**
  69434. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  69435. * @param scale defines the scale vector3
  69436. * @param rotation defines the rotation quaternion
  69437. * @param translation defines the translation vector3
  69438. * @param result defines the target matrix
  69439. */
  69440. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  69441. /**
  69442. * Creates a new identity matrix
  69443. * @returns a new identity matrix
  69444. */
  69445. static Identity(): Matrix;
  69446. /**
  69447. * Creates a new identity matrix and stores the result in a given matrix
  69448. * @param result defines the target matrix
  69449. */
  69450. static IdentityToRef(result: Matrix): void;
  69451. /**
  69452. * Creates a new zero matrix
  69453. * @returns a new zero matrix
  69454. */
  69455. static Zero(): Matrix;
  69456. /**
  69457. * Creates a new rotation matrix for "angle" radians around the X axis
  69458. * @param angle defines the angle (in radians) to use
  69459. * @return the new matrix
  69460. */
  69461. static RotationX(angle: number): Matrix;
  69462. /**
  69463. * Creates a new matrix as the invert of a given matrix
  69464. * @param source defines the source matrix
  69465. * @returns the new matrix
  69466. */
  69467. static Invert(source: DeepImmutable<Matrix>): Matrix;
  69468. /**
  69469. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  69470. * @param angle defines the angle (in radians) to use
  69471. * @param result defines the target matrix
  69472. */
  69473. static RotationXToRef(angle: number, result: Matrix): void;
  69474. /**
  69475. * Creates a new rotation matrix for "angle" radians around the Y axis
  69476. * @param angle defines the angle (in radians) to use
  69477. * @return the new matrix
  69478. */
  69479. static RotationY(angle: number): Matrix;
  69480. /**
  69481. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  69482. * @param angle defines the angle (in radians) to use
  69483. * @param result defines the target matrix
  69484. */
  69485. static RotationYToRef(angle: number, result: Matrix): void;
  69486. /**
  69487. * Creates a new rotation matrix for "angle" radians around the Z axis
  69488. * @param angle defines the angle (in radians) to use
  69489. * @return the new matrix
  69490. */
  69491. static RotationZ(angle: number): Matrix;
  69492. /**
  69493. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  69494. * @param angle defines the angle (in radians) to use
  69495. * @param result defines the target matrix
  69496. */
  69497. static RotationZToRef(angle: number, result: Matrix): void;
  69498. /**
  69499. * Creates a new rotation matrix for "angle" radians around the given axis
  69500. * @param axis defines the axis to use
  69501. * @param angle defines the angle (in radians) to use
  69502. * @return the new matrix
  69503. */
  69504. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  69505. /**
  69506. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  69507. * @param axis defines the axis to use
  69508. * @param angle defines the angle (in radians) to use
  69509. * @param result defines the target matrix
  69510. */
  69511. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  69512. /**
  69513. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  69514. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  69515. * @param from defines the vector to align
  69516. * @param to defines the vector to align to
  69517. * @param result defines the target matrix
  69518. */
  69519. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  69520. /**
  69521. * Creates a rotation matrix
  69522. * @param yaw defines the yaw angle in radians (Y axis)
  69523. * @param pitch defines the pitch angle in radians (X axis)
  69524. * @param roll defines the roll angle in radians (X axis)
  69525. * @returns the new rotation matrix
  69526. */
  69527. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  69528. /**
  69529. * Creates a rotation matrix and stores it in a given matrix
  69530. * @param yaw defines the yaw angle in radians (Y axis)
  69531. * @param pitch defines the pitch angle in radians (X axis)
  69532. * @param roll defines the roll angle in radians (X axis)
  69533. * @param result defines the target matrix
  69534. */
  69535. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  69536. /**
  69537. * Creates a scaling matrix
  69538. * @param x defines the scale factor on X axis
  69539. * @param y defines the scale factor on Y axis
  69540. * @param z defines the scale factor on Z axis
  69541. * @returns the new matrix
  69542. */
  69543. static Scaling(x: number, y: number, z: number): Matrix;
  69544. /**
  69545. * Creates a scaling matrix and stores it in a given matrix
  69546. * @param x defines the scale factor on X axis
  69547. * @param y defines the scale factor on Y axis
  69548. * @param z defines the scale factor on Z axis
  69549. * @param result defines the target matrix
  69550. */
  69551. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  69552. /**
  69553. * Creates a translation matrix
  69554. * @param x defines the translation on X axis
  69555. * @param y defines the translation on Y axis
  69556. * @param z defines the translationon Z axis
  69557. * @returns the new matrix
  69558. */
  69559. static Translation(x: number, y: number, z: number): Matrix;
  69560. /**
  69561. * Creates a translation matrix and stores it in a given matrix
  69562. * @param x defines the translation on X axis
  69563. * @param y defines the translation on Y axis
  69564. * @param z defines the translationon Z axis
  69565. * @param result defines the target matrix
  69566. */
  69567. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  69568. /**
  69569. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  69570. * @param startValue defines the start value
  69571. * @param endValue defines the end value
  69572. * @param gradient defines the gradient factor
  69573. * @returns the new matrix
  69574. */
  69575. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  69576. /**
  69577. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  69578. * @param startValue defines the start value
  69579. * @param endValue defines the end value
  69580. * @param gradient defines the gradient factor
  69581. * @param result defines the Matrix object where to store data
  69582. */
  69583. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  69584. /**
  69585. * Builds a new matrix whose values are computed by:
  69586. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  69587. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  69588. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  69589. * @param startValue defines the first matrix
  69590. * @param endValue defines the second matrix
  69591. * @param gradient defines the gradient between the two matrices
  69592. * @returns the new matrix
  69593. */
  69594. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  69595. /**
  69596. * Update a matrix to values which are computed by:
  69597. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  69598. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  69599. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  69600. * @param startValue defines the first matrix
  69601. * @param endValue defines the second matrix
  69602. * @param gradient defines the gradient between the two matrices
  69603. * @param result defines the target matrix
  69604. */
  69605. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  69606. /**
  69607. * 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"
  69608. * This function works in left handed mode
  69609. * @param eye defines the final position of the entity
  69610. * @param target defines where the entity should look at
  69611. * @param up defines the up vector for the entity
  69612. * @returns the new matrix
  69613. */
  69614. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  69615. /**
  69616. * 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".
  69617. * This function works in left handed mode
  69618. * @param eye defines the final position of the entity
  69619. * @param target defines where the entity should look at
  69620. * @param up defines the up vector for the entity
  69621. * @param result defines the target matrix
  69622. */
  69623. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  69624. /**
  69625. * 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"
  69626. * This function works in right handed mode
  69627. * @param eye defines the final position of the entity
  69628. * @param target defines where the entity should look at
  69629. * @param up defines the up vector for the entity
  69630. * @returns the new matrix
  69631. */
  69632. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  69633. /**
  69634. * 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".
  69635. * This function works in right handed mode
  69636. * @param eye defines the final position of the entity
  69637. * @param target defines where the entity should look at
  69638. * @param up defines the up vector for the entity
  69639. * @param result defines the target matrix
  69640. */
  69641. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  69642. /**
  69643. * Create a left-handed orthographic projection matrix
  69644. * @param width defines the viewport width
  69645. * @param height defines the viewport height
  69646. * @param znear defines the near clip plane
  69647. * @param zfar defines the far clip plane
  69648. * @returns a new matrix as a left-handed orthographic projection matrix
  69649. */
  69650. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  69651. /**
  69652. * Store a left-handed orthographic projection to a given matrix
  69653. * @param width defines the viewport width
  69654. * @param height defines the viewport height
  69655. * @param znear defines the near clip plane
  69656. * @param zfar defines the far clip plane
  69657. * @param result defines the target matrix
  69658. */
  69659. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  69660. /**
  69661. * Create a left-handed orthographic projection matrix
  69662. * @param left defines the viewport left coordinate
  69663. * @param right defines the viewport right coordinate
  69664. * @param bottom defines the viewport bottom coordinate
  69665. * @param top defines the viewport top coordinate
  69666. * @param znear defines the near clip plane
  69667. * @param zfar defines the far clip plane
  69668. * @returns a new matrix as a left-handed orthographic projection matrix
  69669. */
  69670. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  69671. /**
  69672. * Stores a left-handed orthographic projection into a given matrix
  69673. * @param left defines the viewport left coordinate
  69674. * @param right defines the viewport right coordinate
  69675. * @param bottom defines the viewport bottom coordinate
  69676. * @param top defines the viewport top coordinate
  69677. * @param znear defines the near clip plane
  69678. * @param zfar defines the far clip plane
  69679. * @param result defines the target matrix
  69680. */
  69681. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  69682. /**
  69683. * Creates a right-handed orthographic projection matrix
  69684. * @param left defines the viewport left coordinate
  69685. * @param right defines the viewport right coordinate
  69686. * @param bottom defines the viewport bottom coordinate
  69687. * @param top defines the viewport top coordinate
  69688. * @param znear defines the near clip plane
  69689. * @param zfar defines the far clip plane
  69690. * @returns a new matrix as a right-handed orthographic projection matrix
  69691. */
  69692. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  69693. /**
  69694. * Stores a right-handed orthographic projection into a given matrix
  69695. * @param left defines the viewport left coordinate
  69696. * @param right defines the viewport right coordinate
  69697. * @param bottom defines the viewport bottom coordinate
  69698. * @param top defines the viewport top coordinate
  69699. * @param znear defines the near clip plane
  69700. * @param zfar defines the far clip plane
  69701. * @param result defines the target matrix
  69702. */
  69703. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  69704. /**
  69705. * Creates a left-handed perspective projection matrix
  69706. * @param width defines the viewport width
  69707. * @param height defines the viewport height
  69708. * @param znear defines the near clip plane
  69709. * @param zfar defines the far clip plane
  69710. * @returns a new matrix as a left-handed perspective projection matrix
  69711. */
  69712. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  69713. /**
  69714. * Creates a left-handed perspective projection matrix
  69715. * @param fov defines the horizontal field of view
  69716. * @param aspect defines the aspect ratio
  69717. * @param znear defines the near clip plane
  69718. * @param zfar defines the far clip plane
  69719. * @returns a new matrix as a left-handed perspective projection matrix
  69720. */
  69721. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  69722. /**
  69723. * Stores a left-handed perspective projection into a given matrix
  69724. * @param fov defines the horizontal field of view
  69725. * @param aspect defines the aspect ratio
  69726. * @param znear defines the near clip plane
  69727. * @param zfar defines the far clip plane
  69728. * @param result defines the target matrix
  69729. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  69730. */
  69731. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  69732. /**
  69733. * Creates a right-handed perspective projection matrix
  69734. * @param fov defines the horizontal field of view
  69735. * @param aspect defines the aspect ratio
  69736. * @param znear defines the near clip plane
  69737. * @param zfar defines the far clip plane
  69738. * @returns a new matrix as a right-handed perspective projection matrix
  69739. */
  69740. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  69741. /**
  69742. * Stores a right-handed perspective projection into a given matrix
  69743. * @param fov defines the horizontal field of view
  69744. * @param aspect defines the aspect ratio
  69745. * @param znear defines the near clip plane
  69746. * @param zfar defines the far clip plane
  69747. * @param result defines the target matrix
  69748. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  69749. */
  69750. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  69751. /**
  69752. * Stores a perspective projection for WebVR info a given matrix
  69753. * @param fov defines the field of view
  69754. * @param znear defines the near clip plane
  69755. * @param zfar defines the far clip plane
  69756. * @param result defines the target matrix
  69757. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  69758. */
  69759. static PerspectiveFovWebVRToRef(fov: {
  69760. upDegrees: number;
  69761. downDegrees: number;
  69762. leftDegrees: number;
  69763. rightDegrees: number;
  69764. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  69765. /**
  69766. * Computes a complete transformation matrix
  69767. * @param viewport defines the viewport to use
  69768. * @param world defines the world matrix
  69769. * @param view defines the view matrix
  69770. * @param projection defines the projection matrix
  69771. * @param zmin defines the near clip plane
  69772. * @param zmax defines the far clip plane
  69773. * @returns the transformation matrix
  69774. */
  69775. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  69776. /**
  69777. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  69778. * @param matrix defines the matrix to use
  69779. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  69780. */
  69781. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  69782. /**
  69783. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  69784. * @param matrix defines the matrix to use
  69785. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  69786. */
  69787. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  69788. /**
  69789. * Compute the transpose of a given matrix
  69790. * @param matrix defines the matrix to transpose
  69791. * @returns the new matrix
  69792. */
  69793. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  69794. /**
  69795. * Compute the transpose of a matrix and store it in a target matrix
  69796. * @param matrix defines the matrix to transpose
  69797. * @param result defines the target matrix
  69798. */
  69799. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  69800. /**
  69801. * Computes a reflection matrix from a plane
  69802. * @param plane defines the reflection plane
  69803. * @returns a new matrix
  69804. */
  69805. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  69806. /**
  69807. * Computes a reflection matrix from a plane
  69808. * @param plane defines the reflection plane
  69809. * @param result defines the target matrix
  69810. */
  69811. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  69812. /**
  69813. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  69814. * @param xaxis defines the value of the 1st axis
  69815. * @param yaxis defines the value of the 2nd axis
  69816. * @param zaxis defines the value of the 3rd axis
  69817. * @param result defines the target matrix
  69818. */
  69819. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  69820. /**
  69821. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  69822. * @param quat defines the quaternion to use
  69823. * @param result defines the target matrix
  69824. */
  69825. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  69826. }
  69827. /**
  69828. * @hidden
  69829. */
  69830. export class TmpVectors {
  69831. static Vector2: Vector2[];
  69832. static Vector3: Vector3[];
  69833. static Vector4: Vector4[];
  69834. static Quaternion: Quaternion[];
  69835. static Matrix: Matrix[];
  69836. }
  69837. }
  69838. declare module BABYLON {
  69839. /** Defines the cross module used constants to avoid circular dependncies */
  69840. export class Constants {
  69841. /** Defines that alpha blending is disabled */
  69842. static readonly ALPHA_DISABLE: number;
  69843. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  69844. static readonly ALPHA_ADD: number;
  69845. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  69846. static readonly ALPHA_COMBINE: number;
  69847. /** Defines that alpha blending to DEST - SRC * DEST */
  69848. static readonly ALPHA_SUBTRACT: number;
  69849. /** Defines that alpha blending to SRC * DEST */
  69850. static readonly ALPHA_MULTIPLY: number;
  69851. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  69852. static readonly ALPHA_MAXIMIZED: number;
  69853. /** Defines that alpha blending to SRC + DEST */
  69854. static readonly ALPHA_ONEONE: number;
  69855. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  69856. static readonly ALPHA_PREMULTIPLIED: number;
  69857. /**
  69858. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  69859. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  69860. */
  69861. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  69862. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  69863. static readonly ALPHA_INTERPOLATE: number;
  69864. /**
  69865. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  69866. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  69867. */
  69868. static readonly ALPHA_SCREENMODE: number;
  69869. /** Defines that the ressource is not delayed*/
  69870. static readonly DELAYLOADSTATE_NONE: number;
  69871. /** Defines that the ressource was successfully delay loaded */
  69872. static readonly DELAYLOADSTATE_LOADED: number;
  69873. /** Defines that the ressource is currently delay loading */
  69874. static readonly DELAYLOADSTATE_LOADING: number;
  69875. /** Defines that the ressource is delayed and has not started loading */
  69876. static readonly DELAYLOADSTATE_NOTLOADED: number;
  69877. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  69878. static readonly NEVER: number;
  69879. /** 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 */
  69880. static readonly ALWAYS: number;
  69881. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  69882. static readonly LESS: number;
  69883. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  69884. static readonly EQUAL: number;
  69885. /** 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 */
  69886. static readonly LEQUAL: number;
  69887. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  69888. static readonly GREATER: number;
  69889. /** 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 */
  69890. static readonly GEQUAL: number;
  69891. /** 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 */
  69892. static readonly NOTEQUAL: number;
  69893. /** Passed to stencilOperation to specify that stencil value must be kept */
  69894. static readonly KEEP: number;
  69895. /** Passed to stencilOperation to specify that stencil value must be replaced */
  69896. static readonly REPLACE: number;
  69897. /** Passed to stencilOperation to specify that stencil value must be incremented */
  69898. static readonly INCR: number;
  69899. /** Passed to stencilOperation to specify that stencil value must be decremented */
  69900. static readonly DECR: number;
  69901. /** Passed to stencilOperation to specify that stencil value must be inverted */
  69902. static readonly INVERT: number;
  69903. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  69904. static readonly INCR_WRAP: number;
  69905. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  69906. static readonly DECR_WRAP: number;
  69907. /** Texture is not repeating outside of 0..1 UVs */
  69908. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  69909. /** Texture is repeating outside of 0..1 UVs */
  69910. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  69911. /** Texture is repeating and mirrored */
  69912. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  69913. /** ALPHA */
  69914. static readonly TEXTUREFORMAT_ALPHA: number;
  69915. /** LUMINANCE */
  69916. static readonly TEXTUREFORMAT_LUMINANCE: number;
  69917. /** LUMINANCE_ALPHA */
  69918. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  69919. /** RGB */
  69920. static readonly TEXTUREFORMAT_RGB: number;
  69921. /** RGBA */
  69922. static readonly TEXTUREFORMAT_RGBA: number;
  69923. /** RED */
  69924. static readonly TEXTUREFORMAT_RED: number;
  69925. /** RED (2nd reference) */
  69926. static readonly TEXTUREFORMAT_R: number;
  69927. /** RG */
  69928. static readonly TEXTUREFORMAT_RG: number;
  69929. /** RED_INTEGER */
  69930. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  69931. /** RED_INTEGER (2nd reference) */
  69932. static readonly TEXTUREFORMAT_R_INTEGER: number;
  69933. /** RG_INTEGER */
  69934. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  69935. /** RGB_INTEGER */
  69936. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  69937. /** RGBA_INTEGER */
  69938. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  69939. /** UNSIGNED_BYTE */
  69940. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  69941. /** UNSIGNED_BYTE (2nd reference) */
  69942. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  69943. /** FLOAT */
  69944. static readonly TEXTURETYPE_FLOAT: number;
  69945. /** HALF_FLOAT */
  69946. static readonly TEXTURETYPE_HALF_FLOAT: number;
  69947. /** BYTE */
  69948. static readonly TEXTURETYPE_BYTE: number;
  69949. /** SHORT */
  69950. static readonly TEXTURETYPE_SHORT: number;
  69951. /** UNSIGNED_SHORT */
  69952. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  69953. /** INT */
  69954. static readonly TEXTURETYPE_INT: number;
  69955. /** UNSIGNED_INT */
  69956. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  69957. /** UNSIGNED_SHORT_4_4_4_4 */
  69958. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  69959. /** UNSIGNED_SHORT_5_5_5_1 */
  69960. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  69961. /** UNSIGNED_SHORT_5_6_5 */
  69962. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  69963. /** UNSIGNED_INT_2_10_10_10_REV */
  69964. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  69965. /** UNSIGNED_INT_24_8 */
  69966. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  69967. /** UNSIGNED_INT_10F_11F_11F_REV */
  69968. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  69969. /** UNSIGNED_INT_5_9_9_9_REV */
  69970. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  69971. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  69972. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  69973. /** nearest is mag = nearest and min = nearest and mip = linear */
  69974. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  69975. /** Bilinear is mag = linear and min = linear and mip = nearest */
  69976. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  69977. /** Trilinear is mag = linear and min = linear and mip = linear */
  69978. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  69979. /** nearest is mag = nearest and min = nearest and mip = linear */
  69980. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  69981. /** Bilinear is mag = linear and min = linear and mip = nearest */
  69982. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  69983. /** Trilinear is mag = linear and min = linear and mip = linear */
  69984. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  69985. /** mag = nearest and min = nearest and mip = nearest */
  69986. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  69987. /** mag = nearest and min = linear and mip = nearest */
  69988. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  69989. /** mag = nearest and min = linear and mip = linear */
  69990. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  69991. /** mag = nearest and min = linear and mip = none */
  69992. static readonly TEXTURE_NEAREST_LINEAR: number;
  69993. /** mag = nearest and min = nearest and mip = none */
  69994. static readonly TEXTURE_NEAREST_NEAREST: number;
  69995. /** mag = linear and min = nearest and mip = nearest */
  69996. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  69997. /** mag = linear and min = nearest and mip = linear */
  69998. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  69999. /** mag = linear and min = linear and mip = none */
  70000. static readonly TEXTURE_LINEAR_LINEAR: number;
  70001. /** mag = linear and min = nearest and mip = none */
  70002. static readonly TEXTURE_LINEAR_NEAREST: number;
  70003. /** Explicit coordinates mode */
  70004. static readonly TEXTURE_EXPLICIT_MODE: number;
  70005. /** Spherical coordinates mode */
  70006. static readonly TEXTURE_SPHERICAL_MODE: number;
  70007. /** Planar coordinates mode */
  70008. static readonly TEXTURE_PLANAR_MODE: number;
  70009. /** Cubic coordinates mode */
  70010. static readonly TEXTURE_CUBIC_MODE: number;
  70011. /** Projection coordinates mode */
  70012. static readonly TEXTURE_PROJECTION_MODE: number;
  70013. /** Skybox coordinates mode */
  70014. static readonly TEXTURE_SKYBOX_MODE: number;
  70015. /** Inverse Cubic coordinates mode */
  70016. static readonly TEXTURE_INVCUBIC_MODE: number;
  70017. /** Equirectangular coordinates mode */
  70018. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  70019. /** Equirectangular Fixed coordinates mode */
  70020. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  70021. /** Equirectangular Fixed Mirrored coordinates mode */
  70022. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  70023. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  70024. static readonly SCALEMODE_FLOOR: number;
  70025. /** Defines that texture rescaling will look for the nearest power of 2 size */
  70026. static readonly SCALEMODE_NEAREST: number;
  70027. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  70028. static readonly SCALEMODE_CEILING: number;
  70029. /**
  70030. * The dirty texture flag value
  70031. */
  70032. static readonly MATERIAL_TextureDirtyFlag: number;
  70033. /**
  70034. * The dirty light flag value
  70035. */
  70036. static readonly MATERIAL_LightDirtyFlag: number;
  70037. /**
  70038. * The dirty fresnel flag value
  70039. */
  70040. static readonly MATERIAL_FresnelDirtyFlag: number;
  70041. /**
  70042. * The dirty attribute flag value
  70043. */
  70044. static readonly MATERIAL_AttributesDirtyFlag: number;
  70045. /**
  70046. * The dirty misc flag value
  70047. */
  70048. static readonly MATERIAL_MiscDirtyFlag: number;
  70049. /**
  70050. * The all dirty flag value
  70051. */
  70052. static readonly MATERIAL_AllDirtyFlag: number;
  70053. /**
  70054. * Returns the triangle fill mode
  70055. */
  70056. static readonly MATERIAL_TriangleFillMode: number;
  70057. /**
  70058. * Returns the wireframe mode
  70059. */
  70060. static readonly MATERIAL_WireFrameFillMode: number;
  70061. /**
  70062. * Returns the point fill mode
  70063. */
  70064. static readonly MATERIAL_PointFillMode: number;
  70065. /**
  70066. * Returns the point list draw mode
  70067. */
  70068. static readonly MATERIAL_PointListDrawMode: number;
  70069. /**
  70070. * Returns the line list draw mode
  70071. */
  70072. static readonly MATERIAL_LineListDrawMode: number;
  70073. /**
  70074. * Returns the line loop draw mode
  70075. */
  70076. static readonly MATERIAL_LineLoopDrawMode: number;
  70077. /**
  70078. * Returns the line strip draw mode
  70079. */
  70080. static readonly MATERIAL_LineStripDrawMode: number;
  70081. /**
  70082. * Returns the triangle strip draw mode
  70083. */
  70084. static readonly MATERIAL_TriangleStripDrawMode: number;
  70085. /**
  70086. * Returns the triangle fan draw mode
  70087. */
  70088. static readonly MATERIAL_TriangleFanDrawMode: number;
  70089. /**
  70090. * Stores the clock-wise side orientation
  70091. */
  70092. static readonly MATERIAL_ClockWiseSideOrientation: number;
  70093. /**
  70094. * Stores the counter clock-wise side orientation
  70095. */
  70096. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  70097. /**
  70098. * Nothing
  70099. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70100. */
  70101. static readonly ACTION_NothingTrigger: number;
  70102. /**
  70103. * On pick
  70104. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70105. */
  70106. static readonly ACTION_OnPickTrigger: number;
  70107. /**
  70108. * On left pick
  70109. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70110. */
  70111. static readonly ACTION_OnLeftPickTrigger: number;
  70112. /**
  70113. * On right pick
  70114. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70115. */
  70116. static readonly ACTION_OnRightPickTrigger: number;
  70117. /**
  70118. * On center pick
  70119. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70120. */
  70121. static readonly ACTION_OnCenterPickTrigger: number;
  70122. /**
  70123. * On pick down
  70124. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70125. */
  70126. static readonly ACTION_OnPickDownTrigger: number;
  70127. /**
  70128. * On double pick
  70129. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70130. */
  70131. static readonly ACTION_OnDoublePickTrigger: number;
  70132. /**
  70133. * On pick up
  70134. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70135. */
  70136. static readonly ACTION_OnPickUpTrigger: number;
  70137. /**
  70138. * On pick out.
  70139. * This trigger will only be raised if you also declared a OnPickDown
  70140. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70141. */
  70142. static readonly ACTION_OnPickOutTrigger: number;
  70143. /**
  70144. * On long press
  70145. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70146. */
  70147. static readonly ACTION_OnLongPressTrigger: number;
  70148. /**
  70149. * On pointer over
  70150. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70151. */
  70152. static readonly ACTION_OnPointerOverTrigger: number;
  70153. /**
  70154. * On pointer out
  70155. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70156. */
  70157. static readonly ACTION_OnPointerOutTrigger: number;
  70158. /**
  70159. * On every frame
  70160. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70161. */
  70162. static readonly ACTION_OnEveryFrameTrigger: number;
  70163. /**
  70164. * On intersection enter
  70165. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70166. */
  70167. static readonly ACTION_OnIntersectionEnterTrigger: number;
  70168. /**
  70169. * On intersection exit
  70170. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70171. */
  70172. static readonly ACTION_OnIntersectionExitTrigger: number;
  70173. /**
  70174. * On key down
  70175. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70176. */
  70177. static readonly ACTION_OnKeyDownTrigger: number;
  70178. /**
  70179. * On key up
  70180. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70181. */
  70182. static readonly ACTION_OnKeyUpTrigger: number;
  70183. /**
  70184. * Billboard mode will only apply to Y axis
  70185. */
  70186. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  70187. /**
  70188. * Billboard mode will apply to all axes
  70189. */
  70190. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  70191. /**
  70192. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  70193. */
  70194. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  70195. /**
  70196. * Gets or sets base Assets URL
  70197. */
  70198. static PARTICLES_BaseAssetsUrl: string;
  70199. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  70200. * Test order :
  70201. * Is the bounding sphere outside the frustum ?
  70202. * If not, are the bounding box vertices outside the frustum ?
  70203. * It not, then the cullable object is in the frustum.
  70204. */
  70205. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  70206. /** Culling strategy : Bounding Sphere Only.
  70207. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  70208. * It's also less accurate than the standard because some not visible objects can still be selected.
  70209. * Test : is the bounding sphere outside the frustum ?
  70210. * If not, then the cullable object is in the frustum.
  70211. */
  70212. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  70213. /** Culling strategy : Optimistic Inclusion.
  70214. * This in an inclusion test first, then the standard exclusion test.
  70215. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  70216. * 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.
  70217. * Anyway, it's as accurate as the standard strategy.
  70218. * Test :
  70219. * Is the cullable object bounding sphere center in the frustum ?
  70220. * If not, apply the default culling strategy.
  70221. */
  70222. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  70223. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  70224. * This in an inclusion test first, then the bounding sphere only exclusion test.
  70225. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  70226. * 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.
  70227. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  70228. * Test :
  70229. * Is the cullable object bounding sphere center in the frustum ?
  70230. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  70231. */
  70232. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  70233. /**
  70234. * No logging while loading
  70235. */
  70236. static readonly SCENELOADER_NO_LOGGING: number;
  70237. /**
  70238. * Minimal logging while loading
  70239. */
  70240. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  70241. /**
  70242. * Summary logging while loading
  70243. */
  70244. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  70245. /**
  70246. * Detailled logging while loading
  70247. */
  70248. static readonly SCENELOADER_DETAILED_LOGGING: number;
  70249. }
  70250. }
  70251. declare module BABYLON {
  70252. /**
  70253. * Class used to store and describe the pipeline context associated with an effect
  70254. */
  70255. export interface IPipelineContext {
  70256. /**
  70257. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  70258. */
  70259. isAsync: boolean;
  70260. /**
  70261. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  70262. */
  70263. isReady: boolean;
  70264. /** @hidden */
  70265. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  70266. }
  70267. }
  70268. declare module BABYLON {
  70269. /** @hidden */
  70270. export interface IShaderProcessor {
  70271. attributeProcessor?: (attribute: string) => string;
  70272. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  70273. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  70274. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  70275. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  70276. lineProcessor?: (line: string, isFragment: boolean) => string;
  70277. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  70278. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  70279. }
  70280. }
  70281. declare module BABYLON {
  70282. /** @hidden */
  70283. export interface ProcessingOptions {
  70284. defines: string[];
  70285. indexParameters: any;
  70286. isFragment: boolean;
  70287. shouldUseHighPrecisionShader: boolean;
  70288. supportsUniformBuffers: boolean;
  70289. shadersRepository: string;
  70290. includesShadersStore: {
  70291. [key: string]: string;
  70292. };
  70293. processor?: IShaderProcessor;
  70294. version: string;
  70295. platformName: string;
  70296. lookForClosingBracketForUniformBuffer?: boolean;
  70297. }
  70298. }
  70299. declare module BABYLON {
  70300. /**
  70301. * Helper to manipulate strings
  70302. */
  70303. export class StringTools {
  70304. /**
  70305. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  70306. * @param str Source string
  70307. * @param suffix Suffix to search for in the source string
  70308. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  70309. */
  70310. static EndsWith(str: string, suffix: string): boolean;
  70311. /**
  70312. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  70313. * @param str Source string
  70314. * @param suffix Suffix to search for in the source string
  70315. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  70316. */
  70317. static StartsWith(str: string, suffix: string): boolean;
  70318. }
  70319. }
  70320. declare module BABYLON {
  70321. /** @hidden */
  70322. export class ShaderCodeNode {
  70323. line: string;
  70324. children: ShaderCodeNode[];
  70325. additionalDefineKey?: string;
  70326. additionalDefineValue?: string;
  70327. isValid(preprocessors: {
  70328. [key: string]: string;
  70329. }): boolean;
  70330. process(preprocessors: {
  70331. [key: string]: string;
  70332. }, options: ProcessingOptions): string;
  70333. }
  70334. }
  70335. declare module BABYLON {
  70336. /** @hidden */
  70337. export class ShaderCodeCursor {
  70338. private _lines;
  70339. lineIndex: number;
  70340. readonly currentLine: string;
  70341. readonly canRead: boolean;
  70342. lines: string[];
  70343. }
  70344. }
  70345. declare module BABYLON {
  70346. /** @hidden */
  70347. export class ShaderCodeConditionNode extends ShaderCodeNode {
  70348. process(preprocessors: {
  70349. [key: string]: string;
  70350. }, options: ProcessingOptions): string;
  70351. }
  70352. }
  70353. declare module BABYLON {
  70354. /** @hidden */
  70355. export class ShaderDefineExpression {
  70356. isTrue(preprocessors: {
  70357. [key: string]: string;
  70358. }): boolean;
  70359. }
  70360. }
  70361. declare module BABYLON {
  70362. /** @hidden */
  70363. export class ShaderCodeTestNode extends ShaderCodeNode {
  70364. testExpression: ShaderDefineExpression;
  70365. isValid(preprocessors: {
  70366. [key: string]: string;
  70367. }): boolean;
  70368. }
  70369. }
  70370. declare module BABYLON {
  70371. /** @hidden */
  70372. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  70373. define: string;
  70374. not: boolean;
  70375. constructor(define: string, not?: boolean);
  70376. isTrue(preprocessors: {
  70377. [key: string]: string;
  70378. }): boolean;
  70379. }
  70380. }
  70381. declare module BABYLON {
  70382. /** @hidden */
  70383. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  70384. leftOperand: ShaderDefineExpression;
  70385. rightOperand: ShaderDefineExpression;
  70386. isTrue(preprocessors: {
  70387. [key: string]: string;
  70388. }): boolean;
  70389. }
  70390. }
  70391. declare module BABYLON {
  70392. /** @hidden */
  70393. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  70394. leftOperand: ShaderDefineExpression;
  70395. rightOperand: ShaderDefineExpression;
  70396. isTrue(preprocessors: {
  70397. [key: string]: string;
  70398. }): boolean;
  70399. }
  70400. }
  70401. declare module BABYLON {
  70402. /** @hidden */
  70403. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  70404. define: string;
  70405. operand: string;
  70406. testValue: string;
  70407. constructor(define: string, operand: string, testValue: string);
  70408. isTrue(preprocessors: {
  70409. [key: string]: string;
  70410. }): boolean;
  70411. }
  70412. }
  70413. declare module BABYLON {
  70414. /**
  70415. * @ignore
  70416. * Application error to support additional information when loading a file
  70417. */
  70418. export class LoadFileError extends Error {
  70419. /** defines the optional web request */
  70420. request?: WebRequest | undefined;
  70421. private static _setPrototypeOf;
  70422. /**
  70423. * Creates a new LoadFileError
  70424. * @param message defines the message of the error
  70425. * @param request defines the optional web request
  70426. */
  70427. constructor(message: string,
  70428. /** defines the optional web request */
  70429. request?: WebRequest | undefined);
  70430. }
  70431. }
  70432. declare module BABYLON {
  70433. /**
  70434. * Class used to enable access to offline support
  70435. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  70436. */
  70437. export interface IOfflineProvider {
  70438. /**
  70439. * Gets a boolean indicating if scene must be saved in the database
  70440. */
  70441. enableSceneOffline: boolean;
  70442. /**
  70443. * Gets a boolean indicating if textures must be saved in the database
  70444. */
  70445. enableTexturesOffline: boolean;
  70446. /**
  70447. * Open the offline support and make it available
  70448. * @param successCallback defines the callback to call on success
  70449. * @param errorCallback defines the callback to call on error
  70450. */
  70451. open(successCallback: () => void, errorCallback: () => void): void;
  70452. /**
  70453. * Loads an image from the offline support
  70454. * @param url defines the url to load from
  70455. * @param image defines the target DOM image
  70456. */
  70457. loadImage(url: string, image: HTMLImageElement): void;
  70458. /**
  70459. * Loads a file from offline support
  70460. * @param url defines the URL to load from
  70461. * @param sceneLoaded defines a callback to call on success
  70462. * @param progressCallBack defines a callback to call when progress changed
  70463. * @param errorCallback defines a callback to call on error
  70464. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  70465. */
  70466. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  70467. }
  70468. }
  70469. declare module BABYLON {
  70470. /**
  70471. * Class used to help managing file picking and drag'n'drop
  70472. * File Storage
  70473. */
  70474. export class FilesInputStore {
  70475. /**
  70476. * List of files ready to be loaded
  70477. */
  70478. static FilesToLoad: {
  70479. [key: string]: File;
  70480. };
  70481. }
  70482. }
  70483. declare module BABYLON {
  70484. /**
  70485. * Class used to define a retry strategy when error happens while loading assets
  70486. */
  70487. export class RetryStrategy {
  70488. /**
  70489. * Function used to defines an exponential back off strategy
  70490. * @param maxRetries defines the maximum number of retries (3 by default)
  70491. * @param baseInterval defines the interval between retries
  70492. * @returns the strategy function to use
  70493. */
  70494. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  70495. }
  70496. }
  70497. declare module BABYLON {
  70498. /**
  70499. * @hidden
  70500. */
  70501. export class FileTools {
  70502. /**
  70503. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  70504. */
  70505. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  70506. /**
  70507. * Gets or sets the base URL to use to load assets
  70508. */
  70509. static BaseUrl: string;
  70510. /**
  70511. * Default behaviour for cors in the application.
  70512. * It can be a string if the expected behavior is identical in the entire app.
  70513. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  70514. */
  70515. static CorsBehavior: string | ((url: string | string[]) => string);
  70516. /**
  70517. * Gets or sets a function used to pre-process url before using them to load assets
  70518. */
  70519. static PreprocessUrl: (url: string) => string;
  70520. /**
  70521. * Removes unwanted characters from an url
  70522. * @param url defines the url to clean
  70523. * @returns the cleaned url
  70524. */
  70525. private static _CleanUrl;
  70526. /**
  70527. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  70528. * @param url define the url we are trying
  70529. * @param element define the dom element where to configure the cors policy
  70530. */
  70531. static SetCorsBehavior(url: string | string[], element: {
  70532. crossOrigin: string | null;
  70533. }): void;
  70534. /**
  70535. * Loads an image as an HTMLImageElement.
  70536. * @param input url string, ArrayBuffer, or Blob to load
  70537. * @param onLoad callback called when the image successfully loads
  70538. * @param onError callback called when the image fails to load
  70539. * @param offlineProvider offline provider for caching
  70540. * @returns the HTMLImageElement of the loaded image
  70541. */
  70542. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  70543. /**
  70544. * Loads a file
  70545. * @param fileToLoad defines the file to load
  70546. * @param callback defines the callback to call when data is loaded
  70547. * @param progressCallBack defines the callback to call during loading process
  70548. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  70549. * @returns a file request object
  70550. */
  70551. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  70552. /**
  70553. * Loads a file
  70554. * @param url url string, ArrayBuffer, or Blob to load
  70555. * @param onSuccess callback called when the file successfully loads
  70556. * @param onProgress callback called while file is loading (if the server supports this mode)
  70557. * @param offlineProvider defines the offline provider for caching
  70558. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  70559. * @param onError callback called when the file fails to load
  70560. * @returns a file request object
  70561. */
  70562. 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;
  70563. /**
  70564. * Checks if the loaded document was accessed via `file:`-Protocol.
  70565. * @returns boolean
  70566. */
  70567. static IsFileURL(): boolean;
  70568. }
  70569. }
  70570. declare module BABYLON {
  70571. /** @hidden */
  70572. export class ShaderProcessor {
  70573. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  70574. private static _ProcessPrecision;
  70575. private static _ExtractOperation;
  70576. private static _BuildSubExpression;
  70577. private static _BuildExpression;
  70578. private static _MoveCursorWithinIf;
  70579. private static _MoveCursor;
  70580. private static _EvaluatePreProcessors;
  70581. private static _PreparePreProcessors;
  70582. private static _ProcessShaderConversion;
  70583. private static _ProcessIncludes;
  70584. }
  70585. }
  70586. declare module BABYLON {
  70587. /**
  70588. * Class used to hold a RBG color
  70589. */
  70590. export class Color3 {
  70591. /**
  70592. * Defines the red component (between 0 and 1, default is 0)
  70593. */
  70594. r: number;
  70595. /**
  70596. * Defines the green component (between 0 and 1, default is 0)
  70597. */
  70598. g: number;
  70599. /**
  70600. * Defines the blue component (between 0 and 1, default is 0)
  70601. */
  70602. b: number;
  70603. /**
  70604. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  70605. * @param r defines the red component (between 0 and 1, default is 0)
  70606. * @param g defines the green component (between 0 and 1, default is 0)
  70607. * @param b defines the blue component (between 0 and 1, default is 0)
  70608. */
  70609. constructor(
  70610. /**
  70611. * Defines the red component (between 0 and 1, default is 0)
  70612. */
  70613. r?: number,
  70614. /**
  70615. * Defines the green component (between 0 and 1, default is 0)
  70616. */
  70617. g?: number,
  70618. /**
  70619. * Defines the blue component (between 0 and 1, default is 0)
  70620. */
  70621. b?: number);
  70622. /**
  70623. * Creates a string with the Color3 current values
  70624. * @returns the string representation of the Color3 object
  70625. */
  70626. toString(): string;
  70627. /**
  70628. * Returns the string "Color3"
  70629. * @returns "Color3"
  70630. */
  70631. getClassName(): string;
  70632. /**
  70633. * Compute the Color3 hash code
  70634. * @returns an unique number that can be used to hash Color3 objects
  70635. */
  70636. getHashCode(): number;
  70637. /**
  70638. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  70639. * @param array defines the array where to store the r,g,b components
  70640. * @param index defines an optional index in the target array to define where to start storing values
  70641. * @returns the current Color3 object
  70642. */
  70643. toArray(array: FloatArray, index?: number): Color3;
  70644. /**
  70645. * Returns a new Color4 object from the current Color3 and the given alpha
  70646. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  70647. * @returns a new Color4 object
  70648. */
  70649. toColor4(alpha?: number): Color4;
  70650. /**
  70651. * Returns a new array populated with 3 numeric elements : red, green and blue values
  70652. * @returns the new array
  70653. */
  70654. asArray(): number[];
  70655. /**
  70656. * Returns the luminance value
  70657. * @returns a float value
  70658. */
  70659. toLuminance(): number;
  70660. /**
  70661. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  70662. * @param otherColor defines the second operand
  70663. * @returns the new Color3 object
  70664. */
  70665. multiply(otherColor: DeepImmutable<Color3>): Color3;
  70666. /**
  70667. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  70668. * @param otherColor defines the second operand
  70669. * @param result defines the Color3 object where to store the result
  70670. * @returns the current Color3
  70671. */
  70672. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  70673. /**
  70674. * Determines equality between Color3 objects
  70675. * @param otherColor defines the second operand
  70676. * @returns true if the rgb values are equal to the given ones
  70677. */
  70678. equals(otherColor: DeepImmutable<Color3>): boolean;
  70679. /**
  70680. * Determines equality between the current Color3 object and a set of r,b,g values
  70681. * @param r defines the red component to check
  70682. * @param g defines the green component to check
  70683. * @param b defines the blue component to check
  70684. * @returns true if the rgb values are equal to the given ones
  70685. */
  70686. equalsFloats(r: number, g: number, b: number): boolean;
  70687. /**
  70688. * Multiplies in place each rgb value by scale
  70689. * @param scale defines the scaling factor
  70690. * @returns the updated Color3
  70691. */
  70692. scale(scale: number): Color3;
  70693. /**
  70694. * Multiplies the rgb values by scale and stores the result into "result"
  70695. * @param scale defines the scaling factor
  70696. * @param result defines the Color3 object where to store the result
  70697. * @returns the unmodified current Color3
  70698. */
  70699. scaleToRef(scale: number, result: Color3): Color3;
  70700. /**
  70701. * Scale the current Color3 values by a factor and add the result to a given Color3
  70702. * @param scale defines the scale factor
  70703. * @param result defines color to store the result into
  70704. * @returns the unmodified current Color3
  70705. */
  70706. scaleAndAddToRef(scale: number, result: Color3): Color3;
  70707. /**
  70708. * Clamps the rgb values by the min and max values and stores the result into "result"
  70709. * @param min defines minimum clamping value (default is 0)
  70710. * @param max defines maximum clamping value (default is 1)
  70711. * @param result defines color to store the result into
  70712. * @returns the original Color3
  70713. */
  70714. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  70715. /**
  70716. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  70717. * @param otherColor defines the second operand
  70718. * @returns the new Color3
  70719. */
  70720. add(otherColor: DeepImmutable<Color3>): Color3;
  70721. /**
  70722. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  70723. * @param otherColor defines the second operand
  70724. * @param result defines Color3 object to store the result into
  70725. * @returns the unmodified current Color3
  70726. */
  70727. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  70728. /**
  70729. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  70730. * @param otherColor defines the second operand
  70731. * @returns the new Color3
  70732. */
  70733. subtract(otherColor: DeepImmutable<Color3>): Color3;
  70734. /**
  70735. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  70736. * @param otherColor defines the second operand
  70737. * @param result defines Color3 object to store the result into
  70738. * @returns the unmodified current Color3
  70739. */
  70740. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  70741. /**
  70742. * Copy the current object
  70743. * @returns a new Color3 copied the current one
  70744. */
  70745. clone(): Color3;
  70746. /**
  70747. * Copies the rgb values from the source in the current Color3
  70748. * @param source defines the source Color3 object
  70749. * @returns the updated Color3 object
  70750. */
  70751. copyFrom(source: DeepImmutable<Color3>): Color3;
  70752. /**
  70753. * Updates the Color3 rgb values from the given floats
  70754. * @param r defines the red component to read from
  70755. * @param g defines the green component to read from
  70756. * @param b defines the blue component to read from
  70757. * @returns the current Color3 object
  70758. */
  70759. copyFromFloats(r: number, g: number, b: number): Color3;
  70760. /**
  70761. * Updates the Color3 rgb values from the given floats
  70762. * @param r defines the red component to read from
  70763. * @param g defines the green component to read from
  70764. * @param b defines the blue component to read from
  70765. * @returns the current Color3 object
  70766. */
  70767. set(r: number, g: number, b: number): Color3;
  70768. /**
  70769. * Compute the Color3 hexadecimal code as a string
  70770. * @returns a string containing the hexadecimal representation of the Color3 object
  70771. */
  70772. toHexString(): string;
  70773. /**
  70774. * Computes a new Color3 converted from the current one to linear space
  70775. * @returns a new Color3 object
  70776. */
  70777. toLinearSpace(): Color3;
  70778. /**
  70779. * Converts current color in rgb space to HSV values
  70780. * @returns a new color3 representing the HSV values
  70781. */
  70782. toHSV(): Color3;
  70783. /**
  70784. * Converts current color in rgb space to HSV values
  70785. * @param result defines the Color3 where to store the HSV values
  70786. */
  70787. toHSVToRef(result: Color3): void;
  70788. /**
  70789. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  70790. * @param convertedColor defines the Color3 object where to store the linear space version
  70791. * @returns the unmodified Color3
  70792. */
  70793. toLinearSpaceToRef(convertedColor: Color3): Color3;
  70794. /**
  70795. * Computes a new Color3 converted from the current one to gamma space
  70796. * @returns a new Color3 object
  70797. */
  70798. toGammaSpace(): Color3;
  70799. /**
  70800. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  70801. * @param convertedColor defines the Color3 object where to store the gamma space version
  70802. * @returns the unmodified Color3
  70803. */
  70804. toGammaSpaceToRef(convertedColor: Color3): Color3;
  70805. private static _BlackReadOnly;
  70806. /**
  70807. * Convert Hue, saturation and value to a Color3 (RGB)
  70808. * @param hue defines the hue
  70809. * @param saturation defines the saturation
  70810. * @param value defines the value
  70811. * @param result defines the Color3 where to store the RGB values
  70812. */
  70813. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  70814. /**
  70815. * Creates a new Color3 from the string containing valid hexadecimal values
  70816. * @param hex defines a string containing valid hexadecimal values
  70817. * @returns a new Color3 object
  70818. */
  70819. static FromHexString(hex: string): Color3;
  70820. /**
  70821. * Creates a new Color3 from the starting index of the given array
  70822. * @param array defines the source array
  70823. * @param offset defines an offset in the source array
  70824. * @returns a new Color3 object
  70825. */
  70826. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  70827. /**
  70828. * Creates a new Color3 from integer values (< 256)
  70829. * @param r defines the red component to read from (value between 0 and 255)
  70830. * @param g defines the green component to read from (value between 0 and 255)
  70831. * @param b defines the blue component to read from (value between 0 and 255)
  70832. * @returns a new Color3 object
  70833. */
  70834. static FromInts(r: number, g: number, b: number): Color3;
  70835. /**
  70836. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  70837. * @param start defines the start Color3 value
  70838. * @param end defines the end Color3 value
  70839. * @param amount defines the gradient value between start and end
  70840. * @returns a new Color3 object
  70841. */
  70842. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  70843. /**
  70844. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  70845. * @param left defines the start value
  70846. * @param right defines the end value
  70847. * @param amount defines the gradient factor
  70848. * @param result defines the Color3 object where to store the result
  70849. */
  70850. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  70851. /**
  70852. * Returns a Color3 value containing a red color
  70853. * @returns a new Color3 object
  70854. */
  70855. static Red(): Color3;
  70856. /**
  70857. * Returns a Color3 value containing a green color
  70858. * @returns a new Color3 object
  70859. */
  70860. static Green(): Color3;
  70861. /**
  70862. * Returns a Color3 value containing a blue color
  70863. * @returns a new Color3 object
  70864. */
  70865. static Blue(): Color3;
  70866. /**
  70867. * Returns a Color3 value containing a black color
  70868. * @returns a new Color3 object
  70869. */
  70870. static Black(): Color3;
  70871. /**
  70872. * Gets a Color3 value containing a black color that must not be updated
  70873. */
  70874. static readonly BlackReadOnly: DeepImmutable<Color3>;
  70875. /**
  70876. * Returns a Color3 value containing a white color
  70877. * @returns a new Color3 object
  70878. */
  70879. static White(): Color3;
  70880. /**
  70881. * Returns a Color3 value containing a purple color
  70882. * @returns a new Color3 object
  70883. */
  70884. static Purple(): Color3;
  70885. /**
  70886. * Returns a Color3 value containing a magenta color
  70887. * @returns a new Color3 object
  70888. */
  70889. static Magenta(): Color3;
  70890. /**
  70891. * Returns a Color3 value containing a yellow color
  70892. * @returns a new Color3 object
  70893. */
  70894. static Yellow(): Color3;
  70895. /**
  70896. * Returns a Color3 value containing a gray color
  70897. * @returns a new Color3 object
  70898. */
  70899. static Gray(): Color3;
  70900. /**
  70901. * Returns a Color3 value containing a teal color
  70902. * @returns a new Color3 object
  70903. */
  70904. static Teal(): Color3;
  70905. /**
  70906. * Returns a Color3 value containing a random color
  70907. * @returns a new Color3 object
  70908. */
  70909. static Random(): Color3;
  70910. }
  70911. /**
  70912. * Class used to hold a RBGA color
  70913. */
  70914. export class Color4 {
  70915. /**
  70916. * Defines the red component (between 0 and 1, default is 0)
  70917. */
  70918. r: number;
  70919. /**
  70920. * Defines the green component (between 0 and 1, default is 0)
  70921. */
  70922. g: number;
  70923. /**
  70924. * Defines the blue component (between 0 and 1, default is 0)
  70925. */
  70926. b: number;
  70927. /**
  70928. * Defines the alpha component (between 0 and 1, default is 1)
  70929. */
  70930. a: number;
  70931. /**
  70932. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  70933. * @param r defines the red component (between 0 and 1, default is 0)
  70934. * @param g defines the green component (between 0 and 1, default is 0)
  70935. * @param b defines the blue component (between 0 and 1, default is 0)
  70936. * @param a defines the alpha component (between 0 and 1, default is 1)
  70937. */
  70938. constructor(
  70939. /**
  70940. * Defines the red component (between 0 and 1, default is 0)
  70941. */
  70942. r?: number,
  70943. /**
  70944. * Defines the green component (between 0 and 1, default is 0)
  70945. */
  70946. g?: number,
  70947. /**
  70948. * Defines the blue component (between 0 and 1, default is 0)
  70949. */
  70950. b?: number,
  70951. /**
  70952. * Defines the alpha component (between 0 and 1, default is 1)
  70953. */
  70954. a?: number);
  70955. /**
  70956. * Adds in place the given Color4 values to the current Color4 object
  70957. * @param right defines the second operand
  70958. * @returns the current updated Color4 object
  70959. */
  70960. addInPlace(right: DeepImmutable<Color4>): Color4;
  70961. /**
  70962. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  70963. * @returns the new array
  70964. */
  70965. asArray(): number[];
  70966. /**
  70967. * Stores from the starting index in the given array the Color4 successive values
  70968. * @param array defines the array where to store the r,g,b components
  70969. * @param index defines an optional index in the target array to define where to start storing values
  70970. * @returns the current Color4 object
  70971. */
  70972. toArray(array: number[], index?: number): Color4;
  70973. /**
  70974. * Determines equality between Color4 objects
  70975. * @param otherColor defines the second operand
  70976. * @returns true if the rgba values are equal to the given ones
  70977. */
  70978. equals(otherColor: DeepImmutable<Color4>): boolean;
  70979. /**
  70980. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  70981. * @param right defines the second operand
  70982. * @returns a new Color4 object
  70983. */
  70984. add(right: DeepImmutable<Color4>): Color4;
  70985. /**
  70986. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  70987. * @param right defines the second operand
  70988. * @returns a new Color4 object
  70989. */
  70990. subtract(right: DeepImmutable<Color4>): Color4;
  70991. /**
  70992. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  70993. * @param right defines the second operand
  70994. * @param result defines the Color4 object where to store the result
  70995. * @returns the current Color4 object
  70996. */
  70997. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  70998. /**
  70999. * Creates a new Color4 with the current Color4 values multiplied by scale
  71000. * @param scale defines the scaling factor to apply
  71001. * @returns a new Color4 object
  71002. */
  71003. scale(scale: number): Color4;
  71004. /**
  71005. * Multiplies the current Color4 values by scale and stores the result in "result"
  71006. * @param scale defines the scaling factor to apply
  71007. * @param result defines the Color4 object where to store the result
  71008. * @returns the current unmodified Color4
  71009. */
  71010. scaleToRef(scale: number, result: Color4): Color4;
  71011. /**
  71012. * Scale the current Color4 values by a factor and add the result to a given Color4
  71013. * @param scale defines the scale factor
  71014. * @param result defines the Color4 object where to store the result
  71015. * @returns the unmodified current Color4
  71016. */
  71017. scaleAndAddToRef(scale: number, result: Color4): Color4;
  71018. /**
  71019. * Clamps the rgb values by the min and max values and stores the result into "result"
  71020. * @param min defines minimum clamping value (default is 0)
  71021. * @param max defines maximum clamping value (default is 1)
  71022. * @param result defines color to store the result into.
  71023. * @returns the cuurent Color4
  71024. */
  71025. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  71026. /**
  71027. * Multipy an Color4 value by another and return a new Color4 object
  71028. * @param color defines the Color4 value to multiply by
  71029. * @returns a new Color4 object
  71030. */
  71031. multiply(color: Color4): Color4;
  71032. /**
  71033. * Multipy a Color4 value by another and push the result in a reference value
  71034. * @param color defines the Color4 value to multiply by
  71035. * @param result defines the Color4 to fill the result in
  71036. * @returns the result Color4
  71037. */
  71038. multiplyToRef(color: Color4, result: Color4): Color4;
  71039. /**
  71040. * Creates a string with the Color4 current values
  71041. * @returns the string representation of the Color4 object
  71042. */
  71043. toString(): string;
  71044. /**
  71045. * Returns the string "Color4"
  71046. * @returns "Color4"
  71047. */
  71048. getClassName(): string;
  71049. /**
  71050. * Compute the Color4 hash code
  71051. * @returns an unique number that can be used to hash Color4 objects
  71052. */
  71053. getHashCode(): number;
  71054. /**
  71055. * Creates a new Color4 copied from the current one
  71056. * @returns a new Color4 object
  71057. */
  71058. clone(): Color4;
  71059. /**
  71060. * Copies the given Color4 values into the current one
  71061. * @param source defines the source Color4 object
  71062. * @returns the current updated Color4 object
  71063. */
  71064. copyFrom(source: Color4): Color4;
  71065. /**
  71066. * Copies the given float values into the current one
  71067. * @param r defines the red component to read from
  71068. * @param g defines the green component to read from
  71069. * @param b defines the blue component to read from
  71070. * @param a defines the alpha component to read from
  71071. * @returns the current updated Color4 object
  71072. */
  71073. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  71074. /**
  71075. * Copies the given float values into the current one
  71076. * @param r defines the red component to read from
  71077. * @param g defines the green component to read from
  71078. * @param b defines the blue component to read from
  71079. * @param a defines the alpha component to read from
  71080. * @returns the current updated Color4 object
  71081. */
  71082. set(r: number, g: number, b: number, a: number): Color4;
  71083. /**
  71084. * Compute the Color4 hexadecimal code as a string
  71085. * @returns a string containing the hexadecimal representation of the Color4 object
  71086. */
  71087. toHexString(): string;
  71088. /**
  71089. * Computes a new Color4 converted from the current one to linear space
  71090. * @returns a new Color4 object
  71091. */
  71092. toLinearSpace(): Color4;
  71093. /**
  71094. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  71095. * @param convertedColor defines the Color4 object where to store the linear space version
  71096. * @returns the unmodified Color4
  71097. */
  71098. toLinearSpaceToRef(convertedColor: Color4): Color4;
  71099. /**
  71100. * Computes a new Color4 converted from the current one to gamma space
  71101. * @returns a new Color4 object
  71102. */
  71103. toGammaSpace(): Color4;
  71104. /**
  71105. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  71106. * @param convertedColor defines the Color4 object where to store the gamma space version
  71107. * @returns the unmodified Color4
  71108. */
  71109. toGammaSpaceToRef(convertedColor: Color4): Color4;
  71110. /**
  71111. * Creates a new Color4 from the string containing valid hexadecimal values
  71112. * @param hex defines a string containing valid hexadecimal values
  71113. * @returns a new Color4 object
  71114. */
  71115. static FromHexString(hex: string): Color4;
  71116. /**
  71117. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  71118. * @param left defines the start value
  71119. * @param right defines the end value
  71120. * @param amount defines the gradient factor
  71121. * @returns a new Color4 object
  71122. */
  71123. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  71124. /**
  71125. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  71126. * @param left defines the start value
  71127. * @param right defines the end value
  71128. * @param amount defines the gradient factor
  71129. * @param result defines the Color4 object where to store data
  71130. */
  71131. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  71132. /**
  71133. * Creates a new Color4 from a Color3 and an alpha value
  71134. * @param color3 defines the source Color3 to read from
  71135. * @param alpha defines the alpha component (1.0 by default)
  71136. * @returns a new Color4 object
  71137. */
  71138. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  71139. /**
  71140. * Creates a new Color4 from the starting index element of the given array
  71141. * @param array defines the source array to read from
  71142. * @param offset defines the offset in the source array
  71143. * @returns a new Color4 object
  71144. */
  71145. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  71146. /**
  71147. * Creates a new Color3 from integer values (< 256)
  71148. * @param r defines the red component to read from (value between 0 and 255)
  71149. * @param g defines the green component to read from (value between 0 and 255)
  71150. * @param b defines the blue component to read from (value between 0 and 255)
  71151. * @param a defines the alpha component to read from (value between 0 and 255)
  71152. * @returns a new Color3 object
  71153. */
  71154. static FromInts(r: number, g: number, b: number, a: number): Color4;
  71155. /**
  71156. * Check the content of a given array and convert it to an array containing RGBA data
  71157. * If the original array was already containing count * 4 values then it is returned directly
  71158. * @param colors defines the array to check
  71159. * @param count defines the number of RGBA data to expect
  71160. * @returns an array containing count * 4 values (RGBA)
  71161. */
  71162. static CheckColors4(colors: number[], count: number): number[];
  71163. }
  71164. /**
  71165. * @hidden
  71166. */
  71167. export class TmpColors {
  71168. static Color3: Color3[];
  71169. static Color4: Color4[];
  71170. }
  71171. }
  71172. declare module BABYLON {
  71173. /**
  71174. * Class representing spherical harmonics coefficients to the 3rd degree
  71175. */
  71176. export class SphericalHarmonics {
  71177. /**
  71178. * Defines whether or not the harmonics have been prescaled for rendering.
  71179. */
  71180. preScaled: boolean;
  71181. /**
  71182. * The l0,0 coefficients of the spherical harmonics
  71183. */
  71184. l00: Vector3;
  71185. /**
  71186. * The l1,-1 coefficients of the spherical harmonics
  71187. */
  71188. l1_1: Vector3;
  71189. /**
  71190. * The l1,0 coefficients of the spherical harmonics
  71191. */
  71192. l10: Vector3;
  71193. /**
  71194. * The l1,1 coefficients of the spherical harmonics
  71195. */
  71196. l11: Vector3;
  71197. /**
  71198. * The l2,-2 coefficients of the spherical harmonics
  71199. */
  71200. l2_2: Vector3;
  71201. /**
  71202. * The l2,-1 coefficients of the spherical harmonics
  71203. */
  71204. l2_1: Vector3;
  71205. /**
  71206. * The l2,0 coefficients of the spherical harmonics
  71207. */
  71208. l20: Vector3;
  71209. /**
  71210. * The l2,1 coefficients of the spherical harmonics
  71211. */
  71212. l21: Vector3;
  71213. /**
  71214. * The l2,2 coefficients of the spherical harmonics
  71215. */
  71216. l22: Vector3;
  71217. /**
  71218. * Adds a light to the spherical harmonics
  71219. * @param direction the direction of the light
  71220. * @param color the color of the light
  71221. * @param deltaSolidAngle the delta solid angle of the light
  71222. */
  71223. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  71224. /**
  71225. * Scales the spherical harmonics by the given amount
  71226. * @param scale the amount to scale
  71227. */
  71228. scaleInPlace(scale: number): void;
  71229. /**
  71230. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  71231. *
  71232. * ```
  71233. * E_lm = A_l * L_lm
  71234. * ```
  71235. *
  71236. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  71237. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  71238. * the scaling factors are given in equation 9.
  71239. */
  71240. convertIncidentRadianceToIrradiance(): void;
  71241. /**
  71242. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  71243. *
  71244. * ```
  71245. * L = (1/pi) * E * rho
  71246. * ```
  71247. *
  71248. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  71249. */
  71250. convertIrradianceToLambertianRadiance(): void;
  71251. /**
  71252. * Integrates the reconstruction coefficients directly in to the SH preventing further
  71253. * required operations at run time.
  71254. *
  71255. * This is simply done by scaling back the SH with Ylm constants parameter.
  71256. * The trigonometric part being applied by the shader at run time.
  71257. */
  71258. preScaleForRendering(): void;
  71259. /**
  71260. * Constructs a spherical harmonics from an array.
  71261. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  71262. * @returns the spherical harmonics
  71263. */
  71264. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  71265. /**
  71266. * Gets the spherical harmonics from polynomial
  71267. * @param polynomial the spherical polynomial
  71268. * @returns the spherical harmonics
  71269. */
  71270. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  71271. }
  71272. /**
  71273. * Class representing spherical polynomial coefficients to the 3rd degree
  71274. */
  71275. export class SphericalPolynomial {
  71276. private _harmonics;
  71277. /**
  71278. * The spherical harmonics used to create the polynomials.
  71279. */
  71280. readonly preScaledHarmonics: SphericalHarmonics;
  71281. /**
  71282. * The x coefficients of the spherical polynomial
  71283. */
  71284. x: Vector3;
  71285. /**
  71286. * The y coefficients of the spherical polynomial
  71287. */
  71288. y: Vector3;
  71289. /**
  71290. * The z coefficients of the spherical polynomial
  71291. */
  71292. z: Vector3;
  71293. /**
  71294. * The xx coefficients of the spherical polynomial
  71295. */
  71296. xx: Vector3;
  71297. /**
  71298. * The yy coefficients of the spherical polynomial
  71299. */
  71300. yy: Vector3;
  71301. /**
  71302. * The zz coefficients of the spherical polynomial
  71303. */
  71304. zz: Vector3;
  71305. /**
  71306. * The xy coefficients of the spherical polynomial
  71307. */
  71308. xy: Vector3;
  71309. /**
  71310. * The yz coefficients of the spherical polynomial
  71311. */
  71312. yz: Vector3;
  71313. /**
  71314. * The zx coefficients of the spherical polynomial
  71315. */
  71316. zx: Vector3;
  71317. /**
  71318. * Adds an ambient color to the spherical polynomial
  71319. * @param color the color to add
  71320. */
  71321. addAmbient(color: Color3): void;
  71322. /**
  71323. * Scales the spherical polynomial by the given amount
  71324. * @param scale the amount to scale
  71325. */
  71326. scaleInPlace(scale: number): void;
  71327. /**
  71328. * Gets the spherical polynomial from harmonics
  71329. * @param harmonics the spherical harmonics
  71330. * @returns the spherical polynomial
  71331. */
  71332. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  71333. /**
  71334. * Constructs a spherical polynomial from an array.
  71335. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  71336. * @returns the spherical polynomial
  71337. */
  71338. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  71339. }
  71340. }
  71341. declare module BABYLON {
  71342. /**
  71343. * Define options used to create a render target texture
  71344. */
  71345. export class RenderTargetCreationOptions {
  71346. /**
  71347. * Specifies is mipmaps must be generated
  71348. */
  71349. generateMipMaps?: boolean;
  71350. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  71351. generateDepthBuffer?: boolean;
  71352. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  71353. generateStencilBuffer?: boolean;
  71354. /** Defines texture type (int by default) */
  71355. type?: number;
  71356. /** Defines sampling mode (trilinear by default) */
  71357. samplingMode?: number;
  71358. /** Defines format (RGBA by default) */
  71359. format?: number;
  71360. }
  71361. }
  71362. declare module BABYLON {
  71363. /**
  71364. * @hidden
  71365. **/
  71366. export class _AlphaState {
  71367. private _isAlphaBlendDirty;
  71368. private _isBlendFunctionParametersDirty;
  71369. private _isBlendEquationParametersDirty;
  71370. private _isBlendConstantsDirty;
  71371. private _alphaBlend;
  71372. private _blendFunctionParameters;
  71373. private _blendEquationParameters;
  71374. private _blendConstants;
  71375. /**
  71376. * Initializes the state.
  71377. */
  71378. constructor();
  71379. readonly isDirty: boolean;
  71380. alphaBlend: boolean;
  71381. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  71382. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  71383. setAlphaEquationParameters(rgb: number, alpha: number): void;
  71384. reset(): void;
  71385. apply(gl: WebGLRenderingContext): void;
  71386. }
  71387. }
  71388. declare module BABYLON {
  71389. /**
  71390. * @hidden
  71391. **/
  71392. export class _DepthCullingState {
  71393. private _isDepthTestDirty;
  71394. private _isDepthMaskDirty;
  71395. private _isDepthFuncDirty;
  71396. private _isCullFaceDirty;
  71397. private _isCullDirty;
  71398. private _isZOffsetDirty;
  71399. private _isFrontFaceDirty;
  71400. private _depthTest;
  71401. private _depthMask;
  71402. private _depthFunc;
  71403. private _cull;
  71404. private _cullFace;
  71405. private _zOffset;
  71406. private _frontFace;
  71407. /**
  71408. * Initializes the state.
  71409. */
  71410. constructor();
  71411. readonly isDirty: boolean;
  71412. zOffset: number;
  71413. cullFace: Nullable<number>;
  71414. cull: Nullable<boolean>;
  71415. depthFunc: Nullable<number>;
  71416. depthMask: boolean;
  71417. depthTest: boolean;
  71418. frontFace: Nullable<number>;
  71419. reset(): void;
  71420. apply(gl: WebGLRenderingContext): void;
  71421. }
  71422. }
  71423. declare module BABYLON {
  71424. /**
  71425. * @hidden
  71426. **/
  71427. export class _StencilState {
  71428. /** 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 */
  71429. static readonly ALWAYS: number;
  71430. /** Passed to stencilOperation to specify that stencil value must be kept */
  71431. static readonly KEEP: number;
  71432. /** Passed to stencilOperation to specify that stencil value must be replaced */
  71433. static readonly REPLACE: number;
  71434. private _isStencilTestDirty;
  71435. private _isStencilMaskDirty;
  71436. private _isStencilFuncDirty;
  71437. private _isStencilOpDirty;
  71438. private _stencilTest;
  71439. private _stencilMask;
  71440. private _stencilFunc;
  71441. private _stencilFuncRef;
  71442. private _stencilFuncMask;
  71443. private _stencilOpStencilFail;
  71444. private _stencilOpDepthFail;
  71445. private _stencilOpStencilDepthPass;
  71446. readonly isDirty: boolean;
  71447. stencilFunc: number;
  71448. stencilFuncRef: number;
  71449. stencilFuncMask: number;
  71450. stencilOpStencilFail: number;
  71451. stencilOpDepthFail: number;
  71452. stencilOpStencilDepthPass: number;
  71453. stencilMask: number;
  71454. stencilTest: boolean;
  71455. constructor();
  71456. reset(): void;
  71457. apply(gl: WebGLRenderingContext): void;
  71458. }
  71459. }
  71460. declare module BABYLON {
  71461. /**
  71462. * @hidden
  71463. **/
  71464. export class _TimeToken {
  71465. _startTimeQuery: Nullable<WebGLQuery>;
  71466. _endTimeQuery: Nullable<WebGLQuery>;
  71467. _timeElapsedQuery: Nullable<WebGLQuery>;
  71468. _timeElapsedQueryEnded: boolean;
  71469. }
  71470. }
  71471. declare module BABYLON {
  71472. /**
  71473. * Class used to evalaute queries containing `and` and `or` operators
  71474. */
  71475. export class AndOrNotEvaluator {
  71476. /**
  71477. * Evaluate a query
  71478. * @param query defines the query to evaluate
  71479. * @param evaluateCallback defines the callback used to filter result
  71480. * @returns true if the query matches
  71481. */
  71482. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  71483. private static _HandleParenthesisContent;
  71484. private static _SimplifyNegation;
  71485. }
  71486. }
  71487. declare module BABYLON {
  71488. /**
  71489. * Class used to store custom tags
  71490. */
  71491. export class Tags {
  71492. /**
  71493. * Adds support for tags on the given object
  71494. * @param obj defines the object to use
  71495. */
  71496. static EnableFor(obj: any): void;
  71497. /**
  71498. * Removes tags support
  71499. * @param obj defines the object to use
  71500. */
  71501. static DisableFor(obj: any): void;
  71502. /**
  71503. * Gets a boolean indicating if the given object has tags
  71504. * @param obj defines the object to use
  71505. * @returns a boolean
  71506. */
  71507. static HasTags(obj: any): boolean;
  71508. /**
  71509. * Gets the tags available on a given object
  71510. * @param obj defines the object to use
  71511. * @param asString defines if the tags must be returned as a string instead of an array of strings
  71512. * @returns the tags
  71513. */
  71514. static GetTags(obj: any, asString?: boolean): any;
  71515. /**
  71516. * Adds tags to an object
  71517. * @param obj defines the object to use
  71518. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  71519. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  71520. */
  71521. static AddTagsTo(obj: any, tagsString: string): void;
  71522. /**
  71523. * @hidden
  71524. */
  71525. static _AddTagTo(obj: any, tag: string): void;
  71526. /**
  71527. * Removes specific tags from a specific object
  71528. * @param obj defines the object to use
  71529. * @param tagsString defines the tags to remove
  71530. */
  71531. static RemoveTagsFrom(obj: any, tagsString: string): void;
  71532. /**
  71533. * @hidden
  71534. */
  71535. static _RemoveTagFrom(obj: any, tag: string): void;
  71536. /**
  71537. * Defines if tags hosted on an object match a given query
  71538. * @param obj defines the object to use
  71539. * @param tagsQuery defines the tag query
  71540. * @returns a boolean
  71541. */
  71542. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  71543. }
  71544. }
  71545. declare module BABYLON {
  71546. /**
  71547. * Defines potential orientation for back face culling
  71548. */
  71549. export enum Orientation {
  71550. /**
  71551. * Clockwise
  71552. */
  71553. CW = 0,
  71554. /** Counter clockwise */
  71555. CCW = 1
  71556. }
  71557. /** Class used to represent a Bezier curve */
  71558. export class BezierCurve {
  71559. /**
  71560. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  71561. * @param t defines the time
  71562. * @param x1 defines the left coordinate on X axis
  71563. * @param y1 defines the left coordinate on Y axis
  71564. * @param x2 defines the right coordinate on X axis
  71565. * @param y2 defines the right coordinate on Y axis
  71566. * @returns the interpolated value
  71567. */
  71568. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  71569. }
  71570. /**
  71571. * Defines angle representation
  71572. */
  71573. export class Angle {
  71574. private _radians;
  71575. /**
  71576. * Creates an Angle object of "radians" radians (float).
  71577. * @param radians the angle in radians
  71578. */
  71579. constructor(radians: number);
  71580. /**
  71581. * Get value in degrees
  71582. * @returns the Angle value in degrees (float)
  71583. */
  71584. degrees(): number;
  71585. /**
  71586. * Get value in radians
  71587. * @returns the Angle value in radians (float)
  71588. */
  71589. radians(): number;
  71590. /**
  71591. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  71592. * @param a defines first vector
  71593. * @param b defines second vector
  71594. * @returns a new Angle
  71595. */
  71596. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  71597. /**
  71598. * Gets a new Angle object from the given float in radians
  71599. * @param radians defines the angle value in radians
  71600. * @returns a new Angle
  71601. */
  71602. static FromRadians(radians: number): Angle;
  71603. /**
  71604. * Gets a new Angle object from the given float in degrees
  71605. * @param degrees defines the angle value in degrees
  71606. * @returns a new Angle
  71607. */
  71608. static FromDegrees(degrees: number): Angle;
  71609. }
  71610. /**
  71611. * This represents an arc in a 2d space.
  71612. */
  71613. export class Arc2 {
  71614. /** Defines the start point of the arc */
  71615. startPoint: Vector2;
  71616. /** Defines the mid point of the arc */
  71617. midPoint: Vector2;
  71618. /** Defines the end point of the arc */
  71619. endPoint: Vector2;
  71620. /**
  71621. * Defines the center point of the arc.
  71622. */
  71623. centerPoint: Vector2;
  71624. /**
  71625. * Defines the radius of the arc.
  71626. */
  71627. radius: number;
  71628. /**
  71629. * Defines the angle of the arc (from mid point to end point).
  71630. */
  71631. angle: Angle;
  71632. /**
  71633. * Defines the start angle of the arc (from start point to middle point).
  71634. */
  71635. startAngle: Angle;
  71636. /**
  71637. * Defines the orientation of the arc (clock wise/counter clock wise).
  71638. */
  71639. orientation: Orientation;
  71640. /**
  71641. * Creates an Arc object from the three given points : start, middle and end.
  71642. * @param startPoint Defines the start point of the arc
  71643. * @param midPoint Defines the midlle point of the arc
  71644. * @param endPoint Defines the end point of the arc
  71645. */
  71646. constructor(
  71647. /** Defines the start point of the arc */
  71648. startPoint: Vector2,
  71649. /** Defines the mid point of the arc */
  71650. midPoint: Vector2,
  71651. /** Defines the end point of the arc */
  71652. endPoint: Vector2);
  71653. }
  71654. /**
  71655. * Represents a 2D path made up of multiple 2D points
  71656. */
  71657. export class Path2 {
  71658. private _points;
  71659. private _length;
  71660. /**
  71661. * If the path start and end point are the same
  71662. */
  71663. closed: boolean;
  71664. /**
  71665. * Creates a Path2 object from the starting 2D coordinates x and y.
  71666. * @param x the starting points x value
  71667. * @param y the starting points y value
  71668. */
  71669. constructor(x: number, y: number);
  71670. /**
  71671. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  71672. * @param x the added points x value
  71673. * @param y the added points y value
  71674. * @returns the updated Path2.
  71675. */
  71676. addLineTo(x: number, y: number): Path2;
  71677. /**
  71678. * 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.
  71679. * @param midX middle point x value
  71680. * @param midY middle point y value
  71681. * @param endX end point x value
  71682. * @param endY end point y value
  71683. * @param numberOfSegments (default: 36)
  71684. * @returns the updated Path2.
  71685. */
  71686. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  71687. /**
  71688. * Closes the Path2.
  71689. * @returns the Path2.
  71690. */
  71691. close(): Path2;
  71692. /**
  71693. * Gets the sum of the distance between each sequential point in the path
  71694. * @returns the Path2 total length (float).
  71695. */
  71696. length(): number;
  71697. /**
  71698. * Gets the points which construct the path
  71699. * @returns the Path2 internal array of points.
  71700. */
  71701. getPoints(): Vector2[];
  71702. /**
  71703. * Retreives the point at the distance aways from the starting point
  71704. * @param normalizedLengthPosition the length along the path to retreive the point from
  71705. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  71706. */
  71707. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  71708. /**
  71709. * Creates a new path starting from an x and y position
  71710. * @param x starting x value
  71711. * @param y starting y value
  71712. * @returns a new Path2 starting at the coordinates (x, y).
  71713. */
  71714. static StartingAt(x: number, y: number): Path2;
  71715. }
  71716. /**
  71717. * Represents a 3D path made up of multiple 3D points
  71718. */
  71719. export class Path3D {
  71720. /**
  71721. * an array of Vector3, the curve axis of the Path3D
  71722. */
  71723. path: Vector3[];
  71724. private _curve;
  71725. private _distances;
  71726. private _tangents;
  71727. private _normals;
  71728. private _binormals;
  71729. private _raw;
  71730. /**
  71731. * new Path3D(path, normal, raw)
  71732. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  71733. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  71734. * @param path an array of Vector3, the curve axis of the Path3D
  71735. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  71736. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  71737. */
  71738. constructor(
  71739. /**
  71740. * an array of Vector3, the curve axis of the Path3D
  71741. */
  71742. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  71743. /**
  71744. * Returns the Path3D array of successive Vector3 designing its curve.
  71745. * @returns the Path3D array of successive Vector3 designing its curve.
  71746. */
  71747. getCurve(): Vector3[];
  71748. /**
  71749. * Returns an array populated with tangent vectors on each Path3D curve point.
  71750. * @returns an array populated with tangent vectors on each Path3D curve point.
  71751. */
  71752. getTangents(): Vector3[];
  71753. /**
  71754. * Returns an array populated with normal vectors on each Path3D curve point.
  71755. * @returns an array populated with normal vectors on each Path3D curve point.
  71756. */
  71757. getNormals(): Vector3[];
  71758. /**
  71759. * Returns an array populated with binormal vectors on each Path3D curve point.
  71760. * @returns an array populated with binormal vectors on each Path3D curve point.
  71761. */
  71762. getBinormals(): Vector3[];
  71763. /**
  71764. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  71765. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  71766. */
  71767. getDistances(): number[];
  71768. /**
  71769. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  71770. * @param path path which all values are copied into the curves points
  71771. * @param firstNormal which should be projected onto the curve
  71772. * @returns the same object updated.
  71773. */
  71774. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  71775. private _compute;
  71776. private _getFirstNonNullVector;
  71777. private _getLastNonNullVector;
  71778. private _normalVector;
  71779. }
  71780. /**
  71781. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  71782. * A Curve3 is designed from a series of successive Vector3.
  71783. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  71784. */
  71785. export class Curve3 {
  71786. private _points;
  71787. private _length;
  71788. /**
  71789. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  71790. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  71791. * @param v1 (Vector3) the control point
  71792. * @param v2 (Vector3) the end point of the Quadratic Bezier
  71793. * @param nbPoints (integer) the wanted number of points in the curve
  71794. * @returns the created Curve3
  71795. */
  71796. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  71797. /**
  71798. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  71799. * @param v0 (Vector3) the origin point of the Cubic Bezier
  71800. * @param v1 (Vector3) the first control point
  71801. * @param v2 (Vector3) the second control point
  71802. * @param v3 (Vector3) the end point of the Cubic Bezier
  71803. * @param nbPoints (integer) the wanted number of points in the curve
  71804. * @returns the created Curve3
  71805. */
  71806. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  71807. /**
  71808. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  71809. * @param p1 (Vector3) the origin point of the Hermite Spline
  71810. * @param t1 (Vector3) the tangent vector at the origin point
  71811. * @param p2 (Vector3) the end point of the Hermite Spline
  71812. * @param t2 (Vector3) the tangent vector at the end point
  71813. * @param nbPoints (integer) the wanted number of points in the curve
  71814. * @returns the created Curve3
  71815. */
  71816. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  71817. /**
  71818. * Returns a Curve3 object along a CatmullRom Spline curve :
  71819. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  71820. * @param nbPoints (integer) the wanted number of points between each curve control points
  71821. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  71822. * @returns the created Curve3
  71823. */
  71824. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  71825. /**
  71826. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  71827. * A Curve3 is designed from a series of successive Vector3.
  71828. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  71829. * @param points points which make up the curve
  71830. */
  71831. constructor(points: Vector3[]);
  71832. /**
  71833. * @returns the Curve3 stored array of successive Vector3
  71834. */
  71835. getPoints(): Vector3[];
  71836. /**
  71837. * @returns the computed length (float) of the curve.
  71838. */
  71839. length(): number;
  71840. /**
  71841. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  71842. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  71843. * curveA and curveB keep unchanged.
  71844. * @param curve the curve to continue from this curve
  71845. * @returns the newly constructed curve
  71846. */
  71847. continue(curve: DeepImmutable<Curve3>): Curve3;
  71848. private _computeLength;
  71849. }
  71850. }
  71851. declare module BABYLON {
  71852. /**
  71853. * This represents the main contract an easing function should follow.
  71854. * Easing functions are used throughout the animation system.
  71855. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71856. */
  71857. export interface IEasingFunction {
  71858. /**
  71859. * Given an input gradient between 0 and 1, this returns the corrseponding value
  71860. * of the easing function.
  71861. * The link below provides some of the most common examples of easing functions.
  71862. * @see https://easings.net/
  71863. * @param gradient Defines the value between 0 and 1 we want the easing value for
  71864. * @returns the corresponding value on the curve defined by the easing function
  71865. */
  71866. ease(gradient: number): number;
  71867. }
  71868. /**
  71869. * Base class used for every default easing function.
  71870. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71871. */
  71872. export class EasingFunction implements IEasingFunction {
  71873. /**
  71874. * Interpolation follows the mathematical formula associated with the easing function.
  71875. */
  71876. static readonly EASINGMODE_EASEIN: number;
  71877. /**
  71878. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  71879. */
  71880. static readonly EASINGMODE_EASEOUT: number;
  71881. /**
  71882. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  71883. */
  71884. static readonly EASINGMODE_EASEINOUT: number;
  71885. private _easingMode;
  71886. /**
  71887. * Sets the easing mode of the current function.
  71888. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  71889. */
  71890. setEasingMode(easingMode: number): void;
  71891. /**
  71892. * Gets the current easing mode.
  71893. * @returns the easing mode
  71894. */
  71895. getEasingMode(): number;
  71896. /**
  71897. * @hidden
  71898. */
  71899. easeInCore(gradient: number): number;
  71900. /**
  71901. * Given an input gradient between 0 and 1, this returns the corresponding value
  71902. * of the easing function.
  71903. * @param gradient Defines the value between 0 and 1 we want the easing value for
  71904. * @returns the corresponding value on the curve defined by the easing function
  71905. */
  71906. ease(gradient: number): number;
  71907. }
  71908. /**
  71909. * Easing function with a circle shape (see link below).
  71910. * @see https://easings.net/#easeInCirc
  71911. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71912. */
  71913. export class CircleEase extends EasingFunction implements IEasingFunction {
  71914. /** @hidden */
  71915. easeInCore(gradient: number): number;
  71916. }
  71917. /**
  71918. * Easing function with a ease back shape (see link below).
  71919. * @see https://easings.net/#easeInBack
  71920. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71921. */
  71922. export class BackEase extends EasingFunction implements IEasingFunction {
  71923. /** Defines the amplitude of the function */
  71924. amplitude: number;
  71925. /**
  71926. * Instantiates a back ease easing
  71927. * @see https://easings.net/#easeInBack
  71928. * @param amplitude Defines the amplitude of the function
  71929. */
  71930. constructor(
  71931. /** Defines the amplitude of the function */
  71932. amplitude?: number);
  71933. /** @hidden */
  71934. easeInCore(gradient: number): number;
  71935. }
  71936. /**
  71937. * Easing function with a bouncing shape (see link below).
  71938. * @see https://easings.net/#easeInBounce
  71939. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71940. */
  71941. export class BounceEase extends EasingFunction implements IEasingFunction {
  71942. /** Defines the number of bounces */
  71943. bounces: number;
  71944. /** Defines the amplitude of the bounce */
  71945. bounciness: number;
  71946. /**
  71947. * Instantiates a bounce easing
  71948. * @see https://easings.net/#easeInBounce
  71949. * @param bounces Defines the number of bounces
  71950. * @param bounciness Defines the amplitude of the bounce
  71951. */
  71952. constructor(
  71953. /** Defines the number of bounces */
  71954. bounces?: number,
  71955. /** Defines the amplitude of the bounce */
  71956. bounciness?: number);
  71957. /** @hidden */
  71958. easeInCore(gradient: number): number;
  71959. }
  71960. /**
  71961. * Easing function with a power of 3 shape (see link below).
  71962. * @see https://easings.net/#easeInCubic
  71963. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71964. */
  71965. export class CubicEase extends EasingFunction implements IEasingFunction {
  71966. /** @hidden */
  71967. easeInCore(gradient: number): number;
  71968. }
  71969. /**
  71970. * Easing function with an elastic shape (see link below).
  71971. * @see https://easings.net/#easeInElastic
  71972. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71973. */
  71974. export class ElasticEase extends EasingFunction implements IEasingFunction {
  71975. /** Defines the number of oscillations*/
  71976. oscillations: number;
  71977. /** Defines the amplitude of the oscillations*/
  71978. springiness: number;
  71979. /**
  71980. * Instantiates an elastic easing function
  71981. * @see https://easings.net/#easeInElastic
  71982. * @param oscillations Defines the number of oscillations
  71983. * @param springiness Defines the amplitude of the oscillations
  71984. */
  71985. constructor(
  71986. /** Defines the number of oscillations*/
  71987. oscillations?: number,
  71988. /** Defines the amplitude of the oscillations*/
  71989. springiness?: number);
  71990. /** @hidden */
  71991. easeInCore(gradient: number): number;
  71992. }
  71993. /**
  71994. * Easing function with an exponential shape (see link below).
  71995. * @see https://easings.net/#easeInExpo
  71996. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71997. */
  71998. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  71999. /** Defines the exponent of the function */
  72000. exponent: number;
  72001. /**
  72002. * Instantiates an exponential easing function
  72003. * @see https://easings.net/#easeInExpo
  72004. * @param exponent Defines the exponent of the function
  72005. */
  72006. constructor(
  72007. /** Defines the exponent of the function */
  72008. exponent?: number);
  72009. /** @hidden */
  72010. easeInCore(gradient: number): number;
  72011. }
  72012. /**
  72013. * Easing function with a power shape (see link below).
  72014. * @see https://easings.net/#easeInQuad
  72015. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72016. */
  72017. export class PowerEase extends EasingFunction implements IEasingFunction {
  72018. /** Defines the power of the function */
  72019. power: number;
  72020. /**
  72021. * Instantiates an power base easing function
  72022. * @see https://easings.net/#easeInQuad
  72023. * @param power Defines the power of the function
  72024. */
  72025. constructor(
  72026. /** Defines the power of the function */
  72027. power?: number);
  72028. /** @hidden */
  72029. easeInCore(gradient: number): number;
  72030. }
  72031. /**
  72032. * Easing function with a power of 2 shape (see link below).
  72033. * @see https://easings.net/#easeInQuad
  72034. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72035. */
  72036. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  72037. /** @hidden */
  72038. easeInCore(gradient: number): number;
  72039. }
  72040. /**
  72041. * Easing function with a power of 4 shape (see link below).
  72042. * @see https://easings.net/#easeInQuart
  72043. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72044. */
  72045. export class QuarticEase extends EasingFunction implements IEasingFunction {
  72046. /** @hidden */
  72047. easeInCore(gradient: number): number;
  72048. }
  72049. /**
  72050. * Easing function with a power of 5 shape (see link below).
  72051. * @see https://easings.net/#easeInQuint
  72052. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72053. */
  72054. export class QuinticEase extends EasingFunction implements IEasingFunction {
  72055. /** @hidden */
  72056. easeInCore(gradient: number): number;
  72057. }
  72058. /**
  72059. * Easing function with a sin shape (see link below).
  72060. * @see https://easings.net/#easeInSine
  72061. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72062. */
  72063. export class SineEase extends EasingFunction implements IEasingFunction {
  72064. /** @hidden */
  72065. easeInCore(gradient: number): number;
  72066. }
  72067. /**
  72068. * Easing function with a bezier shape (see link below).
  72069. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  72070. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72071. */
  72072. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  72073. /** Defines the x component of the start tangent in the bezier curve */
  72074. x1: number;
  72075. /** Defines the y component of the start tangent in the bezier curve */
  72076. y1: number;
  72077. /** Defines the x component of the end tangent in the bezier curve */
  72078. x2: number;
  72079. /** Defines the y component of the end tangent in the bezier curve */
  72080. y2: number;
  72081. /**
  72082. * Instantiates a bezier function
  72083. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  72084. * @param x1 Defines the x component of the start tangent in the bezier curve
  72085. * @param y1 Defines the y component of the start tangent in the bezier curve
  72086. * @param x2 Defines the x component of the end tangent in the bezier curve
  72087. * @param y2 Defines the y component of the end tangent in the bezier curve
  72088. */
  72089. constructor(
  72090. /** Defines the x component of the start tangent in the bezier curve */
  72091. x1?: number,
  72092. /** Defines the y component of the start tangent in the bezier curve */
  72093. y1?: number,
  72094. /** Defines the x component of the end tangent in the bezier curve */
  72095. x2?: number,
  72096. /** Defines the y component of the end tangent in the bezier curve */
  72097. y2?: number);
  72098. /** @hidden */
  72099. easeInCore(gradient: number): number;
  72100. }
  72101. }
  72102. declare module BABYLON {
  72103. /**
  72104. * Defines an interface which represents an animation key frame
  72105. */
  72106. export interface IAnimationKey {
  72107. /**
  72108. * Frame of the key frame
  72109. */
  72110. frame: number;
  72111. /**
  72112. * Value at the specifies key frame
  72113. */
  72114. value: any;
  72115. /**
  72116. * The input tangent for the cubic hermite spline
  72117. */
  72118. inTangent?: any;
  72119. /**
  72120. * The output tangent for the cubic hermite spline
  72121. */
  72122. outTangent?: any;
  72123. /**
  72124. * The animation interpolation type
  72125. */
  72126. interpolation?: AnimationKeyInterpolation;
  72127. }
  72128. /**
  72129. * Enum for the animation key frame interpolation type
  72130. */
  72131. export enum AnimationKeyInterpolation {
  72132. /**
  72133. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  72134. */
  72135. STEP = 1
  72136. }
  72137. }
  72138. declare module BABYLON {
  72139. /**
  72140. * Represents the range of an animation
  72141. */
  72142. export class AnimationRange {
  72143. /**The name of the animation range**/
  72144. name: string;
  72145. /**The starting frame of the animation */
  72146. from: number;
  72147. /**The ending frame of the animation*/
  72148. to: number;
  72149. /**
  72150. * Initializes the range of an animation
  72151. * @param name The name of the animation range
  72152. * @param from The starting frame of the animation
  72153. * @param to The ending frame of the animation
  72154. */
  72155. constructor(
  72156. /**The name of the animation range**/
  72157. name: string,
  72158. /**The starting frame of the animation */
  72159. from: number,
  72160. /**The ending frame of the animation*/
  72161. to: number);
  72162. /**
  72163. * Makes a copy of the animation range
  72164. * @returns A copy of the animation range
  72165. */
  72166. clone(): AnimationRange;
  72167. }
  72168. }
  72169. declare module BABYLON {
  72170. /**
  72171. * Composed of a frame, and an action function
  72172. */
  72173. export class AnimationEvent {
  72174. /** The frame for which the event is triggered **/
  72175. frame: number;
  72176. /** The event to perform when triggered **/
  72177. action: (currentFrame: number) => void;
  72178. /** Specifies if the event should be triggered only once**/
  72179. onlyOnce?: boolean | undefined;
  72180. /**
  72181. * Specifies if the animation event is done
  72182. */
  72183. isDone: boolean;
  72184. /**
  72185. * Initializes the animation event
  72186. * @param frame The frame for which the event is triggered
  72187. * @param action The event to perform when triggered
  72188. * @param onlyOnce Specifies if the event should be triggered only once
  72189. */
  72190. constructor(
  72191. /** The frame for which the event is triggered **/
  72192. frame: number,
  72193. /** The event to perform when triggered **/
  72194. action: (currentFrame: number) => void,
  72195. /** Specifies if the event should be triggered only once**/
  72196. onlyOnce?: boolean | undefined);
  72197. /** @hidden */
  72198. _clone(): AnimationEvent;
  72199. }
  72200. }
  72201. declare module BABYLON {
  72202. /**
  72203. * Interface used to define a behavior
  72204. */
  72205. export interface Behavior<T> {
  72206. /** gets or sets behavior's name */
  72207. name: string;
  72208. /**
  72209. * Function called when the behavior needs to be initialized (after attaching it to a target)
  72210. */
  72211. init(): void;
  72212. /**
  72213. * Called when the behavior is attached to a target
  72214. * @param target defines the target where the behavior is attached to
  72215. */
  72216. attach(target: T): void;
  72217. /**
  72218. * Called when the behavior is detached from its target
  72219. */
  72220. detach(): void;
  72221. }
  72222. /**
  72223. * Interface implemented by classes supporting behaviors
  72224. */
  72225. export interface IBehaviorAware<T> {
  72226. /**
  72227. * Attach a behavior
  72228. * @param behavior defines the behavior to attach
  72229. * @returns the current host
  72230. */
  72231. addBehavior(behavior: Behavior<T>): T;
  72232. /**
  72233. * Remove a behavior from the current object
  72234. * @param behavior defines the behavior to detach
  72235. * @returns the current host
  72236. */
  72237. removeBehavior(behavior: Behavior<T>): T;
  72238. /**
  72239. * Gets a behavior using its name to search
  72240. * @param name defines the name to search
  72241. * @returns the behavior or null if not found
  72242. */
  72243. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  72244. }
  72245. }
  72246. declare module BABYLON {
  72247. /**
  72248. * Defines an array and its length.
  72249. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  72250. */
  72251. export interface ISmartArrayLike<T> {
  72252. /**
  72253. * The data of the array.
  72254. */
  72255. data: Array<T>;
  72256. /**
  72257. * The active length of the array.
  72258. */
  72259. length: number;
  72260. }
  72261. /**
  72262. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  72263. */
  72264. export class SmartArray<T> implements ISmartArrayLike<T> {
  72265. /**
  72266. * The full set of data from the array.
  72267. */
  72268. data: Array<T>;
  72269. /**
  72270. * The active length of the array.
  72271. */
  72272. length: number;
  72273. protected _id: number;
  72274. /**
  72275. * Instantiates a Smart Array.
  72276. * @param capacity defines the default capacity of the array.
  72277. */
  72278. constructor(capacity: number);
  72279. /**
  72280. * Pushes a value at the end of the active data.
  72281. * @param value defines the object to push in the array.
  72282. */
  72283. push(value: T): void;
  72284. /**
  72285. * Iterates over the active data and apply the lambda to them.
  72286. * @param func defines the action to apply on each value.
  72287. */
  72288. forEach(func: (content: T) => void): void;
  72289. /**
  72290. * Sorts the full sets of data.
  72291. * @param compareFn defines the comparison function to apply.
  72292. */
  72293. sort(compareFn: (a: T, b: T) => number): void;
  72294. /**
  72295. * Resets the active data to an empty array.
  72296. */
  72297. reset(): void;
  72298. /**
  72299. * Releases all the data from the array as well as the array.
  72300. */
  72301. dispose(): void;
  72302. /**
  72303. * Concats the active data with a given array.
  72304. * @param array defines the data to concatenate with.
  72305. */
  72306. concat(array: any): void;
  72307. /**
  72308. * Returns the position of a value in the active data.
  72309. * @param value defines the value to find the index for
  72310. * @returns the index if found in the active data otherwise -1
  72311. */
  72312. indexOf(value: T): number;
  72313. /**
  72314. * Returns whether an element is part of the active data.
  72315. * @param value defines the value to look for
  72316. * @returns true if found in the active data otherwise false
  72317. */
  72318. contains(value: T): boolean;
  72319. private static _GlobalId;
  72320. }
  72321. /**
  72322. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  72323. * The data in this array can only be present once
  72324. */
  72325. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  72326. private _duplicateId;
  72327. /**
  72328. * Pushes a value at the end of the active data.
  72329. * THIS DOES NOT PREVENT DUPPLICATE DATA
  72330. * @param value defines the object to push in the array.
  72331. */
  72332. push(value: T): void;
  72333. /**
  72334. * Pushes a value at the end of the active data.
  72335. * If the data is already present, it won t be added again
  72336. * @param value defines the object to push in the array.
  72337. * @returns true if added false if it was already present
  72338. */
  72339. pushNoDuplicate(value: T): boolean;
  72340. /**
  72341. * Resets the active data to an empty array.
  72342. */
  72343. reset(): void;
  72344. /**
  72345. * Concats the active data with a given array.
  72346. * This ensures no dupplicate will be present in the result.
  72347. * @param array defines the data to concatenate with.
  72348. */
  72349. concatWithNoDuplicate(array: any): void;
  72350. }
  72351. }
  72352. declare module BABYLON {
  72353. /**
  72354. * @ignore
  72355. * This is a list of all the different input types that are available in the application.
  72356. * Fo instance: ArcRotateCameraGamepadInput...
  72357. */
  72358. export var CameraInputTypes: {};
  72359. /**
  72360. * This is the contract to implement in order to create a new input class.
  72361. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  72362. */
  72363. export interface ICameraInput<TCamera extends Camera> {
  72364. /**
  72365. * Defines the camera the input is attached to.
  72366. */
  72367. camera: Nullable<TCamera>;
  72368. /**
  72369. * Gets the class name of the current intput.
  72370. * @returns the class name
  72371. */
  72372. getClassName(): string;
  72373. /**
  72374. * Get the friendly name associated with the input class.
  72375. * @returns the input friendly name
  72376. */
  72377. getSimpleName(): string;
  72378. /**
  72379. * Attach the input controls to a specific dom element to get the input from.
  72380. * @param element Defines the element the controls should be listened from
  72381. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72382. */
  72383. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72384. /**
  72385. * Detach the current controls from the specified dom element.
  72386. * @param element Defines the element to stop listening the inputs from
  72387. */
  72388. detachControl(element: Nullable<HTMLElement>): void;
  72389. /**
  72390. * Update the current camera state depending on the inputs that have been used this frame.
  72391. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72392. */
  72393. checkInputs?: () => void;
  72394. }
  72395. /**
  72396. * Represents a map of input types to input instance or input index to input instance.
  72397. */
  72398. export interface CameraInputsMap<TCamera extends Camera> {
  72399. /**
  72400. * Accessor to the input by input type.
  72401. */
  72402. [name: string]: ICameraInput<TCamera>;
  72403. /**
  72404. * Accessor to the input by input index.
  72405. */
  72406. [idx: number]: ICameraInput<TCamera>;
  72407. }
  72408. /**
  72409. * This represents the input manager used within a camera.
  72410. * It helps dealing with all the different kind of input attached to a camera.
  72411. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72412. */
  72413. export class CameraInputsManager<TCamera extends Camera> {
  72414. /**
  72415. * Defines the list of inputs attahed to the camera.
  72416. */
  72417. attached: CameraInputsMap<TCamera>;
  72418. /**
  72419. * Defines the dom element the camera is collecting inputs from.
  72420. * This is null if the controls have not been attached.
  72421. */
  72422. attachedElement: Nullable<HTMLElement>;
  72423. /**
  72424. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72425. */
  72426. noPreventDefault: boolean;
  72427. /**
  72428. * Defined the camera the input manager belongs to.
  72429. */
  72430. camera: TCamera;
  72431. /**
  72432. * Update the current camera state depending on the inputs that have been used this frame.
  72433. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72434. */
  72435. checkInputs: () => void;
  72436. /**
  72437. * Instantiate a new Camera Input Manager.
  72438. * @param camera Defines the camera the input manager blongs to
  72439. */
  72440. constructor(camera: TCamera);
  72441. /**
  72442. * Add an input method to a camera
  72443. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72444. * @param input camera input method
  72445. */
  72446. add(input: ICameraInput<TCamera>): void;
  72447. /**
  72448. * Remove a specific input method from a camera
  72449. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  72450. * @param inputToRemove camera input method
  72451. */
  72452. remove(inputToRemove: ICameraInput<TCamera>): void;
  72453. /**
  72454. * Remove a specific input type from a camera
  72455. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  72456. * @param inputType the type of the input to remove
  72457. */
  72458. removeByType(inputType: string): void;
  72459. private _addCheckInputs;
  72460. /**
  72461. * Attach the input controls to the currently attached dom element to listen the events from.
  72462. * @param input Defines the input to attach
  72463. */
  72464. attachInput(input: ICameraInput<TCamera>): void;
  72465. /**
  72466. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  72467. * @param element Defines the dom element to collect the events from
  72468. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72469. */
  72470. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  72471. /**
  72472. * Detach the current manager inputs controls from a specific dom element.
  72473. * @param element Defines the dom element to collect the events from
  72474. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  72475. */
  72476. detachElement(element: HTMLElement, disconnect?: boolean): void;
  72477. /**
  72478. * Rebuild the dynamic inputCheck function from the current list of
  72479. * defined inputs in the manager.
  72480. */
  72481. rebuildInputCheck(): void;
  72482. /**
  72483. * Remove all attached input methods from a camera
  72484. */
  72485. clear(): void;
  72486. /**
  72487. * Serialize the current input manager attached to a camera.
  72488. * This ensures than once parsed,
  72489. * the input associated to the camera will be identical to the current ones
  72490. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  72491. */
  72492. serialize(serializedCamera: any): void;
  72493. /**
  72494. * Parses an input manager serialized JSON to restore the previous list of inputs
  72495. * and states associated to a camera.
  72496. * @param parsedCamera Defines the JSON to parse
  72497. */
  72498. parse(parsedCamera: any): void;
  72499. }
  72500. }
  72501. declare module BABYLON {
  72502. /**
  72503. * @hidden
  72504. */
  72505. export class IntersectionInfo {
  72506. bu: Nullable<number>;
  72507. bv: Nullable<number>;
  72508. distance: number;
  72509. faceId: number;
  72510. subMeshId: number;
  72511. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  72512. }
  72513. }
  72514. declare module BABYLON {
  72515. /**
  72516. * Represens a plane by the equation ax + by + cz + d = 0
  72517. */
  72518. export class Plane {
  72519. private static _TmpMatrix;
  72520. /**
  72521. * Normal of the plane (a,b,c)
  72522. */
  72523. normal: Vector3;
  72524. /**
  72525. * d component of the plane
  72526. */
  72527. d: number;
  72528. /**
  72529. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  72530. * @param a a component of the plane
  72531. * @param b b component of the plane
  72532. * @param c c component of the plane
  72533. * @param d d component of the plane
  72534. */
  72535. constructor(a: number, b: number, c: number, d: number);
  72536. /**
  72537. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  72538. */
  72539. asArray(): number[];
  72540. /**
  72541. * @returns a new plane copied from the current Plane.
  72542. */
  72543. clone(): Plane;
  72544. /**
  72545. * @returns the string "Plane".
  72546. */
  72547. getClassName(): string;
  72548. /**
  72549. * @returns the Plane hash code.
  72550. */
  72551. getHashCode(): number;
  72552. /**
  72553. * Normalize the current Plane in place.
  72554. * @returns the updated Plane.
  72555. */
  72556. normalize(): Plane;
  72557. /**
  72558. * Applies a transformation the plane and returns the result
  72559. * @param transformation the transformation matrix to be applied to the plane
  72560. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  72561. */
  72562. transform(transformation: DeepImmutable<Matrix>): Plane;
  72563. /**
  72564. * Calcualtte the dot product between the point and the plane normal
  72565. * @param point point to calculate the dot product with
  72566. * @returns the dot product (float) of the point coordinates and the plane normal.
  72567. */
  72568. dotCoordinate(point: DeepImmutable<Vector3>): number;
  72569. /**
  72570. * Updates the current Plane from the plane defined by the three given points.
  72571. * @param point1 one of the points used to contruct the plane
  72572. * @param point2 one of the points used to contruct the plane
  72573. * @param point3 one of the points used to contruct the plane
  72574. * @returns the updated Plane.
  72575. */
  72576. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  72577. /**
  72578. * Checks if the plane is facing a given direction
  72579. * @param direction the direction to check if the plane is facing
  72580. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  72581. * @returns True is the vector "direction" is the same side than the plane normal.
  72582. */
  72583. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  72584. /**
  72585. * Calculates the distance to a point
  72586. * @param point point to calculate distance to
  72587. * @returns the signed distance (float) from the given point to the Plane.
  72588. */
  72589. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  72590. /**
  72591. * Creates a plane from an array
  72592. * @param array the array to create a plane from
  72593. * @returns a new Plane from the given array.
  72594. */
  72595. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  72596. /**
  72597. * Creates a plane from three points
  72598. * @param point1 point used to create the plane
  72599. * @param point2 point used to create the plane
  72600. * @param point3 point used to create the plane
  72601. * @returns a new Plane defined by the three given points.
  72602. */
  72603. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  72604. /**
  72605. * Creates a plane from an origin point and a normal
  72606. * @param origin origin of the plane to be constructed
  72607. * @param normal normal of the plane to be constructed
  72608. * @returns a new Plane the normal vector to this plane at the given origin point.
  72609. * Note : the vector "normal" is updated because normalized.
  72610. */
  72611. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  72612. /**
  72613. * Calculates the distance from a plane and a point
  72614. * @param origin origin of the plane to be constructed
  72615. * @param normal normal of the plane to be constructed
  72616. * @param point point to calculate distance to
  72617. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  72618. */
  72619. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  72620. }
  72621. }
  72622. declare module BABYLON {
  72623. /**
  72624. * Class used to store bounding sphere information
  72625. */
  72626. export class BoundingSphere {
  72627. /**
  72628. * Gets the center of the bounding sphere in local space
  72629. */
  72630. readonly center: Vector3;
  72631. /**
  72632. * Radius of the bounding sphere in local space
  72633. */
  72634. radius: number;
  72635. /**
  72636. * Gets the center of the bounding sphere in world space
  72637. */
  72638. readonly centerWorld: Vector3;
  72639. /**
  72640. * Radius of the bounding sphere in world space
  72641. */
  72642. radiusWorld: number;
  72643. /**
  72644. * Gets the minimum vector in local space
  72645. */
  72646. readonly minimum: Vector3;
  72647. /**
  72648. * Gets the maximum vector in local space
  72649. */
  72650. readonly maximum: Vector3;
  72651. private _worldMatrix;
  72652. private static readonly TmpVector3;
  72653. /**
  72654. * Creates a new bounding sphere
  72655. * @param min defines the minimum vector (in local space)
  72656. * @param max defines the maximum vector (in local space)
  72657. * @param worldMatrix defines the new world matrix
  72658. */
  72659. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  72660. /**
  72661. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  72662. * @param min defines the new minimum vector (in local space)
  72663. * @param max defines the new maximum vector (in local space)
  72664. * @param worldMatrix defines the new world matrix
  72665. */
  72666. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  72667. /**
  72668. * Scale the current bounding sphere by applying a scale factor
  72669. * @param factor defines the scale factor to apply
  72670. * @returns the current bounding box
  72671. */
  72672. scale(factor: number): BoundingSphere;
  72673. /**
  72674. * Gets the world matrix of the bounding box
  72675. * @returns a matrix
  72676. */
  72677. getWorldMatrix(): DeepImmutable<Matrix>;
  72678. /** @hidden */
  72679. _update(worldMatrix: DeepImmutable<Matrix>): void;
  72680. /**
  72681. * Tests if the bounding sphere is intersecting the frustum planes
  72682. * @param frustumPlanes defines the frustum planes to test
  72683. * @returns true if there is an intersection
  72684. */
  72685. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72686. /**
  72687. * Tests if the bounding sphere center is in between the frustum planes.
  72688. * Used for optimistic fast inclusion.
  72689. * @param frustumPlanes defines the frustum planes to test
  72690. * @returns true if the sphere center is in between the frustum planes
  72691. */
  72692. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72693. /**
  72694. * Tests if a point is inside the bounding sphere
  72695. * @param point defines the point to test
  72696. * @returns true if the point is inside the bounding sphere
  72697. */
  72698. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  72699. /**
  72700. * Checks if two sphere intersct
  72701. * @param sphere0 sphere 0
  72702. * @param sphere1 sphere 1
  72703. * @returns true if the speres intersect
  72704. */
  72705. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  72706. }
  72707. }
  72708. declare module BABYLON {
  72709. /**
  72710. * Class used to store bounding box information
  72711. */
  72712. export class BoundingBox implements ICullable {
  72713. /**
  72714. * Gets the 8 vectors representing the bounding box in local space
  72715. */
  72716. readonly vectors: Vector3[];
  72717. /**
  72718. * Gets the center of the bounding box in local space
  72719. */
  72720. readonly center: Vector3;
  72721. /**
  72722. * Gets the center of the bounding box in world space
  72723. */
  72724. readonly centerWorld: Vector3;
  72725. /**
  72726. * Gets the extend size in local space
  72727. */
  72728. readonly extendSize: Vector3;
  72729. /**
  72730. * Gets the extend size in world space
  72731. */
  72732. readonly extendSizeWorld: Vector3;
  72733. /**
  72734. * Gets the OBB (object bounding box) directions
  72735. */
  72736. readonly directions: Vector3[];
  72737. /**
  72738. * Gets the 8 vectors representing the bounding box in world space
  72739. */
  72740. readonly vectorsWorld: Vector3[];
  72741. /**
  72742. * Gets the minimum vector in world space
  72743. */
  72744. readonly minimumWorld: Vector3;
  72745. /**
  72746. * Gets the maximum vector in world space
  72747. */
  72748. readonly maximumWorld: Vector3;
  72749. /**
  72750. * Gets the minimum vector in local space
  72751. */
  72752. readonly minimum: Vector3;
  72753. /**
  72754. * Gets the maximum vector in local space
  72755. */
  72756. readonly maximum: Vector3;
  72757. private _worldMatrix;
  72758. private static readonly TmpVector3;
  72759. /**
  72760. * @hidden
  72761. */
  72762. _tag: number;
  72763. /**
  72764. * Creates a new bounding box
  72765. * @param min defines the minimum vector (in local space)
  72766. * @param max defines the maximum vector (in local space)
  72767. * @param worldMatrix defines the new world matrix
  72768. */
  72769. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  72770. /**
  72771. * Recreates the entire bounding box from scratch as if we call the constructor in place
  72772. * @param min defines the new minimum vector (in local space)
  72773. * @param max defines the new maximum vector (in local space)
  72774. * @param worldMatrix defines the new world matrix
  72775. */
  72776. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  72777. /**
  72778. * Scale the current bounding box by applying a scale factor
  72779. * @param factor defines the scale factor to apply
  72780. * @returns the current bounding box
  72781. */
  72782. scale(factor: number): BoundingBox;
  72783. /**
  72784. * Gets the world matrix of the bounding box
  72785. * @returns a matrix
  72786. */
  72787. getWorldMatrix(): DeepImmutable<Matrix>;
  72788. /** @hidden */
  72789. _update(world: DeepImmutable<Matrix>): void;
  72790. /**
  72791. * Tests if the bounding box is intersecting the frustum planes
  72792. * @param frustumPlanes defines the frustum planes to test
  72793. * @returns true if there is an intersection
  72794. */
  72795. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72796. /**
  72797. * Tests if the bounding box is entirely inside the frustum planes
  72798. * @param frustumPlanes defines the frustum planes to test
  72799. * @returns true if there is an inclusion
  72800. */
  72801. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72802. /**
  72803. * Tests if a point is inside the bounding box
  72804. * @param point defines the point to test
  72805. * @returns true if the point is inside the bounding box
  72806. */
  72807. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  72808. /**
  72809. * Tests if the bounding box intersects with a bounding sphere
  72810. * @param sphere defines the sphere to test
  72811. * @returns true if there is an intersection
  72812. */
  72813. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  72814. /**
  72815. * Tests if the bounding box intersects with a box defined by a min and max vectors
  72816. * @param min defines the min vector to use
  72817. * @param max defines the max vector to use
  72818. * @returns true if there is an intersection
  72819. */
  72820. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  72821. /**
  72822. * Tests if two bounding boxes are intersections
  72823. * @param box0 defines the first box to test
  72824. * @param box1 defines the second box to test
  72825. * @returns true if there is an intersection
  72826. */
  72827. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  72828. /**
  72829. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  72830. * @param minPoint defines the minimum vector of the bounding box
  72831. * @param maxPoint defines the maximum vector of the bounding box
  72832. * @param sphereCenter defines the sphere center
  72833. * @param sphereRadius defines the sphere radius
  72834. * @returns true if there is an intersection
  72835. */
  72836. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  72837. /**
  72838. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  72839. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  72840. * @param frustumPlanes defines the frustum planes to test
  72841. * @return true if there is an inclusion
  72842. */
  72843. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72844. /**
  72845. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  72846. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  72847. * @param frustumPlanes defines the frustum planes to test
  72848. * @return true if there is an intersection
  72849. */
  72850. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72851. }
  72852. }
  72853. declare module BABYLON {
  72854. /** @hidden */
  72855. export class Collider {
  72856. /** Define if a collision was found */
  72857. collisionFound: boolean;
  72858. /**
  72859. * Define last intersection point in local space
  72860. */
  72861. intersectionPoint: Vector3;
  72862. /**
  72863. * Define last collided mesh
  72864. */
  72865. collidedMesh: Nullable<AbstractMesh>;
  72866. private _collisionPoint;
  72867. private _planeIntersectionPoint;
  72868. private _tempVector;
  72869. private _tempVector2;
  72870. private _tempVector3;
  72871. private _tempVector4;
  72872. private _edge;
  72873. private _baseToVertex;
  72874. private _destinationPoint;
  72875. private _slidePlaneNormal;
  72876. private _displacementVector;
  72877. /** @hidden */
  72878. _radius: Vector3;
  72879. /** @hidden */
  72880. _retry: number;
  72881. private _velocity;
  72882. private _basePoint;
  72883. private _epsilon;
  72884. /** @hidden */
  72885. _velocityWorldLength: number;
  72886. /** @hidden */
  72887. _basePointWorld: Vector3;
  72888. private _velocityWorld;
  72889. private _normalizedVelocity;
  72890. /** @hidden */
  72891. _initialVelocity: Vector3;
  72892. /** @hidden */
  72893. _initialPosition: Vector3;
  72894. private _nearestDistance;
  72895. private _collisionMask;
  72896. collisionMask: number;
  72897. /**
  72898. * Gets the plane normal used to compute the sliding response (in local space)
  72899. */
  72900. readonly slidePlaneNormal: Vector3;
  72901. /** @hidden */
  72902. _initialize(source: Vector3, dir: Vector3, e: number): void;
  72903. /** @hidden */
  72904. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  72905. /** @hidden */
  72906. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  72907. /** @hidden */
  72908. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  72909. /** @hidden */
  72910. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  72911. /** @hidden */
  72912. _getResponse(pos: Vector3, vel: Vector3): void;
  72913. }
  72914. }
  72915. declare module BABYLON {
  72916. /**
  72917. * Interface for cullable objects
  72918. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  72919. */
  72920. export interface ICullable {
  72921. /**
  72922. * Checks if the object or part of the object is in the frustum
  72923. * @param frustumPlanes Camera near/planes
  72924. * @returns true if the object is in frustum otherwise false
  72925. */
  72926. isInFrustum(frustumPlanes: Plane[]): boolean;
  72927. /**
  72928. * Checks if a cullable object (mesh...) is in the camera frustum
  72929. * Unlike isInFrustum this cheks the full bounding box
  72930. * @param frustumPlanes Camera near/planes
  72931. * @returns true if the object is in frustum otherwise false
  72932. */
  72933. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  72934. }
  72935. /**
  72936. * Info for a bounding data of a mesh
  72937. */
  72938. export class BoundingInfo implements ICullable {
  72939. /**
  72940. * Bounding box for the mesh
  72941. */
  72942. readonly boundingBox: BoundingBox;
  72943. /**
  72944. * Bounding sphere for the mesh
  72945. */
  72946. readonly boundingSphere: BoundingSphere;
  72947. private _isLocked;
  72948. private static readonly TmpVector3;
  72949. /**
  72950. * Constructs bounding info
  72951. * @param minimum min vector of the bounding box/sphere
  72952. * @param maximum max vector of the bounding box/sphere
  72953. * @param worldMatrix defines the new world matrix
  72954. */
  72955. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  72956. /**
  72957. * Recreates the entire bounding info from scratch as if we call the constructor in place
  72958. * @param min defines the new minimum vector (in local space)
  72959. * @param max defines the new maximum vector (in local space)
  72960. * @param worldMatrix defines the new world matrix
  72961. */
  72962. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  72963. /**
  72964. * min vector of the bounding box/sphere
  72965. */
  72966. readonly minimum: Vector3;
  72967. /**
  72968. * max vector of the bounding box/sphere
  72969. */
  72970. readonly maximum: Vector3;
  72971. /**
  72972. * If the info is locked and won't be updated to avoid perf overhead
  72973. */
  72974. isLocked: boolean;
  72975. /**
  72976. * Updates the bounding sphere and box
  72977. * @param world world matrix to be used to update
  72978. */
  72979. update(world: DeepImmutable<Matrix>): void;
  72980. /**
  72981. * Recreate the bounding info to be centered around a specific point given a specific extend.
  72982. * @param center New center of the bounding info
  72983. * @param extend New extend of the bounding info
  72984. * @returns the current bounding info
  72985. */
  72986. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  72987. /**
  72988. * Scale the current bounding info by applying a scale factor
  72989. * @param factor defines the scale factor to apply
  72990. * @returns the current bounding info
  72991. */
  72992. scale(factor: number): BoundingInfo;
  72993. /**
  72994. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  72995. * @param frustumPlanes defines the frustum to test
  72996. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  72997. * @returns true if the bounding info is in the frustum planes
  72998. */
  72999. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  73000. /**
  73001. * Gets the world distance between the min and max points of the bounding box
  73002. */
  73003. readonly diagonalLength: number;
  73004. /**
  73005. * Checks if a cullable object (mesh...) is in the camera frustum
  73006. * Unlike isInFrustum this cheks the full bounding box
  73007. * @param frustumPlanes Camera near/planes
  73008. * @returns true if the object is in frustum otherwise false
  73009. */
  73010. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73011. /** @hidden */
  73012. _checkCollision(collider: Collider): boolean;
  73013. /**
  73014. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  73015. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  73016. * @param point the point to check intersection with
  73017. * @returns if the point intersects
  73018. */
  73019. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  73020. /**
  73021. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  73022. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  73023. * @param boundingInfo the bounding info to check intersection with
  73024. * @param precise if the intersection should be done using OBB
  73025. * @returns if the bounding info intersects
  73026. */
  73027. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  73028. }
  73029. }
  73030. declare module BABYLON {
  73031. /**
  73032. * Extracts minimum and maximum values from a list of indexed positions
  73033. * @param positions defines the positions to use
  73034. * @param indices defines the indices to the positions
  73035. * @param indexStart defines the start index
  73036. * @param indexCount defines the end index
  73037. * @param bias defines bias value to add to the result
  73038. * @return minimum and maximum values
  73039. */
  73040. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  73041. minimum: Vector3;
  73042. maximum: Vector3;
  73043. };
  73044. /**
  73045. * Extracts minimum and maximum values from a list of positions
  73046. * @param positions defines the positions to use
  73047. * @param start defines the start index in the positions array
  73048. * @param count defines the number of positions to handle
  73049. * @param bias defines bias value to add to the result
  73050. * @param stride defines the stride size to use (distance between two positions in the positions array)
  73051. * @return minimum and maximum values
  73052. */
  73053. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  73054. minimum: Vector3;
  73055. maximum: Vector3;
  73056. };
  73057. }
  73058. declare module BABYLON {
  73059. /**
  73060. * Enum that determines the text-wrapping mode to use.
  73061. */
  73062. export enum InspectableType {
  73063. /**
  73064. * Checkbox for booleans
  73065. */
  73066. Checkbox = 0,
  73067. /**
  73068. * Sliders for numbers
  73069. */
  73070. Slider = 1,
  73071. /**
  73072. * Vector3
  73073. */
  73074. Vector3 = 2,
  73075. /**
  73076. * Quaternions
  73077. */
  73078. Quaternion = 3,
  73079. /**
  73080. * Color3
  73081. */
  73082. Color3 = 4,
  73083. /**
  73084. * String
  73085. */
  73086. String = 5
  73087. }
  73088. /**
  73089. * Interface used to define custom inspectable properties.
  73090. * This interface is used by the inspector to display custom property grids
  73091. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  73092. */
  73093. export interface IInspectable {
  73094. /**
  73095. * Gets the label to display
  73096. */
  73097. label: string;
  73098. /**
  73099. * Gets the name of the property to edit
  73100. */
  73101. propertyName: string;
  73102. /**
  73103. * Gets the type of the editor to use
  73104. */
  73105. type: InspectableType;
  73106. /**
  73107. * Gets the minimum value of the property when using in "slider" mode
  73108. */
  73109. min?: number;
  73110. /**
  73111. * Gets the maximum value of the property when using in "slider" mode
  73112. */
  73113. max?: number;
  73114. /**
  73115. * Gets the setp to use when using in "slider" mode
  73116. */
  73117. step?: number;
  73118. }
  73119. }
  73120. declare module BABYLON {
  73121. /**
  73122. * Class used to provide helper for timing
  73123. */
  73124. export class TimingTools {
  73125. /**
  73126. * Polyfill for setImmediate
  73127. * @param action defines the action to execute after the current execution block
  73128. */
  73129. static SetImmediate(action: () => void): void;
  73130. }
  73131. }
  73132. declare module BABYLON {
  73133. /**
  73134. * Class used to enable instatition of objects by class name
  73135. */
  73136. export class InstantiationTools {
  73137. /**
  73138. * Use this object to register external classes like custom textures or material
  73139. * to allow the laoders to instantiate them
  73140. */
  73141. static RegisteredExternalClasses: {
  73142. [key: string]: Object;
  73143. };
  73144. /**
  73145. * Tries to instantiate a new object from a given class name
  73146. * @param className defines the class name to instantiate
  73147. * @returns the new object or null if the system was not able to do the instantiation
  73148. */
  73149. static Instantiate(className: string): any;
  73150. }
  73151. }
  73152. declare module BABYLON {
  73153. /**
  73154. * This represents the required contract to create a new type of texture loader.
  73155. */
  73156. export interface IInternalTextureLoader {
  73157. /**
  73158. * Defines wether the loader supports cascade loading the different faces.
  73159. */
  73160. supportCascades: boolean;
  73161. /**
  73162. * This returns if the loader support the current file information.
  73163. * @param extension defines the file extension of the file being loaded
  73164. * @param textureFormatInUse defines the current compressed format in use iun the engine
  73165. * @param fallback defines the fallback internal texture if any
  73166. * @param isBase64 defines whether the texture is encoded as a base64
  73167. * @param isBuffer defines whether the texture data are stored as a buffer
  73168. * @returns true if the loader can load the specified file
  73169. */
  73170. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  73171. /**
  73172. * Transform the url before loading if required.
  73173. * @param rootUrl the url of the texture
  73174. * @param textureFormatInUse defines the current compressed format in use iun the engine
  73175. * @returns the transformed texture
  73176. */
  73177. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  73178. /**
  73179. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  73180. * @param rootUrl the url of the texture
  73181. * @param textureFormatInUse defines the current compressed format in use iun the engine
  73182. * @returns the fallback texture
  73183. */
  73184. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  73185. /**
  73186. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  73187. * @param data contains the texture data
  73188. * @param texture defines the BabylonJS internal texture
  73189. * @param createPolynomials will be true if polynomials have been requested
  73190. * @param onLoad defines the callback to trigger once the texture is ready
  73191. * @param onError defines the callback to trigger in case of error
  73192. */
  73193. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  73194. /**
  73195. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  73196. * @param data contains the texture data
  73197. * @param texture defines the BabylonJS internal texture
  73198. * @param callback defines the method to call once ready to upload
  73199. */
  73200. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  73201. }
  73202. }
  73203. declare module BABYLON {
  73204. interface Engine {
  73205. /**
  73206. * Creates a depth stencil cube texture.
  73207. * This is only available in WebGL 2.
  73208. * @param size The size of face edge in the cube texture.
  73209. * @param options The options defining the cube texture.
  73210. * @returns The cube texture
  73211. */
  73212. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  73213. /**
  73214. * Creates a cube texture
  73215. * @param rootUrl defines the url where the files to load is located
  73216. * @param scene defines the current scene
  73217. * @param files defines the list of files to load (1 per face)
  73218. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  73219. * @param onLoad defines an optional callback raised when the texture is loaded
  73220. * @param onError defines an optional callback raised if there is an issue to load the texture
  73221. * @param format defines the format of the data
  73222. * @param forcedExtension defines the extension to use to pick the right loader
  73223. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  73224. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  73225. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  73226. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  73227. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  73228. * @returns the cube texture as an InternalTexture
  73229. */
  73230. 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;
  73231. /**
  73232. * Creates a cube texture
  73233. * @param rootUrl defines the url where the files to load is located
  73234. * @param scene defines the current scene
  73235. * @param files defines the list of files to load (1 per face)
  73236. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  73237. * @param onLoad defines an optional callback raised when the texture is loaded
  73238. * @param onError defines an optional callback raised if there is an issue to load the texture
  73239. * @param format defines the format of the data
  73240. * @param forcedExtension defines the extension to use to pick the right loader
  73241. * @returns the cube texture as an InternalTexture
  73242. */
  73243. 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;
  73244. /**
  73245. * Creates a cube texture
  73246. * @param rootUrl defines the url where the files to load is located
  73247. * @param scene defines the current scene
  73248. * @param files defines the list of files to load (1 per face)
  73249. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  73250. * @param onLoad defines an optional callback raised when the texture is loaded
  73251. * @param onError defines an optional callback raised if there is an issue to load the texture
  73252. * @param format defines the format of the data
  73253. * @param forcedExtension defines the extension to use to pick the right loader
  73254. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  73255. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  73256. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  73257. * @returns the cube texture as an InternalTexture
  73258. */
  73259. 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;
  73260. /** @hidden */
  73261. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  73262. /** @hidden */
  73263. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  73264. /** @hidden */
  73265. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  73266. /** @hidden */
  73267. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  73268. }
  73269. }
  73270. declare module BABYLON {
  73271. /**
  73272. * Class for creating a cube texture
  73273. */
  73274. export class CubeTexture extends BaseTexture {
  73275. private _delayedOnLoad;
  73276. /**
  73277. * The url of the texture
  73278. */
  73279. url: string;
  73280. /**
  73281. * Gets or sets the center of the bounding box associated with the cube texture.
  73282. * It must define where the camera used to render the texture was set
  73283. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  73284. */
  73285. boundingBoxPosition: Vector3;
  73286. private _boundingBoxSize;
  73287. /**
  73288. * Gets or sets the size of the bounding box associated with the cube texture
  73289. * When defined, the cubemap will switch to local mode
  73290. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  73291. * @example https://www.babylonjs-playground.com/#RNASML
  73292. */
  73293. /**
  73294. * Returns the bounding box size
  73295. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  73296. */
  73297. boundingBoxSize: Vector3;
  73298. protected _rotationY: number;
  73299. /**
  73300. * Sets texture matrix rotation angle around Y axis in radians.
  73301. */
  73302. /**
  73303. * Gets texture matrix rotation angle around Y axis radians.
  73304. */
  73305. rotationY: number;
  73306. /**
  73307. * Are mip maps generated for this texture or not.
  73308. */
  73309. readonly noMipmap: boolean;
  73310. private _noMipmap;
  73311. private _files;
  73312. private _extensions;
  73313. private _textureMatrix;
  73314. private _format;
  73315. private _createPolynomials;
  73316. /** @hidden */
  73317. _prefiltered: boolean;
  73318. /**
  73319. * Creates a cube texture from an array of image urls
  73320. * @param files defines an array of image urls
  73321. * @param scene defines the hosting scene
  73322. * @param noMipmap specifies if mip maps are not used
  73323. * @returns a cube texture
  73324. */
  73325. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  73326. /**
  73327. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  73328. * @param url defines the url of the prefiltered texture
  73329. * @param scene defines the scene the texture is attached to
  73330. * @param forcedExtension defines the extension of the file if different from the url
  73331. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  73332. * @return the prefiltered texture
  73333. */
  73334. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  73335. /**
  73336. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  73337. * as prefiltered data.
  73338. * @param rootUrl defines the url of the texture or the root name of the six images
  73339. * @param scene defines the scene the texture is attached to
  73340. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  73341. * @param noMipmap defines if mipmaps should be created or not
  73342. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  73343. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  73344. * @param onError defines a callback triggered in case of error during load
  73345. * @param format defines the internal format to use for the texture once loaded
  73346. * @param prefiltered defines whether or not the texture is created from prefiltered data
  73347. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  73348. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  73349. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  73350. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  73351. * @return the cube texture
  73352. */
  73353. 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);
  73354. /**
  73355. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  73356. */
  73357. readonly isPrefiltered: boolean;
  73358. /**
  73359. * Get the current class name of the texture useful for serialization or dynamic coding.
  73360. * @returns "CubeTexture"
  73361. */
  73362. getClassName(): string;
  73363. /**
  73364. * Update the url (and optional buffer) of this texture if url was null during construction.
  73365. * @param url the url of the texture
  73366. * @param forcedExtension defines the extension to use
  73367. * @param onLoad callback called when the texture is loaded (defaults to null)
  73368. */
  73369. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  73370. /**
  73371. * Delays loading of the cube texture
  73372. * @param forcedExtension defines the extension to use
  73373. */
  73374. delayLoad(forcedExtension?: string): void;
  73375. /**
  73376. * Returns the reflection texture matrix
  73377. * @returns the reflection texture matrix
  73378. */
  73379. getReflectionTextureMatrix(): Matrix;
  73380. /**
  73381. * Sets the reflection texture matrix
  73382. * @param value Reflection texture matrix
  73383. */
  73384. setReflectionTextureMatrix(value: Matrix): void;
  73385. /**
  73386. * Parses text to create a cube texture
  73387. * @param parsedTexture define the serialized text to read from
  73388. * @param scene defines the hosting scene
  73389. * @param rootUrl defines the root url of the cube texture
  73390. * @returns a cube texture
  73391. */
  73392. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  73393. /**
  73394. * Makes a clone, or deep copy, of the cube texture
  73395. * @returns a new cube texture
  73396. */
  73397. clone(): CubeTexture;
  73398. }
  73399. }
  73400. declare module BABYLON {
  73401. /**
  73402. * Manages the defines for the Material
  73403. */
  73404. export class MaterialDefines {
  73405. /** @hidden */
  73406. protected _keys: string[];
  73407. private _isDirty;
  73408. /** @hidden */
  73409. _renderId: number;
  73410. /** @hidden */
  73411. _areLightsDirty: boolean;
  73412. /** @hidden */
  73413. _areLightsDisposed: boolean;
  73414. /** @hidden */
  73415. _areAttributesDirty: boolean;
  73416. /** @hidden */
  73417. _areTexturesDirty: boolean;
  73418. /** @hidden */
  73419. _areFresnelDirty: boolean;
  73420. /** @hidden */
  73421. _areMiscDirty: boolean;
  73422. /** @hidden */
  73423. _areImageProcessingDirty: boolean;
  73424. /** @hidden */
  73425. _normals: boolean;
  73426. /** @hidden */
  73427. _uvs: boolean;
  73428. /** @hidden */
  73429. _needNormals: boolean;
  73430. /** @hidden */
  73431. _needUVs: boolean;
  73432. [id: string]: any;
  73433. /**
  73434. * Specifies if the material needs to be re-calculated
  73435. */
  73436. readonly isDirty: boolean;
  73437. /**
  73438. * Marks the material to indicate that it has been re-calculated
  73439. */
  73440. markAsProcessed(): void;
  73441. /**
  73442. * Marks the material to indicate that it needs to be re-calculated
  73443. */
  73444. markAsUnprocessed(): void;
  73445. /**
  73446. * Marks the material to indicate all of its defines need to be re-calculated
  73447. */
  73448. markAllAsDirty(): void;
  73449. /**
  73450. * Marks the material to indicate that image processing needs to be re-calculated
  73451. */
  73452. markAsImageProcessingDirty(): void;
  73453. /**
  73454. * Marks the material to indicate the lights need to be re-calculated
  73455. * @param disposed Defines whether the light is dirty due to dispose or not
  73456. */
  73457. markAsLightDirty(disposed?: boolean): void;
  73458. /**
  73459. * Marks the attribute state as changed
  73460. */
  73461. markAsAttributesDirty(): void;
  73462. /**
  73463. * Marks the texture state as changed
  73464. */
  73465. markAsTexturesDirty(): void;
  73466. /**
  73467. * Marks the fresnel state as changed
  73468. */
  73469. markAsFresnelDirty(): void;
  73470. /**
  73471. * Marks the misc state as changed
  73472. */
  73473. markAsMiscDirty(): void;
  73474. /**
  73475. * Rebuilds the material defines
  73476. */
  73477. rebuild(): void;
  73478. /**
  73479. * Specifies if two material defines are equal
  73480. * @param other - A material define instance to compare to
  73481. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  73482. */
  73483. isEqual(other: MaterialDefines): boolean;
  73484. /**
  73485. * Clones this instance's defines to another instance
  73486. * @param other - material defines to clone values to
  73487. */
  73488. cloneTo(other: MaterialDefines): void;
  73489. /**
  73490. * Resets the material define values
  73491. */
  73492. reset(): void;
  73493. /**
  73494. * Converts the material define values to a string
  73495. * @returns - String of material define information
  73496. */
  73497. toString(): string;
  73498. }
  73499. }
  73500. declare module BABYLON {
  73501. /**
  73502. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  73503. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  73504. * 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;
  73505. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  73506. */
  73507. export class ColorCurves {
  73508. private _dirty;
  73509. private _tempColor;
  73510. private _globalCurve;
  73511. private _highlightsCurve;
  73512. private _midtonesCurve;
  73513. private _shadowsCurve;
  73514. private _positiveCurve;
  73515. private _negativeCurve;
  73516. private _globalHue;
  73517. private _globalDensity;
  73518. private _globalSaturation;
  73519. private _globalExposure;
  73520. /**
  73521. * Gets the global Hue value.
  73522. * 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).
  73523. */
  73524. /**
  73525. * Sets the global Hue value.
  73526. * 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).
  73527. */
  73528. globalHue: number;
  73529. /**
  73530. * Gets the global Density value.
  73531. * 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.
  73532. * Values less than zero provide a filter of opposite hue.
  73533. */
  73534. /**
  73535. * Sets the global Density value.
  73536. * 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.
  73537. * Values less than zero provide a filter of opposite hue.
  73538. */
  73539. globalDensity: number;
  73540. /**
  73541. * Gets the global Saturation value.
  73542. * 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.
  73543. */
  73544. /**
  73545. * Sets the global Saturation value.
  73546. * 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.
  73547. */
  73548. globalSaturation: number;
  73549. /**
  73550. * Gets the global Exposure value.
  73551. * 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.
  73552. */
  73553. /**
  73554. * Sets the global Exposure value.
  73555. * 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.
  73556. */
  73557. globalExposure: number;
  73558. private _highlightsHue;
  73559. private _highlightsDensity;
  73560. private _highlightsSaturation;
  73561. private _highlightsExposure;
  73562. /**
  73563. * Gets the highlights Hue value.
  73564. * 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).
  73565. */
  73566. /**
  73567. * Sets the highlights Hue value.
  73568. * 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).
  73569. */
  73570. highlightsHue: number;
  73571. /**
  73572. * Gets the highlights Density value.
  73573. * 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.
  73574. * Values less than zero provide a filter of opposite hue.
  73575. */
  73576. /**
  73577. * Sets the highlights Density value.
  73578. * 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.
  73579. * Values less than zero provide a filter of opposite hue.
  73580. */
  73581. highlightsDensity: number;
  73582. /**
  73583. * Gets the highlights Saturation value.
  73584. * 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.
  73585. */
  73586. /**
  73587. * Sets the highlights Saturation value.
  73588. * 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.
  73589. */
  73590. highlightsSaturation: number;
  73591. /**
  73592. * Gets the highlights Exposure value.
  73593. * 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.
  73594. */
  73595. /**
  73596. * Sets the highlights Exposure value.
  73597. * 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.
  73598. */
  73599. highlightsExposure: number;
  73600. private _midtonesHue;
  73601. private _midtonesDensity;
  73602. private _midtonesSaturation;
  73603. private _midtonesExposure;
  73604. /**
  73605. * Gets the midtones Hue value.
  73606. * 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).
  73607. */
  73608. /**
  73609. * Sets the midtones Hue value.
  73610. * 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).
  73611. */
  73612. midtonesHue: number;
  73613. /**
  73614. * Gets the midtones Density value.
  73615. * 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.
  73616. * Values less than zero provide a filter of opposite hue.
  73617. */
  73618. /**
  73619. * Sets the midtones Density value.
  73620. * 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.
  73621. * Values less than zero provide a filter of opposite hue.
  73622. */
  73623. midtonesDensity: number;
  73624. /**
  73625. * Gets the midtones Saturation value.
  73626. * 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.
  73627. */
  73628. /**
  73629. * Sets the midtones Saturation value.
  73630. * 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.
  73631. */
  73632. midtonesSaturation: number;
  73633. /**
  73634. * Gets the midtones Exposure value.
  73635. * 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.
  73636. */
  73637. /**
  73638. * Sets the midtones Exposure value.
  73639. * 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.
  73640. */
  73641. midtonesExposure: number;
  73642. private _shadowsHue;
  73643. private _shadowsDensity;
  73644. private _shadowsSaturation;
  73645. private _shadowsExposure;
  73646. /**
  73647. * Gets the shadows Hue value.
  73648. * 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).
  73649. */
  73650. /**
  73651. * Sets the shadows Hue value.
  73652. * 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).
  73653. */
  73654. shadowsHue: number;
  73655. /**
  73656. * Gets the shadows Density value.
  73657. * 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.
  73658. * Values less than zero provide a filter of opposite hue.
  73659. */
  73660. /**
  73661. * Sets the shadows Density value.
  73662. * 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.
  73663. * Values less than zero provide a filter of opposite hue.
  73664. */
  73665. shadowsDensity: number;
  73666. /**
  73667. * Gets the shadows Saturation value.
  73668. * 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.
  73669. */
  73670. /**
  73671. * Sets the shadows Saturation value.
  73672. * 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.
  73673. */
  73674. shadowsSaturation: number;
  73675. /**
  73676. * Gets the shadows Exposure value.
  73677. * 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.
  73678. */
  73679. /**
  73680. * Sets the shadows Exposure value.
  73681. * 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.
  73682. */
  73683. shadowsExposure: number;
  73684. /**
  73685. * Returns the class name
  73686. * @returns The class name
  73687. */
  73688. getClassName(): string;
  73689. /**
  73690. * Binds the color curves to the shader.
  73691. * @param colorCurves The color curve to bind
  73692. * @param effect The effect to bind to
  73693. * @param positiveUniform The positive uniform shader parameter
  73694. * @param neutralUniform The neutral uniform shader parameter
  73695. * @param negativeUniform The negative uniform shader parameter
  73696. */
  73697. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  73698. /**
  73699. * Prepare the list of uniforms associated with the ColorCurves effects.
  73700. * @param uniformsList The list of uniforms used in the effect
  73701. */
  73702. static PrepareUniforms(uniformsList: string[]): void;
  73703. /**
  73704. * Returns color grading data based on a hue, density, saturation and exposure value.
  73705. * @param filterHue The hue of the color filter.
  73706. * @param filterDensity The density of the color filter.
  73707. * @param saturation The saturation.
  73708. * @param exposure The exposure.
  73709. * @param result The result data container.
  73710. */
  73711. private getColorGradingDataToRef;
  73712. /**
  73713. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  73714. * @param value The input slider value in range [-100,100].
  73715. * @returns Adjusted value.
  73716. */
  73717. private static applyColorGradingSliderNonlinear;
  73718. /**
  73719. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  73720. * @param hue The hue (H) input.
  73721. * @param saturation The saturation (S) input.
  73722. * @param brightness The brightness (B) input.
  73723. * @result An RGBA color represented as Vector4.
  73724. */
  73725. private static fromHSBToRef;
  73726. /**
  73727. * Returns a value clamped between min and max
  73728. * @param value The value to clamp
  73729. * @param min The minimum of value
  73730. * @param max The maximum of value
  73731. * @returns The clamped value.
  73732. */
  73733. private static clamp;
  73734. /**
  73735. * Clones the current color curve instance.
  73736. * @return The cloned curves
  73737. */
  73738. clone(): ColorCurves;
  73739. /**
  73740. * Serializes the current color curve instance to a json representation.
  73741. * @return a JSON representation
  73742. */
  73743. serialize(): any;
  73744. /**
  73745. * Parses the color curve from a json representation.
  73746. * @param source the JSON source to parse
  73747. * @return The parsed curves
  73748. */
  73749. static Parse(source: any): ColorCurves;
  73750. }
  73751. }
  73752. declare module BABYLON {
  73753. /**
  73754. * Interface to follow in your material defines to integrate easily the
  73755. * Image proccessing functions.
  73756. * @hidden
  73757. */
  73758. export interface IImageProcessingConfigurationDefines {
  73759. IMAGEPROCESSING: boolean;
  73760. VIGNETTE: boolean;
  73761. VIGNETTEBLENDMODEMULTIPLY: boolean;
  73762. VIGNETTEBLENDMODEOPAQUE: boolean;
  73763. TONEMAPPING: boolean;
  73764. TONEMAPPING_ACES: boolean;
  73765. CONTRAST: boolean;
  73766. EXPOSURE: boolean;
  73767. COLORCURVES: boolean;
  73768. COLORGRADING: boolean;
  73769. COLORGRADING3D: boolean;
  73770. SAMPLER3DGREENDEPTH: boolean;
  73771. SAMPLER3DBGRMAP: boolean;
  73772. IMAGEPROCESSINGPOSTPROCESS: boolean;
  73773. }
  73774. /**
  73775. * @hidden
  73776. */
  73777. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  73778. IMAGEPROCESSING: boolean;
  73779. VIGNETTE: boolean;
  73780. VIGNETTEBLENDMODEMULTIPLY: boolean;
  73781. VIGNETTEBLENDMODEOPAQUE: boolean;
  73782. TONEMAPPING: boolean;
  73783. TONEMAPPING_ACES: boolean;
  73784. CONTRAST: boolean;
  73785. COLORCURVES: boolean;
  73786. COLORGRADING: boolean;
  73787. COLORGRADING3D: boolean;
  73788. SAMPLER3DGREENDEPTH: boolean;
  73789. SAMPLER3DBGRMAP: boolean;
  73790. IMAGEPROCESSINGPOSTPROCESS: boolean;
  73791. EXPOSURE: boolean;
  73792. constructor();
  73793. }
  73794. /**
  73795. * This groups together the common properties used for image processing either in direct forward pass
  73796. * or through post processing effect depending on the use of the image processing pipeline in your scene
  73797. * or not.
  73798. */
  73799. export class ImageProcessingConfiguration {
  73800. /**
  73801. * Default tone mapping applied in BabylonJS.
  73802. */
  73803. static readonly TONEMAPPING_STANDARD: number;
  73804. /**
  73805. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  73806. * to other engines rendering to increase portability.
  73807. */
  73808. static readonly TONEMAPPING_ACES: number;
  73809. /**
  73810. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  73811. */
  73812. colorCurves: Nullable<ColorCurves>;
  73813. private _colorCurvesEnabled;
  73814. /**
  73815. * Gets wether the color curves effect is enabled.
  73816. */
  73817. /**
  73818. * Sets wether the color curves effect is enabled.
  73819. */
  73820. colorCurvesEnabled: boolean;
  73821. private _colorGradingTexture;
  73822. /**
  73823. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  73824. */
  73825. /**
  73826. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  73827. */
  73828. colorGradingTexture: Nullable<BaseTexture>;
  73829. private _colorGradingEnabled;
  73830. /**
  73831. * Gets wether the color grading effect is enabled.
  73832. */
  73833. /**
  73834. * Sets wether the color grading effect is enabled.
  73835. */
  73836. colorGradingEnabled: boolean;
  73837. private _colorGradingWithGreenDepth;
  73838. /**
  73839. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  73840. */
  73841. /**
  73842. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  73843. */
  73844. colorGradingWithGreenDepth: boolean;
  73845. private _colorGradingBGR;
  73846. /**
  73847. * Gets wether the color grading texture contains BGR values.
  73848. */
  73849. /**
  73850. * Sets wether the color grading texture contains BGR values.
  73851. */
  73852. colorGradingBGR: boolean;
  73853. /** @hidden */
  73854. _exposure: number;
  73855. /**
  73856. * Gets the Exposure used in the effect.
  73857. */
  73858. /**
  73859. * Sets the Exposure used in the effect.
  73860. */
  73861. exposure: number;
  73862. private _toneMappingEnabled;
  73863. /**
  73864. * Gets wether the tone mapping effect is enabled.
  73865. */
  73866. /**
  73867. * Sets wether the tone mapping effect is enabled.
  73868. */
  73869. toneMappingEnabled: boolean;
  73870. private _toneMappingType;
  73871. /**
  73872. * Gets the type of tone mapping effect.
  73873. */
  73874. /**
  73875. * Sets the type of tone mapping effect used in BabylonJS.
  73876. */
  73877. toneMappingType: number;
  73878. protected _contrast: number;
  73879. /**
  73880. * Gets the contrast used in the effect.
  73881. */
  73882. /**
  73883. * Sets the contrast used in the effect.
  73884. */
  73885. contrast: number;
  73886. /**
  73887. * Vignette stretch size.
  73888. */
  73889. vignetteStretch: number;
  73890. /**
  73891. * Vignette centre X Offset.
  73892. */
  73893. vignetteCentreX: number;
  73894. /**
  73895. * Vignette centre Y Offset.
  73896. */
  73897. vignetteCentreY: number;
  73898. /**
  73899. * Vignette weight or intensity of the vignette effect.
  73900. */
  73901. vignetteWeight: number;
  73902. /**
  73903. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  73904. * if vignetteEnabled is set to true.
  73905. */
  73906. vignetteColor: Color4;
  73907. /**
  73908. * Camera field of view used by the Vignette effect.
  73909. */
  73910. vignetteCameraFov: number;
  73911. private _vignetteBlendMode;
  73912. /**
  73913. * Gets the vignette blend mode allowing different kind of effect.
  73914. */
  73915. /**
  73916. * Sets the vignette blend mode allowing different kind of effect.
  73917. */
  73918. vignetteBlendMode: number;
  73919. private _vignetteEnabled;
  73920. /**
  73921. * Gets wether the vignette effect is enabled.
  73922. */
  73923. /**
  73924. * Sets wether the vignette effect is enabled.
  73925. */
  73926. vignetteEnabled: boolean;
  73927. private _applyByPostProcess;
  73928. /**
  73929. * Gets wether the image processing is applied through a post process or not.
  73930. */
  73931. /**
  73932. * Sets wether the image processing is applied through a post process or not.
  73933. */
  73934. applyByPostProcess: boolean;
  73935. private _isEnabled;
  73936. /**
  73937. * Gets wether the image processing is enabled or not.
  73938. */
  73939. /**
  73940. * Sets wether the image processing is enabled or not.
  73941. */
  73942. isEnabled: boolean;
  73943. /**
  73944. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  73945. */
  73946. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  73947. /**
  73948. * Method called each time the image processing information changes requires to recompile the effect.
  73949. */
  73950. protected _updateParameters(): void;
  73951. /**
  73952. * Gets the current class name.
  73953. * @return "ImageProcessingConfiguration"
  73954. */
  73955. getClassName(): string;
  73956. /**
  73957. * Prepare the list of uniforms associated with the Image Processing effects.
  73958. * @param uniforms The list of uniforms used in the effect
  73959. * @param defines the list of defines currently in use
  73960. */
  73961. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  73962. /**
  73963. * Prepare the list of samplers associated with the Image Processing effects.
  73964. * @param samplersList The list of uniforms used in the effect
  73965. * @param defines the list of defines currently in use
  73966. */
  73967. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  73968. /**
  73969. * Prepare the list of defines associated to the shader.
  73970. * @param defines the list of defines to complete
  73971. * @param forPostProcess Define if we are currently in post process mode or not
  73972. */
  73973. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  73974. /**
  73975. * Returns true if all the image processing information are ready.
  73976. * @returns True if ready, otherwise, false
  73977. */
  73978. isReady(): boolean;
  73979. /**
  73980. * Binds the image processing to the shader.
  73981. * @param effect The effect to bind to
  73982. * @param aspectRatio Define the current aspect ratio of the effect
  73983. */
  73984. bind(effect: Effect, aspectRatio?: number): void;
  73985. /**
  73986. * Clones the current image processing instance.
  73987. * @return The cloned image processing
  73988. */
  73989. clone(): ImageProcessingConfiguration;
  73990. /**
  73991. * Serializes the current image processing instance to a json representation.
  73992. * @return a JSON representation
  73993. */
  73994. serialize(): any;
  73995. /**
  73996. * Parses the image processing from a json representation.
  73997. * @param source the JSON source to parse
  73998. * @return The parsed image processing
  73999. */
  74000. static Parse(source: any): ImageProcessingConfiguration;
  74001. private static _VIGNETTEMODE_MULTIPLY;
  74002. private static _VIGNETTEMODE_OPAQUE;
  74003. /**
  74004. * Used to apply the vignette as a mix with the pixel color.
  74005. */
  74006. static readonly VIGNETTEMODE_MULTIPLY: number;
  74007. /**
  74008. * Used to apply the vignette as a replacement of the pixel color.
  74009. */
  74010. static readonly VIGNETTEMODE_OPAQUE: number;
  74011. }
  74012. }
  74013. declare module BABYLON {
  74014. /** @hidden */
  74015. export var postprocessVertexShader: {
  74016. name: string;
  74017. shader: string;
  74018. };
  74019. }
  74020. declare module BABYLON {
  74021. /** Defines supported spaces */
  74022. export enum Space {
  74023. /** Local (object) space */
  74024. LOCAL = 0,
  74025. /** World space */
  74026. WORLD = 1,
  74027. /** Bone space */
  74028. BONE = 2
  74029. }
  74030. /** Defines the 3 main axes */
  74031. export class Axis {
  74032. /** X axis */
  74033. static X: Vector3;
  74034. /** Y axis */
  74035. static Y: Vector3;
  74036. /** Z axis */
  74037. static Z: Vector3;
  74038. }
  74039. }
  74040. declare module BABYLON {
  74041. /**
  74042. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  74043. * This is the base of the follow, arc rotate cameras and Free camera
  74044. * @see http://doc.babylonjs.com/features/cameras
  74045. */
  74046. export class TargetCamera extends Camera {
  74047. private static _RigCamTransformMatrix;
  74048. private static _TargetTransformMatrix;
  74049. private static _TargetFocalPoint;
  74050. /**
  74051. * Define the current direction the camera is moving to
  74052. */
  74053. cameraDirection: Vector3;
  74054. /**
  74055. * Define the current rotation the camera is rotating to
  74056. */
  74057. cameraRotation: Vector2;
  74058. /**
  74059. * When set, the up vector of the camera will be updated by the rotation of the camera
  74060. */
  74061. updateUpVectorFromRotation: boolean;
  74062. private _tmpQuaternion;
  74063. /**
  74064. * Define the current rotation of the camera
  74065. */
  74066. rotation: Vector3;
  74067. /**
  74068. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  74069. */
  74070. rotationQuaternion: Quaternion;
  74071. /**
  74072. * Define the current speed of the camera
  74073. */
  74074. speed: number;
  74075. /**
  74076. * Add cconstraint to the camera to prevent it to move freely in all directions and
  74077. * around all axis.
  74078. */
  74079. noRotationConstraint: boolean;
  74080. /**
  74081. * Define the current target of the camera as an object or a position.
  74082. */
  74083. lockedTarget: any;
  74084. /** @hidden */
  74085. _currentTarget: Vector3;
  74086. /** @hidden */
  74087. _initialFocalDistance: number;
  74088. /** @hidden */
  74089. _viewMatrix: Matrix;
  74090. /** @hidden */
  74091. _camMatrix: Matrix;
  74092. /** @hidden */
  74093. _cameraTransformMatrix: Matrix;
  74094. /** @hidden */
  74095. _cameraRotationMatrix: Matrix;
  74096. /** @hidden */
  74097. _referencePoint: Vector3;
  74098. /** @hidden */
  74099. _transformedReferencePoint: Vector3;
  74100. protected _globalCurrentTarget: Vector3;
  74101. protected _globalCurrentUpVector: Vector3;
  74102. /** @hidden */
  74103. _reset: () => void;
  74104. private _defaultUp;
  74105. /**
  74106. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  74107. * This is the base of the follow, arc rotate cameras and Free camera
  74108. * @see http://doc.babylonjs.com/features/cameras
  74109. * @param name Defines the name of the camera in the scene
  74110. * @param position Defines the start position of the camera in the scene
  74111. * @param scene Defines the scene the camera belongs to
  74112. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  74113. */
  74114. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  74115. /**
  74116. * Gets the position in front of the camera at a given distance.
  74117. * @param distance The distance from the camera we want the position to be
  74118. * @returns the position
  74119. */
  74120. getFrontPosition(distance: number): Vector3;
  74121. /** @hidden */
  74122. _getLockedTargetPosition(): Nullable<Vector3>;
  74123. private _storedPosition;
  74124. private _storedRotation;
  74125. private _storedRotationQuaternion;
  74126. /**
  74127. * Store current camera state of the camera (fov, position, rotation, etc..)
  74128. * @returns the camera
  74129. */
  74130. storeState(): Camera;
  74131. /**
  74132. * Restored camera state. You must call storeState() first
  74133. * @returns whether it was successful or not
  74134. * @hidden
  74135. */
  74136. _restoreStateValues(): boolean;
  74137. /** @hidden */
  74138. _initCache(): void;
  74139. /** @hidden */
  74140. _updateCache(ignoreParentClass?: boolean): void;
  74141. /** @hidden */
  74142. _isSynchronizedViewMatrix(): boolean;
  74143. /** @hidden */
  74144. _computeLocalCameraSpeed(): number;
  74145. /**
  74146. * Defines the target the camera should look at.
  74147. * @param target Defines the new target as a Vector or a mesh
  74148. */
  74149. setTarget(target: Vector3): void;
  74150. /**
  74151. * Return the current target position of the camera. This value is expressed in local space.
  74152. * @returns the target position
  74153. */
  74154. getTarget(): Vector3;
  74155. /** @hidden */
  74156. _decideIfNeedsToMove(): boolean;
  74157. /** @hidden */
  74158. _updatePosition(): void;
  74159. /** @hidden */
  74160. _checkInputs(): void;
  74161. protected _updateCameraRotationMatrix(): void;
  74162. /**
  74163. * 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)
  74164. * @returns the current camera
  74165. */
  74166. private _rotateUpVectorWithCameraRotationMatrix;
  74167. private _cachedRotationZ;
  74168. private _cachedQuaternionRotationZ;
  74169. /** @hidden */
  74170. _getViewMatrix(): Matrix;
  74171. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  74172. /**
  74173. * @hidden
  74174. */
  74175. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  74176. /**
  74177. * @hidden
  74178. */
  74179. _updateRigCameras(): void;
  74180. private _getRigCamPositionAndTarget;
  74181. /**
  74182. * Gets the current object class name.
  74183. * @return the class name
  74184. */
  74185. getClassName(): string;
  74186. }
  74187. }
  74188. declare module BABYLON {
  74189. /**
  74190. * Gather the list of keyboard event types as constants.
  74191. */
  74192. export class KeyboardEventTypes {
  74193. /**
  74194. * The keydown event is fired when a key becomes active (pressed).
  74195. */
  74196. static readonly KEYDOWN: number;
  74197. /**
  74198. * The keyup event is fired when a key has been released.
  74199. */
  74200. static readonly KEYUP: number;
  74201. }
  74202. /**
  74203. * This class is used to store keyboard related info for the onKeyboardObservable event.
  74204. */
  74205. export class KeyboardInfo {
  74206. /**
  74207. * Defines the type of event (KeyboardEventTypes)
  74208. */
  74209. type: number;
  74210. /**
  74211. * Defines the related dom event
  74212. */
  74213. event: KeyboardEvent;
  74214. /**
  74215. * Instantiates a new keyboard info.
  74216. * This class is used to store keyboard related info for the onKeyboardObservable event.
  74217. * @param type Defines the type of event (KeyboardEventTypes)
  74218. * @param event Defines the related dom event
  74219. */
  74220. constructor(
  74221. /**
  74222. * Defines the type of event (KeyboardEventTypes)
  74223. */
  74224. type: number,
  74225. /**
  74226. * Defines the related dom event
  74227. */
  74228. event: KeyboardEvent);
  74229. }
  74230. /**
  74231. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  74232. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  74233. */
  74234. export class KeyboardInfoPre extends KeyboardInfo {
  74235. /**
  74236. * Defines the type of event (KeyboardEventTypes)
  74237. */
  74238. type: number;
  74239. /**
  74240. * Defines the related dom event
  74241. */
  74242. event: KeyboardEvent;
  74243. /**
  74244. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  74245. */
  74246. skipOnPointerObservable: boolean;
  74247. /**
  74248. * Instantiates a new keyboard pre info.
  74249. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  74250. * @param type Defines the type of event (KeyboardEventTypes)
  74251. * @param event Defines the related dom event
  74252. */
  74253. constructor(
  74254. /**
  74255. * Defines the type of event (KeyboardEventTypes)
  74256. */
  74257. type: number,
  74258. /**
  74259. * Defines the related dom event
  74260. */
  74261. event: KeyboardEvent);
  74262. }
  74263. }
  74264. declare module BABYLON {
  74265. /**
  74266. * Manage the keyboard inputs to control the movement of a free camera.
  74267. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  74268. */
  74269. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  74270. /**
  74271. * Defines the camera the input is attached to.
  74272. */
  74273. camera: FreeCamera;
  74274. /**
  74275. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  74276. */
  74277. keysUp: number[];
  74278. /**
  74279. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  74280. */
  74281. keysDown: number[];
  74282. /**
  74283. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  74284. */
  74285. keysLeft: number[];
  74286. /**
  74287. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  74288. */
  74289. keysRight: number[];
  74290. private _keys;
  74291. private _onCanvasBlurObserver;
  74292. private _onKeyboardObserver;
  74293. private _engine;
  74294. private _scene;
  74295. /**
  74296. * Attach the input controls to a specific dom element to get the input from.
  74297. * @param element Defines the element the controls should be listened from
  74298. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  74299. */
  74300. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  74301. /**
  74302. * Detach the current controls from the specified dom element.
  74303. * @param element Defines the element to stop listening the inputs from
  74304. */
  74305. detachControl(element: Nullable<HTMLElement>): void;
  74306. /**
  74307. * Update the current camera state depending on the inputs that have been used this frame.
  74308. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  74309. */
  74310. checkInputs(): void;
  74311. /**
  74312. * Gets the class name of the current intput.
  74313. * @returns the class name
  74314. */
  74315. getClassName(): string;
  74316. /** @hidden */
  74317. _onLostFocus(): void;
  74318. /**
  74319. * Get the friendly name associated with the input class.
  74320. * @returns the input friendly name
  74321. */
  74322. getSimpleName(): string;
  74323. }
  74324. }
  74325. declare module BABYLON {
  74326. /**
  74327. * Interface describing all the common properties and methods a shadow light needs to implement.
  74328. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  74329. * as well as binding the different shadow properties to the effects.
  74330. */
  74331. export interface IShadowLight extends Light {
  74332. /**
  74333. * The light id in the scene (used in scene.findLighById for instance)
  74334. */
  74335. id: string;
  74336. /**
  74337. * The position the shdow will be casted from.
  74338. */
  74339. position: Vector3;
  74340. /**
  74341. * In 2d mode (needCube being false), the direction used to cast the shadow.
  74342. */
  74343. direction: Vector3;
  74344. /**
  74345. * The transformed position. Position of the light in world space taking parenting in account.
  74346. */
  74347. transformedPosition: Vector3;
  74348. /**
  74349. * The transformed direction. Direction of the light in world space taking parenting in account.
  74350. */
  74351. transformedDirection: Vector3;
  74352. /**
  74353. * The friendly name of the light in the scene.
  74354. */
  74355. name: string;
  74356. /**
  74357. * Defines the shadow projection clipping minimum z value.
  74358. */
  74359. shadowMinZ: number;
  74360. /**
  74361. * Defines the shadow projection clipping maximum z value.
  74362. */
  74363. shadowMaxZ: number;
  74364. /**
  74365. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  74366. * @returns true if the information has been computed, false if it does not need to (no parenting)
  74367. */
  74368. computeTransformedInformation(): boolean;
  74369. /**
  74370. * Gets the scene the light belongs to.
  74371. * @returns The scene
  74372. */
  74373. getScene(): Scene;
  74374. /**
  74375. * Callback defining a custom Projection Matrix Builder.
  74376. * This can be used to override the default projection matrix computation.
  74377. */
  74378. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  74379. /**
  74380. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  74381. * @param matrix The materix to updated with the projection information
  74382. * @param viewMatrix The transform matrix of the light
  74383. * @param renderList The list of mesh to render in the map
  74384. * @returns The current light
  74385. */
  74386. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  74387. /**
  74388. * Gets the current depth scale used in ESM.
  74389. * @returns The scale
  74390. */
  74391. getDepthScale(): number;
  74392. /**
  74393. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  74394. * @returns true if a cube texture needs to be use
  74395. */
  74396. needCube(): boolean;
  74397. /**
  74398. * Detects if the projection matrix requires to be recomputed this frame.
  74399. * @returns true if it requires to be recomputed otherwise, false.
  74400. */
  74401. needProjectionMatrixCompute(): boolean;
  74402. /**
  74403. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  74404. */
  74405. forceProjectionMatrixCompute(): void;
  74406. /**
  74407. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  74408. * @param faceIndex The index of the face we are computed the direction to generate shadow
  74409. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  74410. */
  74411. getShadowDirection(faceIndex?: number): Vector3;
  74412. /**
  74413. * Gets the minZ used for shadow according to both the scene and the light.
  74414. * @param activeCamera The camera we are returning the min for
  74415. * @returns the depth min z
  74416. */
  74417. getDepthMinZ(activeCamera: Camera): number;
  74418. /**
  74419. * Gets the maxZ used for shadow according to both the scene and the light.
  74420. * @param activeCamera The camera we are returning the max for
  74421. * @returns the depth max z
  74422. */
  74423. getDepthMaxZ(activeCamera: Camera): number;
  74424. }
  74425. /**
  74426. * Base implementation IShadowLight
  74427. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  74428. */
  74429. export abstract class ShadowLight extends Light implements IShadowLight {
  74430. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  74431. protected _position: Vector3;
  74432. protected _setPosition(value: Vector3): void;
  74433. /**
  74434. * Sets the position the shadow will be casted from. Also use as the light position for both
  74435. * point and spot lights.
  74436. */
  74437. /**
  74438. * Sets the position the shadow will be casted from. Also use as the light position for both
  74439. * point and spot lights.
  74440. */
  74441. position: Vector3;
  74442. protected _direction: Vector3;
  74443. protected _setDirection(value: Vector3): void;
  74444. /**
  74445. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  74446. * Also use as the light direction on spot and directional lights.
  74447. */
  74448. /**
  74449. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  74450. * Also use as the light direction on spot and directional lights.
  74451. */
  74452. direction: Vector3;
  74453. private _shadowMinZ;
  74454. /**
  74455. * Gets the shadow projection clipping minimum z value.
  74456. */
  74457. /**
  74458. * Sets the shadow projection clipping minimum z value.
  74459. */
  74460. shadowMinZ: number;
  74461. private _shadowMaxZ;
  74462. /**
  74463. * Sets the shadow projection clipping maximum z value.
  74464. */
  74465. /**
  74466. * Gets the shadow projection clipping maximum z value.
  74467. */
  74468. shadowMaxZ: number;
  74469. /**
  74470. * Callback defining a custom Projection Matrix Builder.
  74471. * This can be used to override the default projection matrix computation.
  74472. */
  74473. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  74474. /**
  74475. * The transformed position. Position of the light in world space taking parenting in account.
  74476. */
  74477. transformedPosition: Vector3;
  74478. /**
  74479. * The transformed direction. Direction of the light in world space taking parenting in account.
  74480. */
  74481. transformedDirection: Vector3;
  74482. private _needProjectionMatrixCompute;
  74483. /**
  74484. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  74485. * @returns true if the information has been computed, false if it does not need to (no parenting)
  74486. */
  74487. computeTransformedInformation(): boolean;
  74488. /**
  74489. * Return the depth scale used for the shadow map.
  74490. * @returns the depth scale.
  74491. */
  74492. getDepthScale(): number;
  74493. /**
  74494. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  74495. * @param faceIndex The index of the face we are computed the direction to generate shadow
  74496. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  74497. */
  74498. getShadowDirection(faceIndex?: number): Vector3;
  74499. /**
  74500. * Returns the ShadowLight absolute position in the World.
  74501. * @returns the position vector in world space
  74502. */
  74503. getAbsolutePosition(): Vector3;
  74504. /**
  74505. * Sets the ShadowLight direction toward the passed target.
  74506. * @param target The point to target in local space
  74507. * @returns the updated ShadowLight direction
  74508. */
  74509. setDirectionToTarget(target: Vector3): Vector3;
  74510. /**
  74511. * Returns the light rotation in euler definition.
  74512. * @returns the x y z rotation in local space.
  74513. */
  74514. getRotation(): Vector3;
  74515. /**
  74516. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  74517. * @returns true if a cube texture needs to be use
  74518. */
  74519. needCube(): boolean;
  74520. /**
  74521. * Detects if the projection matrix requires to be recomputed this frame.
  74522. * @returns true if it requires to be recomputed otherwise, false.
  74523. */
  74524. needProjectionMatrixCompute(): boolean;
  74525. /**
  74526. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  74527. */
  74528. forceProjectionMatrixCompute(): void;
  74529. /** @hidden */
  74530. _initCache(): void;
  74531. /** @hidden */
  74532. _isSynchronized(): boolean;
  74533. /**
  74534. * Computes the world matrix of the node
  74535. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  74536. * @returns the world matrix
  74537. */
  74538. computeWorldMatrix(force?: boolean): Matrix;
  74539. /**
  74540. * Gets the minZ used for shadow according to both the scene and the light.
  74541. * @param activeCamera The camera we are returning the min for
  74542. * @returns the depth min z
  74543. */
  74544. getDepthMinZ(activeCamera: Camera): number;
  74545. /**
  74546. * Gets the maxZ used for shadow according to both the scene and the light.
  74547. * @param activeCamera The camera we are returning the max for
  74548. * @returns the depth max z
  74549. */
  74550. getDepthMaxZ(activeCamera: Camera): number;
  74551. /**
  74552. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  74553. * @param matrix The materix to updated with the projection information
  74554. * @param viewMatrix The transform matrix of the light
  74555. * @param renderList The list of mesh to render in the map
  74556. * @returns The current light
  74557. */
  74558. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  74559. }
  74560. }
  74561. declare module BABYLON {
  74562. /**
  74563. * "Static Class" containing the most commonly used helper while dealing with material for
  74564. * rendering purpose.
  74565. *
  74566. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  74567. *
  74568. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  74569. */
  74570. export class MaterialHelper {
  74571. /**
  74572. * Bind the current view position to an effect.
  74573. * @param effect The effect to be bound
  74574. * @param scene The scene the eyes position is used from
  74575. */
  74576. static BindEyePosition(effect: Effect, scene: Scene): void;
  74577. /**
  74578. * Helps preparing the defines values about the UVs in used in the effect.
  74579. * UVs are shared as much as we can accross channels in the shaders.
  74580. * @param texture The texture we are preparing the UVs for
  74581. * @param defines The defines to update
  74582. * @param key The channel key "diffuse", "specular"... used in the shader
  74583. */
  74584. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  74585. /**
  74586. * Binds a texture matrix value to its corrsponding uniform
  74587. * @param texture The texture to bind the matrix for
  74588. * @param uniformBuffer The uniform buffer receivin the data
  74589. * @param key The channel key "diffuse", "specular"... used in the shader
  74590. */
  74591. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  74592. /**
  74593. * Gets the current status of the fog (should it be enabled?)
  74594. * @param mesh defines the mesh to evaluate for fog support
  74595. * @param scene defines the hosting scene
  74596. * @returns true if fog must be enabled
  74597. */
  74598. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  74599. /**
  74600. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  74601. * @param mesh defines the current mesh
  74602. * @param scene defines the current scene
  74603. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  74604. * @param pointsCloud defines if point cloud rendering has to be turned on
  74605. * @param fogEnabled defines if fog has to be turned on
  74606. * @param alphaTest defines if alpha testing has to be turned on
  74607. * @param defines defines the current list of defines
  74608. */
  74609. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  74610. /**
  74611. * Helper used to prepare the list of defines associated with frame values for shader compilation
  74612. * @param scene defines the current scene
  74613. * @param engine defines the current engine
  74614. * @param defines specifies the list of active defines
  74615. * @param useInstances defines if instances have to be turned on
  74616. * @param useClipPlane defines if clip plane have to be turned on
  74617. */
  74618. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  74619. /**
  74620. * Prepares the defines for bones
  74621. * @param mesh The mesh containing the geometry data we will draw
  74622. * @param defines The defines to update
  74623. */
  74624. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  74625. /**
  74626. * Prepares the defines for morph targets
  74627. * @param mesh The mesh containing the geometry data we will draw
  74628. * @param defines The defines to update
  74629. */
  74630. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  74631. /**
  74632. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  74633. * @param mesh The mesh containing the geometry data we will draw
  74634. * @param defines The defines to update
  74635. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  74636. * @param useBones Precise whether bones should be used or not (override mesh info)
  74637. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  74638. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  74639. * @returns false if defines are considered not dirty and have not been checked
  74640. */
  74641. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  74642. /**
  74643. * Prepares the defines related to multiview
  74644. * @param scene The scene we are intending to draw
  74645. * @param defines The defines to update
  74646. */
  74647. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  74648. /**
  74649. * Prepares the defines related to the light information passed in parameter
  74650. * @param scene The scene we are intending to draw
  74651. * @param mesh The mesh the effect is compiling for
  74652. * @param light The light the effect is compiling for
  74653. * @param lightIndex The index of the light
  74654. * @param defines The defines to update
  74655. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  74656. * @param state Defines the current state regarding what is needed (normals, etc...)
  74657. */
  74658. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  74659. needNormals: boolean;
  74660. needRebuild: boolean;
  74661. shadowEnabled: boolean;
  74662. specularEnabled: boolean;
  74663. lightmapMode: boolean;
  74664. }): void;
  74665. /**
  74666. * Prepares the defines related to the light information passed in parameter
  74667. * @param scene The scene we are intending to draw
  74668. * @param mesh The mesh the effect is compiling for
  74669. * @param defines The defines to update
  74670. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  74671. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  74672. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  74673. * @returns true if normals will be required for the rest of the effect
  74674. */
  74675. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  74676. /**
  74677. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  74678. * @param lightIndex defines the light index
  74679. * @param uniformsList The uniform list
  74680. * @param samplersList The sampler list
  74681. * @param projectedLightTexture defines if projected texture must be used
  74682. * @param uniformBuffersList defines an optional list of uniform buffers
  74683. */
  74684. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  74685. /**
  74686. * Prepares the uniforms and samplers list to be used in the effect
  74687. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  74688. * @param samplersList The sampler list
  74689. * @param defines The defines helping in the list generation
  74690. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  74691. */
  74692. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  74693. /**
  74694. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  74695. * @param defines The defines to update while falling back
  74696. * @param fallbacks The authorized effect fallbacks
  74697. * @param maxSimultaneousLights The maximum number of lights allowed
  74698. * @param rank the current rank of the Effect
  74699. * @returns The newly affected rank
  74700. */
  74701. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  74702. private static _TmpMorphInfluencers;
  74703. /**
  74704. * Prepares the list of attributes required for morph targets according to the effect defines.
  74705. * @param attribs The current list of supported attribs
  74706. * @param mesh The mesh to prepare the morph targets attributes for
  74707. * @param influencers The number of influencers
  74708. */
  74709. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  74710. /**
  74711. * Prepares the list of attributes required for morph targets according to the effect defines.
  74712. * @param attribs The current list of supported attribs
  74713. * @param mesh The mesh to prepare the morph targets attributes for
  74714. * @param defines The current Defines of the effect
  74715. */
  74716. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  74717. /**
  74718. * Prepares the list of attributes required for bones according to the effect defines.
  74719. * @param attribs The current list of supported attribs
  74720. * @param mesh The mesh to prepare the bones attributes for
  74721. * @param defines The current Defines of the effect
  74722. * @param fallbacks The current efffect fallback strategy
  74723. */
  74724. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  74725. /**
  74726. * Check and prepare the list of attributes required for instances according to the effect defines.
  74727. * @param attribs The current list of supported attribs
  74728. * @param defines The current MaterialDefines of the effect
  74729. */
  74730. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  74731. /**
  74732. * Add the list of attributes required for instances to the attribs array.
  74733. * @param attribs The current list of supported attribs
  74734. */
  74735. static PushAttributesForInstances(attribs: string[]): void;
  74736. /**
  74737. * Binds the light shadow information to the effect for the given mesh.
  74738. * @param light The light containing the generator
  74739. * @param scene The scene the lights belongs to
  74740. * @param mesh The mesh we are binding the information to render
  74741. * @param lightIndex The light index in the effect used to render the mesh
  74742. * @param effect The effect we are binding the data to
  74743. */
  74744. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  74745. /**
  74746. * Binds the light information to the effect.
  74747. * @param light The light containing the generator
  74748. * @param effect The effect we are binding the data to
  74749. * @param lightIndex The light index in the effect used to render
  74750. */
  74751. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  74752. /**
  74753. * Binds the lights information from the scene to the effect for the given mesh.
  74754. * @param light Light to bind
  74755. * @param lightIndex Light index
  74756. * @param scene The scene where the light belongs to
  74757. * @param mesh The mesh we are binding the information to render
  74758. * @param effect The effect we are binding the data to
  74759. * @param useSpecular Defines if specular is supported
  74760. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  74761. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  74762. */
  74763. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  74764. /**
  74765. * Binds the lights information from the scene to the effect for the given mesh.
  74766. * @param scene The scene the lights belongs to
  74767. * @param mesh The mesh we are binding the information to render
  74768. * @param effect The effect we are binding the data to
  74769. * @param defines The generated defines for the effect
  74770. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  74771. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  74772. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  74773. */
  74774. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  74775. private static _tempFogColor;
  74776. /**
  74777. * Binds the fog information from the scene to the effect for the given mesh.
  74778. * @param scene The scene the lights belongs to
  74779. * @param mesh The mesh we are binding the information to render
  74780. * @param effect The effect we are binding the data to
  74781. * @param linearSpace Defines if the fog effect is applied in linear space
  74782. */
  74783. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  74784. /**
  74785. * Binds the bones information from the mesh to the effect.
  74786. * @param mesh The mesh we are binding the information to render
  74787. * @param effect The effect we are binding the data to
  74788. */
  74789. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  74790. /**
  74791. * Binds the morph targets information from the mesh to the effect.
  74792. * @param abstractMesh The mesh we are binding the information to render
  74793. * @param effect The effect we are binding the data to
  74794. */
  74795. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  74796. /**
  74797. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  74798. * @param defines The generated defines used in the effect
  74799. * @param effect The effect we are binding the data to
  74800. * @param scene The scene we are willing to render with logarithmic scale for
  74801. */
  74802. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  74803. /**
  74804. * Binds the clip plane information from the scene to the effect.
  74805. * @param scene The scene the clip plane information are extracted from
  74806. * @param effect The effect we are binding the data to
  74807. */
  74808. static BindClipPlane(effect: Effect, scene: Scene): void;
  74809. }
  74810. }
  74811. declare module BABYLON {
  74812. /** @hidden */
  74813. export var packingFunctions: {
  74814. name: string;
  74815. shader: string;
  74816. };
  74817. }
  74818. declare module BABYLON {
  74819. /** @hidden */
  74820. export var shadowMapPixelShader: {
  74821. name: string;
  74822. shader: string;
  74823. };
  74824. }
  74825. declare module BABYLON {
  74826. /** @hidden */
  74827. export var bonesDeclaration: {
  74828. name: string;
  74829. shader: string;
  74830. };
  74831. }
  74832. declare module BABYLON {
  74833. /** @hidden */
  74834. export var morphTargetsVertexGlobalDeclaration: {
  74835. name: string;
  74836. shader: string;
  74837. };
  74838. }
  74839. declare module BABYLON {
  74840. /** @hidden */
  74841. export var morphTargetsVertexDeclaration: {
  74842. name: string;
  74843. shader: string;
  74844. };
  74845. }
  74846. declare module BABYLON {
  74847. /** @hidden */
  74848. export var instancesDeclaration: {
  74849. name: string;
  74850. shader: string;
  74851. };
  74852. }
  74853. declare module BABYLON {
  74854. /** @hidden */
  74855. export var helperFunctions: {
  74856. name: string;
  74857. shader: string;
  74858. };
  74859. }
  74860. declare module BABYLON {
  74861. /** @hidden */
  74862. export var morphTargetsVertex: {
  74863. name: string;
  74864. shader: string;
  74865. };
  74866. }
  74867. declare module BABYLON {
  74868. /** @hidden */
  74869. export var instancesVertex: {
  74870. name: string;
  74871. shader: string;
  74872. };
  74873. }
  74874. declare module BABYLON {
  74875. /** @hidden */
  74876. export var bonesVertex: {
  74877. name: string;
  74878. shader: string;
  74879. };
  74880. }
  74881. declare module BABYLON {
  74882. /** @hidden */
  74883. export var shadowMapVertexShader: {
  74884. name: string;
  74885. shader: string;
  74886. };
  74887. }
  74888. declare module BABYLON {
  74889. /** @hidden */
  74890. export var depthBoxBlurPixelShader: {
  74891. name: string;
  74892. shader: string;
  74893. };
  74894. }
  74895. declare module BABYLON {
  74896. /**
  74897. * Defines the options associated with the creation of a custom shader for a shadow generator.
  74898. */
  74899. export interface ICustomShaderOptions {
  74900. /**
  74901. * Gets or sets the custom shader name to use
  74902. */
  74903. shaderName: string;
  74904. /**
  74905. * The list of attribute names used in the shader
  74906. */
  74907. attributes?: string[];
  74908. /**
  74909. * The list of unifrom names used in the shader
  74910. */
  74911. uniforms?: string[];
  74912. /**
  74913. * The list of sampler names used in the shader
  74914. */
  74915. samplers?: string[];
  74916. /**
  74917. * The list of defines used in the shader
  74918. */
  74919. defines?: string[];
  74920. }
  74921. /**
  74922. * Interface to implement to create a shadow generator compatible with BJS.
  74923. */
  74924. export interface IShadowGenerator {
  74925. /**
  74926. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  74927. * @returns The render target texture if present otherwise, null
  74928. */
  74929. getShadowMap(): Nullable<RenderTargetTexture>;
  74930. /**
  74931. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  74932. * @returns The render target texture if the shadow map is present otherwise, null
  74933. */
  74934. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  74935. /**
  74936. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  74937. * @param subMesh The submesh we want to render in the shadow map
  74938. * @param useInstances Defines wether will draw in the map using instances
  74939. * @returns true if ready otherwise, false
  74940. */
  74941. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  74942. /**
  74943. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  74944. * @param defines Defines of the material we want to update
  74945. * @param lightIndex Index of the light in the enabled light list of the material
  74946. */
  74947. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  74948. /**
  74949. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  74950. * defined in the generator but impacting the effect).
  74951. * It implies the unifroms available on the materials are the standard BJS ones.
  74952. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  74953. * @param effect The effect we are binfing the information for
  74954. */
  74955. bindShadowLight(lightIndex: string, effect: Effect): void;
  74956. /**
  74957. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  74958. * (eq to shadow prjection matrix * light transform matrix)
  74959. * @returns The transform matrix used to create the shadow map
  74960. */
  74961. getTransformMatrix(): Matrix;
  74962. /**
  74963. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  74964. * Cube and 2D textures for instance.
  74965. */
  74966. recreateShadowMap(): void;
  74967. /**
  74968. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74969. * @param onCompiled Callback triggered at the and of the effects compilation
  74970. * @param options Sets of optional options forcing the compilation with different modes
  74971. */
  74972. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  74973. useInstances: boolean;
  74974. }>): void;
  74975. /**
  74976. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74977. * @param options Sets of optional options forcing the compilation with different modes
  74978. * @returns A promise that resolves when the compilation completes
  74979. */
  74980. forceCompilationAsync(options?: Partial<{
  74981. useInstances: boolean;
  74982. }>): Promise<void>;
  74983. /**
  74984. * Serializes the shadow generator setup to a json object.
  74985. * @returns The serialized JSON object
  74986. */
  74987. serialize(): any;
  74988. /**
  74989. * Disposes the Shadow map and related Textures and effects.
  74990. */
  74991. dispose(): void;
  74992. }
  74993. /**
  74994. * Default implementation IShadowGenerator.
  74995. * This is the main object responsible of generating shadows in the framework.
  74996. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  74997. */
  74998. export class ShadowGenerator implements IShadowGenerator {
  74999. /**
  75000. * Shadow generator mode None: no filtering applied.
  75001. */
  75002. static readonly FILTER_NONE: number;
  75003. /**
  75004. * Shadow generator mode ESM: Exponential Shadow Mapping.
  75005. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  75006. */
  75007. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  75008. /**
  75009. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  75010. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  75011. */
  75012. static readonly FILTER_POISSONSAMPLING: number;
  75013. /**
  75014. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  75015. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  75016. */
  75017. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  75018. /**
  75019. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  75020. * edge artifacts on steep falloff.
  75021. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  75022. */
  75023. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  75024. /**
  75025. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  75026. * edge artifacts on steep falloff.
  75027. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  75028. */
  75029. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  75030. /**
  75031. * Shadow generator mode PCF: Percentage Closer Filtering
  75032. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  75033. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  75034. */
  75035. static readonly FILTER_PCF: number;
  75036. /**
  75037. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  75038. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  75039. * Contact Hardening
  75040. */
  75041. static readonly FILTER_PCSS: number;
  75042. /**
  75043. * Reserved for PCF and PCSS
  75044. * Highest Quality.
  75045. *
  75046. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  75047. *
  75048. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  75049. */
  75050. static readonly QUALITY_HIGH: number;
  75051. /**
  75052. * Reserved for PCF and PCSS
  75053. * Good tradeoff for quality/perf cross devices
  75054. *
  75055. * Execute PCF on a 3*3 kernel.
  75056. *
  75057. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  75058. */
  75059. static readonly QUALITY_MEDIUM: number;
  75060. /**
  75061. * Reserved for PCF and PCSS
  75062. * The lowest quality but the fastest.
  75063. *
  75064. * Execute PCF on a 1*1 kernel.
  75065. *
  75066. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  75067. */
  75068. static readonly QUALITY_LOW: number;
  75069. /** Gets or sets the custom shader name to use */
  75070. customShaderOptions: ICustomShaderOptions;
  75071. /**
  75072. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  75073. */
  75074. onBeforeShadowMapRenderObservable: Observable<Effect>;
  75075. /**
  75076. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  75077. */
  75078. onAfterShadowMapRenderObservable: Observable<Effect>;
  75079. /**
  75080. * Observable triggered before a mesh is rendered in the shadow map.
  75081. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  75082. */
  75083. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  75084. /**
  75085. * Observable triggered after a mesh is rendered in the shadow map.
  75086. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  75087. */
  75088. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  75089. private _bias;
  75090. /**
  75091. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  75092. */
  75093. /**
  75094. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  75095. */
  75096. bias: number;
  75097. private _normalBias;
  75098. /**
  75099. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  75100. */
  75101. /**
  75102. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  75103. */
  75104. normalBias: number;
  75105. private _blurBoxOffset;
  75106. /**
  75107. * Gets the blur box offset: offset applied during the blur pass.
  75108. * Only useful if useKernelBlur = false
  75109. */
  75110. /**
  75111. * Sets the blur box offset: offset applied during the blur pass.
  75112. * Only useful if useKernelBlur = false
  75113. */
  75114. blurBoxOffset: number;
  75115. private _blurScale;
  75116. /**
  75117. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  75118. * 2 means half of the size.
  75119. */
  75120. /**
  75121. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  75122. * 2 means half of the size.
  75123. */
  75124. blurScale: number;
  75125. private _blurKernel;
  75126. /**
  75127. * Gets the blur kernel: kernel size of the blur pass.
  75128. * Only useful if useKernelBlur = true
  75129. */
  75130. /**
  75131. * Sets the blur kernel: kernel size of the blur pass.
  75132. * Only useful if useKernelBlur = true
  75133. */
  75134. blurKernel: number;
  75135. private _useKernelBlur;
  75136. /**
  75137. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  75138. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  75139. */
  75140. /**
  75141. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  75142. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  75143. */
  75144. useKernelBlur: boolean;
  75145. private _depthScale;
  75146. /**
  75147. * Gets the depth scale used in ESM mode.
  75148. */
  75149. /**
  75150. * Sets the depth scale used in ESM mode.
  75151. * This can override the scale stored on the light.
  75152. */
  75153. depthScale: number;
  75154. private _filter;
  75155. /**
  75156. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  75157. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  75158. */
  75159. /**
  75160. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  75161. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  75162. */
  75163. filter: number;
  75164. /**
  75165. * Gets if the current filter is set to Poisson Sampling.
  75166. */
  75167. /**
  75168. * Sets the current filter to Poisson Sampling.
  75169. */
  75170. usePoissonSampling: boolean;
  75171. /**
  75172. * Gets if the current filter is set to ESM.
  75173. */
  75174. /**
  75175. * Sets the current filter is to ESM.
  75176. */
  75177. useExponentialShadowMap: boolean;
  75178. /**
  75179. * Gets if the current filter is set to filtered ESM.
  75180. */
  75181. /**
  75182. * Gets if the current filter is set to filtered ESM.
  75183. */
  75184. useBlurExponentialShadowMap: boolean;
  75185. /**
  75186. * Gets if the current filter is set to "close ESM" (using the inverse of the
  75187. * exponential to prevent steep falloff artifacts).
  75188. */
  75189. /**
  75190. * Sets the current filter to "close ESM" (using the inverse of the
  75191. * exponential to prevent steep falloff artifacts).
  75192. */
  75193. useCloseExponentialShadowMap: boolean;
  75194. /**
  75195. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  75196. * exponential to prevent steep falloff artifacts).
  75197. */
  75198. /**
  75199. * Sets the current filter to filtered "close ESM" (using the inverse of the
  75200. * exponential to prevent steep falloff artifacts).
  75201. */
  75202. useBlurCloseExponentialShadowMap: boolean;
  75203. /**
  75204. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  75205. */
  75206. /**
  75207. * Sets the current filter to "PCF" (percentage closer filtering).
  75208. */
  75209. usePercentageCloserFiltering: boolean;
  75210. private _filteringQuality;
  75211. /**
  75212. * Gets the PCF or PCSS Quality.
  75213. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  75214. */
  75215. /**
  75216. * Sets the PCF or PCSS Quality.
  75217. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  75218. */
  75219. filteringQuality: number;
  75220. /**
  75221. * Gets if the current filter is set to "PCSS" (contact hardening).
  75222. */
  75223. /**
  75224. * Sets the current filter to "PCSS" (contact hardening).
  75225. */
  75226. useContactHardeningShadow: boolean;
  75227. private _contactHardeningLightSizeUVRatio;
  75228. /**
  75229. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  75230. * Using a ratio helps keeping shape stability independently of the map size.
  75231. *
  75232. * It does not account for the light projection as it was having too much
  75233. * instability during the light setup or during light position changes.
  75234. *
  75235. * Only valid if useContactHardeningShadow is true.
  75236. */
  75237. /**
  75238. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  75239. * Using a ratio helps keeping shape stability independently of the map size.
  75240. *
  75241. * It does not account for the light projection as it was having too much
  75242. * instability during the light setup or during light position changes.
  75243. *
  75244. * Only valid if useContactHardeningShadow is true.
  75245. */
  75246. contactHardeningLightSizeUVRatio: number;
  75247. private _darkness;
  75248. /** Gets or sets the actual darkness of a shadow */
  75249. darkness: number;
  75250. /**
  75251. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  75252. * 0 means strongest and 1 would means no shadow.
  75253. * @returns the darkness.
  75254. */
  75255. getDarkness(): number;
  75256. /**
  75257. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  75258. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  75259. * @returns the shadow generator allowing fluent coding.
  75260. */
  75261. setDarkness(darkness: number): ShadowGenerator;
  75262. private _transparencyShadow;
  75263. /** Gets or sets the ability to have transparent shadow */
  75264. transparencyShadow: boolean;
  75265. /**
  75266. * Sets the ability to have transparent shadow (boolean).
  75267. * @param transparent True if transparent else False
  75268. * @returns the shadow generator allowing fluent coding
  75269. */
  75270. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  75271. private _shadowMap;
  75272. private _shadowMap2;
  75273. /**
  75274. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  75275. * @returns The render target texture if present otherwise, null
  75276. */
  75277. getShadowMap(): Nullable<RenderTargetTexture>;
  75278. /**
  75279. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  75280. * @returns The render target texture if the shadow map is present otherwise, null
  75281. */
  75282. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  75283. /**
  75284. * Gets the class name of that object
  75285. * @returns "ShadowGenerator"
  75286. */
  75287. getClassName(): string;
  75288. /**
  75289. * Helper function to add a mesh and its descendants to the list of shadow casters.
  75290. * @param mesh Mesh to add
  75291. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  75292. * @returns the Shadow Generator itself
  75293. */
  75294. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  75295. /**
  75296. * Helper function to remove a mesh and its descendants from the list of shadow casters
  75297. * @param mesh Mesh to remove
  75298. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  75299. * @returns the Shadow Generator itself
  75300. */
  75301. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  75302. /**
  75303. * Controls the extent to which the shadows fade out at the edge of the frustum
  75304. * Used only by directionals and spots
  75305. */
  75306. frustumEdgeFalloff: number;
  75307. private _light;
  75308. /**
  75309. * Returns the associated light object.
  75310. * @returns the light generating the shadow
  75311. */
  75312. getLight(): IShadowLight;
  75313. /**
  75314. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  75315. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  75316. * It might on the other hand introduce peter panning.
  75317. */
  75318. forceBackFacesOnly: boolean;
  75319. private _scene;
  75320. private _lightDirection;
  75321. private _effect;
  75322. private _viewMatrix;
  75323. private _projectionMatrix;
  75324. private _transformMatrix;
  75325. private _cachedPosition;
  75326. private _cachedDirection;
  75327. private _cachedDefines;
  75328. private _currentRenderID;
  75329. private _boxBlurPostprocess;
  75330. private _kernelBlurXPostprocess;
  75331. private _kernelBlurYPostprocess;
  75332. private _blurPostProcesses;
  75333. private _mapSize;
  75334. private _currentFaceIndex;
  75335. private _currentFaceIndexCache;
  75336. private _textureType;
  75337. private _defaultTextureMatrix;
  75338. /** @hidden */
  75339. static _SceneComponentInitialization: (scene: Scene) => void;
  75340. /**
  75341. * Creates a ShadowGenerator object.
  75342. * A ShadowGenerator is the required tool to use the shadows.
  75343. * Each light casting shadows needs to use its own ShadowGenerator.
  75344. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  75345. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  75346. * @param light The light object generating the shadows.
  75347. * @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.
  75348. */
  75349. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  75350. private _initializeGenerator;
  75351. private _initializeShadowMap;
  75352. private _initializeBlurRTTAndPostProcesses;
  75353. private _renderForShadowMap;
  75354. private _renderSubMeshForShadowMap;
  75355. private _applyFilterValues;
  75356. /**
  75357. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  75358. * @param onCompiled Callback triggered at the and of the effects compilation
  75359. * @param options Sets of optional options forcing the compilation with different modes
  75360. */
  75361. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  75362. useInstances: boolean;
  75363. }>): void;
  75364. /**
  75365. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  75366. * @param options Sets of optional options forcing the compilation with different modes
  75367. * @returns A promise that resolves when the compilation completes
  75368. */
  75369. forceCompilationAsync(options?: Partial<{
  75370. useInstances: boolean;
  75371. }>): Promise<void>;
  75372. /**
  75373. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  75374. * @param subMesh The submesh we want to render in the shadow map
  75375. * @param useInstances Defines wether will draw in the map using instances
  75376. * @returns true if ready otherwise, false
  75377. */
  75378. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  75379. /**
  75380. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  75381. * @param defines Defines of the material we want to update
  75382. * @param lightIndex Index of the light in the enabled light list of the material
  75383. */
  75384. prepareDefines(defines: any, lightIndex: number): void;
  75385. /**
  75386. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  75387. * defined in the generator but impacting the effect).
  75388. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  75389. * @param effect The effect we are binfing the information for
  75390. */
  75391. bindShadowLight(lightIndex: string, effect: Effect): void;
  75392. /**
  75393. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  75394. * (eq to shadow prjection matrix * light transform matrix)
  75395. * @returns The transform matrix used to create the shadow map
  75396. */
  75397. getTransformMatrix(): Matrix;
  75398. /**
  75399. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  75400. * Cube and 2D textures for instance.
  75401. */
  75402. recreateShadowMap(): void;
  75403. private _disposeBlurPostProcesses;
  75404. private _disposeRTTandPostProcesses;
  75405. /**
  75406. * Disposes the ShadowGenerator.
  75407. * Returns nothing.
  75408. */
  75409. dispose(): void;
  75410. /**
  75411. * Serializes the shadow generator setup to a json object.
  75412. * @returns The serialized JSON object
  75413. */
  75414. serialize(): any;
  75415. /**
  75416. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  75417. * @param parsedShadowGenerator The JSON object to parse
  75418. * @param scene The scene to create the shadow map for
  75419. * @returns The parsed shadow generator
  75420. */
  75421. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  75422. }
  75423. }
  75424. declare module BABYLON {
  75425. /**
  75426. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  75427. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  75428. * 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.
  75429. */
  75430. export abstract class Light extends Node {
  75431. /**
  75432. * Falloff Default: light is falling off following the material specification:
  75433. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  75434. */
  75435. static readonly FALLOFF_DEFAULT: number;
  75436. /**
  75437. * Falloff Physical: light is falling off following the inverse squared distance law.
  75438. */
  75439. static readonly FALLOFF_PHYSICAL: number;
  75440. /**
  75441. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  75442. * to enhance interoperability with other engines.
  75443. */
  75444. static readonly FALLOFF_GLTF: number;
  75445. /**
  75446. * Falloff Standard: light is falling off like in the standard material
  75447. * to enhance interoperability with other materials.
  75448. */
  75449. static readonly FALLOFF_STANDARD: number;
  75450. /**
  75451. * If every light affecting the material is in this lightmapMode,
  75452. * material.lightmapTexture adds or multiplies
  75453. * (depends on material.useLightmapAsShadowmap)
  75454. * after every other light calculations.
  75455. */
  75456. static readonly LIGHTMAP_DEFAULT: number;
  75457. /**
  75458. * material.lightmapTexture as only diffuse lighting from this light
  75459. * adds only specular lighting from this light
  75460. * adds dynamic shadows
  75461. */
  75462. static readonly LIGHTMAP_SPECULAR: number;
  75463. /**
  75464. * material.lightmapTexture as only lighting
  75465. * no light calculation from this light
  75466. * only adds dynamic shadows from this light
  75467. */
  75468. static readonly LIGHTMAP_SHADOWSONLY: number;
  75469. /**
  75470. * Each light type uses the default quantity according to its type:
  75471. * point/spot lights use luminous intensity
  75472. * directional lights use illuminance
  75473. */
  75474. static readonly INTENSITYMODE_AUTOMATIC: number;
  75475. /**
  75476. * lumen (lm)
  75477. */
  75478. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  75479. /**
  75480. * candela (lm/sr)
  75481. */
  75482. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  75483. /**
  75484. * lux (lm/m^2)
  75485. */
  75486. static readonly INTENSITYMODE_ILLUMINANCE: number;
  75487. /**
  75488. * nit (cd/m^2)
  75489. */
  75490. static readonly INTENSITYMODE_LUMINANCE: number;
  75491. /**
  75492. * Light type const id of the point light.
  75493. */
  75494. static readonly LIGHTTYPEID_POINTLIGHT: number;
  75495. /**
  75496. * Light type const id of the directional light.
  75497. */
  75498. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  75499. /**
  75500. * Light type const id of the spot light.
  75501. */
  75502. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  75503. /**
  75504. * Light type const id of the hemispheric light.
  75505. */
  75506. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  75507. /**
  75508. * Diffuse gives the basic color to an object.
  75509. */
  75510. diffuse: Color3;
  75511. /**
  75512. * Specular produces a highlight color on an object.
  75513. * Note: This is note affecting PBR materials.
  75514. */
  75515. specular: Color3;
  75516. /**
  75517. * Defines the falloff type for this light. This lets overrriding how punctual light are
  75518. * falling off base on range or angle.
  75519. * This can be set to any values in Light.FALLOFF_x.
  75520. *
  75521. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  75522. * other types of materials.
  75523. */
  75524. falloffType: number;
  75525. /**
  75526. * Strength of the light.
  75527. * Note: By default it is define in the framework own unit.
  75528. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  75529. */
  75530. intensity: number;
  75531. private _range;
  75532. protected _inverseSquaredRange: number;
  75533. /**
  75534. * Defines how far from the source the light is impacting in scene units.
  75535. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  75536. */
  75537. /**
  75538. * Defines how far from the source the light is impacting in scene units.
  75539. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  75540. */
  75541. range: number;
  75542. /**
  75543. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  75544. * of light.
  75545. */
  75546. private _photometricScale;
  75547. private _intensityMode;
  75548. /**
  75549. * Gets the photometric scale used to interpret the intensity.
  75550. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  75551. */
  75552. /**
  75553. * Sets the photometric scale used to interpret the intensity.
  75554. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  75555. */
  75556. intensityMode: number;
  75557. private _radius;
  75558. /**
  75559. * Gets the light radius used by PBR Materials to simulate soft area lights.
  75560. */
  75561. /**
  75562. * sets the light radius used by PBR Materials to simulate soft area lights.
  75563. */
  75564. radius: number;
  75565. private _renderPriority;
  75566. /**
  75567. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  75568. * exceeding the number allowed of the materials.
  75569. */
  75570. renderPriority: number;
  75571. private _shadowEnabled;
  75572. /**
  75573. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  75574. * the current shadow generator.
  75575. */
  75576. /**
  75577. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  75578. * the current shadow generator.
  75579. */
  75580. shadowEnabled: boolean;
  75581. private _includedOnlyMeshes;
  75582. /**
  75583. * Gets the only meshes impacted by this light.
  75584. */
  75585. /**
  75586. * Sets the only meshes impacted by this light.
  75587. */
  75588. includedOnlyMeshes: AbstractMesh[];
  75589. private _excludedMeshes;
  75590. /**
  75591. * Gets the meshes not impacted by this light.
  75592. */
  75593. /**
  75594. * Sets the meshes not impacted by this light.
  75595. */
  75596. excludedMeshes: AbstractMesh[];
  75597. private _excludeWithLayerMask;
  75598. /**
  75599. * Gets the layer id use to find what meshes are not impacted by the light.
  75600. * Inactive if 0
  75601. */
  75602. /**
  75603. * Sets the layer id use to find what meshes are not impacted by the light.
  75604. * Inactive if 0
  75605. */
  75606. excludeWithLayerMask: number;
  75607. private _includeOnlyWithLayerMask;
  75608. /**
  75609. * Gets the layer id use to find what meshes are impacted by the light.
  75610. * Inactive if 0
  75611. */
  75612. /**
  75613. * Sets the layer id use to find what meshes are impacted by the light.
  75614. * Inactive if 0
  75615. */
  75616. includeOnlyWithLayerMask: number;
  75617. private _lightmapMode;
  75618. /**
  75619. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  75620. */
  75621. /**
  75622. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  75623. */
  75624. lightmapMode: number;
  75625. /**
  75626. * Shadow generator associted to the light.
  75627. * @hidden Internal use only.
  75628. */
  75629. _shadowGenerator: Nullable<IShadowGenerator>;
  75630. /**
  75631. * @hidden Internal use only.
  75632. */
  75633. _excludedMeshesIds: string[];
  75634. /**
  75635. * @hidden Internal use only.
  75636. */
  75637. _includedOnlyMeshesIds: string[];
  75638. /**
  75639. * The current light unifom buffer.
  75640. * @hidden Internal use only.
  75641. */
  75642. _uniformBuffer: UniformBuffer;
  75643. /**
  75644. * Creates a Light object in the scene.
  75645. * Documentation : https://doc.babylonjs.com/babylon101/lights
  75646. * @param name The firendly name of the light
  75647. * @param scene The scene the light belongs too
  75648. */
  75649. constructor(name: string, scene: Scene);
  75650. protected abstract _buildUniformLayout(): void;
  75651. /**
  75652. * Sets the passed Effect "effect" with the Light information.
  75653. * @param effect The effect to update
  75654. * @param lightIndex The index of the light in the effect to update
  75655. * @returns The light
  75656. */
  75657. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  75658. /**
  75659. * Sets the passed Effect "effect" with the Light information.
  75660. * @param effect The effect to update
  75661. * @param lightDataUniformName The uniform used to store light data (position or direction)
  75662. * @returns The light
  75663. */
  75664. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  75665. /**
  75666. * Returns the string "Light".
  75667. * @returns the class name
  75668. */
  75669. getClassName(): string;
  75670. /** @hidden */
  75671. readonly _isLight: boolean;
  75672. /**
  75673. * Converts the light information to a readable string for debug purpose.
  75674. * @param fullDetails Supports for multiple levels of logging within scene loading
  75675. * @returns the human readable light info
  75676. */
  75677. toString(fullDetails?: boolean): string;
  75678. /** @hidden */
  75679. protected _syncParentEnabledState(): void;
  75680. /**
  75681. * Set the enabled state of this node.
  75682. * @param value - the new enabled state
  75683. */
  75684. setEnabled(value: boolean): void;
  75685. /**
  75686. * Returns the Light associated shadow generator if any.
  75687. * @return the associated shadow generator.
  75688. */
  75689. getShadowGenerator(): Nullable<IShadowGenerator>;
  75690. /**
  75691. * Returns a Vector3, the absolute light position in the World.
  75692. * @returns the world space position of the light
  75693. */
  75694. getAbsolutePosition(): Vector3;
  75695. /**
  75696. * Specifies if the light will affect the passed mesh.
  75697. * @param mesh The mesh to test against the light
  75698. * @return true the mesh is affected otherwise, false.
  75699. */
  75700. canAffectMesh(mesh: AbstractMesh): boolean;
  75701. /**
  75702. * Sort function to order lights for rendering.
  75703. * @param a First Light object to compare to second.
  75704. * @param b Second Light object to compare first.
  75705. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  75706. */
  75707. static CompareLightsPriority(a: Light, b: Light): number;
  75708. /**
  75709. * Releases resources associated with this node.
  75710. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  75711. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  75712. */
  75713. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  75714. /**
  75715. * Returns the light type ID (integer).
  75716. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  75717. */
  75718. getTypeID(): number;
  75719. /**
  75720. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  75721. * @returns the scaled intensity in intensity mode unit
  75722. */
  75723. getScaledIntensity(): number;
  75724. /**
  75725. * Returns a new Light object, named "name", from the current one.
  75726. * @param name The name of the cloned light
  75727. * @returns the new created light
  75728. */
  75729. clone(name: string): Nullable<Light>;
  75730. /**
  75731. * Serializes the current light into a Serialization object.
  75732. * @returns the serialized object.
  75733. */
  75734. serialize(): any;
  75735. /**
  75736. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  75737. * This new light is named "name" and added to the passed scene.
  75738. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  75739. * @param name The friendly name of the light
  75740. * @param scene The scene the new light will belong to
  75741. * @returns the constructor function
  75742. */
  75743. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  75744. /**
  75745. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  75746. * @param parsedLight The JSON representation of the light
  75747. * @param scene The scene to create the parsed light in
  75748. * @returns the created light after parsing
  75749. */
  75750. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  75751. private _hookArrayForExcluded;
  75752. private _hookArrayForIncludedOnly;
  75753. private _resyncMeshes;
  75754. /**
  75755. * Forces the meshes to update their light related information in their rendering used effects
  75756. * @hidden Internal Use Only
  75757. */
  75758. _markMeshesAsLightDirty(): void;
  75759. /**
  75760. * Recomputes the cached photometric scale if needed.
  75761. */
  75762. private _computePhotometricScale;
  75763. /**
  75764. * Returns the Photometric Scale according to the light type and intensity mode.
  75765. */
  75766. private _getPhotometricScale;
  75767. /**
  75768. * Reorder the light in the scene according to their defined priority.
  75769. * @hidden Internal Use Only
  75770. */
  75771. _reorderLightsInScene(): void;
  75772. /**
  75773. * Prepares the list of defines specific to the light type.
  75774. * @param defines the list of defines
  75775. * @param lightIndex defines the index of the light for the effect
  75776. */
  75777. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  75778. }
  75779. }
  75780. declare module BABYLON {
  75781. /**
  75782. * Interface used to define Action
  75783. */
  75784. export interface IAction {
  75785. /**
  75786. * Trigger for the action
  75787. */
  75788. trigger: number;
  75789. /** Options of the trigger */
  75790. triggerOptions: any;
  75791. /**
  75792. * Gets the trigger parameters
  75793. * @returns the trigger parameters
  75794. */
  75795. getTriggerParameter(): any;
  75796. /**
  75797. * Internal only - executes current action event
  75798. * @hidden
  75799. */
  75800. _executeCurrent(evt?: ActionEvent): void;
  75801. /**
  75802. * Serialize placeholder for child classes
  75803. * @param parent of child
  75804. * @returns the serialized object
  75805. */
  75806. serialize(parent: any): any;
  75807. /**
  75808. * Internal only
  75809. * @hidden
  75810. */
  75811. _prepare(): void;
  75812. /**
  75813. * Internal only - manager for action
  75814. * @hidden
  75815. */
  75816. _actionManager: AbstractActionManager;
  75817. /**
  75818. * Adds action to chain of actions, may be a DoNothingAction
  75819. * @param action defines the next action to execute
  75820. * @returns The action passed in
  75821. * @see https://www.babylonjs-playground.com/#1T30HR#0
  75822. */
  75823. then(action: IAction): IAction;
  75824. }
  75825. /**
  75826. * The action to be carried out following a trigger
  75827. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  75828. */
  75829. export class Action implements IAction {
  75830. /** the trigger, with or without parameters, for the action */
  75831. triggerOptions: any;
  75832. /**
  75833. * Trigger for the action
  75834. */
  75835. trigger: number;
  75836. /**
  75837. * Internal only - manager for action
  75838. * @hidden
  75839. */
  75840. _actionManager: ActionManager;
  75841. private _nextActiveAction;
  75842. private _child;
  75843. private _condition?;
  75844. private _triggerParameter;
  75845. /**
  75846. * An event triggered prior to action being executed.
  75847. */
  75848. onBeforeExecuteObservable: Observable<Action>;
  75849. /**
  75850. * Creates a new Action
  75851. * @param triggerOptions the trigger, with or without parameters, for the action
  75852. * @param condition an optional determinant of action
  75853. */
  75854. constructor(
  75855. /** the trigger, with or without parameters, for the action */
  75856. triggerOptions: any, condition?: Condition);
  75857. /**
  75858. * Internal only
  75859. * @hidden
  75860. */
  75861. _prepare(): void;
  75862. /**
  75863. * Gets the trigger parameters
  75864. * @returns the trigger parameters
  75865. */
  75866. getTriggerParameter(): any;
  75867. /**
  75868. * Internal only - executes current action event
  75869. * @hidden
  75870. */
  75871. _executeCurrent(evt?: ActionEvent): void;
  75872. /**
  75873. * Execute placeholder for child classes
  75874. * @param evt optional action event
  75875. */
  75876. execute(evt?: ActionEvent): void;
  75877. /**
  75878. * Skips to next active action
  75879. */
  75880. skipToNextActiveAction(): void;
  75881. /**
  75882. * Adds action to chain of actions, may be a DoNothingAction
  75883. * @param action defines the next action to execute
  75884. * @returns The action passed in
  75885. * @see https://www.babylonjs-playground.com/#1T30HR#0
  75886. */
  75887. then(action: Action): Action;
  75888. /**
  75889. * Internal only
  75890. * @hidden
  75891. */
  75892. _getProperty(propertyPath: string): string;
  75893. /**
  75894. * Internal only
  75895. * @hidden
  75896. */
  75897. _getEffectiveTarget(target: any, propertyPath: string): any;
  75898. /**
  75899. * Serialize placeholder for child classes
  75900. * @param parent of child
  75901. * @returns the serialized object
  75902. */
  75903. serialize(parent: any): any;
  75904. /**
  75905. * Internal only called by serialize
  75906. * @hidden
  75907. */
  75908. protected _serialize(serializedAction: any, parent?: any): any;
  75909. /**
  75910. * Internal only
  75911. * @hidden
  75912. */
  75913. static _SerializeValueAsString: (value: any) => string;
  75914. /**
  75915. * Internal only
  75916. * @hidden
  75917. */
  75918. static _GetTargetProperty: (target: Node | Scene) => {
  75919. name: string;
  75920. targetType: string;
  75921. value: string;
  75922. };
  75923. }
  75924. }
  75925. declare module BABYLON {
  75926. /**
  75927. * A Condition applied to an Action
  75928. */
  75929. export class Condition {
  75930. /**
  75931. * Internal only - manager for action
  75932. * @hidden
  75933. */
  75934. _actionManager: ActionManager;
  75935. /**
  75936. * Internal only
  75937. * @hidden
  75938. */
  75939. _evaluationId: number;
  75940. /**
  75941. * Internal only
  75942. * @hidden
  75943. */
  75944. _currentResult: boolean;
  75945. /**
  75946. * Creates a new Condition
  75947. * @param actionManager the manager of the action the condition is applied to
  75948. */
  75949. constructor(actionManager: ActionManager);
  75950. /**
  75951. * Check if the current condition is valid
  75952. * @returns a boolean
  75953. */
  75954. isValid(): boolean;
  75955. /**
  75956. * Internal only
  75957. * @hidden
  75958. */
  75959. _getProperty(propertyPath: string): string;
  75960. /**
  75961. * Internal only
  75962. * @hidden
  75963. */
  75964. _getEffectiveTarget(target: any, propertyPath: string): any;
  75965. /**
  75966. * Serialize placeholder for child classes
  75967. * @returns the serialized object
  75968. */
  75969. serialize(): any;
  75970. /**
  75971. * Internal only
  75972. * @hidden
  75973. */
  75974. protected _serialize(serializedCondition: any): any;
  75975. }
  75976. /**
  75977. * Defines specific conditional operators as extensions of Condition
  75978. */
  75979. export class ValueCondition extends Condition {
  75980. /** path to specify the property of the target the conditional operator uses */
  75981. propertyPath: string;
  75982. /** the value compared by the conditional operator against the current value of the property */
  75983. value: any;
  75984. /** the conditional operator, default ValueCondition.IsEqual */
  75985. operator: number;
  75986. /**
  75987. * Internal only
  75988. * @hidden
  75989. */
  75990. private static _IsEqual;
  75991. /**
  75992. * Internal only
  75993. * @hidden
  75994. */
  75995. private static _IsDifferent;
  75996. /**
  75997. * Internal only
  75998. * @hidden
  75999. */
  76000. private static _IsGreater;
  76001. /**
  76002. * Internal only
  76003. * @hidden
  76004. */
  76005. private static _IsLesser;
  76006. /**
  76007. * returns the number for IsEqual
  76008. */
  76009. static readonly IsEqual: number;
  76010. /**
  76011. * Returns the number for IsDifferent
  76012. */
  76013. static readonly IsDifferent: number;
  76014. /**
  76015. * Returns the number for IsGreater
  76016. */
  76017. static readonly IsGreater: number;
  76018. /**
  76019. * Returns the number for IsLesser
  76020. */
  76021. static readonly IsLesser: number;
  76022. /**
  76023. * Internal only The action manager for the condition
  76024. * @hidden
  76025. */
  76026. _actionManager: ActionManager;
  76027. /**
  76028. * Internal only
  76029. * @hidden
  76030. */
  76031. private _target;
  76032. /**
  76033. * Internal only
  76034. * @hidden
  76035. */
  76036. private _effectiveTarget;
  76037. /**
  76038. * Internal only
  76039. * @hidden
  76040. */
  76041. private _property;
  76042. /**
  76043. * Creates a new ValueCondition
  76044. * @param actionManager manager for the action the condition applies to
  76045. * @param target for the action
  76046. * @param propertyPath path to specify the property of the target the conditional operator uses
  76047. * @param value the value compared by the conditional operator against the current value of the property
  76048. * @param operator the conditional operator, default ValueCondition.IsEqual
  76049. */
  76050. constructor(actionManager: ActionManager, target: any,
  76051. /** path to specify the property of the target the conditional operator uses */
  76052. propertyPath: string,
  76053. /** the value compared by the conditional operator against the current value of the property */
  76054. value: any,
  76055. /** the conditional operator, default ValueCondition.IsEqual */
  76056. operator?: number);
  76057. /**
  76058. * Compares the given value with the property value for the specified conditional operator
  76059. * @returns the result of the comparison
  76060. */
  76061. isValid(): boolean;
  76062. /**
  76063. * Serialize the ValueCondition into a JSON compatible object
  76064. * @returns serialization object
  76065. */
  76066. serialize(): any;
  76067. /**
  76068. * Gets the name of the conditional operator for the ValueCondition
  76069. * @param operator the conditional operator
  76070. * @returns the name
  76071. */
  76072. static GetOperatorName(operator: number): string;
  76073. }
  76074. /**
  76075. * Defines a predicate condition as an extension of Condition
  76076. */
  76077. export class PredicateCondition extends Condition {
  76078. /** defines the predicate function used to validate the condition */
  76079. predicate: () => boolean;
  76080. /**
  76081. * Internal only - manager for action
  76082. * @hidden
  76083. */
  76084. _actionManager: ActionManager;
  76085. /**
  76086. * Creates a new PredicateCondition
  76087. * @param actionManager manager for the action the condition applies to
  76088. * @param predicate defines the predicate function used to validate the condition
  76089. */
  76090. constructor(actionManager: ActionManager,
  76091. /** defines the predicate function used to validate the condition */
  76092. predicate: () => boolean);
  76093. /**
  76094. * @returns the validity of the predicate condition
  76095. */
  76096. isValid(): boolean;
  76097. }
  76098. /**
  76099. * Defines a state condition as an extension of Condition
  76100. */
  76101. export class StateCondition extends Condition {
  76102. /** Value to compare with target state */
  76103. value: string;
  76104. /**
  76105. * Internal only - manager for action
  76106. * @hidden
  76107. */
  76108. _actionManager: ActionManager;
  76109. /**
  76110. * Internal only
  76111. * @hidden
  76112. */
  76113. private _target;
  76114. /**
  76115. * Creates a new StateCondition
  76116. * @param actionManager manager for the action the condition applies to
  76117. * @param target of the condition
  76118. * @param value to compare with target state
  76119. */
  76120. constructor(actionManager: ActionManager, target: any,
  76121. /** Value to compare with target state */
  76122. value: string);
  76123. /**
  76124. * Gets a boolean indicating if the current condition is met
  76125. * @returns the validity of the state
  76126. */
  76127. isValid(): boolean;
  76128. /**
  76129. * Serialize the StateCondition into a JSON compatible object
  76130. * @returns serialization object
  76131. */
  76132. serialize(): any;
  76133. }
  76134. }
  76135. declare module BABYLON {
  76136. /**
  76137. * This defines an action responsible to toggle a boolean once triggered.
  76138. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76139. */
  76140. export class SwitchBooleanAction extends Action {
  76141. /**
  76142. * The path to the boolean property in the target object
  76143. */
  76144. propertyPath: string;
  76145. private _target;
  76146. private _effectiveTarget;
  76147. private _property;
  76148. /**
  76149. * Instantiate the action
  76150. * @param triggerOptions defines the trigger options
  76151. * @param target defines the object containing the boolean
  76152. * @param propertyPath defines the path to the boolean property in the target object
  76153. * @param condition defines the trigger related conditions
  76154. */
  76155. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  76156. /** @hidden */
  76157. _prepare(): void;
  76158. /**
  76159. * Execute the action toggle the boolean value.
  76160. */
  76161. execute(): void;
  76162. /**
  76163. * Serializes the actions and its related information.
  76164. * @param parent defines the object to serialize in
  76165. * @returns the serialized object
  76166. */
  76167. serialize(parent: any): any;
  76168. }
  76169. /**
  76170. * This defines an action responsible to set a the state field of the target
  76171. * to a desired value once triggered.
  76172. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76173. */
  76174. export class SetStateAction extends Action {
  76175. /**
  76176. * The value to store in the state field.
  76177. */
  76178. value: string;
  76179. private _target;
  76180. /**
  76181. * Instantiate the action
  76182. * @param triggerOptions defines the trigger options
  76183. * @param target defines the object containing the state property
  76184. * @param value defines the value to store in the state field
  76185. * @param condition defines the trigger related conditions
  76186. */
  76187. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  76188. /**
  76189. * Execute the action and store the value on the target state property.
  76190. */
  76191. execute(): void;
  76192. /**
  76193. * Serializes the actions and its related information.
  76194. * @param parent defines the object to serialize in
  76195. * @returns the serialized object
  76196. */
  76197. serialize(parent: any): any;
  76198. }
  76199. /**
  76200. * This defines an action responsible to set a property of the target
  76201. * to a desired value once triggered.
  76202. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76203. */
  76204. export class SetValueAction extends Action {
  76205. /**
  76206. * The path of the property to set in the target.
  76207. */
  76208. propertyPath: string;
  76209. /**
  76210. * The value to set in the property
  76211. */
  76212. value: any;
  76213. private _target;
  76214. private _effectiveTarget;
  76215. private _property;
  76216. /**
  76217. * Instantiate the action
  76218. * @param triggerOptions defines the trigger options
  76219. * @param target defines the object containing the property
  76220. * @param propertyPath defines the path of the property to set in the target
  76221. * @param value defines the value to set in the property
  76222. * @param condition defines the trigger related conditions
  76223. */
  76224. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  76225. /** @hidden */
  76226. _prepare(): void;
  76227. /**
  76228. * Execute the action and set the targetted property to the desired value.
  76229. */
  76230. execute(): void;
  76231. /**
  76232. * Serializes the actions and its related information.
  76233. * @param parent defines the object to serialize in
  76234. * @returns the serialized object
  76235. */
  76236. serialize(parent: any): any;
  76237. }
  76238. /**
  76239. * This defines an action responsible to increment the target value
  76240. * to a desired value once triggered.
  76241. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76242. */
  76243. export class IncrementValueAction extends Action {
  76244. /**
  76245. * The path of the property to increment in the target.
  76246. */
  76247. propertyPath: string;
  76248. /**
  76249. * The value we should increment the property by.
  76250. */
  76251. value: any;
  76252. private _target;
  76253. private _effectiveTarget;
  76254. private _property;
  76255. /**
  76256. * Instantiate the action
  76257. * @param triggerOptions defines the trigger options
  76258. * @param target defines the object containing the property
  76259. * @param propertyPath defines the path of the property to increment in the target
  76260. * @param value defines the value value we should increment the property by
  76261. * @param condition defines the trigger related conditions
  76262. */
  76263. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  76264. /** @hidden */
  76265. _prepare(): void;
  76266. /**
  76267. * Execute the action and increment the target of the value amount.
  76268. */
  76269. execute(): void;
  76270. /**
  76271. * Serializes the actions and its related information.
  76272. * @param parent defines the object to serialize in
  76273. * @returns the serialized object
  76274. */
  76275. serialize(parent: any): any;
  76276. }
  76277. /**
  76278. * This defines an action responsible to start an animation once triggered.
  76279. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76280. */
  76281. export class PlayAnimationAction extends Action {
  76282. /**
  76283. * Where the animation should start (animation frame)
  76284. */
  76285. from: number;
  76286. /**
  76287. * Where the animation should stop (animation frame)
  76288. */
  76289. to: number;
  76290. /**
  76291. * Define if the animation should loop or stop after the first play.
  76292. */
  76293. loop?: boolean;
  76294. private _target;
  76295. /**
  76296. * Instantiate the action
  76297. * @param triggerOptions defines the trigger options
  76298. * @param target defines the target animation or animation name
  76299. * @param from defines from where the animation should start (animation frame)
  76300. * @param end defines where the animation should stop (animation frame)
  76301. * @param loop defines if the animation should loop or stop after the first play
  76302. * @param condition defines the trigger related conditions
  76303. */
  76304. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  76305. /** @hidden */
  76306. _prepare(): void;
  76307. /**
  76308. * Execute the action and play the animation.
  76309. */
  76310. execute(): void;
  76311. /**
  76312. * Serializes the actions and its related information.
  76313. * @param parent defines the object to serialize in
  76314. * @returns the serialized object
  76315. */
  76316. serialize(parent: any): any;
  76317. }
  76318. /**
  76319. * This defines an action responsible to stop an animation once triggered.
  76320. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76321. */
  76322. export class StopAnimationAction extends Action {
  76323. private _target;
  76324. /**
  76325. * Instantiate the action
  76326. * @param triggerOptions defines the trigger options
  76327. * @param target defines the target animation or animation name
  76328. * @param condition defines the trigger related conditions
  76329. */
  76330. constructor(triggerOptions: any, target: any, condition?: Condition);
  76331. /** @hidden */
  76332. _prepare(): void;
  76333. /**
  76334. * Execute the action and stop the animation.
  76335. */
  76336. execute(): void;
  76337. /**
  76338. * Serializes the actions and its related information.
  76339. * @param parent defines the object to serialize in
  76340. * @returns the serialized object
  76341. */
  76342. serialize(parent: any): any;
  76343. }
  76344. /**
  76345. * This defines an action responsible that does nothing once triggered.
  76346. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76347. */
  76348. export class DoNothingAction extends Action {
  76349. /**
  76350. * Instantiate the action
  76351. * @param triggerOptions defines the trigger options
  76352. * @param condition defines the trigger related conditions
  76353. */
  76354. constructor(triggerOptions?: any, condition?: Condition);
  76355. /**
  76356. * Execute the action and do nothing.
  76357. */
  76358. execute(): void;
  76359. /**
  76360. * Serializes the actions and its related information.
  76361. * @param parent defines the object to serialize in
  76362. * @returns the serialized object
  76363. */
  76364. serialize(parent: any): any;
  76365. }
  76366. /**
  76367. * This defines an action responsible to trigger several actions once triggered.
  76368. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76369. */
  76370. export class CombineAction extends Action {
  76371. /**
  76372. * The list of aggregated animations to run.
  76373. */
  76374. children: Action[];
  76375. /**
  76376. * Instantiate the action
  76377. * @param triggerOptions defines the trigger options
  76378. * @param children defines the list of aggregated animations to run
  76379. * @param condition defines the trigger related conditions
  76380. */
  76381. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  76382. /** @hidden */
  76383. _prepare(): void;
  76384. /**
  76385. * Execute the action and executes all the aggregated actions.
  76386. */
  76387. execute(evt: ActionEvent): void;
  76388. /**
  76389. * Serializes the actions and its related information.
  76390. * @param parent defines the object to serialize in
  76391. * @returns the serialized object
  76392. */
  76393. serialize(parent: any): any;
  76394. }
  76395. /**
  76396. * This defines an action responsible to run code (external event) once triggered.
  76397. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76398. */
  76399. export class ExecuteCodeAction extends Action {
  76400. /**
  76401. * The callback function to run.
  76402. */
  76403. func: (evt: ActionEvent) => void;
  76404. /**
  76405. * Instantiate the action
  76406. * @param triggerOptions defines the trigger options
  76407. * @param func defines the callback function to run
  76408. * @param condition defines the trigger related conditions
  76409. */
  76410. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  76411. /**
  76412. * Execute the action and run the attached code.
  76413. */
  76414. execute(evt: ActionEvent): void;
  76415. }
  76416. /**
  76417. * This defines an action responsible to set the parent property of the target once triggered.
  76418. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76419. */
  76420. export class SetParentAction extends Action {
  76421. private _parent;
  76422. private _target;
  76423. /**
  76424. * Instantiate the action
  76425. * @param triggerOptions defines the trigger options
  76426. * @param target defines the target containing the parent property
  76427. * @param parent defines from where the animation should start (animation frame)
  76428. * @param condition defines the trigger related conditions
  76429. */
  76430. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  76431. /** @hidden */
  76432. _prepare(): void;
  76433. /**
  76434. * Execute the action and set the parent property.
  76435. */
  76436. execute(): void;
  76437. /**
  76438. * Serializes the actions and its related information.
  76439. * @param parent defines the object to serialize in
  76440. * @returns the serialized object
  76441. */
  76442. serialize(parent: any): any;
  76443. }
  76444. }
  76445. declare module BABYLON {
  76446. /**
  76447. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  76448. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  76449. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76450. */
  76451. export class ActionManager extends AbstractActionManager {
  76452. /**
  76453. * Nothing
  76454. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76455. */
  76456. static readonly NothingTrigger: number;
  76457. /**
  76458. * On pick
  76459. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76460. */
  76461. static readonly OnPickTrigger: number;
  76462. /**
  76463. * On left pick
  76464. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76465. */
  76466. static readonly OnLeftPickTrigger: number;
  76467. /**
  76468. * On right pick
  76469. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76470. */
  76471. static readonly OnRightPickTrigger: number;
  76472. /**
  76473. * On center pick
  76474. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76475. */
  76476. static readonly OnCenterPickTrigger: number;
  76477. /**
  76478. * On pick down
  76479. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76480. */
  76481. static readonly OnPickDownTrigger: number;
  76482. /**
  76483. * On double pick
  76484. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76485. */
  76486. static readonly OnDoublePickTrigger: number;
  76487. /**
  76488. * On pick up
  76489. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76490. */
  76491. static readonly OnPickUpTrigger: number;
  76492. /**
  76493. * On pick out.
  76494. * This trigger will only be raised if you also declared a OnPickDown
  76495. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76496. */
  76497. static readonly OnPickOutTrigger: number;
  76498. /**
  76499. * On long press
  76500. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76501. */
  76502. static readonly OnLongPressTrigger: number;
  76503. /**
  76504. * On pointer over
  76505. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76506. */
  76507. static readonly OnPointerOverTrigger: number;
  76508. /**
  76509. * On pointer out
  76510. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76511. */
  76512. static readonly OnPointerOutTrigger: number;
  76513. /**
  76514. * On every frame
  76515. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76516. */
  76517. static readonly OnEveryFrameTrigger: number;
  76518. /**
  76519. * On intersection enter
  76520. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76521. */
  76522. static readonly OnIntersectionEnterTrigger: number;
  76523. /**
  76524. * On intersection exit
  76525. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76526. */
  76527. static readonly OnIntersectionExitTrigger: number;
  76528. /**
  76529. * On key down
  76530. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76531. */
  76532. static readonly OnKeyDownTrigger: number;
  76533. /**
  76534. * On key up
  76535. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76536. */
  76537. static readonly OnKeyUpTrigger: number;
  76538. private _scene;
  76539. /**
  76540. * Creates a new action manager
  76541. * @param scene defines the hosting scene
  76542. */
  76543. constructor(scene: Scene);
  76544. /**
  76545. * Releases all associated resources
  76546. */
  76547. dispose(): void;
  76548. /**
  76549. * Gets hosting scene
  76550. * @returns the hosting scene
  76551. */
  76552. getScene(): Scene;
  76553. /**
  76554. * Does this action manager handles actions of any of the given triggers
  76555. * @param triggers defines the triggers to be tested
  76556. * @return a boolean indicating whether one (or more) of the triggers is handled
  76557. */
  76558. hasSpecificTriggers(triggers: number[]): boolean;
  76559. /**
  76560. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  76561. * speed.
  76562. * @param triggerA defines the trigger to be tested
  76563. * @param triggerB defines the trigger to be tested
  76564. * @return a boolean indicating whether one (or more) of the triggers is handled
  76565. */
  76566. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  76567. /**
  76568. * Does this action manager handles actions of a given trigger
  76569. * @param trigger defines the trigger to be tested
  76570. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  76571. * @return whether the trigger is handled
  76572. */
  76573. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  76574. /**
  76575. * Does this action manager has pointer triggers
  76576. */
  76577. readonly hasPointerTriggers: boolean;
  76578. /**
  76579. * Does this action manager has pick triggers
  76580. */
  76581. readonly hasPickTriggers: boolean;
  76582. /**
  76583. * Registers an action to this action manager
  76584. * @param action defines the action to be registered
  76585. * @return the action amended (prepared) after registration
  76586. */
  76587. registerAction(action: IAction): Nullable<IAction>;
  76588. /**
  76589. * Unregisters an action to this action manager
  76590. * @param action defines the action to be unregistered
  76591. * @return a boolean indicating whether the action has been unregistered
  76592. */
  76593. unregisterAction(action: IAction): Boolean;
  76594. /**
  76595. * Process a specific trigger
  76596. * @param trigger defines the trigger to process
  76597. * @param evt defines the event details to be processed
  76598. */
  76599. processTrigger(trigger: number, evt?: IActionEvent): void;
  76600. /** @hidden */
  76601. _getEffectiveTarget(target: any, propertyPath: string): any;
  76602. /** @hidden */
  76603. _getProperty(propertyPath: string): string;
  76604. /**
  76605. * Serialize this manager to a JSON object
  76606. * @param name defines the property name to store this manager
  76607. * @returns a JSON representation of this manager
  76608. */
  76609. serialize(name: string): any;
  76610. /**
  76611. * Creates a new ActionManager from a JSON data
  76612. * @param parsedActions defines the JSON data to read from
  76613. * @param object defines the hosting mesh
  76614. * @param scene defines the hosting scene
  76615. */
  76616. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  76617. /**
  76618. * Get a trigger name by index
  76619. * @param trigger defines the trigger index
  76620. * @returns a trigger name
  76621. */
  76622. static GetTriggerName(trigger: number): string;
  76623. }
  76624. }
  76625. declare module BABYLON {
  76626. /**
  76627. * Class representing a ray with position and direction
  76628. */
  76629. export class Ray {
  76630. /** origin point */
  76631. origin: Vector3;
  76632. /** direction */
  76633. direction: Vector3;
  76634. /** length of the ray */
  76635. length: number;
  76636. private static readonly TmpVector3;
  76637. private _tmpRay;
  76638. /**
  76639. * Creates a new ray
  76640. * @param origin origin point
  76641. * @param direction direction
  76642. * @param length length of the ray
  76643. */
  76644. constructor(
  76645. /** origin point */
  76646. origin: Vector3,
  76647. /** direction */
  76648. direction: Vector3,
  76649. /** length of the ray */
  76650. length?: number);
  76651. /**
  76652. * Checks if the ray intersects a box
  76653. * @param minimum bound of the box
  76654. * @param maximum bound of the box
  76655. * @param intersectionTreshold extra extend to be added to the box in all direction
  76656. * @returns if the box was hit
  76657. */
  76658. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  76659. /**
  76660. * Checks if the ray intersects a box
  76661. * @param box the bounding box to check
  76662. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  76663. * @returns if the box was hit
  76664. */
  76665. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  76666. /**
  76667. * If the ray hits a sphere
  76668. * @param sphere the bounding sphere to check
  76669. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  76670. * @returns true if it hits the sphere
  76671. */
  76672. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  76673. /**
  76674. * If the ray hits a triange
  76675. * @param vertex0 triangle vertex
  76676. * @param vertex1 triangle vertex
  76677. * @param vertex2 triangle vertex
  76678. * @returns intersection information if hit
  76679. */
  76680. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  76681. /**
  76682. * Checks if ray intersects a plane
  76683. * @param plane the plane to check
  76684. * @returns the distance away it was hit
  76685. */
  76686. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  76687. /**
  76688. * Calculate the intercept of a ray on a given axis
  76689. * @param axis to check 'x' | 'y' | 'z'
  76690. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  76691. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  76692. */
  76693. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  76694. /**
  76695. * Checks if ray intersects a mesh
  76696. * @param mesh the mesh to check
  76697. * @param fastCheck if only the bounding box should checked
  76698. * @returns picking info of the intersecton
  76699. */
  76700. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  76701. /**
  76702. * Checks if ray intersects a mesh
  76703. * @param meshes the meshes to check
  76704. * @param fastCheck if only the bounding box should checked
  76705. * @param results array to store result in
  76706. * @returns Array of picking infos
  76707. */
  76708. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  76709. private _comparePickingInfo;
  76710. private static smallnum;
  76711. private static rayl;
  76712. /**
  76713. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  76714. * @param sega the first point of the segment to test the intersection against
  76715. * @param segb the second point of the segment to test the intersection against
  76716. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  76717. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  76718. */
  76719. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  76720. /**
  76721. * Update the ray from viewport position
  76722. * @param x position
  76723. * @param y y position
  76724. * @param viewportWidth viewport width
  76725. * @param viewportHeight viewport height
  76726. * @param world world matrix
  76727. * @param view view matrix
  76728. * @param projection projection matrix
  76729. * @returns this ray updated
  76730. */
  76731. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  76732. /**
  76733. * Creates a ray with origin and direction of 0,0,0
  76734. * @returns the new ray
  76735. */
  76736. static Zero(): Ray;
  76737. /**
  76738. * Creates a new ray from screen space and viewport
  76739. * @param x position
  76740. * @param y y position
  76741. * @param viewportWidth viewport width
  76742. * @param viewportHeight viewport height
  76743. * @param world world matrix
  76744. * @param view view matrix
  76745. * @param projection projection matrix
  76746. * @returns new ray
  76747. */
  76748. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  76749. /**
  76750. * 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
  76751. * transformed to the given world matrix.
  76752. * @param origin The origin point
  76753. * @param end The end point
  76754. * @param world a matrix to transform the ray to. Default is the identity matrix.
  76755. * @returns the new ray
  76756. */
  76757. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  76758. /**
  76759. * Transforms a ray by a matrix
  76760. * @param ray ray to transform
  76761. * @param matrix matrix to apply
  76762. * @returns the resulting new ray
  76763. */
  76764. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  76765. /**
  76766. * Transforms a ray by a matrix
  76767. * @param ray ray to transform
  76768. * @param matrix matrix to apply
  76769. * @param result ray to store result in
  76770. */
  76771. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  76772. /**
  76773. * Unproject a ray from screen space to object space
  76774. * @param sourceX defines the screen space x coordinate to use
  76775. * @param sourceY defines the screen space y coordinate to use
  76776. * @param viewportWidth defines the current width of the viewport
  76777. * @param viewportHeight defines the current height of the viewport
  76778. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76779. * @param view defines the view matrix to use
  76780. * @param projection defines the projection matrix to use
  76781. */
  76782. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  76783. }
  76784. /**
  76785. * Type used to define predicate used to select faces when a mesh intersection is detected
  76786. */
  76787. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  76788. interface Scene {
  76789. /** @hidden */
  76790. _tempPickingRay: Nullable<Ray>;
  76791. /** @hidden */
  76792. _cachedRayForTransform: Ray;
  76793. /** @hidden */
  76794. _pickWithRayInverseMatrix: Matrix;
  76795. /** @hidden */
  76796. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  76797. /** @hidden */
  76798. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  76799. }
  76800. }
  76801. declare module BABYLON {
  76802. /**
  76803. * Groups all the scene component constants in one place to ease maintenance.
  76804. * @hidden
  76805. */
  76806. export class SceneComponentConstants {
  76807. static readonly NAME_EFFECTLAYER: string;
  76808. static readonly NAME_LAYER: string;
  76809. static readonly NAME_LENSFLARESYSTEM: string;
  76810. static readonly NAME_BOUNDINGBOXRENDERER: string;
  76811. static readonly NAME_PARTICLESYSTEM: string;
  76812. static readonly NAME_GAMEPAD: string;
  76813. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  76814. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  76815. static readonly NAME_DEPTHRENDERER: string;
  76816. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  76817. static readonly NAME_SPRITE: string;
  76818. static readonly NAME_OUTLINERENDERER: string;
  76819. static readonly NAME_PROCEDURALTEXTURE: string;
  76820. static readonly NAME_SHADOWGENERATOR: string;
  76821. static readonly NAME_OCTREE: string;
  76822. static readonly NAME_PHYSICSENGINE: string;
  76823. static readonly NAME_AUDIO: string;
  76824. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  76825. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  76826. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  76827. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  76828. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  76829. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  76830. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  76831. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  76832. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  76833. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  76834. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  76835. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  76836. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  76837. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  76838. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  76839. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  76840. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  76841. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  76842. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  76843. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  76844. static readonly STEP_AFTERRENDER_AUDIO: number;
  76845. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  76846. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  76847. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  76848. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  76849. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  76850. static readonly STEP_POINTERMOVE_SPRITE: number;
  76851. static readonly STEP_POINTERDOWN_SPRITE: number;
  76852. static readonly STEP_POINTERUP_SPRITE: number;
  76853. }
  76854. /**
  76855. * This represents a scene component.
  76856. *
  76857. * This is used to decouple the dependency the scene is having on the different workloads like
  76858. * layers, post processes...
  76859. */
  76860. export interface ISceneComponent {
  76861. /**
  76862. * The name of the component. Each component must have a unique name.
  76863. */
  76864. name: string;
  76865. /**
  76866. * The scene the component belongs to.
  76867. */
  76868. scene: Scene;
  76869. /**
  76870. * Register the component to one instance of a scene.
  76871. */
  76872. register(): void;
  76873. /**
  76874. * Rebuilds the elements related to this component in case of
  76875. * context lost for instance.
  76876. */
  76877. rebuild(): void;
  76878. /**
  76879. * Disposes the component and the associated ressources.
  76880. */
  76881. dispose(): void;
  76882. }
  76883. /**
  76884. * This represents a SERIALIZABLE scene component.
  76885. *
  76886. * This extends Scene Component to add Serialization methods on top.
  76887. */
  76888. export interface ISceneSerializableComponent extends ISceneComponent {
  76889. /**
  76890. * Adds all the elements from the container to the scene
  76891. * @param container the container holding the elements
  76892. */
  76893. addFromContainer(container: AbstractScene): void;
  76894. /**
  76895. * Removes all the elements in the container from the scene
  76896. * @param container contains the elements to remove
  76897. * @param dispose if the removed element should be disposed (default: false)
  76898. */
  76899. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  76900. /**
  76901. * Serializes the component data to the specified json object
  76902. * @param serializationObject The object to serialize to
  76903. */
  76904. serialize(serializationObject: any): void;
  76905. }
  76906. /**
  76907. * Strong typing of a Mesh related stage step action
  76908. */
  76909. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  76910. /**
  76911. * Strong typing of a Evaluate Sub Mesh related stage step action
  76912. */
  76913. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  76914. /**
  76915. * Strong typing of a Active Mesh related stage step action
  76916. */
  76917. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  76918. /**
  76919. * Strong typing of a Camera related stage step action
  76920. */
  76921. export type CameraStageAction = (camera: Camera) => void;
  76922. /**
  76923. * Strong typing of a Camera Frame buffer related stage step action
  76924. */
  76925. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  76926. /**
  76927. * Strong typing of a Render Target related stage step action
  76928. */
  76929. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  76930. /**
  76931. * Strong typing of a RenderingGroup related stage step action
  76932. */
  76933. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  76934. /**
  76935. * Strong typing of a Mesh Render related stage step action
  76936. */
  76937. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  76938. /**
  76939. * Strong typing of a simple stage step action
  76940. */
  76941. export type SimpleStageAction = () => void;
  76942. /**
  76943. * Strong typing of a render target action.
  76944. */
  76945. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  76946. /**
  76947. * Strong typing of a pointer move action.
  76948. */
  76949. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  76950. /**
  76951. * Strong typing of a pointer up/down action.
  76952. */
  76953. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  76954. /**
  76955. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  76956. * @hidden
  76957. */
  76958. export class Stage<T extends Function> extends Array<{
  76959. index: number;
  76960. component: ISceneComponent;
  76961. action: T;
  76962. }> {
  76963. /**
  76964. * Hide ctor from the rest of the world.
  76965. * @param items The items to add.
  76966. */
  76967. private constructor();
  76968. /**
  76969. * Creates a new Stage.
  76970. * @returns A new instance of a Stage
  76971. */
  76972. static Create<T extends Function>(): Stage<T>;
  76973. /**
  76974. * Registers a step in an ordered way in the targeted stage.
  76975. * @param index Defines the position to register the step in
  76976. * @param component Defines the component attached to the step
  76977. * @param action Defines the action to launch during the step
  76978. */
  76979. registerStep(index: number, component: ISceneComponent, action: T): void;
  76980. /**
  76981. * Clears all the steps from the stage.
  76982. */
  76983. clear(): void;
  76984. }
  76985. }
  76986. declare module BABYLON {
  76987. interface Scene {
  76988. /** @hidden */
  76989. _pointerOverSprite: Nullable<Sprite>;
  76990. /** @hidden */
  76991. _pickedDownSprite: Nullable<Sprite>;
  76992. /** @hidden */
  76993. _tempSpritePickingRay: Nullable<Ray>;
  76994. /**
  76995. * All of the sprite managers added to this scene
  76996. * @see http://doc.babylonjs.com/babylon101/sprites
  76997. */
  76998. spriteManagers: Array<ISpriteManager>;
  76999. /**
  77000. * An event triggered when sprites rendering is about to start
  77001. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  77002. */
  77003. onBeforeSpritesRenderingObservable: Observable<Scene>;
  77004. /**
  77005. * An event triggered when sprites rendering is done
  77006. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  77007. */
  77008. onAfterSpritesRenderingObservable: Observable<Scene>;
  77009. /** @hidden */
  77010. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  77011. /** Launch a ray to try to pick a sprite in the scene
  77012. * @param x position on screen
  77013. * @param y position on screen
  77014. * @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
  77015. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  77016. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  77017. * @returns a PickingInfo
  77018. */
  77019. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  77020. /** Use the given ray to pick a sprite in the scene
  77021. * @param ray The ray (in world space) to use to pick meshes
  77022. * @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
  77023. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  77024. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  77025. * @returns a PickingInfo
  77026. */
  77027. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  77028. /** @hidden */
  77029. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  77030. /** Launch a ray to try to pick sprites in the scene
  77031. * @param x position on screen
  77032. * @param y position on screen
  77033. * @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
  77034. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  77035. * @returns a PickingInfo array
  77036. */
  77037. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  77038. /** Use the given ray to pick sprites in the scene
  77039. * @param ray The ray (in world space) to use to pick meshes
  77040. * @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
  77041. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  77042. * @returns a PickingInfo array
  77043. */
  77044. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  77045. /**
  77046. * Force the sprite under the pointer
  77047. * @param sprite defines the sprite to use
  77048. */
  77049. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  77050. /**
  77051. * Gets the sprite under the pointer
  77052. * @returns a Sprite or null if no sprite is under the pointer
  77053. */
  77054. getPointerOverSprite(): Nullable<Sprite>;
  77055. }
  77056. /**
  77057. * Defines the sprite scene component responsible to manage sprites
  77058. * in a given scene.
  77059. */
  77060. export class SpriteSceneComponent implements ISceneComponent {
  77061. /**
  77062. * The component name helpfull to identify the component in the list of scene components.
  77063. */
  77064. readonly name: string;
  77065. /**
  77066. * The scene the component belongs to.
  77067. */
  77068. scene: Scene;
  77069. /** @hidden */
  77070. private _spritePredicate;
  77071. /**
  77072. * Creates a new instance of the component for the given scene
  77073. * @param scene Defines the scene to register the component in
  77074. */
  77075. constructor(scene: Scene);
  77076. /**
  77077. * Registers the component in a given scene
  77078. */
  77079. register(): void;
  77080. /**
  77081. * Rebuilds the elements related to this component in case of
  77082. * context lost for instance.
  77083. */
  77084. rebuild(): void;
  77085. /**
  77086. * Disposes the component and the associated ressources.
  77087. */
  77088. dispose(): void;
  77089. private _pickSpriteButKeepRay;
  77090. private _pointerMove;
  77091. private _pointerDown;
  77092. private _pointerUp;
  77093. }
  77094. }
  77095. declare module BABYLON {
  77096. /** @hidden */
  77097. export var fogFragmentDeclaration: {
  77098. name: string;
  77099. shader: string;
  77100. };
  77101. }
  77102. declare module BABYLON {
  77103. /** @hidden */
  77104. export var fogFragment: {
  77105. name: string;
  77106. shader: string;
  77107. };
  77108. }
  77109. declare module BABYLON {
  77110. /** @hidden */
  77111. export var spritesPixelShader: {
  77112. name: string;
  77113. shader: string;
  77114. };
  77115. }
  77116. declare module BABYLON {
  77117. /** @hidden */
  77118. export var fogVertexDeclaration: {
  77119. name: string;
  77120. shader: string;
  77121. };
  77122. }
  77123. declare module BABYLON {
  77124. /** @hidden */
  77125. export var spritesVertexShader: {
  77126. name: string;
  77127. shader: string;
  77128. };
  77129. }
  77130. declare module BABYLON {
  77131. /**
  77132. * Defines the minimum interface to fullfil in order to be a sprite manager.
  77133. */
  77134. export interface ISpriteManager extends IDisposable {
  77135. /**
  77136. * Restricts the camera to viewing objects with the same layerMask.
  77137. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  77138. */
  77139. layerMask: number;
  77140. /**
  77141. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  77142. */
  77143. isPickable: boolean;
  77144. /**
  77145. * Specifies the rendering group id for this mesh (0 by default)
  77146. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  77147. */
  77148. renderingGroupId: number;
  77149. /**
  77150. * Defines the list of sprites managed by the manager.
  77151. */
  77152. sprites: Array<Sprite>;
  77153. /**
  77154. * Tests the intersection of a sprite with a specific ray.
  77155. * @param ray The ray we are sending to test the collision
  77156. * @param camera The camera space we are sending rays in
  77157. * @param predicate A predicate allowing excluding sprites from the list of object to test
  77158. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  77159. * @returns picking info or null.
  77160. */
  77161. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  77162. /**
  77163. * Intersects the sprites with a ray
  77164. * @param ray defines the ray to intersect with
  77165. * @param camera defines the current active camera
  77166. * @param predicate defines a predicate used to select candidate sprites
  77167. * @returns null if no hit or a PickingInfo array
  77168. */
  77169. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  77170. /**
  77171. * Renders the list of sprites on screen.
  77172. */
  77173. render(): void;
  77174. }
  77175. /**
  77176. * Class used to manage multiple sprites on the same spritesheet
  77177. * @see http://doc.babylonjs.com/babylon101/sprites
  77178. */
  77179. export class SpriteManager implements ISpriteManager {
  77180. /** defines the manager's name */
  77181. name: string;
  77182. /** Gets the list of sprites */
  77183. sprites: Sprite[];
  77184. /** Gets or sets the rendering group id (0 by default) */
  77185. renderingGroupId: number;
  77186. /** Gets or sets camera layer mask */
  77187. layerMask: number;
  77188. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  77189. fogEnabled: boolean;
  77190. /** Gets or sets a boolean indicating if the sprites are pickable */
  77191. isPickable: boolean;
  77192. /** Defines the default width of a cell in the spritesheet */
  77193. cellWidth: number;
  77194. /** Defines the default height of a cell in the spritesheet */
  77195. cellHeight: number;
  77196. /** Associative array from JSON sprite data file */
  77197. private _cellData;
  77198. /** Array of sprite names from JSON sprite data file */
  77199. private _spriteMap;
  77200. /** True when packed cell data from JSON file is ready*/
  77201. private _packedAndReady;
  77202. /**
  77203. * An event triggered when the manager is disposed.
  77204. */
  77205. onDisposeObservable: Observable<SpriteManager>;
  77206. private _onDisposeObserver;
  77207. /**
  77208. * Callback called when the manager is disposed
  77209. */
  77210. onDispose: () => void;
  77211. private _capacity;
  77212. private _fromPacked;
  77213. private _spriteTexture;
  77214. private _epsilon;
  77215. private _scene;
  77216. private _vertexData;
  77217. private _buffer;
  77218. private _vertexBuffers;
  77219. private _indexBuffer;
  77220. private _effectBase;
  77221. private _effectFog;
  77222. /**
  77223. * Gets or sets the spritesheet texture
  77224. */
  77225. texture: Texture;
  77226. /**
  77227. * Creates a new sprite manager
  77228. * @param name defines the manager's name
  77229. * @param imgUrl defines the sprite sheet url
  77230. * @param capacity defines the maximum allowed number of sprites
  77231. * @param cellSize defines the size of a sprite cell
  77232. * @param scene defines the hosting scene
  77233. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  77234. * @param samplingMode defines the smapling mode to use with spritesheet
  77235. * @param fromPacked set to false; do not alter
  77236. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  77237. */
  77238. constructor(
  77239. /** defines the manager's name */
  77240. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  77241. private _makePacked;
  77242. private _appendSpriteVertex;
  77243. /**
  77244. * Intersects the sprites with a ray
  77245. * @param ray defines the ray to intersect with
  77246. * @param camera defines the current active camera
  77247. * @param predicate defines a predicate used to select candidate sprites
  77248. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  77249. * @returns null if no hit or a PickingInfo
  77250. */
  77251. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  77252. /**
  77253. * Intersects the sprites with a ray
  77254. * @param ray defines the ray to intersect with
  77255. * @param camera defines the current active camera
  77256. * @param predicate defines a predicate used to select candidate sprites
  77257. * @returns null if no hit or a PickingInfo array
  77258. */
  77259. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  77260. /**
  77261. * Render all child sprites
  77262. */
  77263. render(): void;
  77264. /**
  77265. * Release associated resources
  77266. */
  77267. dispose(): void;
  77268. }
  77269. }
  77270. declare module BABYLON {
  77271. /**
  77272. * Class used to represent a sprite
  77273. * @see http://doc.babylonjs.com/babylon101/sprites
  77274. */
  77275. export class Sprite {
  77276. /** defines the name */
  77277. name: string;
  77278. /** Gets or sets the current world position */
  77279. position: Vector3;
  77280. /** Gets or sets the main color */
  77281. color: Color4;
  77282. /** Gets or sets the width */
  77283. width: number;
  77284. /** Gets or sets the height */
  77285. height: number;
  77286. /** Gets or sets rotation angle */
  77287. angle: number;
  77288. /** Gets or sets the cell index in the sprite sheet */
  77289. cellIndex: number;
  77290. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  77291. cellRef: string;
  77292. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  77293. invertU: number;
  77294. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  77295. invertV: number;
  77296. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  77297. disposeWhenFinishedAnimating: boolean;
  77298. /** Gets the list of attached animations */
  77299. animations: Animation[];
  77300. /** Gets or sets a boolean indicating if the sprite can be picked */
  77301. isPickable: boolean;
  77302. /**
  77303. * Gets or sets the associated action manager
  77304. */
  77305. actionManager: Nullable<ActionManager>;
  77306. private _animationStarted;
  77307. private _loopAnimation;
  77308. private _fromIndex;
  77309. private _toIndex;
  77310. private _delay;
  77311. private _direction;
  77312. private _manager;
  77313. private _time;
  77314. private _onAnimationEnd;
  77315. /**
  77316. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  77317. */
  77318. isVisible: boolean;
  77319. /**
  77320. * Gets or sets the sprite size
  77321. */
  77322. size: number;
  77323. /**
  77324. * Creates a new Sprite
  77325. * @param name defines the name
  77326. * @param manager defines the manager
  77327. */
  77328. constructor(
  77329. /** defines the name */
  77330. name: string, manager: ISpriteManager);
  77331. /**
  77332. * Starts an animation
  77333. * @param from defines the initial key
  77334. * @param to defines the end key
  77335. * @param loop defines if the animation must loop
  77336. * @param delay defines the start delay (in ms)
  77337. * @param onAnimationEnd defines a callback to call when animation ends
  77338. */
  77339. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  77340. /** Stops current animation (if any) */
  77341. stopAnimation(): void;
  77342. /** @hidden */
  77343. _animate(deltaTime: number): void;
  77344. /** Release associated resources */
  77345. dispose(): void;
  77346. }
  77347. }
  77348. declare module BABYLON {
  77349. /**
  77350. * Information about the result of picking within a scene
  77351. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  77352. */
  77353. export class PickingInfo {
  77354. /** @hidden */
  77355. _pickingUnavailable: boolean;
  77356. /**
  77357. * If the pick collided with an object
  77358. */
  77359. hit: boolean;
  77360. /**
  77361. * Distance away where the pick collided
  77362. */
  77363. distance: number;
  77364. /**
  77365. * The location of pick collision
  77366. */
  77367. pickedPoint: Nullable<Vector3>;
  77368. /**
  77369. * The mesh corresponding the the pick collision
  77370. */
  77371. pickedMesh: Nullable<AbstractMesh>;
  77372. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  77373. bu: number;
  77374. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  77375. bv: number;
  77376. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  77377. faceId: number;
  77378. /** Id of the the submesh that was picked */
  77379. subMeshId: number;
  77380. /** If a sprite was picked, this will be the sprite the pick collided with */
  77381. pickedSprite: Nullable<Sprite>;
  77382. /**
  77383. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  77384. */
  77385. originMesh: Nullable<AbstractMesh>;
  77386. /**
  77387. * The ray that was used to perform the picking.
  77388. */
  77389. ray: Nullable<Ray>;
  77390. /**
  77391. * Gets the normal correspodning to the face the pick collided with
  77392. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  77393. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  77394. * @returns The normal correspodning to the face the pick collided with
  77395. */
  77396. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  77397. /**
  77398. * Gets the texture coordinates of where the pick occured
  77399. * @returns the vector containing the coordnates of the texture
  77400. */
  77401. getTextureCoordinates(): Nullable<Vector2>;
  77402. }
  77403. }
  77404. declare module BABYLON {
  77405. /**
  77406. * Gather the list of pointer event types as constants.
  77407. */
  77408. export class PointerEventTypes {
  77409. /**
  77410. * 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.
  77411. */
  77412. static readonly POINTERDOWN: number;
  77413. /**
  77414. * The pointerup event is fired when a pointer is no longer active.
  77415. */
  77416. static readonly POINTERUP: number;
  77417. /**
  77418. * The pointermove event is fired when a pointer changes coordinates.
  77419. */
  77420. static readonly POINTERMOVE: number;
  77421. /**
  77422. * The pointerwheel event is fired when a mouse wheel has been rotated.
  77423. */
  77424. static readonly POINTERWHEEL: number;
  77425. /**
  77426. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  77427. */
  77428. static readonly POINTERPICK: number;
  77429. /**
  77430. * The pointertap event is fired when a the object has been touched and released without drag.
  77431. */
  77432. static readonly POINTERTAP: number;
  77433. /**
  77434. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  77435. */
  77436. static readonly POINTERDOUBLETAP: number;
  77437. }
  77438. /**
  77439. * Base class of pointer info types.
  77440. */
  77441. export class PointerInfoBase {
  77442. /**
  77443. * Defines the type of event (PointerEventTypes)
  77444. */
  77445. type: number;
  77446. /**
  77447. * Defines the related dom event
  77448. */
  77449. event: PointerEvent | MouseWheelEvent;
  77450. /**
  77451. * Instantiates the base class of pointers info.
  77452. * @param type Defines the type of event (PointerEventTypes)
  77453. * @param event Defines the related dom event
  77454. */
  77455. constructor(
  77456. /**
  77457. * Defines the type of event (PointerEventTypes)
  77458. */
  77459. type: number,
  77460. /**
  77461. * Defines the related dom event
  77462. */
  77463. event: PointerEvent | MouseWheelEvent);
  77464. }
  77465. /**
  77466. * This class is used to store pointer related info for the onPrePointerObservable event.
  77467. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  77468. */
  77469. export class PointerInfoPre extends PointerInfoBase {
  77470. /**
  77471. * Ray from a pointer if availible (eg. 6dof controller)
  77472. */
  77473. ray: Nullable<Ray>;
  77474. /**
  77475. * Defines the local position of the pointer on the canvas.
  77476. */
  77477. localPosition: Vector2;
  77478. /**
  77479. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  77480. */
  77481. skipOnPointerObservable: boolean;
  77482. /**
  77483. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  77484. * @param type Defines the type of event (PointerEventTypes)
  77485. * @param event Defines the related dom event
  77486. * @param localX Defines the local x coordinates of the pointer when the event occured
  77487. * @param localY Defines the local y coordinates of the pointer when the event occured
  77488. */
  77489. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  77490. }
  77491. /**
  77492. * This type contains all the data related to a pointer event in Babylon.js.
  77493. * 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.
  77494. */
  77495. export class PointerInfo extends PointerInfoBase {
  77496. /**
  77497. * Defines the picking info associated to the info (if any)\
  77498. */
  77499. pickInfo: Nullable<PickingInfo>;
  77500. /**
  77501. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  77502. * @param type Defines the type of event (PointerEventTypes)
  77503. * @param event Defines the related dom event
  77504. * @param pickInfo Defines the picking info associated to the info (if any)\
  77505. */
  77506. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  77507. /**
  77508. * Defines the picking info associated to the info (if any)\
  77509. */
  77510. pickInfo: Nullable<PickingInfo>);
  77511. }
  77512. /**
  77513. * Data relating to a touch event on the screen.
  77514. */
  77515. export interface PointerTouch {
  77516. /**
  77517. * X coordinate of touch.
  77518. */
  77519. x: number;
  77520. /**
  77521. * Y coordinate of touch.
  77522. */
  77523. y: number;
  77524. /**
  77525. * Id of touch. Unique for each finger.
  77526. */
  77527. pointerId: number;
  77528. /**
  77529. * Event type passed from DOM.
  77530. */
  77531. type: any;
  77532. }
  77533. }
  77534. declare module BABYLON {
  77535. /**
  77536. * Manage the mouse inputs to control the movement of a free camera.
  77537. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  77538. */
  77539. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  77540. /**
  77541. * Define if touch is enabled in the mouse input
  77542. */
  77543. touchEnabled: boolean;
  77544. /**
  77545. * Defines the camera the input is attached to.
  77546. */
  77547. camera: FreeCamera;
  77548. /**
  77549. * Defines the buttons associated with the input to handle camera move.
  77550. */
  77551. buttons: number[];
  77552. /**
  77553. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  77554. */
  77555. angularSensibility: number;
  77556. private _pointerInput;
  77557. private _onMouseMove;
  77558. private _observer;
  77559. private previousPosition;
  77560. /**
  77561. * Observable for when a pointer move event occurs containing the move offset
  77562. */
  77563. onPointerMovedObservable: Observable<{
  77564. offsetX: number;
  77565. offsetY: number;
  77566. }>;
  77567. /**
  77568. * @hidden
  77569. * If the camera should be rotated automatically based on pointer movement
  77570. */
  77571. _allowCameraRotation: boolean;
  77572. /**
  77573. * Manage the mouse inputs to control the movement of a free camera.
  77574. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  77575. * @param touchEnabled Defines if touch is enabled or not
  77576. */
  77577. constructor(
  77578. /**
  77579. * Define if touch is enabled in the mouse input
  77580. */
  77581. touchEnabled?: boolean);
  77582. /**
  77583. * Attach the input controls to a specific dom element to get the input from.
  77584. * @param element Defines the element the controls should be listened from
  77585. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  77586. */
  77587. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  77588. /**
  77589. * Called on JS contextmenu event.
  77590. * Override this method to provide functionality.
  77591. */
  77592. protected onContextMenu(evt: PointerEvent): void;
  77593. /**
  77594. * Detach the current controls from the specified dom element.
  77595. * @param element Defines the element to stop listening the inputs from
  77596. */
  77597. detachControl(element: Nullable<HTMLElement>): void;
  77598. /**
  77599. * Gets the class name of the current intput.
  77600. * @returns the class name
  77601. */
  77602. getClassName(): string;
  77603. /**
  77604. * Get the friendly name associated with the input class.
  77605. * @returns the input friendly name
  77606. */
  77607. getSimpleName(): string;
  77608. }
  77609. }
  77610. declare module BABYLON {
  77611. /**
  77612. * Manage the touch inputs to control the movement of a free camera.
  77613. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  77614. */
  77615. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  77616. /**
  77617. * Defines the camera the input is attached to.
  77618. */
  77619. camera: FreeCamera;
  77620. /**
  77621. * Defines the touch sensibility for rotation.
  77622. * The higher the faster.
  77623. */
  77624. touchAngularSensibility: number;
  77625. /**
  77626. * Defines the touch sensibility for move.
  77627. * The higher the faster.
  77628. */
  77629. touchMoveSensibility: number;
  77630. private _offsetX;
  77631. private _offsetY;
  77632. private _pointerPressed;
  77633. private _pointerInput;
  77634. private _observer;
  77635. private _onLostFocus;
  77636. /**
  77637. * Attach the input controls to a specific dom element to get the input from.
  77638. * @param element Defines the element the controls should be listened from
  77639. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  77640. */
  77641. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  77642. /**
  77643. * Detach the current controls from the specified dom element.
  77644. * @param element Defines the element to stop listening the inputs from
  77645. */
  77646. detachControl(element: Nullable<HTMLElement>): void;
  77647. /**
  77648. * Update the current camera state depending on the inputs that have been used this frame.
  77649. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  77650. */
  77651. checkInputs(): void;
  77652. /**
  77653. * Gets the class name of the current intput.
  77654. * @returns the class name
  77655. */
  77656. getClassName(): string;
  77657. /**
  77658. * Get the friendly name associated with the input class.
  77659. * @returns the input friendly name
  77660. */
  77661. getSimpleName(): string;
  77662. }
  77663. }
  77664. declare module BABYLON {
  77665. /**
  77666. * Default Inputs manager for the FreeCamera.
  77667. * It groups all the default supported inputs for ease of use.
  77668. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  77669. */
  77670. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  77671. /**
  77672. * @hidden
  77673. */
  77674. _mouseInput: Nullable<FreeCameraMouseInput>;
  77675. /**
  77676. * Instantiates a new FreeCameraInputsManager.
  77677. * @param camera Defines the camera the inputs belong to
  77678. */
  77679. constructor(camera: FreeCamera);
  77680. /**
  77681. * Add keyboard input support to the input manager.
  77682. * @returns the current input manager
  77683. */
  77684. addKeyboard(): FreeCameraInputsManager;
  77685. /**
  77686. * Add mouse input support to the input manager.
  77687. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  77688. * @returns the current input manager
  77689. */
  77690. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  77691. /**
  77692. * Removes the mouse input support from the manager
  77693. * @returns the current input manager
  77694. */
  77695. removeMouse(): FreeCameraInputsManager;
  77696. /**
  77697. * Add touch input support to the input manager.
  77698. * @returns the current input manager
  77699. */
  77700. addTouch(): FreeCameraInputsManager;
  77701. /**
  77702. * Remove all attached input methods from a camera
  77703. */
  77704. clear(): void;
  77705. }
  77706. }
  77707. declare module BABYLON {
  77708. /**
  77709. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  77710. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  77711. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  77712. */
  77713. export class FreeCamera extends TargetCamera {
  77714. /**
  77715. * Define the collision ellipsoid of the camera.
  77716. * This is helpful to simulate a camera body like the player body around the camera
  77717. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  77718. */
  77719. ellipsoid: Vector3;
  77720. /**
  77721. * Define an offset for the position of the ellipsoid around the camera.
  77722. * This can be helpful to determine the center of the body near the gravity center of the body
  77723. * instead of its head.
  77724. */
  77725. ellipsoidOffset: Vector3;
  77726. /**
  77727. * Enable or disable collisions of the camera with the rest of the scene objects.
  77728. */
  77729. checkCollisions: boolean;
  77730. /**
  77731. * Enable or disable gravity on the camera.
  77732. */
  77733. applyGravity: boolean;
  77734. /**
  77735. * Define the input manager associated to the camera.
  77736. */
  77737. inputs: FreeCameraInputsManager;
  77738. /**
  77739. * Gets the input sensibility for a mouse input. (default is 2000.0)
  77740. * Higher values reduce sensitivity.
  77741. */
  77742. /**
  77743. * Sets the input sensibility for a mouse input. (default is 2000.0)
  77744. * Higher values reduce sensitivity.
  77745. */
  77746. angularSensibility: number;
  77747. /**
  77748. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  77749. */
  77750. keysUp: number[];
  77751. /**
  77752. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  77753. */
  77754. keysDown: number[];
  77755. /**
  77756. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  77757. */
  77758. keysLeft: number[];
  77759. /**
  77760. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  77761. */
  77762. keysRight: number[];
  77763. /**
  77764. * Event raised when the camera collide with a mesh in the scene.
  77765. */
  77766. onCollide: (collidedMesh: AbstractMesh) => void;
  77767. private _collider;
  77768. private _needMoveForGravity;
  77769. private _oldPosition;
  77770. private _diffPosition;
  77771. private _newPosition;
  77772. /** @hidden */
  77773. _localDirection: Vector3;
  77774. /** @hidden */
  77775. _transformedDirection: Vector3;
  77776. /**
  77777. * Instantiates a Free Camera.
  77778. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  77779. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  77780. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  77781. * @param name Define the name of the camera in the scene
  77782. * @param position Define the start position of the camera in the scene
  77783. * @param scene Define the scene the camera belongs to
  77784. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  77785. */
  77786. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  77787. /**
  77788. * Attached controls to the current camera.
  77789. * @param element Defines the element the controls should be listened from
  77790. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  77791. */
  77792. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  77793. /**
  77794. * Detach the current controls from the camera.
  77795. * The camera will stop reacting to inputs.
  77796. * @param element Defines the element to stop listening the inputs from
  77797. */
  77798. detachControl(element: HTMLElement): void;
  77799. private _collisionMask;
  77800. /**
  77801. * Define a collision mask to limit the list of object the camera can collide with
  77802. */
  77803. collisionMask: number;
  77804. /** @hidden */
  77805. _collideWithWorld(displacement: Vector3): void;
  77806. private _onCollisionPositionChange;
  77807. /** @hidden */
  77808. _checkInputs(): void;
  77809. /** @hidden */
  77810. _decideIfNeedsToMove(): boolean;
  77811. /** @hidden */
  77812. _updatePosition(): void;
  77813. /**
  77814. * Destroy the camera and release the current resources hold by it.
  77815. */
  77816. dispose(): void;
  77817. /**
  77818. * Gets the current object class name.
  77819. * @return the class name
  77820. */
  77821. getClassName(): string;
  77822. }
  77823. }
  77824. declare module BABYLON {
  77825. /**
  77826. * Represents a gamepad control stick position
  77827. */
  77828. export class StickValues {
  77829. /**
  77830. * The x component of the control stick
  77831. */
  77832. x: number;
  77833. /**
  77834. * The y component of the control stick
  77835. */
  77836. y: number;
  77837. /**
  77838. * Initializes the gamepad x and y control stick values
  77839. * @param x The x component of the gamepad control stick value
  77840. * @param y The y component of the gamepad control stick value
  77841. */
  77842. constructor(
  77843. /**
  77844. * The x component of the control stick
  77845. */
  77846. x: number,
  77847. /**
  77848. * The y component of the control stick
  77849. */
  77850. y: number);
  77851. }
  77852. /**
  77853. * An interface which manages callbacks for gamepad button changes
  77854. */
  77855. export interface GamepadButtonChanges {
  77856. /**
  77857. * Called when a gamepad has been changed
  77858. */
  77859. changed: boolean;
  77860. /**
  77861. * Called when a gamepad press event has been triggered
  77862. */
  77863. pressChanged: boolean;
  77864. /**
  77865. * Called when a touch event has been triggered
  77866. */
  77867. touchChanged: boolean;
  77868. /**
  77869. * Called when a value has changed
  77870. */
  77871. valueChanged: boolean;
  77872. }
  77873. /**
  77874. * Represents a gamepad
  77875. */
  77876. export class Gamepad {
  77877. /**
  77878. * The id of the gamepad
  77879. */
  77880. id: string;
  77881. /**
  77882. * The index of the gamepad
  77883. */
  77884. index: number;
  77885. /**
  77886. * The browser gamepad
  77887. */
  77888. browserGamepad: any;
  77889. /**
  77890. * Specifies what type of gamepad this represents
  77891. */
  77892. type: number;
  77893. private _leftStick;
  77894. private _rightStick;
  77895. /** @hidden */
  77896. _isConnected: boolean;
  77897. private _leftStickAxisX;
  77898. private _leftStickAxisY;
  77899. private _rightStickAxisX;
  77900. private _rightStickAxisY;
  77901. /**
  77902. * Triggered when the left control stick has been changed
  77903. */
  77904. private _onleftstickchanged;
  77905. /**
  77906. * Triggered when the right control stick has been changed
  77907. */
  77908. private _onrightstickchanged;
  77909. /**
  77910. * Represents a gamepad controller
  77911. */
  77912. static GAMEPAD: number;
  77913. /**
  77914. * Represents a generic controller
  77915. */
  77916. static GENERIC: number;
  77917. /**
  77918. * Represents an XBox controller
  77919. */
  77920. static XBOX: number;
  77921. /**
  77922. * Represents a pose-enabled controller
  77923. */
  77924. static POSE_ENABLED: number;
  77925. /**
  77926. * Represents an Dual Shock controller
  77927. */
  77928. static DUALSHOCK: number;
  77929. /**
  77930. * Specifies whether the left control stick should be Y-inverted
  77931. */
  77932. protected _invertLeftStickY: boolean;
  77933. /**
  77934. * Specifies if the gamepad has been connected
  77935. */
  77936. readonly isConnected: boolean;
  77937. /**
  77938. * Initializes the gamepad
  77939. * @param id The id of the gamepad
  77940. * @param index The index of the gamepad
  77941. * @param browserGamepad The browser gamepad
  77942. * @param leftStickX The x component of the left joystick
  77943. * @param leftStickY The y component of the left joystick
  77944. * @param rightStickX The x component of the right joystick
  77945. * @param rightStickY The y component of the right joystick
  77946. */
  77947. constructor(
  77948. /**
  77949. * The id of the gamepad
  77950. */
  77951. id: string,
  77952. /**
  77953. * The index of the gamepad
  77954. */
  77955. index: number,
  77956. /**
  77957. * The browser gamepad
  77958. */
  77959. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  77960. /**
  77961. * Callback triggered when the left joystick has changed
  77962. * @param callback
  77963. */
  77964. onleftstickchanged(callback: (values: StickValues) => void): void;
  77965. /**
  77966. * Callback triggered when the right joystick has changed
  77967. * @param callback
  77968. */
  77969. onrightstickchanged(callback: (values: StickValues) => void): void;
  77970. /**
  77971. * Gets the left joystick
  77972. */
  77973. /**
  77974. * Sets the left joystick values
  77975. */
  77976. leftStick: StickValues;
  77977. /**
  77978. * Gets the right joystick
  77979. */
  77980. /**
  77981. * Sets the right joystick value
  77982. */
  77983. rightStick: StickValues;
  77984. /**
  77985. * Updates the gamepad joystick positions
  77986. */
  77987. update(): void;
  77988. /**
  77989. * Disposes the gamepad
  77990. */
  77991. dispose(): void;
  77992. }
  77993. /**
  77994. * Represents a generic gamepad
  77995. */
  77996. export class GenericPad extends Gamepad {
  77997. private _buttons;
  77998. private _onbuttondown;
  77999. private _onbuttonup;
  78000. /**
  78001. * Observable triggered when a button has been pressed
  78002. */
  78003. onButtonDownObservable: Observable<number>;
  78004. /**
  78005. * Observable triggered when a button has been released
  78006. */
  78007. onButtonUpObservable: Observable<number>;
  78008. /**
  78009. * Callback triggered when a button has been pressed
  78010. * @param callback Called when a button has been pressed
  78011. */
  78012. onbuttondown(callback: (buttonPressed: number) => void): void;
  78013. /**
  78014. * Callback triggered when a button has been released
  78015. * @param callback Called when a button has been released
  78016. */
  78017. onbuttonup(callback: (buttonReleased: number) => void): void;
  78018. /**
  78019. * Initializes the generic gamepad
  78020. * @param id The id of the generic gamepad
  78021. * @param index The index of the generic gamepad
  78022. * @param browserGamepad The browser gamepad
  78023. */
  78024. constructor(id: string, index: number, browserGamepad: any);
  78025. private _setButtonValue;
  78026. /**
  78027. * Updates the generic gamepad
  78028. */
  78029. update(): void;
  78030. /**
  78031. * Disposes the generic gamepad
  78032. */
  78033. dispose(): void;
  78034. }
  78035. }
  78036. declare module BABYLON {
  78037. interface Engine {
  78038. /**
  78039. * Creates a raw texture
  78040. * @param data defines the data to store in the texture
  78041. * @param width defines the width of the texture
  78042. * @param height defines the height of the texture
  78043. * @param format defines the format of the data
  78044. * @param generateMipMaps defines if the engine should generate the mip levels
  78045. * @param invertY defines if data must be stored with Y axis inverted
  78046. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  78047. * @param compression defines the compression used (null by default)
  78048. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78049. * @returns the raw texture inside an InternalTexture
  78050. */
  78051. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  78052. /**
  78053. * Update a raw texture
  78054. * @param texture defines the texture to update
  78055. * @param data defines the data to store in the texture
  78056. * @param format defines the format of the data
  78057. * @param invertY defines if data must be stored with Y axis inverted
  78058. */
  78059. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  78060. /**
  78061. * Update a raw texture
  78062. * @param texture defines the texture to update
  78063. * @param data defines the data to store in the texture
  78064. * @param format defines the format of the data
  78065. * @param invertY defines if data must be stored with Y axis inverted
  78066. * @param compression defines the compression used (null by default)
  78067. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78068. */
  78069. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  78070. /**
  78071. * Creates a new raw cube texture
  78072. * @param data defines the array of data to use to create each face
  78073. * @param size defines the size of the textures
  78074. * @param format defines the format of the data
  78075. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78076. * @param generateMipMaps defines if the engine should generate the mip levels
  78077. * @param invertY defines if data must be stored with Y axis inverted
  78078. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78079. * @param compression defines the compression used (null by default)
  78080. * @returns the cube texture as an InternalTexture
  78081. */
  78082. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  78083. /**
  78084. * Update a raw cube texture
  78085. * @param texture defines the texture to udpdate
  78086. * @param data defines the data to store
  78087. * @param format defines the data format
  78088. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78089. * @param invertY defines if data must be stored with Y axis inverted
  78090. */
  78091. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  78092. /**
  78093. * Update a raw cube texture
  78094. * @param texture defines the texture to udpdate
  78095. * @param data defines the data to store
  78096. * @param format defines the data format
  78097. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78098. * @param invertY defines if data must be stored with Y axis inverted
  78099. * @param compression defines the compression used (null by default)
  78100. */
  78101. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  78102. /**
  78103. * Update a raw cube texture
  78104. * @param texture defines the texture to udpdate
  78105. * @param data defines the data to store
  78106. * @param format defines the data format
  78107. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78108. * @param invertY defines if data must be stored with Y axis inverted
  78109. * @param compression defines the compression used (null by default)
  78110. * @param level defines which level of the texture to update
  78111. */
  78112. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  78113. /**
  78114. * Creates a new raw cube texture from a specified url
  78115. * @param url defines the url where the data is located
  78116. * @param scene defines the current scene
  78117. * @param size defines the size of the textures
  78118. * @param format defines the format of the data
  78119. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78120. * @param noMipmap defines if the engine should avoid generating the mip levels
  78121. * @param callback defines a callback used to extract texture data from loaded data
  78122. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  78123. * @param onLoad defines a callback called when texture is loaded
  78124. * @param onError defines a callback called if there is an error
  78125. * @returns the cube texture as an InternalTexture
  78126. */
  78127. 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;
  78128. /**
  78129. * Creates a new raw cube texture from a specified url
  78130. * @param url defines the url where the data is located
  78131. * @param scene defines the current scene
  78132. * @param size defines the size of the textures
  78133. * @param format defines the format of the data
  78134. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78135. * @param noMipmap defines if the engine should avoid generating the mip levels
  78136. * @param callback defines a callback used to extract texture data from loaded data
  78137. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  78138. * @param onLoad defines a callback called when texture is loaded
  78139. * @param onError defines a callback called if there is an error
  78140. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78141. * @param invertY defines if data must be stored with Y axis inverted
  78142. * @returns the cube texture as an InternalTexture
  78143. */
  78144. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>, samplingMode: number, invertY: boolean): InternalTexture;
  78145. /**
  78146. * Creates a new raw 3D texture
  78147. * @param data defines the data used to create the texture
  78148. * @param width defines the width of the texture
  78149. * @param height defines the height of the texture
  78150. * @param depth defines the depth of the texture
  78151. * @param format defines the format of the texture
  78152. * @param generateMipMaps defines if the engine must generate mip levels
  78153. * @param invertY defines if data must be stored with Y axis inverted
  78154. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78155. * @param compression defines the compressed used (can be null)
  78156. * @param textureType defines the compressed used (can be null)
  78157. * @returns a new raw 3D texture (stored in an InternalTexture)
  78158. */
  78159. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  78160. /**
  78161. * Update a raw 3D texture
  78162. * @param texture defines the texture to update
  78163. * @param data defines the data to store
  78164. * @param format defines the data format
  78165. * @param invertY defines if data must be stored with Y axis inverted
  78166. */
  78167. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  78168. /**
  78169. * Update a raw 3D texture
  78170. * @param texture defines the texture to update
  78171. * @param data defines the data to store
  78172. * @param format defines the data format
  78173. * @param invertY defines if data must be stored with Y axis inverted
  78174. * @param compression defines the used compression (can be null)
  78175. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  78176. */
  78177. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  78178. }
  78179. }
  78180. declare module BABYLON {
  78181. /**
  78182. * Raw texture can help creating a texture directly from an array of data.
  78183. * This can be super useful if you either get the data from an uncompressed source or
  78184. * if you wish to create your texture pixel by pixel.
  78185. */
  78186. export class RawTexture extends Texture {
  78187. /**
  78188. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78189. */
  78190. format: number;
  78191. private _engine;
  78192. /**
  78193. * Instantiates a new RawTexture.
  78194. * Raw texture can help creating a texture directly from an array of data.
  78195. * This can be super useful if you either get the data from an uncompressed source or
  78196. * if you wish to create your texture pixel by pixel.
  78197. * @param data define the array of data to use to create the texture
  78198. * @param width define the width of the texture
  78199. * @param height define the height of the texture
  78200. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78201. * @param scene define the scene the texture belongs to
  78202. * @param generateMipMaps define whether mip maps should be generated or not
  78203. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78204. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78205. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78206. */
  78207. constructor(data: ArrayBufferView, width: number, height: number,
  78208. /**
  78209. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78210. */
  78211. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  78212. /**
  78213. * Updates the texture underlying data.
  78214. * @param data Define the new data of the texture
  78215. */
  78216. update(data: ArrayBufferView): void;
  78217. /**
  78218. * Creates a luminance texture from some data.
  78219. * @param data Define the texture data
  78220. * @param width Define the width of the texture
  78221. * @param height Define the height of the texture
  78222. * @param scene Define the scene the texture belongs to
  78223. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78224. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78225. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78226. * @returns the luminance texture
  78227. */
  78228. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78229. /**
  78230. * Creates a luminance alpha texture from some data.
  78231. * @param data Define the texture data
  78232. * @param width Define the width of the texture
  78233. * @param height Define the height of the texture
  78234. * @param scene Define the scene the texture belongs to
  78235. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78236. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78237. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78238. * @returns the luminance alpha texture
  78239. */
  78240. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78241. /**
  78242. * Creates an alpha texture from some data.
  78243. * @param data Define the texture data
  78244. * @param width Define the width of the texture
  78245. * @param height Define the height of the texture
  78246. * @param scene Define the scene the texture belongs to
  78247. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78248. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78249. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78250. * @returns the alpha texture
  78251. */
  78252. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78253. /**
  78254. * Creates a RGB texture from some data.
  78255. * @param data Define the texture data
  78256. * @param width Define the width of the texture
  78257. * @param height Define the height of the texture
  78258. * @param scene Define the scene the texture belongs to
  78259. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78260. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78261. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78262. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78263. * @returns the RGB alpha texture
  78264. */
  78265. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  78266. /**
  78267. * Creates a RGBA texture from some data.
  78268. * @param data Define the texture data
  78269. * @param width Define the width of the texture
  78270. * @param height Define the height of the texture
  78271. * @param scene Define the scene the texture belongs to
  78272. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78273. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78274. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78275. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78276. * @returns the RGBA texture
  78277. */
  78278. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  78279. /**
  78280. * Creates a R texture from some data.
  78281. * @param data Define the texture data
  78282. * @param width Define the width of the texture
  78283. * @param height Define the height of the texture
  78284. * @param scene Define the scene the texture belongs to
  78285. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78286. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78287. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78288. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78289. * @returns the R texture
  78290. */
  78291. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  78292. }
  78293. }
  78294. declare module BABYLON {
  78295. /**
  78296. * Interface for the size containing width and height
  78297. */
  78298. export interface ISize {
  78299. /**
  78300. * Width
  78301. */
  78302. width: number;
  78303. /**
  78304. * Heighht
  78305. */
  78306. height: number;
  78307. }
  78308. /**
  78309. * Size containing widht and height
  78310. */
  78311. export class Size implements ISize {
  78312. /**
  78313. * Width
  78314. */
  78315. width: number;
  78316. /**
  78317. * Height
  78318. */
  78319. height: number;
  78320. /**
  78321. * Creates a Size object from the given width and height (floats).
  78322. * @param width width of the new size
  78323. * @param height height of the new size
  78324. */
  78325. constructor(width: number, height: number);
  78326. /**
  78327. * Returns a string with the Size width and height
  78328. * @returns a string with the Size width and height
  78329. */
  78330. toString(): string;
  78331. /**
  78332. * "Size"
  78333. * @returns the string "Size"
  78334. */
  78335. getClassName(): string;
  78336. /**
  78337. * Returns the Size hash code.
  78338. * @returns a hash code for a unique width and height
  78339. */
  78340. getHashCode(): number;
  78341. /**
  78342. * Updates the current size from the given one.
  78343. * @param src the given size
  78344. */
  78345. copyFrom(src: Size): void;
  78346. /**
  78347. * Updates in place the current Size from the given floats.
  78348. * @param width width of the new size
  78349. * @param height height of the new size
  78350. * @returns the updated Size.
  78351. */
  78352. copyFromFloats(width: number, height: number): Size;
  78353. /**
  78354. * Updates in place the current Size from the given floats.
  78355. * @param width width to set
  78356. * @param height height to set
  78357. * @returns the updated Size.
  78358. */
  78359. set(width: number, height: number): Size;
  78360. /**
  78361. * Multiplies the width and height by numbers
  78362. * @param w factor to multiple the width by
  78363. * @param h factor to multiple the height by
  78364. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  78365. */
  78366. multiplyByFloats(w: number, h: number): Size;
  78367. /**
  78368. * Clones the size
  78369. * @returns a new Size copied from the given one.
  78370. */
  78371. clone(): Size;
  78372. /**
  78373. * True if the current Size and the given one width and height are strictly equal.
  78374. * @param other the other size to compare against
  78375. * @returns True if the current Size and the given one width and height are strictly equal.
  78376. */
  78377. equals(other: Size): boolean;
  78378. /**
  78379. * The surface of the Size : width * height (float).
  78380. */
  78381. readonly surface: number;
  78382. /**
  78383. * Create a new size of zero
  78384. * @returns a new Size set to (0.0, 0.0)
  78385. */
  78386. static Zero(): Size;
  78387. /**
  78388. * Sums the width and height of two sizes
  78389. * @param otherSize size to add to this size
  78390. * @returns a new Size set as the addition result of the current Size and the given one.
  78391. */
  78392. add(otherSize: Size): Size;
  78393. /**
  78394. * Subtracts the width and height of two
  78395. * @param otherSize size to subtract to this size
  78396. * @returns a new Size set as the subtraction result of the given one from the current Size.
  78397. */
  78398. subtract(otherSize: Size): Size;
  78399. /**
  78400. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  78401. * @param start starting size to lerp between
  78402. * @param end end size to lerp between
  78403. * @param amount amount to lerp between the start and end values
  78404. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  78405. */
  78406. static Lerp(start: Size, end: Size, amount: number): Size;
  78407. }
  78408. }
  78409. declare module BABYLON {
  78410. /**
  78411. * Defines a runtime animation
  78412. */
  78413. export class RuntimeAnimation {
  78414. private _events;
  78415. /**
  78416. * The current frame of the runtime animation
  78417. */
  78418. private _currentFrame;
  78419. /**
  78420. * The animation used by the runtime animation
  78421. */
  78422. private _animation;
  78423. /**
  78424. * The target of the runtime animation
  78425. */
  78426. private _target;
  78427. /**
  78428. * The initiating animatable
  78429. */
  78430. private _host;
  78431. /**
  78432. * The original value of the runtime animation
  78433. */
  78434. private _originalValue;
  78435. /**
  78436. * The original blend value of the runtime animation
  78437. */
  78438. private _originalBlendValue;
  78439. /**
  78440. * The offsets cache of the runtime animation
  78441. */
  78442. private _offsetsCache;
  78443. /**
  78444. * The high limits cache of the runtime animation
  78445. */
  78446. private _highLimitsCache;
  78447. /**
  78448. * Specifies if the runtime animation has been stopped
  78449. */
  78450. private _stopped;
  78451. /**
  78452. * The blending factor of the runtime animation
  78453. */
  78454. private _blendingFactor;
  78455. /**
  78456. * The BabylonJS scene
  78457. */
  78458. private _scene;
  78459. /**
  78460. * The current value of the runtime animation
  78461. */
  78462. private _currentValue;
  78463. /** @hidden */
  78464. _animationState: _IAnimationState;
  78465. /**
  78466. * The active target of the runtime animation
  78467. */
  78468. private _activeTargets;
  78469. private _currentActiveTarget;
  78470. private _directTarget;
  78471. /**
  78472. * The target path of the runtime animation
  78473. */
  78474. private _targetPath;
  78475. /**
  78476. * The weight of the runtime animation
  78477. */
  78478. private _weight;
  78479. /**
  78480. * The ratio offset of the runtime animation
  78481. */
  78482. private _ratioOffset;
  78483. /**
  78484. * The previous delay of the runtime animation
  78485. */
  78486. private _previousDelay;
  78487. /**
  78488. * The previous ratio of the runtime animation
  78489. */
  78490. private _previousRatio;
  78491. private _enableBlending;
  78492. private _keys;
  78493. private _minFrame;
  78494. private _maxFrame;
  78495. private _minValue;
  78496. private _maxValue;
  78497. private _targetIsArray;
  78498. /**
  78499. * Gets the current frame of the runtime animation
  78500. */
  78501. readonly currentFrame: number;
  78502. /**
  78503. * Gets the weight of the runtime animation
  78504. */
  78505. readonly weight: number;
  78506. /**
  78507. * Gets the current value of the runtime animation
  78508. */
  78509. readonly currentValue: any;
  78510. /**
  78511. * Gets the target path of the runtime animation
  78512. */
  78513. readonly targetPath: string;
  78514. /**
  78515. * Gets the actual target of the runtime animation
  78516. */
  78517. readonly target: any;
  78518. /** @hidden */
  78519. _onLoop: () => void;
  78520. /**
  78521. * Create a new RuntimeAnimation object
  78522. * @param target defines the target of the animation
  78523. * @param animation defines the source animation object
  78524. * @param scene defines the hosting scene
  78525. * @param host defines the initiating Animatable
  78526. */
  78527. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  78528. private _preparePath;
  78529. /**
  78530. * Gets the animation from the runtime animation
  78531. */
  78532. readonly animation: Animation;
  78533. /**
  78534. * Resets the runtime animation to the beginning
  78535. * @param restoreOriginal defines whether to restore the target property to the original value
  78536. */
  78537. reset(restoreOriginal?: boolean): void;
  78538. /**
  78539. * Specifies if the runtime animation is stopped
  78540. * @returns Boolean specifying if the runtime animation is stopped
  78541. */
  78542. isStopped(): boolean;
  78543. /**
  78544. * Disposes of the runtime animation
  78545. */
  78546. dispose(): void;
  78547. /**
  78548. * Apply the interpolated value to the target
  78549. * @param currentValue defines the value computed by the animation
  78550. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  78551. */
  78552. setValue(currentValue: any, weight: number): void;
  78553. private _getOriginalValues;
  78554. private _setValue;
  78555. /**
  78556. * Gets the loop pmode of the runtime animation
  78557. * @returns Loop Mode
  78558. */
  78559. private _getCorrectLoopMode;
  78560. /**
  78561. * Move the current animation to a given frame
  78562. * @param frame defines the frame to move to
  78563. */
  78564. goToFrame(frame: number): void;
  78565. /**
  78566. * @hidden Internal use only
  78567. */
  78568. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  78569. /**
  78570. * Execute the current animation
  78571. * @param delay defines the delay to add to the current frame
  78572. * @param from defines the lower bound of the animation range
  78573. * @param to defines the upper bound of the animation range
  78574. * @param loop defines if the current animation must loop
  78575. * @param speedRatio defines the current speed ratio
  78576. * @param weight defines the weight of the animation (default is -1 so no weight)
  78577. * @param onLoop optional callback called when animation loops
  78578. * @returns a boolean indicating if the animation is running
  78579. */
  78580. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  78581. }
  78582. }
  78583. declare module BABYLON {
  78584. /**
  78585. * Class used to store an actual running animation
  78586. */
  78587. export class Animatable {
  78588. /** defines the target object */
  78589. target: any;
  78590. /** defines the starting frame number (default is 0) */
  78591. fromFrame: number;
  78592. /** defines the ending frame number (default is 100) */
  78593. toFrame: number;
  78594. /** defines if the animation must loop (default is false) */
  78595. loopAnimation: boolean;
  78596. /** defines a callback to call when animation ends if it is not looping */
  78597. onAnimationEnd?: (() => void) | null | undefined;
  78598. /** defines a callback to call when animation loops */
  78599. onAnimationLoop?: (() => void) | null | undefined;
  78600. private _localDelayOffset;
  78601. private _pausedDelay;
  78602. private _runtimeAnimations;
  78603. private _paused;
  78604. private _scene;
  78605. private _speedRatio;
  78606. private _weight;
  78607. private _syncRoot;
  78608. /**
  78609. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  78610. * This will only apply for non looping animation (default is true)
  78611. */
  78612. disposeOnEnd: boolean;
  78613. /**
  78614. * Gets a boolean indicating if the animation has started
  78615. */
  78616. animationStarted: boolean;
  78617. /**
  78618. * Observer raised when the animation ends
  78619. */
  78620. onAnimationEndObservable: Observable<Animatable>;
  78621. /**
  78622. * Observer raised when the animation loops
  78623. */
  78624. onAnimationLoopObservable: Observable<Animatable>;
  78625. /**
  78626. * Gets the root Animatable used to synchronize and normalize animations
  78627. */
  78628. readonly syncRoot: Nullable<Animatable>;
  78629. /**
  78630. * Gets the current frame of the first RuntimeAnimation
  78631. * Used to synchronize Animatables
  78632. */
  78633. readonly masterFrame: number;
  78634. /**
  78635. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  78636. */
  78637. weight: number;
  78638. /**
  78639. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  78640. */
  78641. speedRatio: number;
  78642. /**
  78643. * Creates a new Animatable
  78644. * @param scene defines the hosting scene
  78645. * @param target defines the target object
  78646. * @param fromFrame defines the starting frame number (default is 0)
  78647. * @param toFrame defines the ending frame number (default is 100)
  78648. * @param loopAnimation defines if the animation must loop (default is false)
  78649. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  78650. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  78651. * @param animations defines a group of animation to add to the new Animatable
  78652. * @param onAnimationLoop defines a callback to call when animation loops
  78653. */
  78654. constructor(scene: Scene,
  78655. /** defines the target object */
  78656. target: any,
  78657. /** defines the starting frame number (default is 0) */
  78658. fromFrame?: number,
  78659. /** defines the ending frame number (default is 100) */
  78660. toFrame?: number,
  78661. /** defines if the animation must loop (default is false) */
  78662. loopAnimation?: boolean, speedRatio?: number,
  78663. /** defines a callback to call when animation ends if it is not looping */
  78664. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  78665. /** defines a callback to call when animation loops */
  78666. onAnimationLoop?: (() => void) | null | undefined);
  78667. /**
  78668. * Synchronize and normalize current Animatable with a source Animatable
  78669. * This is useful when using animation weights and when animations are not of the same length
  78670. * @param root defines the root Animatable to synchronize with
  78671. * @returns the current Animatable
  78672. */
  78673. syncWith(root: Animatable): Animatable;
  78674. /**
  78675. * Gets the list of runtime animations
  78676. * @returns an array of RuntimeAnimation
  78677. */
  78678. getAnimations(): RuntimeAnimation[];
  78679. /**
  78680. * Adds more animations to the current animatable
  78681. * @param target defines the target of the animations
  78682. * @param animations defines the new animations to add
  78683. */
  78684. appendAnimations(target: any, animations: Animation[]): void;
  78685. /**
  78686. * Gets the source animation for a specific property
  78687. * @param property defines the propertyu to look for
  78688. * @returns null or the source animation for the given property
  78689. */
  78690. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  78691. /**
  78692. * Gets the runtime animation for a specific property
  78693. * @param property defines the propertyu to look for
  78694. * @returns null or the runtime animation for the given property
  78695. */
  78696. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  78697. /**
  78698. * Resets the animatable to its original state
  78699. */
  78700. reset(): void;
  78701. /**
  78702. * Allows the animatable to blend with current running animations
  78703. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  78704. * @param blendingSpeed defines the blending speed to use
  78705. */
  78706. enableBlending(blendingSpeed: number): void;
  78707. /**
  78708. * Disable animation blending
  78709. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  78710. */
  78711. disableBlending(): void;
  78712. /**
  78713. * Jump directly to a given frame
  78714. * @param frame defines the frame to jump to
  78715. */
  78716. goToFrame(frame: number): void;
  78717. /**
  78718. * Pause the animation
  78719. */
  78720. pause(): void;
  78721. /**
  78722. * Restart the animation
  78723. */
  78724. restart(): void;
  78725. private _raiseOnAnimationEnd;
  78726. /**
  78727. * Stop and delete the current animation
  78728. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  78729. * @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)
  78730. */
  78731. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  78732. /**
  78733. * Wait asynchronously for the animation to end
  78734. * @returns a promise which will be fullfilled when the animation ends
  78735. */
  78736. waitAsync(): Promise<Animatable>;
  78737. /** @hidden */
  78738. _animate(delay: number): boolean;
  78739. }
  78740. interface Scene {
  78741. /** @hidden */
  78742. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  78743. /** @hidden */
  78744. _processLateAnimationBindingsForMatrices(holder: {
  78745. totalWeight: number;
  78746. animations: RuntimeAnimation[];
  78747. originalValue: Matrix;
  78748. }): any;
  78749. /** @hidden */
  78750. _processLateAnimationBindingsForQuaternions(holder: {
  78751. totalWeight: number;
  78752. animations: RuntimeAnimation[];
  78753. originalValue: Quaternion;
  78754. }, refQuaternion: Quaternion): Quaternion;
  78755. /** @hidden */
  78756. _processLateAnimationBindings(): void;
  78757. /**
  78758. * Will start the animation sequence of a given target
  78759. * @param target defines the target
  78760. * @param from defines from which frame should animation start
  78761. * @param to defines until which frame should animation run.
  78762. * @param weight defines the weight to apply to the animation (1.0 by default)
  78763. * @param loop defines if the animation loops
  78764. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78765. * @param onAnimationEnd defines the function to be executed when the animation ends
  78766. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78767. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  78768. * @param onAnimationLoop defines the callback to call when an animation loops
  78769. * @returns the animatable object created for this animation
  78770. */
  78771. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  78772. /**
  78773. * Will start the animation sequence of a given target
  78774. * @param target defines the target
  78775. * @param from defines from which frame should animation start
  78776. * @param to defines until which frame should animation run.
  78777. * @param loop defines if the animation loops
  78778. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78779. * @param onAnimationEnd defines the function to be executed when the animation ends
  78780. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78781. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  78782. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  78783. * @param onAnimationLoop defines the callback to call when an animation loops
  78784. * @returns the animatable object created for this animation
  78785. */
  78786. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  78787. /**
  78788. * Will start the animation sequence of a given target and its hierarchy
  78789. * @param target defines the target
  78790. * @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.
  78791. * @param from defines from which frame should animation start
  78792. * @param to defines until which frame should animation run.
  78793. * @param loop defines if the animation loops
  78794. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78795. * @param onAnimationEnd defines the function to be executed when the animation ends
  78796. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78797. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  78798. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  78799. * @param onAnimationLoop defines the callback to call when an animation loops
  78800. * @returns the list of created animatables
  78801. */
  78802. 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[];
  78803. /**
  78804. * Begin a new animation on a given node
  78805. * @param target defines the target where the animation will take place
  78806. * @param animations defines the list of animations to start
  78807. * @param from defines the initial value
  78808. * @param to defines the final value
  78809. * @param loop defines if you want animation to loop (off by default)
  78810. * @param speedRatio defines the speed ratio to apply to all animations
  78811. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  78812. * @param onAnimationLoop defines the callback to call when an animation loops
  78813. * @returns the list of created animatables
  78814. */
  78815. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  78816. /**
  78817. * Begin a new animation on a given node and its hierarchy
  78818. * @param target defines the root node where the animation will take place
  78819. * @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.
  78820. * @param animations defines the list of animations to start
  78821. * @param from defines the initial value
  78822. * @param to defines the final value
  78823. * @param loop defines if you want animation to loop (off by default)
  78824. * @param speedRatio defines the speed ratio to apply to all animations
  78825. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  78826. * @param onAnimationLoop defines the callback to call when an animation loops
  78827. * @returns the list of animatables created for all nodes
  78828. */
  78829. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  78830. /**
  78831. * Gets the animatable associated with a specific target
  78832. * @param target defines the target of the animatable
  78833. * @returns the required animatable if found
  78834. */
  78835. getAnimatableByTarget(target: any): Nullable<Animatable>;
  78836. /**
  78837. * Gets all animatables associated with a given target
  78838. * @param target defines the target to look animatables for
  78839. * @returns an array of Animatables
  78840. */
  78841. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  78842. /**
  78843. * Stops and removes all animations that have been applied to the scene
  78844. */
  78845. stopAllAnimations(): void;
  78846. }
  78847. interface Bone {
  78848. /**
  78849. * Copy an animation range from another bone
  78850. * @param source defines the source bone
  78851. * @param rangeName defines the range name to copy
  78852. * @param frameOffset defines the frame offset
  78853. * @param rescaleAsRequired defines if rescaling must be applied if required
  78854. * @param skelDimensionsRatio defines the scaling ratio
  78855. * @returns true if operation was successful
  78856. */
  78857. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  78858. }
  78859. }
  78860. declare module BABYLON {
  78861. /**
  78862. * Class used to override all child animations of a given target
  78863. */
  78864. export class AnimationPropertiesOverride {
  78865. /**
  78866. * Gets or sets a value indicating if animation blending must be used
  78867. */
  78868. enableBlending: boolean;
  78869. /**
  78870. * Gets or sets the blending speed to use when enableBlending is true
  78871. */
  78872. blendingSpeed: number;
  78873. /**
  78874. * Gets or sets the default loop mode to use
  78875. */
  78876. loopMode: number;
  78877. }
  78878. }
  78879. declare module BABYLON {
  78880. /**
  78881. * Class used to handle skinning animations
  78882. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  78883. */
  78884. export class Skeleton implements IAnimatable {
  78885. /** defines the skeleton name */
  78886. name: string;
  78887. /** defines the skeleton Id */
  78888. id: string;
  78889. /**
  78890. * Defines the list of child bones
  78891. */
  78892. bones: Bone[];
  78893. /**
  78894. * Defines an estimate of the dimension of the skeleton at rest
  78895. */
  78896. dimensionsAtRest: Vector3;
  78897. /**
  78898. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  78899. */
  78900. needInitialSkinMatrix: boolean;
  78901. /**
  78902. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  78903. */
  78904. overrideMesh: Nullable<AbstractMesh>;
  78905. /**
  78906. * Gets the list of animations attached to this skeleton
  78907. */
  78908. animations: Array<Animation>;
  78909. private _scene;
  78910. private _isDirty;
  78911. private _transformMatrices;
  78912. private _transformMatrixTexture;
  78913. private _meshesWithPoseMatrix;
  78914. private _animatables;
  78915. private _identity;
  78916. private _synchronizedWithMesh;
  78917. private _ranges;
  78918. private _lastAbsoluteTransformsUpdateId;
  78919. private _canUseTextureForBones;
  78920. private _uniqueId;
  78921. /** @hidden */
  78922. _numBonesWithLinkedTransformNode: number;
  78923. /** @hidden */
  78924. _hasWaitingData: Nullable<boolean>;
  78925. /**
  78926. * Specifies if the skeleton should be serialized
  78927. */
  78928. doNotSerialize: boolean;
  78929. private _useTextureToStoreBoneMatrices;
  78930. /**
  78931. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  78932. * Please note that this option is not available if the hardware does not support it
  78933. */
  78934. useTextureToStoreBoneMatrices: boolean;
  78935. private _animationPropertiesOverride;
  78936. /**
  78937. * Gets or sets the animation properties override
  78938. */
  78939. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  78940. /**
  78941. * List of inspectable custom properties (used by the Inspector)
  78942. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  78943. */
  78944. inspectableCustomProperties: IInspectable[];
  78945. /**
  78946. * An observable triggered before computing the skeleton's matrices
  78947. */
  78948. onBeforeComputeObservable: Observable<Skeleton>;
  78949. /**
  78950. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  78951. */
  78952. readonly isUsingTextureForMatrices: boolean;
  78953. /**
  78954. * Gets the unique ID of this skeleton
  78955. */
  78956. readonly uniqueId: number;
  78957. /**
  78958. * Creates a new skeleton
  78959. * @param name defines the skeleton name
  78960. * @param id defines the skeleton Id
  78961. * @param scene defines the hosting scene
  78962. */
  78963. constructor(
  78964. /** defines the skeleton name */
  78965. name: string,
  78966. /** defines the skeleton Id */
  78967. id: string, scene: Scene);
  78968. /**
  78969. * Gets the current object class name.
  78970. * @return the class name
  78971. */
  78972. getClassName(): string;
  78973. /**
  78974. * Returns an array containing the root bones
  78975. * @returns an array containing the root bones
  78976. */
  78977. getChildren(): Array<Bone>;
  78978. /**
  78979. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  78980. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  78981. * @returns a Float32Array containing matrices data
  78982. */
  78983. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  78984. /**
  78985. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  78986. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  78987. * @returns a raw texture containing the data
  78988. */
  78989. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  78990. /**
  78991. * Gets the current hosting scene
  78992. * @returns a scene object
  78993. */
  78994. getScene(): Scene;
  78995. /**
  78996. * Gets a string representing the current skeleton data
  78997. * @param fullDetails defines a boolean indicating if we want a verbose version
  78998. * @returns a string representing the current skeleton data
  78999. */
  79000. toString(fullDetails?: boolean): string;
  79001. /**
  79002. * Get bone's index searching by name
  79003. * @param name defines bone's name to search for
  79004. * @return the indice of the bone. Returns -1 if not found
  79005. */
  79006. getBoneIndexByName(name: string): number;
  79007. /**
  79008. * Creater a new animation range
  79009. * @param name defines the name of the range
  79010. * @param from defines the start key
  79011. * @param to defines the end key
  79012. */
  79013. createAnimationRange(name: string, from: number, to: number): void;
  79014. /**
  79015. * Delete a specific animation range
  79016. * @param name defines the name of the range
  79017. * @param deleteFrames defines if frames must be removed as well
  79018. */
  79019. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  79020. /**
  79021. * Gets a specific animation range
  79022. * @param name defines the name of the range to look for
  79023. * @returns the requested animation range or null if not found
  79024. */
  79025. getAnimationRange(name: string): Nullable<AnimationRange>;
  79026. /**
  79027. * Gets the list of all animation ranges defined on this skeleton
  79028. * @returns an array
  79029. */
  79030. getAnimationRanges(): Nullable<AnimationRange>[];
  79031. /**
  79032. * Copy animation range from a source skeleton.
  79033. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  79034. * @param source defines the source skeleton
  79035. * @param name defines the name of the range to copy
  79036. * @param rescaleAsRequired defines if rescaling must be applied if required
  79037. * @returns true if operation was successful
  79038. */
  79039. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  79040. /**
  79041. * Forces the skeleton to go to rest pose
  79042. */
  79043. returnToRest(): void;
  79044. private _getHighestAnimationFrame;
  79045. /**
  79046. * Begin a specific animation range
  79047. * @param name defines the name of the range to start
  79048. * @param loop defines if looping must be turned on (false by default)
  79049. * @param speedRatio defines the speed ratio to apply (1 by default)
  79050. * @param onAnimationEnd defines a callback which will be called when animation will end
  79051. * @returns a new animatable
  79052. */
  79053. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  79054. /** @hidden */
  79055. _markAsDirty(): void;
  79056. /** @hidden */
  79057. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  79058. /** @hidden */
  79059. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  79060. private _computeTransformMatrices;
  79061. /**
  79062. * Build all resources required to render a skeleton
  79063. */
  79064. prepare(): void;
  79065. /**
  79066. * Gets the list of animatables currently running for this skeleton
  79067. * @returns an array of animatables
  79068. */
  79069. getAnimatables(): IAnimatable[];
  79070. /**
  79071. * Clone the current skeleton
  79072. * @param name defines the name of the new skeleton
  79073. * @param id defines the id of the new skeleton
  79074. * @returns the new skeleton
  79075. */
  79076. clone(name: string, id: string): Skeleton;
  79077. /**
  79078. * Enable animation blending for this skeleton
  79079. * @param blendingSpeed defines the blending speed to apply
  79080. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  79081. */
  79082. enableBlending(blendingSpeed?: number): void;
  79083. /**
  79084. * Releases all resources associated with the current skeleton
  79085. */
  79086. dispose(): void;
  79087. /**
  79088. * Serialize the skeleton in a JSON object
  79089. * @returns a JSON object
  79090. */
  79091. serialize(): any;
  79092. /**
  79093. * Creates a new skeleton from serialized data
  79094. * @param parsedSkeleton defines the serialized data
  79095. * @param scene defines the hosting scene
  79096. * @returns a new skeleton
  79097. */
  79098. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  79099. /**
  79100. * Compute all node absolute transforms
  79101. * @param forceUpdate defines if computation must be done even if cache is up to date
  79102. */
  79103. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  79104. /**
  79105. * Gets the root pose matrix
  79106. * @returns a matrix
  79107. */
  79108. getPoseMatrix(): Nullable<Matrix>;
  79109. /**
  79110. * Sorts bones per internal index
  79111. */
  79112. sortBones(): void;
  79113. private _sortBones;
  79114. }
  79115. }
  79116. declare module BABYLON {
  79117. /**
  79118. * Class used to store bone information
  79119. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  79120. */
  79121. export class Bone extends Node {
  79122. /**
  79123. * defines the bone name
  79124. */
  79125. name: string;
  79126. private static _tmpVecs;
  79127. private static _tmpQuat;
  79128. private static _tmpMats;
  79129. /**
  79130. * Gets the list of child bones
  79131. */
  79132. children: Bone[];
  79133. /** Gets the animations associated with this bone */
  79134. animations: Animation[];
  79135. /**
  79136. * Gets or sets bone length
  79137. */
  79138. length: number;
  79139. /**
  79140. * @hidden Internal only
  79141. * Set this value to map this bone to a different index in the transform matrices
  79142. * Set this value to -1 to exclude the bone from the transform matrices
  79143. */
  79144. _index: Nullable<number>;
  79145. private _skeleton;
  79146. private _localMatrix;
  79147. private _restPose;
  79148. private _baseMatrix;
  79149. private _absoluteTransform;
  79150. private _invertedAbsoluteTransform;
  79151. private _parent;
  79152. private _scalingDeterminant;
  79153. private _worldTransform;
  79154. private _localScaling;
  79155. private _localRotation;
  79156. private _localPosition;
  79157. private _needToDecompose;
  79158. private _needToCompose;
  79159. /** @hidden */
  79160. _linkedTransformNode: Nullable<TransformNode>;
  79161. /** @hidden */
  79162. _waitingTransformNodeId: Nullable<string>;
  79163. /** @hidden */
  79164. /** @hidden */
  79165. _matrix: Matrix;
  79166. /**
  79167. * Create a new bone
  79168. * @param name defines the bone name
  79169. * @param skeleton defines the parent skeleton
  79170. * @param parentBone defines the parent (can be null if the bone is the root)
  79171. * @param localMatrix defines the local matrix
  79172. * @param restPose defines the rest pose matrix
  79173. * @param baseMatrix defines the base matrix
  79174. * @param index defines index of the bone in the hiearchy
  79175. */
  79176. constructor(
  79177. /**
  79178. * defines the bone name
  79179. */
  79180. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  79181. /**
  79182. * Gets the current object class name.
  79183. * @return the class name
  79184. */
  79185. getClassName(): string;
  79186. /**
  79187. * Gets the parent skeleton
  79188. * @returns a skeleton
  79189. */
  79190. getSkeleton(): Skeleton;
  79191. /**
  79192. * Gets parent bone
  79193. * @returns a bone or null if the bone is the root of the bone hierarchy
  79194. */
  79195. getParent(): Nullable<Bone>;
  79196. /**
  79197. * Returns an array containing the root bones
  79198. * @returns an array containing the root bones
  79199. */
  79200. getChildren(): Array<Bone>;
  79201. /**
  79202. * Sets the parent bone
  79203. * @param parent defines the parent (can be null if the bone is the root)
  79204. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  79205. */
  79206. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  79207. /**
  79208. * Gets the local matrix
  79209. * @returns a matrix
  79210. */
  79211. getLocalMatrix(): Matrix;
  79212. /**
  79213. * Gets the base matrix (initial matrix which remains unchanged)
  79214. * @returns a matrix
  79215. */
  79216. getBaseMatrix(): Matrix;
  79217. /**
  79218. * Gets the rest pose matrix
  79219. * @returns a matrix
  79220. */
  79221. getRestPose(): Matrix;
  79222. /**
  79223. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  79224. */
  79225. getWorldMatrix(): Matrix;
  79226. /**
  79227. * Sets the local matrix to rest pose matrix
  79228. */
  79229. returnToRest(): void;
  79230. /**
  79231. * Gets the inverse of the absolute transform matrix.
  79232. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  79233. * @returns a matrix
  79234. */
  79235. getInvertedAbsoluteTransform(): Matrix;
  79236. /**
  79237. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  79238. * @returns a matrix
  79239. */
  79240. getAbsoluteTransform(): Matrix;
  79241. /**
  79242. * Links with the given transform node.
  79243. * The local matrix of this bone is copied from the transform node every frame.
  79244. * @param transformNode defines the transform node to link to
  79245. */
  79246. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  79247. /**
  79248. * Gets the node used to drive the bone's transformation
  79249. * @returns a transform node or null
  79250. */
  79251. getTransformNode(): Nullable<TransformNode>;
  79252. /** Gets or sets current position (in local space) */
  79253. position: Vector3;
  79254. /** Gets or sets current rotation (in local space) */
  79255. rotation: Vector3;
  79256. /** Gets or sets current rotation quaternion (in local space) */
  79257. rotationQuaternion: Quaternion;
  79258. /** Gets or sets current scaling (in local space) */
  79259. scaling: Vector3;
  79260. /**
  79261. * Gets the animation properties override
  79262. */
  79263. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  79264. private _decompose;
  79265. private _compose;
  79266. /**
  79267. * Update the base and local matrices
  79268. * @param matrix defines the new base or local matrix
  79269. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  79270. * @param updateLocalMatrix defines if the local matrix should be updated
  79271. */
  79272. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  79273. /** @hidden */
  79274. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  79275. /**
  79276. * Flag the bone as dirty (Forcing it to update everything)
  79277. */
  79278. markAsDirty(): void;
  79279. /** @hidden */
  79280. _markAsDirtyAndCompose(): void;
  79281. private _markAsDirtyAndDecompose;
  79282. /**
  79283. * Translate the bone in local or world space
  79284. * @param vec The amount to translate the bone
  79285. * @param space The space that the translation is in
  79286. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79287. */
  79288. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  79289. /**
  79290. * Set the postion of the bone in local or world space
  79291. * @param position The position to set the bone
  79292. * @param space The space that the position is in
  79293. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79294. */
  79295. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  79296. /**
  79297. * Set the absolute position of the bone (world space)
  79298. * @param position The position to set the bone
  79299. * @param mesh The mesh that this bone is attached to
  79300. */
  79301. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  79302. /**
  79303. * Scale the bone on the x, y and z axes (in local space)
  79304. * @param x The amount to scale the bone on the x axis
  79305. * @param y The amount to scale the bone on the y axis
  79306. * @param z The amount to scale the bone on the z axis
  79307. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  79308. */
  79309. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  79310. /**
  79311. * Set the bone scaling in local space
  79312. * @param scale defines the scaling vector
  79313. */
  79314. setScale(scale: Vector3): void;
  79315. /**
  79316. * Gets the current scaling in local space
  79317. * @returns the current scaling vector
  79318. */
  79319. getScale(): Vector3;
  79320. /**
  79321. * Gets the current scaling in local space and stores it in a target vector
  79322. * @param result defines the target vector
  79323. */
  79324. getScaleToRef(result: Vector3): void;
  79325. /**
  79326. * Set the yaw, pitch, and roll of the bone in local or world space
  79327. * @param yaw The rotation of the bone on the y axis
  79328. * @param pitch The rotation of the bone on the x axis
  79329. * @param roll The rotation of the bone on the z axis
  79330. * @param space The space that the axes of rotation are in
  79331. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79332. */
  79333. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  79334. /**
  79335. * Add a rotation to the bone on an axis in local or world space
  79336. * @param axis The axis to rotate the bone on
  79337. * @param amount The amount to rotate the bone
  79338. * @param space The space that the axis is in
  79339. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79340. */
  79341. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  79342. /**
  79343. * Set the rotation of the bone to a particular axis angle in local or world space
  79344. * @param axis The axis to rotate the bone on
  79345. * @param angle The angle that the bone should be rotated to
  79346. * @param space The space that the axis is in
  79347. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79348. */
  79349. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  79350. /**
  79351. * Set the euler rotation of the bone in local of world space
  79352. * @param rotation The euler rotation that the bone should be set to
  79353. * @param space The space that the rotation is in
  79354. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79355. */
  79356. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  79357. /**
  79358. * Set the quaternion rotation of the bone in local of world space
  79359. * @param quat The quaternion rotation that the bone should be set to
  79360. * @param space The space that the rotation is in
  79361. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79362. */
  79363. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  79364. /**
  79365. * Set the rotation matrix of the bone in local of world space
  79366. * @param rotMat The rotation matrix that the bone should be set to
  79367. * @param space The space that the rotation is in
  79368. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79369. */
  79370. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  79371. private _rotateWithMatrix;
  79372. private _getNegativeRotationToRef;
  79373. /**
  79374. * Get the position of the bone in local or world space
  79375. * @param space The space that the returned position is in
  79376. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79377. * @returns The position of the bone
  79378. */
  79379. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  79380. /**
  79381. * Copy the position of the bone to a vector3 in local or world space
  79382. * @param space The space that the returned position is in
  79383. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79384. * @param result The vector3 to copy the position to
  79385. */
  79386. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  79387. /**
  79388. * Get the absolute position of the bone (world space)
  79389. * @param mesh The mesh that this bone is attached to
  79390. * @returns The absolute position of the bone
  79391. */
  79392. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  79393. /**
  79394. * Copy the absolute position of the bone (world space) to the result param
  79395. * @param mesh The mesh that this bone is attached to
  79396. * @param result The vector3 to copy the absolute position to
  79397. */
  79398. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  79399. /**
  79400. * Compute the absolute transforms of this bone and its children
  79401. */
  79402. computeAbsoluteTransforms(): void;
  79403. /**
  79404. * Get the world direction from an axis that is in the local space of the bone
  79405. * @param localAxis The local direction that is used to compute the world direction
  79406. * @param mesh The mesh that this bone is attached to
  79407. * @returns The world direction
  79408. */
  79409. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  79410. /**
  79411. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  79412. * @param localAxis The local direction that is used to compute the world direction
  79413. * @param mesh The mesh that this bone is attached to
  79414. * @param result The vector3 that the world direction will be copied to
  79415. */
  79416. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  79417. /**
  79418. * Get the euler rotation of the bone in local or world space
  79419. * @param space The space that the rotation should be in
  79420. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79421. * @returns The euler rotation
  79422. */
  79423. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  79424. /**
  79425. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  79426. * @param space The space that the rotation should be in
  79427. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79428. * @param result The vector3 that the rotation should be copied to
  79429. */
  79430. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  79431. /**
  79432. * Get the quaternion rotation of the bone in either local or world space
  79433. * @param space The space that the rotation should be in
  79434. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79435. * @returns The quaternion rotation
  79436. */
  79437. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  79438. /**
  79439. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  79440. * @param space The space that the rotation should be in
  79441. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79442. * @param result The quaternion that the rotation should be copied to
  79443. */
  79444. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  79445. /**
  79446. * Get the rotation matrix of the bone in local or world space
  79447. * @param space The space that the rotation should be in
  79448. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79449. * @returns The rotation matrix
  79450. */
  79451. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  79452. /**
  79453. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  79454. * @param space The space that the rotation should be in
  79455. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79456. * @param result The quaternion that the rotation should be copied to
  79457. */
  79458. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  79459. /**
  79460. * Get the world position of a point that is in the local space of the bone
  79461. * @param position The local position
  79462. * @param mesh The mesh that this bone is attached to
  79463. * @returns The world position
  79464. */
  79465. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  79466. /**
  79467. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  79468. * @param position The local position
  79469. * @param mesh The mesh that this bone is attached to
  79470. * @param result The vector3 that the world position should be copied to
  79471. */
  79472. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  79473. /**
  79474. * Get the local position of a point that is in world space
  79475. * @param position The world position
  79476. * @param mesh The mesh that this bone is attached to
  79477. * @returns The local position
  79478. */
  79479. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  79480. /**
  79481. * Get the local position of a point that is in world space and copy it to the result param
  79482. * @param position The world position
  79483. * @param mesh The mesh that this bone is attached to
  79484. * @param result The vector3 that the local position should be copied to
  79485. */
  79486. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  79487. }
  79488. }
  79489. declare module BABYLON {
  79490. /**
  79491. * 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.
  79492. * @see https://doc.babylonjs.com/how_to/transformnode
  79493. */
  79494. export class TransformNode extends Node {
  79495. /**
  79496. * Object will not rotate to face the camera
  79497. */
  79498. static BILLBOARDMODE_NONE: number;
  79499. /**
  79500. * Object will rotate to face the camera but only on the x axis
  79501. */
  79502. static BILLBOARDMODE_X: number;
  79503. /**
  79504. * Object will rotate to face the camera but only on the y axis
  79505. */
  79506. static BILLBOARDMODE_Y: number;
  79507. /**
  79508. * Object will rotate to face the camera but only on the z axis
  79509. */
  79510. static BILLBOARDMODE_Z: number;
  79511. /**
  79512. * Object will rotate to face the camera
  79513. */
  79514. static BILLBOARDMODE_ALL: number;
  79515. /**
  79516. * Object will rotate to face the camera's position instead of orientation
  79517. */
  79518. static BILLBOARDMODE_USE_POSITION: number;
  79519. private _forward;
  79520. private _forwardInverted;
  79521. private _up;
  79522. private _right;
  79523. private _rightInverted;
  79524. private _position;
  79525. private _rotation;
  79526. private _rotationQuaternion;
  79527. protected _scaling: Vector3;
  79528. protected _isDirty: boolean;
  79529. private _transformToBoneReferal;
  79530. private _isAbsoluteSynced;
  79531. private _billboardMode;
  79532. /**
  79533. * Gets or sets the billboard mode. Default is 0.
  79534. *
  79535. * | Value | Type | Description |
  79536. * | --- | --- | --- |
  79537. * | 0 | BILLBOARDMODE_NONE | |
  79538. * | 1 | BILLBOARDMODE_X | |
  79539. * | 2 | BILLBOARDMODE_Y | |
  79540. * | 4 | BILLBOARDMODE_Z | |
  79541. * | 7 | BILLBOARDMODE_ALL | |
  79542. *
  79543. */
  79544. billboardMode: number;
  79545. private _preserveParentRotationForBillboard;
  79546. /**
  79547. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  79548. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  79549. */
  79550. preserveParentRotationForBillboard: boolean;
  79551. /**
  79552. * 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
  79553. */
  79554. scalingDeterminant: number;
  79555. private _infiniteDistance;
  79556. /**
  79557. * Gets or sets the distance of the object to max, often used by skybox
  79558. */
  79559. infiniteDistance: boolean;
  79560. /**
  79561. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  79562. * By default the system will update normals to compensate
  79563. */
  79564. ignoreNonUniformScaling: boolean;
  79565. /**
  79566. * 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
  79567. */
  79568. reIntegrateRotationIntoRotationQuaternion: boolean;
  79569. /** @hidden */
  79570. _poseMatrix: Nullable<Matrix>;
  79571. /** @hidden */
  79572. _localMatrix: Matrix;
  79573. private _usePivotMatrix;
  79574. private _absolutePosition;
  79575. private _absoluteScaling;
  79576. private _absoluteRotationQuaternion;
  79577. private _pivotMatrix;
  79578. private _pivotMatrixInverse;
  79579. protected _postMultiplyPivotMatrix: boolean;
  79580. protected _isWorldMatrixFrozen: boolean;
  79581. /** @hidden */
  79582. _indexInSceneTransformNodesArray: number;
  79583. /**
  79584. * An event triggered after the world matrix is updated
  79585. */
  79586. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  79587. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  79588. /**
  79589. * Gets a string identifying the name of the class
  79590. * @returns "TransformNode" string
  79591. */
  79592. getClassName(): string;
  79593. /**
  79594. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  79595. */
  79596. position: Vector3;
  79597. /**
  79598. * 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)).
  79599. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  79600. */
  79601. rotation: Vector3;
  79602. /**
  79603. * 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)).
  79604. */
  79605. scaling: Vector3;
  79606. /**
  79607. * 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).
  79608. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  79609. */
  79610. rotationQuaternion: Nullable<Quaternion>;
  79611. /**
  79612. * The forward direction of that transform in world space.
  79613. */
  79614. readonly forward: Vector3;
  79615. /**
  79616. * The up direction of that transform in world space.
  79617. */
  79618. readonly up: Vector3;
  79619. /**
  79620. * The right direction of that transform in world space.
  79621. */
  79622. readonly right: Vector3;
  79623. /**
  79624. * Copies the parameter passed Matrix into the mesh Pose matrix.
  79625. * @param matrix the matrix to copy the pose from
  79626. * @returns this TransformNode.
  79627. */
  79628. updatePoseMatrix(matrix: Matrix): TransformNode;
  79629. /**
  79630. * Returns the mesh Pose matrix.
  79631. * @returns the pose matrix
  79632. */
  79633. getPoseMatrix(): Matrix;
  79634. /** @hidden */
  79635. _isSynchronized(): boolean;
  79636. /** @hidden */
  79637. _initCache(): void;
  79638. /**
  79639. * Flag the transform node as dirty (Forcing it to update everything)
  79640. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  79641. * @returns this transform node
  79642. */
  79643. markAsDirty(property: string): TransformNode;
  79644. /**
  79645. * Returns the current mesh absolute position.
  79646. * Returns a Vector3.
  79647. */
  79648. readonly absolutePosition: Vector3;
  79649. /**
  79650. * Returns the current mesh absolute scaling.
  79651. * Returns a Vector3.
  79652. */
  79653. readonly absoluteScaling: Vector3;
  79654. /**
  79655. * Returns the current mesh absolute rotation.
  79656. * Returns a Quaternion.
  79657. */
  79658. readonly absoluteRotationQuaternion: Quaternion;
  79659. /**
  79660. * Sets a new matrix to apply before all other transformation
  79661. * @param matrix defines the transform matrix
  79662. * @returns the current TransformNode
  79663. */
  79664. setPreTransformMatrix(matrix: Matrix): TransformNode;
  79665. /**
  79666. * Sets a new pivot matrix to the current node
  79667. * @param matrix defines the new pivot matrix to use
  79668. * @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
  79669. * @returns the current TransformNode
  79670. */
  79671. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  79672. /**
  79673. * Returns the mesh pivot matrix.
  79674. * Default : Identity.
  79675. * @returns the matrix
  79676. */
  79677. getPivotMatrix(): Matrix;
  79678. /**
  79679. * Instantiate (when possible) or clone that node with its hierarchy
  79680. * @param newParent defines the new parent to use for the instance (or clone)
  79681. * @returns an instance (or a clone) of the current node with its hiearchy
  79682. */
  79683. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  79684. /**
  79685. * Prevents the World matrix to be computed any longer
  79686. * @param newWorldMatrix defines an optional matrix to use as world matrix
  79687. * @returns the TransformNode.
  79688. */
  79689. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  79690. /**
  79691. * Allows back the World matrix computation.
  79692. * @returns the TransformNode.
  79693. */
  79694. unfreezeWorldMatrix(): this;
  79695. /**
  79696. * True if the World matrix has been frozen.
  79697. */
  79698. readonly isWorldMatrixFrozen: boolean;
  79699. /**
  79700. * Retuns the mesh absolute position in the World.
  79701. * @returns a Vector3.
  79702. */
  79703. getAbsolutePosition(): Vector3;
  79704. /**
  79705. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  79706. * @param absolutePosition the absolute position to set
  79707. * @returns the TransformNode.
  79708. */
  79709. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  79710. /**
  79711. * Sets the mesh position in its local space.
  79712. * @param vector3 the position to set in localspace
  79713. * @returns the TransformNode.
  79714. */
  79715. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  79716. /**
  79717. * Returns the mesh position in the local space from the current World matrix values.
  79718. * @returns a new Vector3.
  79719. */
  79720. getPositionExpressedInLocalSpace(): Vector3;
  79721. /**
  79722. * Translates the mesh along the passed Vector3 in its local space.
  79723. * @param vector3 the distance to translate in localspace
  79724. * @returns the TransformNode.
  79725. */
  79726. locallyTranslate(vector3: Vector3): TransformNode;
  79727. private static _lookAtVectorCache;
  79728. /**
  79729. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  79730. * @param targetPoint the position (must be in same space as current mesh) to look at
  79731. * @param yawCor optional yaw (y-axis) correction in radians
  79732. * @param pitchCor optional pitch (x-axis) correction in radians
  79733. * @param rollCor optional roll (z-axis) correction in radians
  79734. * @param space the choosen space of the target
  79735. * @returns the TransformNode.
  79736. */
  79737. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  79738. /**
  79739. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  79740. * This Vector3 is expressed in the World space.
  79741. * @param localAxis axis to rotate
  79742. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  79743. */
  79744. getDirection(localAxis: Vector3): Vector3;
  79745. /**
  79746. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  79747. * localAxis is expressed in the mesh local space.
  79748. * result is computed in the Wordl space from the mesh World matrix.
  79749. * @param localAxis axis to rotate
  79750. * @param result the resulting transformnode
  79751. * @returns this TransformNode.
  79752. */
  79753. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  79754. /**
  79755. * Sets this transform node rotation to the given local axis.
  79756. * @param localAxis the axis in local space
  79757. * @param yawCor optional yaw (y-axis) correction in radians
  79758. * @param pitchCor optional pitch (x-axis) correction in radians
  79759. * @param rollCor optional roll (z-axis) correction in radians
  79760. * @returns this TransformNode
  79761. */
  79762. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  79763. /**
  79764. * Sets a new pivot point to the current node
  79765. * @param point defines the new pivot point to use
  79766. * @param space defines if the point is in world or local space (local by default)
  79767. * @returns the current TransformNode
  79768. */
  79769. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  79770. /**
  79771. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  79772. * @returns the pivot point
  79773. */
  79774. getPivotPoint(): Vector3;
  79775. /**
  79776. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  79777. * @param result the vector3 to store the result
  79778. * @returns this TransformNode.
  79779. */
  79780. getPivotPointToRef(result: Vector3): TransformNode;
  79781. /**
  79782. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  79783. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  79784. */
  79785. getAbsolutePivotPoint(): Vector3;
  79786. /**
  79787. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  79788. * @param result vector3 to store the result
  79789. * @returns this TransformNode.
  79790. */
  79791. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  79792. /**
  79793. * Defines the passed node as the parent of the current node.
  79794. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  79795. * @see https://doc.babylonjs.com/how_to/parenting
  79796. * @param node the node ot set as the parent
  79797. * @returns this TransformNode.
  79798. */
  79799. setParent(node: Nullable<Node>): TransformNode;
  79800. private _nonUniformScaling;
  79801. /**
  79802. * True if the scaling property of this object is non uniform eg. (1,2,1)
  79803. */
  79804. readonly nonUniformScaling: boolean;
  79805. /** @hidden */
  79806. _updateNonUniformScalingState(value: boolean): boolean;
  79807. /**
  79808. * Attach the current TransformNode to another TransformNode associated with a bone
  79809. * @param bone Bone affecting the TransformNode
  79810. * @param affectedTransformNode TransformNode associated with the bone
  79811. * @returns this object
  79812. */
  79813. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  79814. /**
  79815. * Detach the transform node if its associated with a bone
  79816. * @returns this object
  79817. */
  79818. detachFromBone(): TransformNode;
  79819. private static _rotationAxisCache;
  79820. /**
  79821. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  79822. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  79823. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  79824. * The passed axis is also normalized.
  79825. * @param axis the axis to rotate around
  79826. * @param amount the amount to rotate in radians
  79827. * @param space Space to rotate in (Default: local)
  79828. * @returns the TransformNode.
  79829. */
  79830. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  79831. /**
  79832. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  79833. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  79834. * The passed axis is also normalized. .
  79835. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  79836. * @param point the point to rotate around
  79837. * @param axis the axis to rotate around
  79838. * @param amount the amount to rotate in radians
  79839. * @returns the TransformNode
  79840. */
  79841. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  79842. /**
  79843. * Translates the mesh along the axis vector for the passed distance in the given space.
  79844. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  79845. * @param axis the axis to translate in
  79846. * @param distance the distance to translate
  79847. * @param space Space to rotate in (Default: local)
  79848. * @returns the TransformNode.
  79849. */
  79850. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  79851. /**
  79852. * Adds a rotation step to the mesh current rotation.
  79853. * x, y, z are Euler angles expressed in radians.
  79854. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  79855. * This means this rotation is made in the mesh local space only.
  79856. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  79857. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  79858. * ```javascript
  79859. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  79860. * ```
  79861. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  79862. * 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.
  79863. * @param x Rotation to add
  79864. * @param y Rotation to add
  79865. * @param z Rotation to add
  79866. * @returns the TransformNode.
  79867. */
  79868. addRotation(x: number, y: number, z: number): TransformNode;
  79869. /**
  79870. * @hidden
  79871. */
  79872. protected _getEffectiveParent(): Nullable<Node>;
  79873. /**
  79874. * Computes the world matrix of the node
  79875. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  79876. * @returns the world matrix
  79877. */
  79878. computeWorldMatrix(force?: boolean): Matrix;
  79879. protected _afterComputeWorldMatrix(): void;
  79880. /**
  79881. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  79882. * @param func callback function to add
  79883. *
  79884. * @returns the TransformNode.
  79885. */
  79886. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  79887. /**
  79888. * Removes a registered callback function.
  79889. * @param func callback function to remove
  79890. * @returns the TransformNode.
  79891. */
  79892. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  79893. /**
  79894. * Gets the position of the current mesh in camera space
  79895. * @param camera defines the camera to use
  79896. * @returns a position
  79897. */
  79898. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  79899. /**
  79900. * Returns the distance from the mesh to the active camera
  79901. * @param camera defines the camera to use
  79902. * @returns the distance
  79903. */
  79904. getDistanceToCamera(camera?: Nullable<Camera>): number;
  79905. /**
  79906. * Clone the current transform node
  79907. * @param name Name of the new clone
  79908. * @param newParent New parent for the clone
  79909. * @param doNotCloneChildren Do not clone children hierarchy
  79910. * @returns the new transform node
  79911. */
  79912. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  79913. /**
  79914. * Serializes the objects information.
  79915. * @param currentSerializationObject defines the object to serialize in
  79916. * @returns the serialized object
  79917. */
  79918. serialize(currentSerializationObject?: any): any;
  79919. /**
  79920. * Returns a new TransformNode object parsed from the source provided.
  79921. * @param parsedTransformNode is the source.
  79922. * @param scene the scne the object belongs to
  79923. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  79924. * @returns a new TransformNode object parsed from the source provided.
  79925. */
  79926. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  79927. /**
  79928. * Get all child-transformNodes of this node
  79929. * @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
  79930. * @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
  79931. * @returns an array of TransformNode
  79932. */
  79933. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  79934. /**
  79935. * Releases resources associated with this transform node.
  79936. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  79937. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  79938. */
  79939. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  79940. /**
  79941. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  79942. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  79943. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  79944. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  79945. * @returns the current mesh
  79946. */
  79947. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  79948. private _syncAbsoluteScalingAndRotation;
  79949. }
  79950. }
  79951. declare module BABYLON {
  79952. /**
  79953. * Defines the types of pose enabled controllers that are supported
  79954. */
  79955. export enum PoseEnabledControllerType {
  79956. /**
  79957. * HTC Vive
  79958. */
  79959. VIVE = 0,
  79960. /**
  79961. * Oculus Rift
  79962. */
  79963. OCULUS = 1,
  79964. /**
  79965. * Windows mixed reality
  79966. */
  79967. WINDOWS = 2,
  79968. /**
  79969. * Samsung gear VR
  79970. */
  79971. GEAR_VR = 3,
  79972. /**
  79973. * Google Daydream
  79974. */
  79975. DAYDREAM = 4,
  79976. /**
  79977. * Generic
  79978. */
  79979. GENERIC = 5
  79980. }
  79981. /**
  79982. * Defines the MutableGamepadButton interface for the state of a gamepad button
  79983. */
  79984. export interface MutableGamepadButton {
  79985. /**
  79986. * Value of the button/trigger
  79987. */
  79988. value: number;
  79989. /**
  79990. * If the button/trigger is currently touched
  79991. */
  79992. touched: boolean;
  79993. /**
  79994. * If the button/trigger is currently pressed
  79995. */
  79996. pressed: boolean;
  79997. }
  79998. /**
  79999. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  80000. * @hidden
  80001. */
  80002. export interface ExtendedGamepadButton extends GamepadButton {
  80003. /**
  80004. * If the button/trigger is currently pressed
  80005. */
  80006. readonly pressed: boolean;
  80007. /**
  80008. * If the button/trigger is currently touched
  80009. */
  80010. readonly touched: boolean;
  80011. /**
  80012. * Value of the button/trigger
  80013. */
  80014. readonly value: number;
  80015. }
  80016. /** @hidden */
  80017. export interface _GamePadFactory {
  80018. /**
  80019. * Returns wether or not the current gamepad can be created for this type of controller.
  80020. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  80021. * @returns true if it can be created, otherwise false
  80022. */
  80023. canCreate(gamepadInfo: any): boolean;
  80024. /**
  80025. * Creates a new instance of the Gamepad.
  80026. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  80027. * @returns the new gamepad instance
  80028. */
  80029. create(gamepadInfo: any): Gamepad;
  80030. }
  80031. /**
  80032. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  80033. */
  80034. export class PoseEnabledControllerHelper {
  80035. /** @hidden */
  80036. static _ControllerFactories: _GamePadFactory[];
  80037. /** @hidden */
  80038. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  80039. /**
  80040. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  80041. * @param vrGamepad the gamepad to initialized
  80042. * @returns a vr controller of the type the gamepad identified as
  80043. */
  80044. static InitiateController(vrGamepad: any): Gamepad;
  80045. }
  80046. /**
  80047. * Defines the PoseEnabledController object that contains state of a vr capable controller
  80048. */
  80049. export class PoseEnabledController extends Gamepad implements PoseControlled {
  80050. /**
  80051. * If the controller is used in a webXR session
  80052. */
  80053. isXR: boolean;
  80054. private _deviceRoomPosition;
  80055. private _deviceRoomRotationQuaternion;
  80056. /**
  80057. * The device position in babylon space
  80058. */
  80059. devicePosition: Vector3;
  80060. /**
  80061. * The device rotation in babylon space
  80062. */
  80063. deviceRotationQuaternion: Quaternion;
  80064. /**
  80065. * The scale factor of the device in babylon space
  80066. */
  80067. deviceScaleFactor: number;
  80068. /**
  80069. * (Likely devicePosition should be used instead) The device position in its room space
  80070. */
  80071. position: Vector3;
  80072. /**
  80073. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  80074. */
  80075. rotationQuaternion: Quaternion;
  80076. /**
  80077. * The type of controller (Eg. Windows mixed reality)
  80078. */
  80079. controllerType: PoseEnabledControllerType;
  80080. protected _calculatedPosition: Vector3;
  80081. private _calculatedRotation;
  80082. /**
  80083. * The raw pose from the device
  80084. */
  80085. rawPose: DevicePose;
  80086. private _trackPosition;
  80087. private _maxRotationDistFromHeadset;
  80088. private _draggedRoomRotation;
  80089. /**
  80090. * @hidden
  80091. */
  80092. _disableTrackPosition(fixedPosition: Vector3): void;
  80093. /**
  80094. * Internal, the mesh attached to the controller
  80095. * @hidden
  80096. */
  80097. _mesh: Nullable<AbstractMesh>;
  80098. private _poseControlledCamera;
  80099. private _leftHandSystemQuaternion;
  80100. /**
  80101. * Internal, matrix used to convert room space to babylon space
  80102. * @hidden
  80103. */
  80104. _deviceToWorld: Matrix;
  80105. /**
  80106. * Node to be used when casting a ray from the controller
  80107. * @hidden
  80108. */
  80109. _pointingPoseNode: Nullable<TransformNode>;
  80110. /**
  80111. * Name of the child mesh that can be used to cast a ray from the controller
  80112. */
  80113. static readonly POINTING_POSE: string;
  80114. /**
  80115. * Creates a new PoseEnabledController from a gamepad
  80116. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  80117. */
  80118. constructor(browserGamepad: any);
  80119. private _workingMatrix;
  80120. /**
  80121. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  80122. */
  80123. update(): void;
  80124. /**
  80125. * Updates only the pose device and mesh without doing any button event checking
  80126. */
  80127. protected _updatePoseAndMesh(): void;
  80128. /**
  80129. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  80130. * @param poseData raw pose fromthe device
  80131. */
  80132. updateFromDevice(poseData: DevicePose): void;
  80133. /**
  80134. * @hidden
  80135. */
  80136. _meshAttachedObservable: Observable<AbstractMesh>;
  80137. /**
  80138. * Attaches a mesh to the controller
  80139. * @param mesh the mesh to be attached
  80140. */
  80141. attachToMesh(mesh: AbstractMesh): void;
  80142. /**
  80143. * Attaches the controllers mesh to a camera
  80144. * @param camera the camera the mesh should be attached to
  80145. */
  80146. attachToPoseControlledCamera(camera: TargetCamera): void;
  80147. /**
  80148. * Disposes of the controller
  80149. */
  80150. dispose(): void;
  80151. /**
  80152. * The mesh that is attached to the controller
  80153. */
  80154. readonly mesh: Nullable<AbstractMesh>;
  80155. /**
  80156. * Gets the ray of the controller in the direction the controller is pointing
  80157. * @param length the length the resulting ray should be
  80158. * @returns a ray in the direction the controller is pointing
  80159. */
  80160. getForwardRay(length?: number): Ray;
  80161. }
  80162. }
  80163. declare module BABYLON {
  80164. /**
  80165. * Defines the WebVRController object that represents controllers tracked in 3D space
  80166. */
  80167. export abstract class WebVRController extends PoseEnabledController {
  80168. /**
  80169. * Internal, the default controller model for the controller
  80170. */
  80171. protected _defaultModel: AbstractMesh;
  80172. /**
  80173. * Fired when the trigger state has changed
  80174. */
  80175. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  80176. /**
  80177. * Fired when the main button state has changed
  80178. */
  80179. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  80180. /**
  80181. * Fired when the secondary button state has changed
  80182. */
  80183. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  80184. /**
  80185. * Fired when the pad state has changed
  80186. */
  80187. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  80188. /**
  80189. * Fired when controllers stick values have changed
  80190. */
  80191. onPadValuesChangedObservable: Observable<StickValues>;
  80192. /**
  80193. * Array of button availible on the controller
  80194. */
  80195. protected _buttons: Array<MutableGamepadButton>;
  80196. private _onButtonStateChange;
  80197. /**
  80198. * Fired when a controller button's state has changed
  80199. * @param callback the callback containing the button that was modified
  80200. */
  80201. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  80202. /**
  80203. * X and Y axis corresponding to the controllers joystick
  80204. */
  80205. pad: StickValues;
  80206. /**
  80207. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  80208. */
  80209. hand: string;
  80210. /**
  80211. * The default controller model for the controller
  80212. */
  80213. readonly defaultModel: AbstractMesh;
  80214. /**
  80215. * Creates a new WebVRController from a gamepad
  80216. * @param vrGamepad the gamepad that the WebVRController should be created from
  80217. */
  80218. constructor(vrGamepad: any);
  80219. /**
  80220. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  80221. */
  80222. update(): void;
  80223. /**
  80224. * Function to be called when a button is modified
  80225. */
  80226. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  80227. /**
  80228. * Loads a mesh and attaches it to the controller
  80229. * @param scene the scene the mesh should be added to
  80230. * @param meshLoaded callback for when the mesh has been loaded
  80231. */
  80232. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  80233. private _setButtonValue;
  80234. private _changes;
  80235. private _checkChanges;
  80236. /**
  80237. * Disposes of th webVRCOntroller
  80238. */
  80239. dispose(): void;
  80240. }
  80241. }
  80242. declare module BABYLON {
  80243. /**
  80244. * The HemisphericLight simulates the ambient environment light,
  80245. * so the passed direction is the light reflection direction, not the incoming direction.
  80246. */
  80247. export class HemisphericLight extends Light {
  80248. /**
  80249. * The groundColor is the light in the opposite direction to the one specified during creation.
  80250. * 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.
  80251. */
  80252. groundColor: Color3;
  80253. /**
  80254. * The light reflection direction, not the incoming direction.
  80255. */
  80256. direction: Vector3;
  80257. /**
  80258. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  80259. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  80260. * The HemisphericLight can't cast shadows.
  80261. * Documentation : https://doc.babylonjs.com/babylon101/lights
  80262. * @param name The friendly name of the light
  80263. * @param direction The direction of the light reflection
  80264. * @param scene The scene the light belongs to
  80265. */
  80266. constructor(name: string, direction: Vector3, scene: Scene);
  80267. protected _buildUniformLayout(): void;
  80268. /**
  80269. * Returns the string "HemisphericLight".
  80270. * @return The class name
  80271. */
  80272. getClassName(): string;
  80273. /**
  80274. * Sets the HemisphericLight direction towards the passed target (Vector3).
  80275. * Returns the updated direction.
  80276. * @param target The target the direction should point to
  80277. * @return The computed direction
  80278. */
  80279. setDirectionToTarget(target: Vector3): Vector3;
  80280. /**
  80281. * Returns the shadow generator associated to the light.
  80282. * @returns Always null for hemispheric lights because it does not support shadows.
  80283. */
  80284. getShadowGenerator(): Nullable<IShadowGenerator>;
  80285. /**
  80286. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  80287. * @param effect The effect to update
  80288. * @param lightIndex The index of the light in the effect to update
  80289. * @returns The hemispheric light
  80290. */
  80291. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  80292. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  80293. /**
  80294. * Computes the world matrix of the node
  80295. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  80296. * @param useWasUpdatedFlag defines a reserved property
  80297. * @returns the world matrix
  80298. */
  80299. computeWorldMatrix(): Matrix;
  80300. /**
  80301. * Returns the integer 3.
  80302. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  80303. */
  80304. getTypeID(): number;
  80305. /**
  80306. * Prepares the list of defines specific to the light type.
  80307. * @param defines the list of defines
  80308. * @param lightIndex defines the index of the light for the effect
  80309. */
  80310. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  80311. }
  80312. }
  80313. declare module BABYLON {
  80314. /** @hidden */
  80315. export var vrMultiviewToSingleviewPixelShader: {
  80316. name: string;
  80317. shader: string;
  80318. };
  80319. }
  80320. declare module BABYLON {
  80321. /**
  80322. * Renders to multiple views with a single draw call
  80323. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  80324. */
  80325. export class MultiviewRenderTarget extends RenderTargetTexture {
  80326. /**
  80327. * Creates a multiview render target
  80328. * @param scene scene used with the render target
  80329. * @param size the size of the render target (used for each view)
  80330. */
  80331. constructor(scene: Scene, size?: number | {
  80332. width: number;
  80333. height: number;
  80334. } | {
  80335. ratio: number;
  80336. });
  80337. /**
  80338. * @hidden
  80339. * @param faceIndex the face index, if its a cube texture
  80340. */
  80341. _bindFrameBuffer(faceIndex?: number): void;
  80342. /**
  80343. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  80344. * @returns the view count
  80345. */
  80346. getViewCount(): number;
  80347. }
  80348. }
  80349. declare module BABYLON {
  80350. /**
  80351. * Represents a camera frustum
  80352. */
  80353. export class Frustum {
  80354. /**
  80355. * Gets the planes representing the frustum
  80356. * @param transform matrix to be applied to the returned planes
  80357. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  80358. */
  80359. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  80360. /**
  80361. * Gets the near frustum plane transformed by the transform matrix
  80362. * @param transform transformation matrix to be applied to the resulting frustum plane
  80363. * @param frustumPlane the resuling frustum plane
  80364. */
  80365. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80366. /**
  80367. * Gets the far frustum plane transformed by the transform matrix
  80368. * @param transform transformation matrix to be applied to the resulting frustum plane
  80369. * @param frustumPlane the resuling frustum plane
  80370. */
  80371. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80372. /**
  80373. * Gets the left frustum plane transformed by the transform matrix
  80374. * @param transform transformation matrix to be applied to the resulting frustum plane
  80375. * @param frustumPlane the resuling frustum plane
  80376. */
  80377. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80378. /**
  80379. * Gets the right frustum plane transformed by the transform matrix
  80380. * @param transform transformation matrix to be applied to the resulting frustum plane
  80381. * @param frustumPlane the resuling frustum plane
  80382. */
  80383. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80384. /**
  80385. * Gets the top frustum plane transformed by the transform matrix
  80386. * @param transform transformation matrix to be applied to the resulting frustum plane
  80387. * @param frustumPlane the resuling frustum plane
  80388. */
  80389. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80390. /**
  80391. * Gets the bottom frustum plane transformed by the transform matrix
  80392. * @param transform transformation matrix to be applied to the resulting frustum plane
  80393. * @param frustumPlane the resuling frustum plane
  80394. */
  80395. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80396. /**
  80397. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  80398. * @param transform transformation matrix to be applied to the resulting frustum planes
  80399. * @param frustumPlanes the resuling frustum planes
  80400. */
  80401. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  80402. }
  80403. }
  80404. declare module BABYLON {
  80405. interface Engine {
  80406. /**
  80407. * Creates a new multiview render target
  80408. * @param width defines the width of the texture
  80409. * @param height defines the height of the texture
  80410. * @returns the created multiview texture
  80411. */
  80412. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  80413. /**
  80414. * Binds a multiview framebuffer to be drawn to
  80415. * @param multiviewTexture texture to bind
  80416. */
  80417. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  80418. }
  80419. interface Camera {
  80420. /**
  80421. * @hidden
  80422. * 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)
  80423. */
  80424. _useMultiviewToSingleView: boolean;
  80425. /**
  80426. * @hidden
  80427. * 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)
  80428. */
  80429. _multiviewTexture: Nullable<RenderTargetTexture>;
  80430. /**
  80431. * @hidden
  80432. * ensures the multiview texture of the camera exists and has the specified width/height
  80433. * @param width height to set on the multiview texture
  80434. * @param height width to set on the multiview texture
  80435. */
  80436. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  80437. }
  80438. interface Scene {
  80439. /** @hidden */
  80440. _transformMatrixR: Matrix;
  80441. /** @hidden */
  80442. _multiviewSceneUbo: Nullable<UniformBuffer>;
  80443. /** @hidden */
  80444. _createMultiviewUbo(): void;
  80445. /** @hidden */
  80446. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  80447. /** @hidden */
  80448. _renderMultiviewToSingleView(camera: Camera): void;
  80449. }
  80450. }
  80451. declare module BABYLON {
  80452. /**
  80453. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  80454. * This will not be used for webXR as it supports displaying texture arrays directly
  80455. */
  80456. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  80457. /**
  80458. * Initializes a VRMultiviewToSingleview
  80459. * @param name name of the post process
  80460. * @param camera camera to be applied to
  80461. * @param scaleFactor scaling factor to the size of the output texture
  80462. */
  80463. constructor(name: string, camera: Camera, scaleFactor: number);
  80464. }
  80465. }
  80466. declare module BABYLON {
  80467. interface Engine {
  80468. /** @hidden */
  80469. _vrDisplay: any;
  80470. /** @hidden */
  80471. _vrSupported: boolean;
  80472. /** @hidden */
  80473. _oldSize: Size;
  80474. /** @hidden */
  80475. _oldHardwareScaleFactor: number;
  80476. /** @hidden */
  80477. _vrExclusivePointerMode: boolean;
  80478. /** @hidden */
  80479. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  80480. /** @hidden */
  80481. _onVRDisplayPointerRestricted: () => void;
  80482. /** @hidden */
  80483. _onVRDisplayPointerUnrestricted: () => void;
  80484. /** @hidden */
  80485. _onVrDisplayConnect: Nullable<(display: any) => void>;
  80486. /** @hidden */
  80487. _onVrDisplayDisconnect: Nullable<() => void>;
  80488. /** @hidden */
  80489. _onVrDisplayPresentChange: Nullable<() => void>;
  80490. /**
  80491. * Observable signaled when VR display mode changes
  80492. */
  80493. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  80494. /**
  80495. * Observable signaled when VR request present is complete
  80496. */
  80497. onVRRequestPresentComplete: Observable<boolean>;
  80498. /**
  80499. * Observable signaled when VR request present starts
  80500. */
  80501. onVRRequestPresentStart: Observable<Engine>;
  80502. /**
  80503. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  80504. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  80505. */
  80506. isInVRExclusivePointerMode: boolean;
  80507. /**
  80508. * Gets a boolean indicating if a webVR device was detected
  80509. * @returns true if a webVR device was detected
  80510. */
  80511. isVRDevicePresent(): boolean;
  80512. /**
  80513. * Gets the current webVR device
  80514. * @returns the current webVR device (or null)
  80515. */
  80516. getVRDevice(): any;
  80517. /**
  80518. * Initializes a webVR display and starts listening to display change events
  80519. * The onVRDisplayChangedObservable will be notified upon these changes
  80520. * @returns A promise containing a VRDisplay and if vr is supported
  80521. */
  80522. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  80523. /** @hidden */
  80524. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  80525. /**
  80526. * Call this function to switch to webVR mode
  80527. * Will do nothing if webVR is not supported or if there is no webVR device
  80528. * @see http://doc.babylonjs.com/how_to/webvr_camera
  80529. */
  80530. enableVR(): void;
  80531. /** @hidden */
  80532. _onVRFullScreenTriggered(): void;
  80533. }
  80534. }
  80535. declare module BABYLON {
  80536. /**
  80537. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  80538. * IMPORTANT!! The data is right-hand data.
  80539. * @export
  80540. * @interface DevicePose
  80541. */
  80542. export interface DevicePose {
  80543. /**
  80544. * The position of the device, values in array are [x,y,z].
  80545. */
  80546. readonly position: Nullable<Float32Array>;
  80547. /**
  80548. * The linearVelocity of the device, values in array are [x,y,z].
  80549. */
  80550. readonly linearVelocity: Nullable<Float32Array>;
  80551. /**
  80552. * The linearAcceleration of the device, values in array are [x,y,z].
  80553. */
  80554. readonly linearAcceleration: Nullable<Float32Array>;
  80555. /**
  80556. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  80557. */
  80558. readonly orientation: Nullable<Float32Array>;
  80559. /**
  80560. * The angularVelocity of the device, values in array are [x,y,z].
  80561. */
  80562. readonly angularVelocity: Nullable<Float32Array>;
  80563. /**
  80564. * The angularAcceleration of the device, values in array are [x,y,z].
  80565. */
  80566. readonly angularAcceleration: Nullable<Float32Array>;
  80567. }
  80568. /**
  80569. * Interface representing a pose controlled object in Babylon.
  80570. * A pose controlled object has both regular pose values as well as pose values
  80571. * from an external device such as a VR head mounted display
  80572. */
  80573. export interface PoseControlled {
  80574. /**
  80575. * The position of the object in babylon space.
  80576. */
  80577. position: Vector3;
  80578. /**
  80579. * The rotation quaternion of the object in babylon space.
  80580. */
  80581. rotationQuaternion: Quaternion;
  80582. /**
  80583. * The position of the device in babylon space.
  80584. */
  80585. devicePosition?: Vector3;
  80586. /**
  80587. * The rotation quaternion of the device in babylon space.
  80588. */
  80589. deviceRotationQuaternion: Quaternion;
  80590. /**
  80591. * The raw pose coming from the device.
  80592. */
  80593. rawPose: Nullable<DevicePose>;
  80594. /**
  80595. * The scale of the device to be used when translating from device space to babylon space.
  80596. */
  80597. deviceScaleFactor: number;
  80598. /**
  80599. * Updates the poseControlled values based on the input device pose.
  80600. * @param poseData the pose data to update the object with
  80601. */
  80602. updateFromDevice(poseData: DevicePose): void;
  80603. }
  80604. /**
  80605. * Set of options to customize the webVRCamera
  80606. */
  80607. export interface WebVROptions {
  80608. /**
  80609. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  80610. */
  80611. trackPosition?: boolean;
  80612. /**
  80613. * Sets the scale of the vrDevice in babylon space. (default: 1)
  80614. */
  80615. positionScale?: number;
  80616. /**
  80617. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  80618. */
  80619. displayName?: string;
  80620. /**
  80621. * Should the native controller meshes be initialized. (default: true)
  80622. */
  80623. controllerMeshes?: boolean;
  80624. /**
  80625. * Creating a default HemiLight only on controllers. (default: true)
  80626. */
  80627. defaultLightingOnControllers?: boolean;
  80628. /**
  80629. * If you don't want to use the default VR button of the helper. (default: false)
  80630. */
  80631. useCustomVRButton?: boolean;
  80632. /**
  80633. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  80634. */
  80635. customVRButton?: HTMLButtonElement;
  80636. /**
  80637. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  80638. */
  80639. rayLength?: number;
  80640. /**
  80641. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  80642. */
  80643. defaultHeight?: number;
  80644. /**
  80645. * If multiview should be used if availible (default: false)
  80646. */
  80647. useMultiview?: boolean;
  80648. }
  80649. /**
  80650. * This represents a WebVR camera.
  80651. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  80652. * @example http://doc.babylonjs.com/how_to/webvr_camera
  80653. */
  80654. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  80655. private webVROptions;
  80656. /**
  80657. * @hidden
  80658. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  80659. */
  80660. _vrDevice: any;
  80661. /**
  80662. * The rawPose of the vrDevice.
  80663. */
  80664. rawPose: Nullable<DevicePose>;
  80665. private _onVREnabled;
  80666. private _specsVersion;
  80667. private _attached;
  80668. private _frameData;
  80669. protected _descendants: Array<Node>;
  80670. private _deviceRoomPosition;
  80671. /** @hidden */
  80672. _deviceRoomRotationQuaternion: Quaternion;
  80673. private _standingMatrix;
  80674. /**
  80675. * Represents device position in babylon space.
  80676. */
  80677. devicePosition: Vector3;
  80678. /**
  80679. * Represents device rotation in babylon space.
  80680. */
  80681. deviceRotationQuaternion: Quaternion;
  80682. /**
  80683. * The scale of the device to be used when translating from device space to babylon space.
  80684. */
  80685. deviceScaleFactor: number;
  80686. private _deviceToWorld;
  80687. private _worldToDevice;
  80688. /**
  80689. * References to the webVR controllers for the vrDevice.
  80690. */
  80691. controllers: Array<WebVRController>;
  80692. /**
  80693. * Emits an event when a controller is attached.
  80694. */
  80695. onControllersAttachedObservable: Observable<WebVRController[]>;
  80696. /**
  80697. * Emits an event when a controller's mesh has been loaded;
  80698. */
  80699. onControllerMeshLoadedObservable: Observable<WebVRController>;
  80700. /**
  80701. * Emits an event when the HMD's pose has been updated.
  80702. */
  80703. onPoseUpdatedFromDeviceObservable: Observable<any>;
  80704. private _poseSet;
  80705. /**
  80706. * If the rig cameras be used as parent instead of this camera.
  80707. */
  80708. rigParenting: boolean;
  80709. private _lightOnControllers;
  80710. private _defaultHeight?;
  80711. /**
  80712. * Instantiates a WebVRFreeCamera.
  80713. * @param name The name of the WebVRFreeCamera
  80714. * @param position The starting anchor position for the camera
  80715. * @param scene The scene the camera belongs to
  80716. * @param webVROptions a set of customizable options for the webVRCamera
  80717. */
  80718. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  80719. /**
  80720. * Gets the device distance from the ground in meters.
  80721. * @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.
  80722. */
  80723. deviceDistanceToRoomGround(): number;
  80724. /**
  80725. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  80726. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  80727. */
  80728. useStandingMatrix(callback?: (bool: boolean) => void): void;
  80729. /**
  80730. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  80731. * @returns A promise with a boolean set to if the standing matrix is supported.
  80732. */
  80733. useStandingMatrixAsync(): Promise<boolean>;
  80734. /**
  80735. * Disposes the camera
  80736. */
  80737. dispose(): void;
  80738. /**
  80739. * Gets a vrController by name.
  80740. * @param name The name of the controller to retreive
  80741. * @returns the controller matching the name specified or null if not found
  80742. */
  80743. getControllerByName(name: string): Nullable<WebVRController>;
  80744. private _leftController;
  80745. /**
  80746. * The controller corresponding to the users left hand.
  80747. */
  80748. readonly leftController: Nullable<WebVRController>;
  80749. private _rightController;
  80750. /**
  80751. * The controller corresponding to the users right hand.
  80752. */
  80753. readonly rightController: Nullable<WebVRController>;
  80754. /**
  80755. * Casts a ray forward from the vrCamera's gaze.
  80756. * @param length Length of the ray (default: 100)
  80757. * @returns the ray corresponding to the gaze
  80758. */
  80759. getForwardRay(length?: number): Ray;
  80760. /**
  80761. * @hidden
  80762. * Updates the camera based on device's frame data
  80763. */
  80764. _checkInputs(): void;
  80765. /**
  80766. * Updates the poseControlled values based on the input device pose.
  80767. * @param poseData Pose coming from the device
  80768. */
  80769. updateFromDevice(poseData: DevicePose): void;
  80770. private _htmlElementAttached;
  80771. private _detachIfAttached;
  80772. /**
  80773. * WebVR's attach control will start broadcasting frames to the device.
  80774. * Note that in certain browsers (chrome for example) this function must be called
  80775. * within a user-interaction callback. Example:
  80776. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  80777. *
  80778. * @param element html element to attach the vrDevice to
  80779. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  80780. */
  80781. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  80782. /**
  80783. * Detaches the camera from the html element and disables VR
  80784. *
  80785. * @param element html element to detach from
  80786. */
  80787. detachControl(element: HTMLElement): void;
  80788. /**
  80789. * @returns the name of this class
  80790. */
  80791. getClassName(): string;
  80792. /**
  80793. * Calls resetPose on the vrDisplay
  80794. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  80795. */
  80796. resetToCurrentRotation(): void;
  80797. /**
  80798. * @hidden
  80799. * Updates the rig cameras (left and right eye)
  80800. */
  80801. _updateRigCameras(): void;
  80802. private _workingVector;
  80803. private _oneVector;
  80804. private _workingMatrix;
  80805. private updateCacheCalled;
  80806. private _correctPositionIfNotTrackPosition;
  80807. /**
  80808. * @hidden
  80809. * Updates the cached values of the camera
  80810. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  80811. */
  80812. _updateCache(ignoreParentClass?: boolean): void;
  80813. /**
  80814. * @hidden
  80815. * Get current device position in babylon world
  80816. */
  80817. _computeDevicePosition(): void;
  80818. /**
  80819. * Updates the current device position and rotation in the babylon world
  80820. */
  80821. update(): void;
  80822. /**
  80823. * @hidden
  80824. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  80825. * @returns an identity matrix
  80826. */
  80827. _getViewMatrix(): Matrix;
  80828. private _tmpMatrix;
  80829. /**
  80830. * This function is called by the two RIG cameras.
  80831. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  80832. * @hidden
  80833. */
  80834. _getWebVRViewMatrix(): Matrix;
  80835. /** @hidden */
  80836. _getWebVRProjectionMatrix(): Matrix;
  80837. private _onGamepadConnectedObserver;
  80838. private _onGamepadDisconnectedObserver;
  80839. private _updateCacheWhenTrackingDisabledObserver;
  80840. /**
  80841. * Initializes the controllers and their meshes
  80842. */
  80843. initControllers(): void;
  80844. }
  80845. }
  80846. declare module BABYLON {
  80847. /**
  80848. * Size options for a post process
  80849. */
  80850. export type PostProcessOptions = {
  80851. width: number;
  80852. height: number;
  80853. };
  80854. /**
  80855. * PostProcess can be used to apply a shader to a texture after it has been rendered
  80856. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  80857. */
  80858. export class PostProcess {
  80859. /** Name of the PostProcess. */
  80860. name: string;
  80861. /**
  80862. * Gets or sets the unique id of the post process
  80863. */
  80864. uniqueId: number;
  80865. /**
  80866. * Width of the texture to apply the post process on
  80867. */
  80868. width: number;
  80869. /**
  80870. * Height of the texture to apply the post process on
  80871. */
  80872. height: number;
  80873. /**
  80874. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  80875. * @hidden
  80876. */
  80877. _outputTexture: Nullable<InternalTexture>;
  80878. /**
  80879. * Sampling mode used by the shader
  80880. * See https://doc.babylonjs.com/classes/3.1/texture
  80881. */
  80882. renderTargetSamplingMode: number;
  80883. /**
  80884. * Clear color to use when screen clearing
  80885. */
  80886. clearColor: Color4;
  80887. /**
  80888. * If the buffer needs to be cleared before applying the post process. (default: true)
  80889. * Should be set to false if shader will overwrite all previous pixels.
  80890. */
  80891. autoClear: boolean;
  80892. /**
  80893. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  80894. */
  80895. alphaMode: number;
  80896. /**
  80897. * Sets the setAlphaBlendConstants of the babylon engine
  80898. */
  80899. alphaConstants: Color4;
  80900. /**
  80901. * Animations to be used for the post processing
  80902. */
  80903. animations: Animation[];
  80904. /**
  80905. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  80906. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  80907. */
  80908. enablePixelPerfectMode: boolean;
  80909. /**
  80910. * Force the postprocess to be applied without taking in account viewport
  80911. */
  80912. forceFullscreenViewport: boolean;
  80913. /**
  80914. * List of inspectable custom properties (used by the Inspector)
  80915. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80916. */
  80917. inspectableCustomProperties: IInspectable[];
  80918. /**
  80919. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  80920. *
  80921. * | Value | Type | Description |
  80922. * | ----- | ----------------------------------- | ----------- |
  80923. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  80924. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  80925. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  80926. *
  80927. */
  80928. scaleMode: number;
  80929. /**
  80930. * Force textures to be a power of two (default: false)
  80931. */
  80932. alwaysForcePOT: boolean;
  80933. private _samples;
  80934. /**
  80935. * Number of sample textures (default: 1)
  80936. */
  80937. samples: number;
  80938. /**
  80939. * Modify the scale of the post process to be the same as the viewport (default: false)
  80940. */
  80941. adaptScaleToCurrentViewport: boolean;
  80942. private _camera;
  80943. private _scene;
  80944. private _engine;
  80945. private _options;
  80946. private _reusable;
  80947. private _textureType;
  80948. /**
  80949. * Smart array of input and output textures for the post process.
  80950. * @hidden
  80951. */
  80952. _textures: SmartArray<InternalTexture>;
  80953. /**
  80954. * The index in _textures that corresponds to the output texture.
  80955. * @hidden
  80956. */
  80957. _currentRenderTextureInd: number;
  80958. private _effect;
  80959. private _samplers;
  80960. private _fragmentUrl;
  80961. private _vertexUrl;
  80962. private _parameters;
  80963. private _scaleRatio;
  80964. protected _indexParameters: any;
  80965. private _shareOutputWithPostProcess;
  80966. private _texelSize;
  80967. private _forcedOutputTexture;
  80968. /**
  80969. * Returns the fragment url or shader name used in the post process.
  80970. * @returns the fragment url or name in the shader store.
  80971. */
  80972. getEffectName(): string;
  80973. /**
  80974. * An event triggered when the postprocess is activated.
  80975. */
  80976. onActivateObservable: Observable<Camera>;
  80977. private _onActivateObserver;
  80978. /**
  80979. * A function that is added to the onActivateObservable
  80980. */
  80981. onActivate: Nullable<(camera: Camera) => void>;
  80982. /**
  80983. * An event triggered when the postprocess changes its size.
  80984. */
  80985. onSizeChangedObservable: Observable<PostProcess>;
  80986. private _onSizeChangedObserver;
  80987. /**
  80988. * A function that is added to the onSizeChangedObservable
  80989. */
  80990. onSizeChanged: (postProcess: PostProcess) => void;
  80991. /**
  80992. * An event triggered when the postprocess applies its effect.
  80993. */
  80994. onApplyObservable: Observable<Effect>;
  80995. private _onApplyObserver;
  80996. /**
  80997. * A function that is added to the onApplyObservable
  80998. */
  80999. onApply: (effect: Effect) => void;
  81000. /**
  81001. * An event triggered before rendering the postprocess
  81002. */
  81003. onBeforeRenderObservable: Observable<Effect>;
  81004. private _onBeforeRenderObserver;
  81005. /**
  81006. * A function that is added to the onBeforeRenderObservable
  81007. */
  81008. onBeforeRender: (effect: Effect) => void;
  81009. /**
  81010. * An event triggered after rendering the postprocess
  81011. */
  81012. onAfterRenderObservable: Observable<Effect>;
  81013. private _onAfterRenderObserver;
  81014. /**
  81015. * A function that is added to the onAfterRenderObservable
  81016. */
  81017. onAfterRender: (efect: Effect) => void;
  81018. /**
  81019. * 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
  81020. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  81021. */
  81022. inputTexture: InternalTexture;
  81023. /**
  81024. * Gets the camera which post process is applied to.
  81025. * @returns The camera the post process is applied to.
  81026. */
  81027. getCamera(): Camera;
  81028. /**
  81029. * Gets the texel size of the postprocess.
  81030. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  81031. */
  81032. readonly texelSize: Vector2;
  81033. /**
  81034. * Creates a new instance PostProcess
  81035. * @param name The name of the PostProcess.
  81036. * @param fragmentUrl The url of the fragment shader to be used.
  81037. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  81038. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  81039. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  81040. * @param camera The camera to apply the render pass to.
  81041. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  81042. * @param engine The engine which the post process will be applied. (default: current engine)
  81043. * @param reusable If the post process can be reused on the same frame. (default: false)
  81044. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  81045. * @param textureType Type of textures used when performing the post process. (default: 0)
  81046. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  81047. * @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
  81048. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  81049. */
  81050. constructor(
  81051. /** Name of the PostProcess. */
  81052. 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);
  81053. /**
  81054. * Gets a string idenfifying the name of the class
  81055. * @returns "PostProcess" string
  81056. */
  81057. getClassName(): string;
  81058. /**
  81059. * Gets the engine which this post process belongs to.
  81060. * @returns The engine the post process was enabled with.
  81061. */
  81062. getEngine(): Engine;
  81063. /**
  81064. * The effect that is created when initializing the post process.
  81065. * @returns The created effect corresponding the the postprocess.
  81066. */
  81067. getEffect(): Effect;
  81068. /**
  81069. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  81070. * @param postProcess The post process to share the output with.
  81071. * @returns This post process.
  81072. */
  81073. shareOutputWith(postProcess: PostProcess): PostProcess;
  81074. /**
  81075. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  81076. * This should be called if the post process that shares output with this post process is disabled/disposed.
  81077. */
  81078. useOwnOutput(): void;
  81079. /**
  81080. * Updates the effect with the current post process compile time values and recompiles the shader.
  81081. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  81082. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  81083. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  81084. * @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
  81085. * @param onCompiled Called when the shader has been compiled.
  81086. * @param onError Called if there is an error when compiling a shader.
  81087. */
  81088. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  81089. /**
  81090. * The post process is reusable if it can be used multiple times within one frame.
  81091. * @returns If the post process is reusable
  81092. */
  81093. isReusable(): boolean;
  81094. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  81095. markTextureDirty(): void;
  81096. /**
  81097. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  81098. * 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.
  81099. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  81100. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  81101. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  81102. * @returns The target texture that was bound to be written to.
  81103. */
  81104. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  81105. /**
  81106. * If the post process is supported.
  81107. */
  81108. readonly isSupported: boolean;
  81109. /**
  81110. * The aspect ratio of the output texture.
  81111. */
  81112. readonly aspectRatio: number;
  81113. /**
  81114. * Get a value indicating if the post-process is ready to be used
  81115. * @returns true if the post-process is ready (shader is compiled)
  81116. */
  81117. isReady(): boolean;
  81118. /**
  81119. * Binds all textures and uniforms to the shader, this will be run on every pass.
  81120. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  81121. */
  81122. apply(): Nullable<Effect>;
  81123. private _disposeTextures;
  81124. /**
  81125. * Disposes the post process.
  81126. * @param camera The camera to dispose the post process on.
  81127. */
  81128. dispose(camera?: Camera): void;
  81129. }
  81130. }
  81131. declare module BABYLON {
  81132. /** @hidden */
  81133. export var kernelBlurVaryingDeclaration: {
  81134. name: string;
  81135. shader: string;
  81136. };
  81137. }
  81138. declare module BABYLON {
  81139. /** @hidden */
  81140. export var kernelBlurFragment: {
  81141. name: string;
  81142. shader: string;
  81143. };
  81144. }
  81145. declare module BABYLON {
  81146. /** @hidden */
  81147. export var kernelBlurFragment2: {
  81148. name: string;
  81149. shader: string;
  81150. };
  81151. }
  81152. declare module BABYLON {
  81153. /** @hidden */
  81154. export var kernelBlurPixelShader: {
  81155. name: string;
  81156. shader: string;
  81157. };
  81158. }
  81159. declare module BABYLON {
  81160. /** @hidden */
  81161. export var kernelBlurVertex: {
  81162. name: string;
  81163. shader: string;
  81164. };
  81165. }
  81166. declare module BABYLON {
  81167. /** @hidden */
  81168. export var kernelBlurVertexShader: {
  81169. name: string;
  81170. shader: string;
  81171. };
  81172. }
  81173. declare module BABYLON {
  81174. /**
  81175. * The Blur Post Process which blurs an image based on a kernel and direction.
  81176. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  81177. */
  81178. export class BlurPostProcess extends PostProcess {
  81179. /** The direction in which to blur the image. */
  81180. direction: Vector2;
  81181. private blockCompilation;
  81182. protected _kernel: number;
  81183. protected _idealKernel: number;
  81184. protected _packedFloat: boolean;
  81185. private _staticDefines;
  81186. /**
  81187. * Sets the length in pixels of the blur sample region
  81188. */
  81189. /**
  81190. * Gets the length in pixels of the blur sample region
  81191. */
  81192. kernel: number;
  81193. /**
  81194. * Sets wether or not the blur needs to unpack/repack floats
  81195. */
  81196. /**
  81197. * Gets wether or not the blur is unpacking/repacking floats
  81198. */
  81199. packedFloat: boolean;
  81200. /**
  81201. * Creates a new instance BlurPostProcess
  81202. * @param name The name of the effect.
  81203. * @param direction The direction in which to blur the image.
  81204. * @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.
  81205. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  81206. * @param camera The camera to apply the render pass to.
  81207. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  81208. * @param engine The engine which the post process will be applied. (default: current engine)
  81209. * @param reusable If the post process can be reused on the same frame. (default: false)
  81210. * @param textureType Type of textures used when performing the post process. (default: 0)
  81211. * @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)
  81212. */
  81213. constructor(name: string,
  81214. /** The direction in which to blur the image. */
  81215. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  81216. /**
  81217. * Updates the effect with the current post process compile time values and recompiles the shader.
  81218. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  81219. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  81220. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  81221. * @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
  81222. * @param onCompiled Called when the shader has been compiled.
  81223. * @param onError Called if there is an error when compiling a shader.
  81224. */
  81225. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  81226. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  81227. /**
  81228. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  81229. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  81230. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  81231. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  81232. * The gaps between physical kernels are compensated for in the weighting of the samples
  81233. * @param idealKernel Ideal blur kernel.
  81234. * @return Nearest best kernel.
  81235. */
  81236. protected _nearestBestKernel(idealKernel: number): number;
  81237. /**
  81238. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  81239. * @param x The point on the Gaussian distribution to sample.
  81240. * @return the value of the Gaussian function at x.
  81241. */
  81242. protected _gaussianWeight(x: number): number;
  81243. /**
  81244. * Generates a string that can be used as a floating point number in GLSL.
  81245. * @param x Value to print.
  81246. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  81247. * @return GLSL float string.
  81248. */
  81249. protected _glslFloat(x: number, decimalFigures?: number): string;
  81250. }
  81251. }
  81252. declare module BABYLON {
  81253. /**
  81254. * Mirror texture can be used to simulate the view from a mirror in a scene.
  81255. * It will dynamically be rendered every frame to adapt to the camera point of view.
  81256. * You can then easily use it as a reflectionTexture on a flat surface.
  81257. * In case the surface is not a plane, please consider relying on reflection probes.
  81258. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  81259. */
  81260. export class MirrorTexture extends RenderTargetTexture {
  81261. private scene;
  81262. /**
  81263. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  81264. * 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.
  81265. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  81266. */
  81267. mirrorPlane: Plane;
  81268. /**
  81269. * Define the blur ratio used to blur the reflection if needed.
  81270. */
  81271. blurRatio: number;
  81272. /**
  81273. * Define the adaptive blur kernel used to blur the reflection if needed.
  81274. * This will autocompute the closest best match for the `blurKernel`
  81275. */
  81276. adaptiveBlurKernel: number;
  81277. /**
  81278. * Define the blur kernel used to blur the reflection if needed.
  81279. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  81280. */
  81281. blurKernel: number;
  81282. /**
  81283. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  81284. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  81285. */
  81286. blurKernelX: number;
  81287. /**
  81288. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  81289. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  81290. */
  81291. blurKernelY: number;
  81292. private _autoComputeBlurKernel;
  81293. protected _onRatioRescale(): void;
  81294. private _updateGammaSpace;
  81295. private _imageProcessingConfigChangeObserver;
  81296. private _transformMatrix;
  81297. private _mirrorMatrix;
  81298. private _savedViewMatrix;
  81299. private _blurX;
  81300. private _blurY;
  81301. private _adaptiveBlurKernel;
  81302. private _blurKernelX;
  81303. private _blurKernelY;
  81304. private _blurRatio;
  81305. /**
  81306. * Instantiates a Mirror Texture.
  81307. * Mirror texture can be used to simulate the view from a mirror in a scene.
  81308. * It will dynamically be rendered every frame to adapt to the camera point of view.
  81309. * You can then easily use it as a reflectionTexture on a flat surface.
  81310. * In case the surface is not a plane, please consider relying on reflection probes.
  81311. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  81312. * @param name
  81313. * @param size
  81314. * @param scene
  81315. * @param generateMipMaps
  81316. * @param type
  81317. * @param samplingMode
  81318. * @param generateDepthBuffer
  81319. */
  81320. constructor(name: string, size: number | {
  81321. width: number;
  81322. height: number;
  81323. } | {
  81324. ratio: number;
  81325. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  81326. private _preparePostProcesses;
  81327. /**
  81328. * Clone the mirror texture.
  81329. * @returns the cloned texture
  81330. */
  81331. clone(): MirrorTexture;
  81332. /**
  81333. * Serialize the texture to a JSON representation you could use in Parse later on
  81334. * @returns the serialized JSON representation
  81335. */
  81336. serialize(): any;
  81337. /**
  81338. * Dispose the texture and release its associated resources.
  81339. */
  81340. dispose(): void;
  81341. }
  81342. }
  81343. declare module BABYLON {
  81344. /**
  81345. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  81346. * @see http://doc.babylonjs.com/babylon101/materials#texture
  81347. */
  81348. export class Texture extends BaseTexture {
  81349. /**
  81350. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  81351. */
  81352. static SerializeBuffers: boolean;
  81353. /** @hidden */
  81354. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  81355. /** @hidden */
  81356. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  81357. /** @hidden */
  81358. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  81359. /** nearest is mag = nearest and min = nearest and mip = linear */
  81360. static readonly NEAREST_SAMPLINGMODE: number;
  81361. /** nearest is mag = nearest and min = nearest and mip = linear */
  81362. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  81363. /** Bilinear is mag = linear and min = linear and mip = nearest */
  81364. static readonly BILINEAR_SAMPLINGMODE: number;
  81365. /** Bilinear is mag = linear and min = linear and mip = nearest */
  81366. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  81367. /** Trilinear is mag = linear and min = linear and mip = linear */
  81368. static readonly TRILINEAR_SAMPLINGMODE: number;
  81369. /** Trilinear is mag = linear and min = linear and mip = linear */
  81370. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  81371. /** mag = nearest and min = nearest and mip = nearest */
  81372. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  81373. /** mag = nearest and min = linear and mip = nearest */
  81374. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  81375. /** mag = nearest and min = linear and mip = linear */
  81376. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  81377. /** mag = nearest and min = linear and mip = none */
  81378. static readonly NEAREST_LINEAR: number;
  81379. /** mag = nearest and min = nearest and mip = none */
  81380. static readonly NEAREST_NEAREST: number;
  81381. /** mag = linear and min = nearest and mip = nearest */
  81382. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  81383. /** mag = linear and min = nearest and mip = linear */
  81384. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  81385. /** mag = linear and min = linear and mip = none */
  81386. static readonly LINEAR_LINEAR: number;
  81387. /** mag = linear and min = nearest and mip = none */
  81388. static readonly LINEAR_NEAREST: number;
  81389. /** Explicit coordinates mode */
  81390. static readonly EXPLICIT_MODE: number;
  81391. /** Spherical coordinates mode */
  81392. static readonly SPHERICAL_MODE: number;
  81393. /** Planar coordinates mode */
  81394. static readonly PLANAR_MODE: number;
  81395. /** Cubic coordinates mode */
  81396. static readonly CUBIC_MODE: number;
  81397. /** Projection coordinates mode */
  81398. static readonly PROJECTION_MODE: number;
  81399. /** Inverse Cubic coordinates mode */
  81400. static readonly SKYBOX_MODE: number;
  81401. /** Inverse Cubic coordinates mode */
  81402. static readonly INVCUBIC_MODE: number;
  81403. /** Equirectangular coordinates mode */
  81404. static readonly EQUIRECTANGULAR_MODE: number;
  81405. /** Equirectangular Fixed coordinates mode */
  81406. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  81407. /** Equirectangular Fixed Mirrored coordinates mode */
  81408. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  81409. /** Texture is not repeating outside of 0..1 UVs */
  81410. static readonly CLAMP_ADDRESSMODE: number;
  81411. /** Texture is repeating outside of 0..1 UVs */
  81412. static readonly WRAP_ADDRESSMODE: number;
  81413. /** Texture is repeating and mirrored */
  81414. static readonly MIRROR_ADDRESSMODE: number;
  81415. /**
  81416. * 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
  81417. */
  81418. static UseSerializedUrlIfAny: boolean;
  81419. /**
  81420. * Define the url of the texture.
  81421. */
  81422. url: Nullable<string>;
  81423. /**
  81424. * Define an offset on the texture to offset the u coordinates of the UVs
  81425. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  81426. */
  81427. uOffset: number;
  81428. /**
  81429. * Define an offset on the texture to offset the v coordinates of the UVs
  81430. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  81431. */
  81432. vOffset: number;
  81433. /**
  81434. * Define an offset on the texture to scale the u coordinates of the UVs
  81435. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  81436. */
  81437. uScale: number;
  81438. /**
  81439. * Define an offset on the texture to scale the v coordinates of the UVs
  81440. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  81441. */
  81442. vScale: number;
  81443. /**
  81444. * Define an offset on the texture to rotate around the u coordinates of the UVs
  81445. * @see http://doc.babylonjs.com/how_to/more_materials
  81446. */
  81447. uAng: number;
  81448. /**
  81449. * Define an offset on the texture to rotate around the v coordinates of the UVs
  81450. * @see http://doc.babylonjs.com/how_to/more_materials
  81451. */
  81452. vAng: number;
  81453. /**
  81454. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  81455. * @see http://doc.babylonjs.com/how_to/more_materials
  81456. */
  81457. wAng: number;
  81458. /**
  81459. * Defines the center of rotation (U)
  81460. */
  81461. uRotationCenter: number;
  81462. /**
  81463. * Defines the center of rotation (V)
  81464. */
  81465. vRotationCenter: number;
  81466. /**
  81467. * Defines the center of rotation (W)
  81468. */
  81469. wRotationCenter: number;
  81470. /**
  81471. * Are mip maps generated for this texture or not.
  81472. */
  81473. readonly noMipmap: boolean;
  81474. /**
  81475. * List of inspectable custom properties (used by the Inspector)
  81476. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81477. */
  81478. inspectableCustomProperties: Nullable<IInspectable[]>;
  81479. private _noMipmap;
  81480. /** @hidden */
  81481. _invertY: boolean;
  81482. private _rowGenerationMatrix;
  81483. private _cachedTextureMatrix;
  81484. private _projectionModeMatrix;
  81485. private _t0;
  81486. private _t1;
  81487. private _t2;
  81488. private _cachedUOffset;
  81489. private _cachedVOffset;
  81490. private _cachedUScale;
  81491. private _cachedVScale;
  81492. private _cachedUAng;
  81493. private _cachedVAng;
  81494. private _cachedWAng;
  81495. private _cachedProjectionMatrixId;
  81496. private _cachedCoordinatesMode;
  81497. /** @hidden */
  81498. protected _initialSamplingMode: number;
  81499. /** @hidden */
  81500. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  81501. private _deleteBuffer;
  81502. protected _format: Nullable<number>;
  81503. private _delayedOnLoad;
  81504. private _delayedOnError;
  81505. /**
  81506. * Observable triggered once the texture has been loaded.
  81507. */
  81508. onLoadObservable: Observable<Texture>;
  81509. protected _isBlocking: boolean;
  81510. /**
  81511. * Is the texture preventing material to render while loading.
  81512. * If false, a default texture will be used instead of the loading one during the preparation step.
  81513. */
  81514. isBlocking: boolean;
  81515. /**
  81516. * Get the current sampling mode associated with the texture.
  81517. */
  81518. readonly samplingMode: number;
  81519. /**
  81520. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  81521. */
  81522. readonly invertY: boolean;
  81523. /**
  81524. * Instantiates a new texture.
  81525. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  81526. * @see http://doc.babylonjs.com/babylon101/materials#texture
  81527. * @param url define the url of the picture to load as a texture
  81528. * @param scene define the scene or engine the texture will belong to
  81529. * @param noMipmap define if the texture will require mip maps or not
  81530. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81531. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81532. * @param onLoad define a callback triggered when the texture has been loaded
  81533. * @param onError define a callback triggered when an error occurred during the loading session
  81534. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  81535. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  81536. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81537. */
  81538. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  81539. /**
  81540. * Update the url (and optional buffer) of this texture if url was null during construction.
  81541. * @param url the url of the texture
  81542. * @param buffer the buffer of the texture (defaults to null)
  81543. * @param onLoad callback called when the texture is loaded (defaults to null)
  81544. */
  81545. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  81546. /**
  81547. * Finish the loading sequence of a texture flagged as delayed load.
  81548. * @hidden
  81549. */
  81550. delayLoad(): void;
  81551. private _prepareRowForTextureGeneration;
  81552. /**
  81553. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  81554. * @returns the transform matrix of the texture.
  81555. */
  81556. getTextureMatrix(): Matrix;
  81557. /**
  81558. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  81559. * @returns The reflection texture transform
  81560. */
  81561. getReflectionTextureMatrix(): Matrix;
  81562. /**
  81563. * Clones the texture.
  81564. * @returns the cloned texture
  81565. */
  81566. clone(): Texture;
  81567. /**
  81568. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  81569. * @returns The JSON representation of the texture
  81570. */
  81571. serialize(): any;
  81572. /**
  81573. * Get the current class name of the texture useful for serialization or dynamic coding.
  81574. * @returns "Texture"
  81575. */
  81576. getClassName(): string;
  81577. /**
  81578. * Dispose the texture and release its associated resources.
  81579. */
  81580. dispose(): void;
  81581. /**
  81582. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  81583. * @param parsedTexture Define the JSON representation of the texture
  81584. * @param scene Define the scene the parsed texture should be instantiated in
  81585. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  81586. * @returns The parsed texture if successful
  81587. */
  81588. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  81589. /**
  81590. * Creates a texture from its base 64 representation.
  81591. * @param data Define the base64 payload without the data: prefix
  81592. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  81593. * @param scene Define the scene the texture should belong to
  81594. * @param noMipmap Forces the texture to not create mip map information if true
  81595. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81596. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81597. * @param onLoad define a callback triggered when the texture has been loaded
  81598. * @param onError define a callback triggered when an error occurred during the loading session
  81599. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81600. * @returns the created texture
  81601. */
  81602. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  81603. /**
  81604. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  81605. * @param data Define the base64 payload without the data: prefix
  81606. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  81607. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  81608. * @param scene Define the scene the texture should belong to
  81609. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  81610. * @param noMipmap Forces the texture to not create mip map information if true
  81611. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81612. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81613. * @param onLoad define a callback triggered when the texture has been loaded
  81614. * @param onError define a callback triggered when an error occurred during the loading session
  81615. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81616. * @returns the created texture
  81617. */
  81618. 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;
  81619. }
  81620. }
  81621. declare module BABYLON {
  81622. /**
  81623. * PostProcessManager is used to manage one or more post processes or post process pipelines
  81624. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  81625. */
  81626. export class PostProcessManager {
  81627. private _scene;
  81628. private _indexBuffer;
  81629. private _vertexBuffers;
  81630. /**
  81631. * Creates a new instance PostProcess
  81632. * @param scene The scene that the post process is associated with.
  81633. */
  81634. constructor(scene: Scene);
  81635. private _prepareBuffers;
  81636. private _buildIndexBuffer;
  81637. /**
  81638. * Rebuilds the vertex buffers of the manager.
  81639. * @hidden
  81640. */
  81641. _rebuild(): void;
  81642. /**
  81643. * Prepares a frame to be run through a post process.
  81644. * @param sourceTexture The input texture to the post procesess. (default: null)
  81645. * @param postProcesses An array of post processes to be run. (default: null)
  81646. * @returns True if the post processes were able to be run.
  81647. * @hidden
  81648. */
  81649. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  81650. /**
  81651. * Manually render a set of post processes to a texture.
  81652. * @param postProcesses An array of post processes to be run.
  81653. * @param targetTexture The target texture to render to.
  81654. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  81655. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  81656. * @param lodLevel defines which lod of the texture to render to
  81657. */
  81658. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  81659. /**
  81660. * Finalize the result of the output of the postprocesses.
  81661. * @param doNotPresent If true the result will not be displayed to the screen.
  81662. * @param targetTexture The target texture to render to.
  81663. * @param faceIndex The index of the face to bind the target texture to.
  81664. * @param postProcesses The array of post processes to render.
  81665. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  81666. * @hidden
  81667. */
  81668. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  81669. /**
  81670. * Disposes of the post process manager.
  81671. */
  81672. dispose(): void;
  81673. }
  81674. }
  81675. declare module BABYLON {
  81676. /** Interface used by value gradients (color, factor, ...) */
  81677. export interface IValueGradient {
  81678. /**
  81679. * Gets or sets the gradient value (between 0 and 1)
  81680. */
  81681. gradient: number;
  81682. }
  81683. /** Class used to store color4 gradient */
  81684. export class ColorGradient implements IValueGradient {
  81685. /**
  81686. * Gets or sets the gradient value (between 0 and 1)
  81687. */
  81688. gradient: number;
  81689. /**
  81690. * Gets or sets first associated color
  81691. */
  81692. color1: Color4;
  81693. /**
  81694. * Gets or sets second associated color
  81695. */
  81696. color2?: Color4;
  81697. /**
  81698. * Will get a color picked randomly between color1 and color2.
  81699. * If color2 is undefined then color1 will be used
  81700. * @param result defines the target Color4 to store the result in
  81701. */
  81702. getColorToRef(result: Color4): void;
  81703. }
  81704. /** Class used to store color 3 gradient */
  81705. export class Color3Gradient implements IValueGradient {
  81706. /**
  81707. * Gets or sets the gradient value (between 0 and 1)
  81708. */
  81709. gradient: number;
  81710. /**
  81711. * Gets or sets the associated color
  81712. */
  81713. color: Color3;
  81714. }
  81715. /** Class used to store factor gradient */
  81716. export class FactorGradient implements IValueGradient {
  81717. /**
  81718. * Gets or sets the gradient value (between 0 and 1)
  81719. */
  81720. gradient: number;
  81721. /**
  81722. * Gets or sets first associated factor
  81723. */
  81724. factor1: number;
  81725. /**
  81726. * Gets or sets second associated factor
  81727. */
  81728. factor2?: number;
  81729. /**
  81730. * Will get a number picked randomly between factor1 and factor2.
  81731. * If factor2 is undefined then factor1 will be used
  81732. * @returns the picked number
  81733. */
  81734. getFactor(): number;
  81735. }
  81736. /**
  81737. * Helper used to simplify some generic gradient tasks
  81738. */
  81739. export class GradientHelper {
  81740. /**
  81741. * Gets the current gradient from an array of IValueGradient
  81742. * @param ratio defines the current ratio to get
  81743. * @param gradients defines the array of IValueGradient
  81744. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  81745. */
  81746. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  81747. }
  81748. }
  81749. declare module BABYLON {
  81750. /**
  81751. * A class extending Texture allowing drawing on a texture
  81752. * @see http://doc.babylonjs.com/how_to/dynamictexture
  81753. */
  81754. export class DynamicTexture extends Texture {
  81755. private _generateMipMaps;
  81756. private _canvas;
  81757. private _context;
  81758. private _engine;
  81759. /**
  81760. * Creates a DynamicTexture
  81761. * @param name defines the name of the texture
  81762. * @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
  81763. * @param scene defines the scene where you want the texture
  81764. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  81765. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  81766. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  81767. */
  81768. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  81769. /**
  81770. * Get the current class name of the texture useful for serialization or dynamic coding.
  81771. * @returns "DynamicTexture"
  81772. */
  81773. getClassName(): string;
  81774. /**
  81775. * Gets the current state of canRescale
  81776. */
  81777. readonly canRescale: boolean;
  81778. private _recreate;
  81779. /**
  81780. * Scales the texture
  81781. * @param ratio the scale factor to apply to both width and height
  81782. */
  81783. scale(ratio: number): void;
  81784. /**
  81785. * Resizes the texture
  81786. * @param width the new width
  81787. * @param height the new height
  81788. */
  81789. scaleTo(width: number, height: number): void;
  81790. /**
  81791. * Gets the context of the canvas used by the texture
  81792. * @returns the canvas context of the dynamic texture
  81793. */
  81794. getContext(): CanvasRenderingContext2D;
  81795. /**
  81796. * Clears the texture
  81797. */
  81798. clear(): void;
  81799. /**
  81800. * Updates the texture
  81801. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  81802. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  81803. */
  81804. update(invertY?: boolean, premulAlpha?: boolean): void;
  81805. /**
  81806. * Draws text onto the texture
  81807. * @param text defines the text to be drawn
  81808. * @param x defines the placement of the text from the left
  81809. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  81810. * @param font defines the font to be used with font-style, font-size, font-name
  81811. * @param color defines the color used for the text
  81812. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  81813. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  81814. * @param update defines whether texture is immediately update (default is true)
  81815. */
  81816. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  81817. /**
  81818. * Clones the texture
  81819. * @returns the clone of the texture.
  81820. */
  81821. clone(): DynamicTexture;
  81822. /**
  81823. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  81824. * @returns a serialized dynamic texture object
  81825. */
  81826. serialize(): any;
  81827. /** @hidden */
  81828. _rebuild(): void;
  81829. }
  81830. }
  81831. declare module BABYLON {
  81832. interface AbstractScene {
  81833. /**
  81834. * The list of procedural textures added to the scene
  81835. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81836. */
  81837. proceduralTextures: Array<ProceduralTexture>;
  81838. }
  81839. /**
  81840. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  81841. * in a given scene.
  81842. */
  81843. export class ProceduralTextureSceneComponent implements ISceneComponent {
  81844. /**
  81845. * The component name helpfull to identify the component in the list of scene components.
  81846. */
  81847. readonly name: string;
  81848. /**
  81849. * The scene the component belongs to.
  81850. */
  81851. scene: Scene;
  81852. /**
  81853. * Creates a new instance of the component for the given scene
  81854. * @param scene Defines the scene to register the component in
  81855. */
  81856. constructor(scene: Scene);
  81857. /**
  81858. * Registers the component in a given scene
  81859. */
  81860. register(): void;
  81861. /**
  81862. * Rebuilds the elements related to this component in case of
  81863. * context lost for instance.
  81864. */
  81865. rebuild(): void;
  81866. /**
  81867. * Disposes the component and the associated ressources.
  81868. */
  81869. dispose(): void;
  81870. private _beforeClear;
  81871. }
  81872. }
  81873. declare module BABYLON {
  81874. interface Engine {
  81875. /**
  81876. * Creates a new render target cube texture
  81877. * @param size defines the size of the texture
  81878. * @param options defines the options used to create the texture
  81879. * @returns a new render target cube texture stored in an InternalTexture
  81880. */
  81881. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  81882. }
  81883. }
  81884. declare module BABYLON {
  81885. /** @hidden */
  81886. export var proceduralVertexShader: {
  81887. name: string;
  81888. shader: string;
  81889. };
  81890. }
  81891. declare module BABYLON {
  81892. /**
  81893. * 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.
  81894. * This is the base class of any Procedural texture and contains most of the shareable code.
  81895. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81896. */
  81897. export class ProceduralTexture extends Texture {
  81898. isCube: boolean;
  81899. /**
  81900. * Define if the texture is enabled or not (disabled texture will not render)
  81901. */
  81902. isEnabled: boolean;
  81903. /**
  81904. * Define if the texture must be cleared before rendering (default is true)
  81905. */
  81906. autoClear: boolean;
  81907. /**
  81908. * Callback called when the texture is generated
  81909. */
  81910. onGenerated: () => void;
  81911. /**
  81912. * Event raised when the texture is generated
  81913. */
  81914. onGeneratedObservable: Observable<ProceduralTexture>;
  81915. /** @hidden */
  81916. _generateMipMaps: boolean;
  81917. /** @hidden **/
  81918. _effect: Effect;
  81919. /** @hidden */
  81920. _textures: {
  81921. [key: string]: Texture;
  81922. };
  81923. private _size;
  81924. private _currentRefreshId;
  81925. private _refreshRate;
  81926. private _vertexBuffers;
  81927. private _indexBuffer;
  81928. private _uniforms;
  81929. private _samplers;
  81930. private _fragment;
  81931. private _floats;
  81932. private _ints;
  81933. private _floatsArrays;
  81934. private _colors3;
  81935. private _colors4;
  81936. private _vectors2;
  81937. private _vectors3;
  81938. private _matrices;
  81939. private _fallbackTexture;
  81940. private _fallbackTextureUsed;
  81941. private _engine;
  81942. private _cachedDefines;
  81943. private _contentUpdateId;
  81944. private _contentData;
  81945. /**
  81946. * Instantiates a new procedural texture.
  81947. * 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.
  81948. * This is the base class of any Procedural texture and contains most of the shareable code.
  81949. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81950. * @param name Define the name of the texture
  81951. * @param size Define the size of the texture to create
  81952. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  81953. * @param scene Define the scene the texture belongs to
  81954. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  81955. * @param generateMipMaps Define if the texture should creates mip maps or not
  81956. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  81957. */
  81958. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  81959. /**
  81960. * The effect that is created when initializing the post process.
  81961. * @returns The created effect corresponding the the postprocess.
  81962. */
  81963. getEffect(): Effect;
  81964. /**
  81965. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  81966. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  81967. */
  81968. getContent(): Nullable<ArrayBufferView>;
  81969. private _createIndexBuffer;
  81970. /** @hidden */
  81971. _rebuild(): void;
  81972. /**
  81973. * Resets the texture in order to recreate its associated resources.
  81974. * This can be called in case of context loss
  81975. */
  81976. reset(): void;
  81977. protected _getDefines(): string;
  81978. /**
  81979. * Is the texture ready to be used ? (rendered at least once)
  81980. * @returns true if ready, otherwise, false.
  81981. */
  81982. isReady(): boolean;
  81983. /**
  81984. * Resets the refresh counter of the texture and start bak from scratch.
  81985. * Could be useful to regenerate the texture if it is setup to render only once.
  81986. */
  81987. resetRefreshCounter(): void;
  81988. /**
  81989. * Set the fragment shader to use in order to render the texture.
  81990. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  81991. */
  81992. setFragment(fragment: any): void;
  81993. /**
  81994. * Define the refresh rate of the texture or the rendering frequency.
  81995. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  81996. */
  81997. refreshRate: number;
  81998. /** @hidden */
  81999. _shouldRender(): boolean;
  82000. /**
  82001. * Get the size the texture is rendering at.
  82002. * @returns the size (texture is always squared)
  82003. */
  82004. getRenderSize(): number;
  82005. /**
  82006. * Resize the texture to new value.
  82007. * @param size Define the new size the texture should have
  82008. * @param generateMipMaps Define whether the new texture should create mip maps
  82009. */
  82010. resize(size: number, generateMipMaps: boolean): void;
  82011. private _checkUniform;
  82012. /**
  82013. * Set a texture in the shader program used to render.
  82014. * @param name Define the name of the uniform samplers as defined in the shader
  82015. * @param texture Define the texture to bind to this sampler
  82016. * @return the texture itself allowing "fluent" like uniform updates
  82017. */
  82018. setTexture(name: string, texture: Texture): ProceduralTexture;
  82019. /**
  82020. * Set a float in the shader.
  82021. * @param name Define the name of the uniform as defined in the shader
  82022. * @param value Define the value to give to the uniform
  82023. * @return the texture itself allowing "fluent" like uniform updates
  82024. */
  82025. setFloat(name: string, value: number): ProceduralTexture;
  82026. /**
  82027. * Set a int in the shader.
  82028. * @param name Define the name of the uniform as defined in the shader
  82029. * @param value Define the value to give to the uniform
  82030. * @return the texture itself allowing "fluent" like uniform updates
  82031. */
  82032. setInt(name: string, value: number): ProceduralTexture;
  82033. /**
  82034. * Set an array of floats in the shader.
  82035. * @param name Define the name of the uniform as defined in the shader
  82036. * @param value Define the value to give to the uniform
  82037. * @return the texture itself allowing "fluent" like uniform updates
  82038. */
  82039. setFloats(name: string, value: number[]): ProceduralTexture;
  82040. /**
  82041. * Set a vec3 in the shader from a Color3.
  82042. * @param name Define the name of the uniform as defined in the shader
  82043. * @param value Define the value to give to the uniform
  82044. * @return the texture itself allowing "fluent" like uniform updates
  82045. */
  82046. setColor3(name: string, value: Color3): ProceduralTexture;
  82047. /**
  82048. * Set a vec4 in the shader from a Color4.
  82049. * @param name Define the name of the uniform as defined in the shader
  82050. * @param value Define the value to give to the uniform
  82051. * @return the texture itself allowing "fluent" like uniform updates
  82052. */
  82053. setColor4(name: string, value: Color4): ProceduralTexture;
  82054. /**
  82055. * Set a vec2 in the shader from a Vector2.
  82056. * @param name Define the name of the uniform as defined in the shader
  82057. * @param value Define the value to give to the uniform
  82058. * @return the texture itself allowing "fluent" like uniform updates
  82059. */
  82060. setVector2(name: string, value: Vector2): ProceduralTexture;
  82061. /**
  82062. * Set a vec3 in the shader from a Vector3.
  82063. * @param name Define the name of the uniform as defined in the shader
  82064. * @param value Define the value to give to the uniform
  82065. * @return the texture itself allowing "fluent" like uniform updates
  82066. */
  82067. setVector3(name: string, value: Vector3): ProceduralTexture;
  82068. /**
  82069. * Set a mat4 in the shader from a MAtrix.
  82070. * @param name Define the name of the uniform as defined in the shader
  82071. * @param value Define the value to give to the uniform
  82072. * @return the texture itself allowing "fluent" like uniform updates
  82073. */
  82074. setMatrix(name: string, value: Matrix): ProceduralTexture;
  82075. /**
  82076. * Render the texture to its associated render target.
  82077. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  82078. */
  82079. render(useCameraPostProcess?: boolean): void;
  82080. /**
  82081. * Clone the texture.
  82082. * @returns the cloned texture
  82083. */
  82084. clone(): ProceduralTexture;
  82085. /**
  82086. * Dispose the texture and release its asoociated resources.
  82087. */
  82088. dispose(): void;
  82089. }
  82090. }
  82091. declare module BABYLON {
  82092. /**
  82093. * This represents the base class for particle system in Babylon.
  82094. * 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.
  82095. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  82096. * @example https://doc.babylonjs.com/babylon101/particles
  82097. */
  82098. export class BaseParticleSystem {
  82099. /**
  82100. * Source color is added to the destination color without alpha affecting the result
  82101. */
  82102. static BLENDMODE_ONEONE: number;
  82103. /**
  82104. * Blend current color and particle color using particle’s alpha
  82105. */
  82106. static BLENDMODE_STANDARD: number;
  82107. /**
  82108. * Add current color and particle color multiplied by particle’s alpha
  82109. */
  82110. static BLENDMODE_ADD: number;
  82111. /**
  82112. * Multiply current color with particle color
  82113. */
  82114. static BLENDMODE_MULTIPLY: number;
  82115. /**
  82116. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  82117. */
  82118. static BLENDMODE_MULTIPLYADD: number;
  82119. /**
  82120. * List of animations used by the particle system.
  82121. */
  82122. animations: Animation[];
  82123. /**
  82124. * The id of the Particle system.
  82125. */
  82126. id: string;
  82127. /**
  82128. * The friendly name of the Particle system.
  82129. */
  82130. name: string;
  82131. /**
  82132. * The rendering group used by the Particle system to chose when to render.
  82133. */
  82134. renderingGroupId: number;
  82135. /**
  82136. * The emitter represents the Mesh or position we are attaching the particle system to.
  82137. */
  82138. emitter: Nullable<AbstractMesh | Vector3>;
  82139. /**
  82140. * The maximum number of particles to emit per frame
  82141. */
  82142. emitRate: number;
  82143. /**
  82144. * If you want to launch only a few particles at once, that can be done, as well.
  82145. */
  82146. manualEmitCount: number;
  82147. /**
  82148. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  82149. */
  82150. updateSpeed: number;
  82151. /**
  82152. * The amount of time the particle system is running (depends of the overall update speed).
  82153. */
  82154. targetStopDuration: number;
  82155. /**
  82156. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  82157. */
  82158. disposeOnStop: boolean;
  82159. /**
  82160. * Minimum power of emitting particles.
  82161. */
  82162. minEmitPower: number;
  82163. /**
  82164. * Maximum power of emitting particles.
  82165. */
  82166. maxEmitPower: number;
  82167. /**
  82168. * Minimum life time of emitting particles.
  82169. */
  82170. minLifeTime: number;
  82171. /**
  82172. * Maximum life time of emitting particles.
  82173. */
  82174. maxLifeTime: number;
  82175. /**
  82176. * Minimum Size of emitting particles.
  82177. */
  82178. minSize: number;
  82179. /**
  82180. * Maximum Size of emitting particles.
  82181. */
  82182. maxSize: number;
  82183. /**
  82184. * Minimum scale of emitting particles on X axis.
  82185. */
  82186. minScaleX: number;
  82187. /**
  82188. * Maximum scale of emitting particles on X axis.
  82189. */
  82190. maxScaleX: number;
  82191. /**
  82192. * Minimum scale of emitting particles on Y axis.
  82193. */
  82194. minScaleY: number;
  82195. /**
  82196. * Maximum scale of emitting particles on Y axis.
  82197. */
  82198. maxScaleY: number;
  82199. /**
  82200. * Gets or sets the minimal initial rotation in radians.
  82201. */
  82202. minInitialRotation: number;
  82203. /**
  82204. * Gets or sets the maximal initial rotation in radians.
  82205. */
  82206. maxInitialRotation: number;
  82207. /**
  82208. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  82209. */
  82210. minAngularSpeed: number;
  82211. /**
  82212. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  82213. */
  82214. maxAngularSpeed: number;
  82215. /**
  82216. * The texture used to render each particle. (this can be a spritesheet)
  82217. */
  82218. particleTexture: Nullable<Texture>;
  82219. /**
  82220. * The layer mask we are rendering the particles through.
  82221. */
  82222. layerMask: number;
  82223. /**
  82224. * This can help using your own shader to render the particle system.
  82225. * The according effect will be created
  82226. */
  82227. customShader: any;
  82228. /**
  82229. * By default particle system starts as soon as they are created. This prevents the
  82230. * automatic start to happen and let you decide when to start emitting particles.
  82231. */
  82232. preventAutoStart: boolean;
  82233. private _noiseTexture;
  82234. /**
  82235. * Gets or sets a texture used to add random noise to particle positions
  82236. */
  82237. noiseTexture: Nullable<ProceduralTexture>;
  82238. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  82239. noiseStrength: Vector3;
  82240. /**
  82241. * Callback triggered when the particle animation is ending.
  82242. */
  82243. onAnimationEnd: Nullable<() => void>;
  82244. /**
  82245. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  82246. */
  82247. blendMode: number;
  82248. /**
  82249. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  82250. * to override the particles.
  82251. */
  82252. forceDepthWrite: boolean;
  82253. /** 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 */
  82254. preWarmCycles: number;
  82255. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  82256. preWarmStepOffset: number;
  82257. /**
  82258. * 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)
  82259. */
  82260. spriteCellChangeSpeed: number;
  82261. /**
  82262. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  82263. */
  82264. startSpriteCellID: number;
  82265. /**
  82266. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  82267. */
  82268. endSpriteCellID: number;
  82269. /**
  82270. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  82271. */
  82272. spriteCellWidth: number;
  82273. /**
  82274. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  82275. */
  82276. spriteCellHeight: number;
  82277. /**
  82278. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  82279. */
  82280. spriteRandomStartCell: boolean;
  82281. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  82282. translationPivot: Vector2;
  82283. /** @hidden */
  82284. protected _isAnimationSheetEnabled: boolean;
  82285. /**
  82286. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  82287. */
  82288. beginAnimationOnStart: boolean;
  82289. /**
  82290. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  82291. */
  82292. beginAnimationFrom: number;
  82293. /**
  82294. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  82295. */
  82296. beginAnimationTo: number;
  82297. /**
  82298. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  82299. */
  82300. beginAnimationLoop: boolean;
  82301. /**
  82302. * Gets or sets a world offset applied to all particles
  82303. */
  82304. worldOffset: Vector3;
  82305. /**
  82306. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  82307. */
  82308. isAnimationSheetEnabled: boolean;
  82309. /**
  82310. * Get hosting scene
  82311. * @returns the scene
  82312. */
  82313. getScene(): Scene;
  82314. /**
  82315. * You can use gravity if you want to give an orientation to your particles.
  82316. */
  82317. gravity: Vector3;
  82318. protected _colorGradients: Nullable<Array<ColorGradient>>;
  82319. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  82320. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  82321. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  82322. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  82323. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  82324. protected _dragGradients: Nullable<Array<FactorGradient>>;
  82325. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  82326. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  82327. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  82328. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  82329. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  82330. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  82331. /**
  82332. * Defines the delay in milliseconds before starting the system (0 by default)
  82333. */
  82334. startDelay: number;
  82335. /**
  82336. * Gets the current list of drag gradients.
  82337. * You must use addDragGradient and removeDragGradient to udpate this list
  82338. * @returns the list of drag gradients
  82339. */
  82340. getDragGradients(): Nullable<Array<FactorGradient>>;
  82341. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  82342. limitVelocityDamping: number;
  82343. /**
  82344. * Gets the current list of limit velocity gradients.
  82345. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  82346. * @returns the list of limit velocity gradients
  82347. */
  82348. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  82349. /**
  82350. * Gets the current list of color gradients.
  82351. * You must use addColorGradient and removeColorGradient to udpate this list
  82352. * @returns the list of color gradients
  82353. */
  82354. getColorGradients(): Nullable<Array<ColorGradient>>;
  82355. /**
  82356. * Gets the current list of size gradients.
  82357. * You must use addSizeGradient and removeSizeGradient to udpate this list
  82358. * @returns the list of size gradients
  82359. */
  82360. getSizeGradients(): Nullable<Array<FactorGradient>>;
  82361. /**
  82362. * Gets the current list of color remap gradients.
  82363. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  82364. * @returns the list of color remap gradients
  82365. */
  82366. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  82367. /**
  82368. * Gets the current list of alpha remap gradients.
  82369. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  82370. * @returns the list of alpha remap gradients
  82371. */
  82372. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  82373. /**
  82374. * Gets the current list of life time gradients.
  82375. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  82376. * @returns the list of life time gradients
  82377. */
  82378. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  82379. /**
  82380. * Gets the current list of angular speed gradients.
  82381. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  82382. * @returns the list of angular speed gradients
  82383. */
  82384. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  82385. /**
  82386. * Gets the current list of velocity gradients.
  82387. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  82388. * @returns the list of velocity gradients
  82389. */
  82390. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  82391. /**
  82392. * Gets the current list of start size gradients.
  82393. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  82394. * @returns the list of start size gradients
  82395. */
  82396. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  82397. /**
  82398. * Gets the current list of emit rate gradients.
  82399. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  82400. * @returns the list of emit rate gradients
  82401. */
  82402. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  82403. /**
  82404. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82405. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82406. */
  82407. direction1: Vector3;
  82408. /**
  82409. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82410. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82411. */
  82412. direction2: Vector3;
  82413. /**
  82414. * 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.
  82415. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82416. */
  82417. minEmitBox: Vector3;
  82418. /**
  82419. * 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.
  82420. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82421. */
  82422. maxEmitBox: Vector3;
  82423. /**
  82424. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  82425. */
  82426. color1: Color4;
  82427. /**
  82428. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  82429. */
  82430. color2: Color4;
  82431. /**
  82432. * Color the particle will have at the end of its lifetime
  82433. */
  82434. colorDead: Color4;
  82435. /**
  82436. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  82437. */
  82438. textureMask: Color4;
  82439. /**
  82440. * The particle emitter type defines the emitter used by the particle system.
  82441. * It can be for example box, sphere, or cone...
  82442. */
  82443. particleEmitterType: IParticleEmitterType;
  82444. /** @hidden */
  82445. _isSubEmitter: boolean;
  82446. /**
  82447. * Gets or sets the billboard mode to use when isBillboardBased = true.
  82448. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  82449. */
  82450. billboardMode: number;
  82451. protected _isBillboardBased: boolean;
  82452. /**
  82453. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  82454. */
  82455. isBillboardBased: boolean;
  82456. /**
  82457. * The scene the particle system belongs to.
  82458. */
  82459. protected _scene: Scene;
  82460. /**
  82461. * Local cache of defines for image processing.
  82462. */
  82463. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  82464. /**
  82465. * Default configuration related to image processing available in the standard Material.
  82466. */
  82467. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  82468. /**
  82469. * Gets the image processing configuration used either in this material.
  82470. */
  82471. /**
  82472. * Sets the Default image processing configuration used either in the this material.
  82473. *
  82474. * If sets to null, the scene one is in use.
  82475. */
  82476. imageProcessingConfiguration: ImageProcessingConfiguration;
  82477. /**
  82478. * Attaches a new image processing configuration to the Standard Material.
  82479. * @param configuration
  82480. */
  82481. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  82482. /** @hidden */
  82483. protected _reset(): void;
  82484. /** @hidden */
  82485. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  82486. /**
  82487. * Instantiates a particle system.
  82488. * 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.
  82489. * @param name The name of the particle system
  82490. */
  82491. constructor(name: string);
  82492. /**
  82493. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  82494. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  82495. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  82496. * @returns the emitter
  82497. */
  82498. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  82499. /**
  82500. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  82501. * @param radius The radius of the hemisphere to emit from
  82502. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  82503. * @returns the emitter
  82504. */
  82505. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  82506. /**
  82507. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  82508. * @param radius The radius of the sphere to emit from
  82509. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  82510. * @returns the emitter
  82511. */
  82512. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  82513. /**
  82514. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  82515. * @param radius The radius of the sphere to emit from
  82516. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  82517. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  82518. * @returns the emitter
  82519. */
  82520. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  82521. /**
  82522. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  82523. * @param radius The radius of the emission cylinder
  82524. * @param height The height of the emission cylinder
  82525. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  82526. * @param directionRandomizer How much to randomize the particle direction [0-1]
  82527. * @returns the emitter
  82528. */
  82529. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  82530. /**
  82531. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  82532. * @param radius The radius of the cylinder to emit from
  82533. * @param height The height of the emission cylinder
  82534. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  82535. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  82536. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  82537. * @returns the emitter
  82538. */
  82539. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  82540. /**
  82541. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  82542. * @param radius The radius of the cone to emit from
  82543. * @param angle The base angle of the cone
  82544. * @returns the emitter
  82545. */
  82546. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  82547. /**
  82548. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  82549. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  82550. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  82551. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  82552. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  82553. * @returns the emitter
  82554. */
  82555. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  82556. }
  82557. }
  82558. declare module BABYLON {
  82559. /**
  82560. * Type of sub emitter
  82561. */
  82562. export enum SubEmitterType {
  82563. /**
  82564. * Attached to the particle over it's lifetime
  82565. */
  82566. ATTACHED = 0,
  82567. /**
  82568. * Created when the particle dies
  82569. */
  82570. END = 1
  82571. }
  82572. /**
  82573. * Sub emitter class used to emit particles from an existing particle
  82574. */
  82575. export class SubEmitter {
  82576. /**
  82577. * the particle system to be used by the sub emitter
  82578. */
  82579. particleSystem: ParticleSystem;
  82580. /**
  82581. * Type of the submitter (Default: END)
  82582. */
  82583. type: SubEmitterType;
  82584. /**
  82585. * 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)
  82586. * Note: This only is supported when using an emitter of type Mesh
  82587. */
  82588. inheritDirection: boolean;
  82589. /**
  82590. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  82591. */
  82592. inheritedVelocityAmount: number;
  82593. /**
  82594. * Creates a sub emitter
  82595. * @param particleSystem the particle system to be used by the sub emitter
  82596. */
  82597. constructor(
  82598. /**
  82599. * the particle system to be used by the sub emitter
  82600. */
  82601. particleSystem: ParticleSystem);
  82602. /**
  82603. * Clones the sub emitter
  82604. * @returns the cloned sub emitter
  82605. */
  82606. clone(): SubEmitter;
  82607. /**
  82608. * Serialize current object to a JSON object
  82609. * @returns the serialized object
  82610. */
  82611. serialize(): any;
  82612. /** @hidden */
  82613. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  82614. /**
  82615. * Creates a new SubEmitter from a serialized JSON version
  82616. * @param serializationObject defines the JSON object to read from
  82617. * @param scene defines the hosting scene
  82618. * @param rootUrl defines the rootUrl for data loading
  82619. * @returns a new SubEmitter
  82620. */
  82621. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  82622. /** Release associated resources */
  82623. dispose(): void;
  82624. }
  82625. }
  82626. declare module BABYLON {
  82627. /** @hidden */
  82628. export var clipPlaneFragmentDeclaration: {
  82629. name: string;
  82630. shader: string;
  82631. };
  82632. }
  82633. declare module BABYLON {
  82634. /** @hidden */
  82635. export var imageProcessingDeclaration: {
  82636. name: string;
  82637. shader: string;
  82638. };
  82639. }
  82640. declare module BABYLON {
  82641. /** @hidden */
  82642. export var imageProcessingFunctions: {
  82643. name: string;
  82644. shader: string;
  82645. };
  82646. }
  82647. declare module BABYLON {
  82648. /** @hidden */
  82649. export var clipPlaneFragment: {
  82650. name: string;
  82651. shader: string;
  82652. };
  82653. }
  82654. declare module BABYLON {
  82655. /** @hidden */
  82656. export var particlesPixelShader: {
  82657. name: string;
  82658. shader: string;
  82659. };
  82660. }
  82661. declare module BABYLON {
  82662. /** @hidden */
  82663. export var clipPlaneVertexDeclaration: {
  82664. name: string;
  82665. shader: string;
  82666. };
  82667. }
  82668. declare module BABYLON {
  82669. /** @hidden */
  82670. export var clipPlaneVertex: {
  82671. name: string;
  82672. shader: string;
  82673. };
  82674. }
  82675. declare module BABYLON {
  82676. /** @hidden */
  82677. export var particlesVertexShader: {
  82678. name: string;
  82679. shader: string;
  82680. };
  82681. }
  82682. declare module BABYLON {
  82683. /**
  82684. * This represents a particle system in Babylon.
  82685. * 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.
  82686. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  82687. * @example https://doc.babylonjs.com/babylon101/particles
  82688. */
  82689. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  82690. /**
  82691. * Billboard mode will only apply to Y axis
  82692. */
  82693. static readonly BILLBOARDMODE_Y: number;
  82694. /**
  82695. * Billboard mode will apply to all axes
  82696. */
  82697. static readonly BILLBOARDMODE_ALL: number;
  82698. /**
  82699. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  82700. */
  82701. static readonly BILLBOARDMODE_STRETCHED: number;
  82702. /**
  82703. * This function can be defined to provide custom update for active particles.
  82704. * This function will be called instead of regular update (age, position, color, etc.).
  82705. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  82706. */
  82707. updateFunction: (particles: Particle[]) => void;
  82708. private _emitterWorldMatrix;
  82709. /**
  82710. * This function can be defined to specify initial direction for every new particle.
  82711. * It by default use the emitterType defined function
  82712. */
  82713. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  82714. /**
  82715. * This function can be defined to specify initial position for every new particle.
  82716. * It by default use the emitterType defined function
  82717. */
  82718. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  82719. /**
  82720. * @hidden
  82721. */
  82722. _inheritedVelocityOffset: Vector3;
  82723. /**
  82724. * An event triggered when the system is disposed
  82725. */
  82726. onDisposeObservable: Observable<ParticleSystem>;
  82727. private _onDisposeObserver;
  82728. /**
  82729. * Sets a callback that will be triggered when the system is disposed
  82730. */
  82731. onDispose: () => void;
  82732. private _particles;
  82733. private _epsilon;
  82734. private _capacity;
  82735. private _stockParticles;
  82736. private _newPartsExcess;
  82737. private _vertexData;
  82738. private _vertexBuffer;
  82739. private _vertexBuffers;
  82740. private _spriteBuffer;
  82741. private _indexBuffer;
  82742. private _effect;
  82743. private _customEffect;
  82744. private _cachedDefines;
  82745. private _scaledColorStep;
  82746. private _colorDiff;
  82747. private _scaledDirection;
  82748. private _scaledGravity;
  82749. private _currentRenderId;
  82750. private _alive;
  82751. private _useInstancing;
  82752. private _started;
  82753. private _stopped;
  82754. private _actualFrame;
  82755. private _scaledUpdateSpeed;
  82756. private _vertexBufferSize;
  82757. /** @hidden */
  82758. _currentEmitRateGradient: Nullable<FactorGradient>;
  82759. /** @hidden */
  82760. _currentEmitRate1: number;
  82761. /** @hidden */
  82762. _currentEmitRate2: number;
  82763. /** @hidden */
  82764. _currentStartSizeGradient: Nullable<FactorGradient>;
  82765. /** @hidden */
  82766. _currentStartSize1: number;
  82767. /** @hidden */
  82768. _currentStartSize2: number;
  82769. private readonly _rawTextureWidth;
  82770. private _rampGradientsTexture;
  82771. private _useRampGradients;
  82772. /** Gets or sets a boolean indicating that ramp gradients must be used
  82773. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  82774. */
  82775. useRampGradients: boolean;
  82776. /**
  82777. * 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.
  82778. * 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: [])
  82779. */
  82780. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  82781. private _subEmitters;
  82782. /**
  82783. * @hidden
  82784. * If the particle systems emitter should be disposed when the particle system is disposed
  82785. */
  82786. _disposeEmitterOnDispose: boolean;
  82787. /**
  82788. * The current active Sub-systems, this property is used by the root particle system only.
  82789. */
  82790. activeSubSystems: Array<ParticleSystem>;
  82791. private _rootParticleSystem;
  82792. /**
  82793. * Gets the current list of active particles
  82794. */
  82795. readonly particles: Particle[];
  82796. /**
  82797. * Returns the string "ParticleSystem"
  82798. * @returns a string containing the class name
  82799. */
  82800. getClassName(): string;
  82801. /**
  82802. * Instantiates a particle system.
  82803. * 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.
  82804. * @param name The name of the particle system
  82805. * @param capacity The max number of particles alive at the same time
  82806. * @param scene The scene the particle system belongs to
  82807. * @param customEffect a custom effect used to change the way particles are rendered by default
  82808. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  82809. * @param epsilon Offset used to render the particles
  82810. */
  82811. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  82812. private _addFactorGradient;
  82813. private _removeFactorGradient;
  82814. /**
  82815. * Adds a new life time gradient
  82816. * @param gradient defines the gradient to use (between 0 and 1)
  82817. * @param factor defines the life time factor to affect to the specified gradient
  82818. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82819. * @returns the current particle system
  82820. */
  82821. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82822. /**
  82823. * Remove a specific life time gradient
  82824. * @param gradient defines the gradient to remove
  82825. * @returns the current particle system
  82826. */
  82827. removeLifeTimeGradient(gradient: number): IParticleSystem;
  82828. /**
  82829. * Adds a new size gradient
  82830. * @param gradient defines the gradient to use (between 0 and 1)
  82831. * @param factor defines the size factor to affect to the specified gradient
  82832. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82833. * @returns the current particle system
  82834. */
  82835. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82836. /**
  82837. * Remove a specific size gradient
  82838. * @param gradient defines the gradient to remove
  82839. * @returns the current particle system
  82840. */
  82841. removeSizeGradient(gradient: number): IParticleSystem;
  82842. /**
  82843. * Adds a new color remap gradient
  82844. * @param gradient defines the gradient to use (between 0 and 1)
  82845. * @param min defines the color remap minimal range
  82846. * @param max defines the color remap maximal range
  82847. * @returns the current particle system
  82848. */
  82849. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  82850. /**
  82851. * Remove a specific color remap gradient
  82852. * @param gradient defines the gradient to remove
  82853. * @returns the current particle system
  82854. */
  82855. removeColorRemapGradient(gradient: number): IParticleSystem;
  82856. /**
  82857. * Adds a new alpha remap gradient
  82858. * @param gradient defines the gradient to use (between 0 and 1)
  82859. * @param min defines the alpha remap minimal range
  82860. * @param max defines the alpha remap maximal range
  82861. * @returns the current particle system
  82862. */
  82863. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  82864. /**
  82865. * Remove a specific alpha remap gradient
  82866. * @param gradient defines the gradient to remove
  82867. * @returns the current particle system
  82868. */
  82869. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  82870. /**
  82871. * Adds a new angular speed gradient
  82872. * @param gradient defines the gradient to use (between 0 and 1)
  82873. * @param factor defines the angular speed to affect to the specified gradient
  82874. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82875. * @returns the current particle system
  82876. */
  82877. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82878. /**
  82879. * Remove a specific angular speed gradient
  82880. * @param gradient defines the gradient to remove
  82881. * @returns the current particle system
  82882. */
  82883. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  82884. /**
  82885. * Adds a new velocity gradient
  82886. * @param gradient defines the gradient to use (between 0 and 1)
  82887. * @param factor defines the velocity to affect to the specified gradient
  82888. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82889. * @returns the current particle system
  82890. */
  82891. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82892. /**
  82893. * Remove a specific velocity gradient
  82894. * @param gradient defines the gradient to remove
  82895. * @returns the current particle system
  82896. */
  82897. removeVelocityGradient(gradient: number): IParticleSystem;
  82898. /**
  82899. * Adds a new limit velocity gradient
  82900. * @param gradient defines the gradient to use (between 0 and 1)
  82901. * @param factor defines the limit velocity value to affect to the specified gradient
  82902. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82903. * @returns the current particle system
  82904. */
  82905. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82906. /**
  82907. * Remove a specific limit velocity gradient
  82908. * @param gradient defines the gradient to remove
  82909. * @returns the current particle system
  82910. */
  82911. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  82912. /**
  82913. * Adds a new drag gradient
  82914. * @param gradient defines the gradient to use (between 0 and 1)
  82915. * @param factor defines the drag value to affect to the specified gradient
  82916. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82917. * @returns the current particle system
  82918. */
  82919. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82920. /**
  82921. * Remove a specific drag gradient
  82922. * @param gradient defines the gradient to remove
  82923. * @returns the current particle system
  82924. */
  82925. removeDragGradient(gradient: number): IParticleSystem;
  82926. /**
  82927. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  82928. * @param gradient defines the gradient to use (between 0 and 1)
  82929. * @param factor defines the emit rate value to affect to the specified gradient
  82930. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82931. * @returns the current particle system
  82932. */
  82933. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82934. /**
  82935. * Remove a specific emit rate gradient
  82936. * @param gradient defines the gradient to remove
  82937. * @returns the current particle system
  82938. */
  82939. removeEmitRateGradient(gradient: number): IParticleSystem;
  82940. /**
  82941. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  82942. * @param gradient defines the gradient to use (between 0 and 1)
  82943. * @param factor defines the start size value to affect to the specified gradient
  82944. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82945. * @returns the current particle system
  82946. */
  82947. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82948. /**
  82949. * Remove a specific start size gradient
  82950. * @param gradient defines the gradient to remove
  82951. * @returns the current particle system
  82952. */
  82953. removeStartSizeGradient(gradient: number): IParticleSystem;
  82954. private _createRampGradientTexture;
  82955. /**
  82956. * Gets the current list of ramp gradients.
  82957. * You must use addRampGradient and removeRampGradient to udpate this list
  82958. * @returns the list of ramp gradients
  82959. */
  82960. getRampGradients(): Nullable<Array<Color3Gradient>>;
  82961. /**
  82962. * Adds a new ramp gradient used to remap particle colors
  82963. * @param gradient defines the gradient to use (between 0 and 1)
  82964. * @param color defines the color to affect to the specified gradient
  82965. * @returns the current particle system
  82966. */
  82967. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  82968. /**
  82969. * Remove a specific ramp gradient
  82970. * @param gradient defines the gradient to remove
  82971. * @returns the current particle system
  82972. */
  82973. removeRampGradient(gradient: number): ParticleSystem;
  82974. /**
  82975. * Adds a new color gradient
  82976. * @param gradient defines the gradient to use (between 0 and 1)
  82977. * @param color1 defines the color to affect to the specified gradient
  82978. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  82979. * @returns this particle system
  82980. */
  82981. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  82982. /**
  82983. * Remove a specific color gradient
  82984. * @param gradient defines the gradient to remove
  82985. * @returns this particle system
  82986. */
  82987. removeColorGradient(gradient: number): IParticleSystem;
  82988. private _fetchR;
  82989. protected _reset(): void;
  82990. private _resetEffect;
  82991. private _createVertexBuffers;
  82992. private _createIndexBuffer;
  82993. /**
  82994. * Gets the maximum number of particles active at the same time.
  82995. * @returns The max number of active particles.
  82996. */
  82997. getCapacity(): number;
  82998. /**
  82999. * Gets whether there are still active particles in the system.
  83000. * @returns True if it is alive, otherwise false.
  83001. */
  83002. isAlive(): boolean;
  83003. /**
  83004. * Gets if the system has been started. (Note: this will still be true after stop is called)
  83005. * @returns True if it has been started, otherwise false.
  83006. */
  83007. isStarted(): boolean;
  83008. private _prepareSubEmitterInternalArray;
  83009. /**
  83010. * Starts the particle system and begins to emit
  83011. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  83012. */
  83013. start(delay?: number): void;
  83014. /**
  83015. * Stops the particle system.
  83016. * @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.
  83017. */
  83018. stop(stopSubEmitters?: boolean): void;
  83019. /**
  83020. * Remove all active particles
  83021. */
  83022. reset(): void;
  83023. /**
  83024. * @hidden (for internal use only)
  83025. */
  83026. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  83027. /**
  83028. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  83029. * Its lifetime will start back at 0.
  83030. */
  83031. recycleParticle: (particle: Particle) => void;
  83032. private _stopSubEmitters;
  83033. private _createParticle;
  83034. private _removeFromRoot;
  83035. private _emitFromParticle;
  83036. private _update;
  83037. /** @hidden */
  83038. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  83039. /** @hidden */
  83040. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  83041. /** @hidden */
  83042. private _getEffect;
  83043. /**
  83044. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  83045. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  83046. */
  83047. animate(preWarmOnly?: boolean): void;
  83048. private _appendParticleVertices;
  83049. /**
  83050. * Rebuilds the particle system.
  83051. */
  83052. rebuild(): void;
  83053. /**
  83054. * Is this system ready to be used/rendered
  83055. * @return true if the system is ready
  83056. */
  83057. isReady(): boolean;
  83058. private _render;
  83059. /**
  83060. * Renders the particle system in its current state.
  83061. * @returns the current number of particles
  83062. */
  83063. render(): number;
  83064. /**
  83065. * Disposes the particle system and free the associated resources
  83066. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  83067. */
  83068. dispose(disposeTexture?: boolean): void;
  83069. /**
  83070. * Clones the particle system.
  83071. * @param name The name of the cloned object
  83072. * @param newEmitter The new emitter to use
  83073. * @returns the cloned particle system
  83074. */
  83075. clone(name: string, newEmitter: any): ParticleSystem;
  83076. /**
  83077. * Serializes the particle system to a JSON object.
  83078. * @returns the JSON object
  83079. */
  83080. serialize(): any;
  83081. /** @hidden */
  83082. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  83083. /** @hidden */
  83084. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  83085. /**
  83086. * Parses a JSON object to create a particle system.
  83087. * @param parsedParticleSystem The JSON object to parse
  83088. * @param scene The scene to create the particle system in
  83089. * @param rootUrl The root url to use to load external dependencies like texture
  83090. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  83091. * @returns the Parsed particle system
  83092. */
  83093. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  83094. }
  83095. }
  83096. declare module BABYLON {
  83097. /**
  83098. * A particle represents one of the element emitted by a particle system.
  83099. * This is mainly define by its coordinates, direction, velocity and age.
  83100. */
  83101. export class Particle {
  83102. /**
  83103. * The particle system the particle belongs to.
  83104. */
  83105. particleSystem: ParticleSystem;
  83106. private static _Count;
  83107. /**
  83108. * Unique ID of the particle
  83109. */
  83110. id: number;
  83111. /**
  83112. * The world position of the particle in the scene.
  83113. */
  83114. position: Vector3;
  83115. /**
  83116. * The world direction of the particle in the scene.
  83117. */
  83118. direction: Vector3;
  83119. /**
  83120. * The color of the particle.
  83121. */
  83122. color: Color4;
  83123. /**
  83124. * The color change of the particle per step.
  83125. */
  83126. colorStep: Color4;
  83127. /**
  83128. * Defines how long will the life of the particle be.
  83129. */
  83130. lifeTime: number;
  83131. /**
  83132. * The current age of the particle.
  83133. */
  83134. age: number;
  83135. /**
  83136. * The current size of the particle.
  83137. */
  83138. size: number;
  83139. /**
  83140. * The current scale of the particle.
  83141. */
  83142. scale: Vector2;
  83143. /**
  83144. * The current angle of the particle.
  83145. */
  83146. angle: number;
  83147. /**
  83148. * Defines how fast is the angle changing.
  83149. */
  83150. angularSpeed: number;
  83151. /**
  83152. * Defines the cell index used by the particle to be rendered from a sprite.
  83153. */
  83154. cellIndex: number;
  83155. /**
  83156. * The information required to support color remapping
  83157. */
  83158. remapData: Vector4;
  83159. /** @hidden */
  83160. _randomCellOffset?: number;
  83161. /** @hidden */
  83162. _initialDirection: Nullable<Vector3>;
  83163. /** @hidden */
  83164. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  83165. /** @hidden */
  83166. _initialStartSpriteCellID: number;
  83167. /** @hidden */
  83168. _initialEndSpriteCellID: number;
  83169. /** @hidden */
  83170. _currentColorGradient: Nullable<ColorGradient>;
  83171. /** @hidden */
  83172. _currentColor1: Color4;
  83173. /** @hidden */
  83174. _currentColor2: Color4;
  83175. /** @hidden */
  83176. _currentSizeGradient: Nullable<FactorGradient>;
  83177. /** @hidden */
  83178. _currentSize1: number;
  83179. /** @hidden */
  83180. _currentSize2: number;
  83181. /** @hidden */
  83182. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  83183. /** @hidden */
  83184. _currentAngularSpeed1: number;
  83185. /** @hidden */
  83186. _currentAngularSpeed2: number;
  83187. /** @hidden */
  83188. _currentVelocityGradient: Nullable<FactorGradient>;
  83189. /** @hidden */
  83190. _currentVelocity1: number;
  83191. /** @hidden */
  83192. _currentVelocity2: number;
  83193. /** @hidden */
  83194. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  83195. /** @hidden */
  83196. _currentLimitVelocity1: number;
  83197. /** @hidden */
  83198. _currentLimitVelocity2: number;
  83199. /** @hidden */
  83200. _currentDragGradient: Nullable<FactorGradient>;
  83201. /** @hidden */
  83202. _currentDrag1: number;
  83203. /** @hidden */
  83204. _currentDrag2: number;
  83205. /** @hidden */
  83206. _randomNoiseCoordinates1: Vector3;
  83207. /** @hidden */
  83208. _randomNoiseCoordinates2: Vector3;
  83209. /**
  83210. * Creates a new instance Particle
  83211. * @param particleSystem the particle system the particle belongs to
  83212. */
  83213. constructor(
  83214. /**
  83215. * The particle system the particle belongs to.
  83216. */
  83217. particleSystem: ParticleSystem);
  83218. private updateCellInfoFromSystem;
  83219. /**
  83220. * Defines how the sprite cell index is updated for the particle
  83221. */
  83222. updateCellIndex(): void;
  83223. /** @hidden */
  83224. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  83225. /** @hidden */
  83226. _inheritParticleInfoToSubEmitters(): void;
  83227. /** @hidden */
  83228. _reset(): void;
  83229. /**
  83230. * Copy the properties of particle to another one.
  83231. * @param other the particle to copy the information to.
  83232. */
  83233. copyTo(other: Particle): void;
  83234. }
  83235. }
  83236. declare module BABYLON {
  83237. /**
  83238. * Particle emitter represents a volume emitting particles.
  83239. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  83240. */
  83241. export interface IParticleEmitterType {
  83242. /**
  83243. * Called by the particle System when the direction is computed for the created particle.
  83244. * @param worldMatrix is the world matrix of the particle system
  83245. * @param directionToUpdate is the direction vector to update with the result
  83246. * @param particle is the particle we are computed the direction for
  83247. */
  83248. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83249. /**
  83250. * Called by the particle System when the position is computed for the created particle.
  83251. * @param worldMatrix is the world matrix of the particle system
  83252. * @param positionToUpdate is the position vector to update with the result
  83253. * @param particle is the particle we are computed the position for
  83254. */
  83255. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83256. /**
  83257. * Clones the current emitter and returns a copy of it
  83258. * @returns the new emitter
  83259. */
  83260. clone(): IParticleEmitterType;
  83261. /**
  83262. * Called by the GPUParticleSystem to setup the update shader
  83263. * @param effect defines the update shader
  83264. */
  83265. applyToShader(effect: Effect): void;
  83266. /**
  83267. * Returns a string to use to update the GPU particles update shader
  83268. * @returns the effect defines string
  83269. */
  83270. getEffectDefines(): string;
  83271. /**
  83272. * Returns a string representing the class name
  83273. * @returns a string containing the class name
  83274. */
  83275. getClassName(): string;
  83276. /**
  83277. * Serializes the particle system to a JSON object.
  83278. * @returns the JSON object
  83279. */
  83280. serialize(): any;
  83281. /**
  83282. * Parse properties from a JSON object
  83283. * @param serializationObject defines the JSON object
  83284. */
  83285. parse(serializationObject: any): void;
  83286. }
  83287. }
  83288. declare module BABYLON {
  83289. /**
  83290. * Particle emitter emitting particles from the inside of a box.
  83291. * It emits the particles randomly between 2 given directions.
  83292. */
  83293. export class BoxParticleEmitter implements IParticleEmitterType {
  83294. /**
  83295. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83296. */
  83297. direction1: Vector3;
  83298. /**
  83299. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83300. */
  83301. direction2: Vector3;
  83302. /**
  83303. * 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.
  83304. */
  83305. minEmitBox: Vector3;
  83306. /**
  83307. * 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.
  83308. */
  83309. maxEmitBox: Vector3;
  83310. /**
  83311. * Creates a new instance BoxParticleEmitter
  83312. */
  83313. constructor();
  83314. /**
  83315. * Called by the particle System when the direction is computed for the created particle.
  83316. * @param worldMatrix is the world matrix of the particle system
  83317. * @param directionToUpdate is the direction vector to update with the result
  83318. * @param particle is the particle we are computed the direction for
  83319. */
  83320. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83321. /**
  83322. * Called by the particle System when the position is computed for the created particle.
  83323. * @param worldMatrix is the world matrix of the particle system
  83324. * @param positionToUpdate is the position vector to update with the result
  83325. * @param particle is the particle we are computed the position for
  83326. */
  83327. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83328. /**
  83329. * Clones the current emitter and returns a copy of it
  83330. * @returns the new emitter
  83331. */
  83332. clone(): BoxParticleEmitter;
  83333. /**
  83334. * Called by the GPUParticleSystem to setup the update shader
  83335. * @param effect defines the update shader
  83336. */
  83337. applyToShader(effect: Effect): void;
  83338. /**
  83339. * Returns a string to use to update the GPU particles update shader
  83340. * @returns a string containng the defines string
  83341. */
  83342. getEffectDefines(): string;
  83343. /**
  83344. * Returns the string "BoxParticleEmitter"
  83345. * @returns a string containing the class name
  83346. */
  83347. getClassName(): string;
  83348. /**
  83349. * Serializes the particle system to a JSON object.
  83350. * @returns the JSON object
  83351. */
  83352. serialize(): any;
  83353. /**
  83354. * Parse properties from a JSON object
  83355. * @param serializationObject defines the JSON object
  83356. */
  83357. parse(serializationObject: any): void;
  83358. }
  83359. }
  83360. declare module BABYLON {
  83361. /**
  83362. * Particle emitter emitting particles from the inside of a cone.
  83363. * It emits the particles alongside the cone volume from the base to the particle.
  83364. * The emission direction might be randomized.
  83365. */
  83366. export class ConeParticleEmitter implements IParticleEmitterType {
  83367. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  83368. directionRandomizer: number;
  83369. private _radius;
  83370. private _angle;
  83371. private _height;
  83372. /**
  83373. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  83374. */
  83375. radiusRange: number;
  83376. /**
  83377. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  83378. */
  83379. heightRange: number;
  83380. /**
  83381. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  83382. */
  83383. emitFromSpawnPointOnly: boolean;
  83384. /**
  83385. * Gets or sets the radius of the emission cone
  83386. */
  83387. radius: number;
  83388. /**
  83389. * Gets or sets the angle of the emission cone
  83390. */
  83391. angle: number;
  83392. private _buildHeight;
  83393. /**
  83394. * Creates a new instance ConeParticleEmitter
  83395. * @param radius the radius of the emission cone (1 by default)
  83396. * @param angle the cone base angle (PI by default)
  83397. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  83398. */
  83399. constructor(radius?: number, angle?: number,
  83400. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  83401. directionRandomizer?: number);
  83402. /**
  83403. * Called by the particle System when the direction is computed for the created particle.
  83404. * @param worldMatrix is the world matrix of the particle system
  83405. * @param directionToUpdate is the direction vector to update with the result
  83406. * @param particle is the particle we are computed the direction for
  83407. */
  83408. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83409. /**
  83410. * Called by the particle System when the position is computed for the created particle.
  83411. * @param worldMatrix is the world matrix of the particle system
  83412. * @param positionToUpdate is the position vector to update with the result
  83413. * @param particle is the particle we are computed the position for
  83414. */
  83415. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83416. /**
  83417. * Clones the current emitter and returns a copy of it
  83418. * @returns the new emitter
  83419. */
  83420. clone(): ConeParticleEmitter;
  83421. /**
  83422. * Called by the GPUParticleSystem to setup the update shader
  83423. * @param effect defines the update shader
  83424. */
  83425. applyToShader(effect: Effect): void;
  83426. /**
  83427. * Returns a string to use to update the GPU particles update shader
  83428. * @returns a string containng the defines string
  83429. */
  83430. getEffectDefines(): string;
  83431. /**
  83432. * Returns the string "ConeParticleEmitter"
  83433. * @returns a string containing the class name
  83434. */
  83435. getClassName(): string;
  83436. /**
  83437. * Serializes the particle system to a JSON object.
  83438. * @returns the JSON object
  83439. */
  83440. serialize(): any;
  83441. /**
  83442. * Parse properties from a JSON object
  83443. * @param serializationObject defines the JSON object
  83444. */
  83445. parse(serializationObject: any): void;
  83446. }
  83447. }
  83448. declare module BABYLON {
  83449. /**
  83450. * Particle emitter emitting particles from the inside of a cylinder.
  83451. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  83452. */
  83453. export class CylinderParticleEmitter implements IParticleEmitterType {
  83454. /**
  83455. * The radius of the emission cylinder.
  83456. */
  83457. radius: number;
  83458. /**
  83459. * The height of the emission cylinder.
  83460. */
  83461. height: number;
  83462. /**
  83463. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83464. */
  83465. radiusRange: number;
  83466. /**
  83467. * How much to randomize the particle direction [0-1].
  83468. */
  83469. directionRandomizer: number;
  83470. /**
  83471. * Creates a new instance CylinderParticleEmitter
  83472. * @param radius the radius of the emission cylinder (1 by default)
  83473. * @param height the height of the emission cylinder (1 by default)
  83474. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83475. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  83476. */
  83477. constructor(
  83478. /**
  83479. * The radius of the emission cylinder.
  83480. */
  83481. radius?: number,
  83482. /**
  83483. * The height of the emission cylinder.
  83484. */
  83485. height?: number,
  83486. /**
  83487. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83488. */
  83489. radiusRange?: number,
  83490. /**
  83491. * How much to randomize the particle direction [0-1].
  83492. */
  83493. directionRandomizer?: number);
  83494. /**
  83495. * Called by the particle System when the direction is computed for the created particle.
  83496. * @param worldMatrix is the world matrix of the particle system
  83497. * @param directionToUpdate is the direction vector to update with the result
  83498. * @param particle is the particle we are computed the direction for
  83499. */
  83500. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83501. /**
  83502. * Called by the particle System when the position is computed for the created particle.
  83503. * @param worldMatrix is the world matrix of the particle system
  83504. * @param positionToUpdate is the position vector to update with the result
  83505. * @param particle is the particle we are computed the position for
  83506. */
  83507. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83508. /**
  83509. * Clones the current emitter and returns a copy of it
  83510. * @returns the new emitter
  83511. */
  83512. clone(): CylinderParticleEmitter;
  83513. /**
  83514. * Called by the GPUParticleSystem to setup the update shader
  83515. * @param effect defines the update shader
  83516. */
  83517. applyToShader(effect: Effect): void;
  83518. /**
  83519. * Returns a string to use to update the GPU particles update shader
  83520. * @returns a string containng the defines string
  83521. */
  83522. getEffectDefines(): string;
  83523. /**
  83524. * Returns the string "CylinderParticleEmitter"
  83525. * @returns a string containing the class name
  83526. */
  83527. getClassName(): string;
  83528. /**
  83529. * Serializes the particle system to a JSON object.
  83530. * @returns the JSON object
  83531. */
  83532. serialize(): any;
  83533. /**
  83534. * Parse properties from a JSON object
  83535. * @param serializationObject defines the JSON object
  83536. */
  83537. parse(serializationObject: any): void;
  83538. }
  83539. /**
  83540. * Particle emitter emitting particles from the inside of a cylinder.
  83541. * It emits the particles randomly between two vectors.
  83542. */
  83543. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  83544. /**
  83545. * The min limit of the emission direction.
  83546. */
  83547. direction1: Vector3;
  83548. /**
  83549. * The max limit of the emission direction.
  83550. */
  83551. direction2: Vector3;
  83552. /**
  83553. * Creates a new instance CylinderDirectedParticleEmitter
  83554. * @param radius the radius of the emission cylinder (1 by default)
  83555. * @param height the height of the emission cylinder (1 by default)
  83556. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83557. * @param direction1 the min limit of the emission direction (up vector by default)
  83558. * @param direction2 the max limit of the emission direction (up vector by default)
  83559. */
  83560. constructor(radius?: number, height?: number, radiusRange?: number,
  83561. /**
  83562. * The min limit of the emission direction.
  83563. */
  83564. direction1?: Vector3,
  83565. /**
  83566. * The max limit of the emission direction.
  83567. */
  83568. direction2?: Vector3);
  83569. /**
  83570. * Called by the particle System when the direction is computed for the created particle.
  83571. * @param worldMatrix is the world matrix of the particle system
  83572. * @param directionToUpdate is the direction vector to update with the result
  83573. * @param particle is the particle we are computed the direction for
  83574. */
  83575. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83576. /**
  83577. * Clones the current emitter and returns a copy of it
  83578. * @returns the new emitter
  83579. */
  83580. clone(): CylinderDirectedParticleEmitter;
  83581. /**
  83582. * Called by the GPUParticleSystem to setup the update shader
  83583. * @param effect defines the update shader
  83584. */
  83585. applyToShader(effect: Effect): void;
  83586. /**
  83587. * Returns a string to use to update the GPU particles update shader
  83588. * @returns a string containng the defines string
  83589. */
  83590. getEffectDefines(): string;
  83591. /**
  83592. * Returns the string "CylinderDirectedParticleEmitter"
  83593. * @returns a string containing the class name
  83594. */
  83595. getClassName(): string;
  83596. /**
  83597. * Serializes the particle system to a JSON object.
  83598. * @returns the JSON object
  83599. */
  83600. serialize(): any;
  83601. /**
  83602. * Parse properties from a JSON object
  83603. * @param serializationObject defines the JSON object
  83604. */
  83605. parse(serializationObject: any): void;
  83606. }
  83607. }
  83608. declare module BABYLON {
  83609. /**
  83610. * Particle emitter emitting particles from the inside of a hemisphere.
  83611. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  83612. */
  83613. export class HemisphericParticleEmitter implements IParticleEmitterType {
  83614. /**
  83615. * The radius of the emission hemisphere.
  83616. */
  83617. radius: number;
  83618. /**
  83619. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83620. */
  83621. radiusRange: number;
  83622. /**
  83623. * How much to randomize the particle direction [0-1].
  83624. */
  83625. directionRandomizer: number;
  83626. /**
  83627. * Creates a new instance HemisphericParticleEmitter
  83628. * @param radius the radius of the emission hemisphere (1 by default)
  83629. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83630. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  83631. */
  83632. constructor(
  83633. /**
  83634. * The radius of the emission hemisphere.
  83635. */
  83636. radius?: number,
  83637. /**
  83638. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83639. */
  83640. radiusRange?: number,
  83641. /**
  83642. * How much to randomize the particle direction [0-1].
  83643. */
  83644. directionRandomizer?: number);
  83645. /**
  83646. * Called by the particle System when the direction is computed for the created particle.
  83647. * @param worldMatrix is the world matrix of the particle system
  83648. * @param directionToUpdate is the direction vector to update with the result
  83649. * @param particle is the particle we are computed the direction for
  83650. */
  83651. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83652. /**
  83653. * Called by the particle System when the position is computed for the created particle.
  83654. * @param worldMatrix is the world matrix of the particle system
  83655. * @param positionToUpdate is the position vector to update with the result
  83656. * @param particle is the particle we are computed the position for
  83657. */
  83658. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83659. /**
  83660. * Clones the current emitter and returns a copy of it
  83661. * @returns the new emitter
  83662. */
  83663. clone(): HemisphericParticleEmitter;
  83664. /**
  83665. * Called by the GPUParticleSystem to setup the update shader
  83666. * @param effect defines the update shader
  83667. */
  83668. applyToShader(effect: Effect): void;
  83669. /**
  83670. * Returns a string to use to update the GPU particles update shader
  83671. * @returns a string containng the defines string
  83672. */
  83673. getEffectDefines(): string;
  83674. /**
  83675. * Returns the string "HemisphericParticleEmitter"
  83676. * @returns a string containing the class name
  83677. */
  83678. getClassName(): string;
  83679. /**
  83680. * Serializes the particle system to a JSON object.
  83681. * @returns the JSON object
  83682. */
  83683. serialize(): any;
  83684. /**
  83685. * Parse properties from a JSON object
  83686. * @param serializationObject defines the JSON object
  83687. */
  83688. parse(serializationObject: any): void;
  83689. }
  83690. }
  83691. declare module BABYLON {
  83692. /**
  83693. * Particle emitter emitting particles from a point.
  83694. * It emits the particles randomly between 2 given directions.
  83695. */
  83696. export class PointParticleEmitter implements IParticleEmitterType {
  83697. /**
  83698. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83699. */
  83700. direction1: Vector3;
  83701. /**
  83702. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83703. */
  83704. direction2: Vector3;
  83705. /**
  83706. * Creates a new instance PointParticleEmitter
  83707. */
  83708. constructor();
  83709. /**
  83710. * Called by the particle System when the direction is computed for the created particle.
  83711. * @param worldMatrix is the world matrix of the particle system
  83712. * @param directionToUpdate is the direction vector to update with the result
  83713. * @param particle is the particle we are computed the direction for
  83714. */
  83715. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83716. /**
  83717. * Called by the particle System when the position is computed for the created particle.
  83718. * @param worldMatrix is the world matrix of the particle system
  83719. * @param positionToUpdate is the position vector to update with the result
  83720. * @param particle is the particle we are computed the position for
  83721. */
  83722. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83723. /**
  83724. * Clones the current emitter and returns a copy of it
  83725. * @returns the new emitter
  83726. */
  83727. clone(): PointParticleEmitter;
  83728. /**
  83729. * Called by the GPUParticleSystem to setup the update shader
  83730. * @param effect defines the update shader
  83731. */
  83732. applyToShader(effect: Effect): void;
  83733. /**
  83734. * Returns a string to use to update the GPU particles update shader
  83735. * @returns a string containng the defines string
  83736. */
  83737. getEffectDefines(): string;
  83738. /**
  83739. * Returns the string "PointParticleEmitter"
  83740. * @returns a string containing the class name
  83741. */
  83742. getClassName(): string;
  83743. /**
  83744. * Serializes the particle system to a JSON object.
  83745. * @returns the JSON object
  83746. */
  83747. serialize(): any;
  83748. /**
  83749. * Parse properties from a JSON object
  83750. * @param serializationObject defines the JSON object
  83751. */
  83752. parse(serializationObject: any): void;
  83753. }
  83754. }
  83755. declare module BABYLON {
  83756. /**
  83757. * Particle emitter emitting particles from the inside of a sphere.
  83758. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  83759. */
  83760. export class SphereParticleEmitter implements IParticleEmitterType {
  83761. /**
  83762. * The radius of the emission sphere.
  83763. */
  83764. radius: number;
  83765. /**
  83766. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83767. */
  83768. radiusRange: number;
  83769. /**
  83770. * How much to randomize the particle direction [0-1].
  83771. */
  83772. directionRandomizer: number;
  83773. /**
  83774. * Creates a new instance SphereParticleEmitter
  83775. * @param radius the radius of the emission sphere (1 by default)
  83776. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83777. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  83778. */
  83779. constructor(
  83780. /**
  83781. * The radius of the emission sphere.
  83782. */
  83783. radius?: number,
  83784. /**
  83785. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83786. */
  83787. radiusRange?: number,
  83788. /**
  83789. * How much to randomize the particle direction [0-1].
  83790. */
  83791. directionRandomizer?: number);
  83792. /**
  83793. * Called by the particle System when the direction is computed for the created particle.
  83794. * @param worldMatrix is the world matrix of the particle system
  83795. * @param directionToUpdate is the direction vector to update with the result
  83796. * @param particle is the particle we are computed the direction for
  83797. */
  83798. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83799. /**
  83800. * Called by the particle System when the position is computed for the created particle.
  83801. * @param worldMatrix is the world matrix of the particle system
  83802. * @param positionToUpdate is the position vector to update with the result
  83803. * @param particle is the particle we are computed the position for
  83804. */
  83805. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83806. /**
  83807. * Clones the current emitter and returns a copy of it
  83808. * @returns the new emitter
  83809. */
  83810. clone(): SphereParticleEmitter;
  83811. /**
  83812. * Called by the GPUParticleSystem to setup the update shader
  83813. * @param effect defines the update shader
  83814. */
  83815. applyToShader(effect: Effect): void;
  83816. /**
  83817. * Returns a string to use to update the GPU particles update shader
  83818. * @returns a string containng the defines string
  83819. */
  83820. getEffectDefines(): string;
  83821. /**
  83822. * Returns the string "SphereParticleEmitter"
  83823. * @returns a string containing the class name
  83824. */
  83825. getClassName(): string;
  83826. /**
  83827. * Serializes the particle system to a JSON object.
  83828. * @returns the JSON object
  83829. */
  83830. serialize(): any;
  83831. /**
  83832. * Parse properties from a JSON object
  83833. * @param serializationObject defines the JSON object
  83834. */
  83835. parse(serializationObject: any): void;
  83836. }
  83837. /**
  83838. * Particle emitter emitting particles from the inside of a sphere.
  83839. * It emits the particles randomly between two vectors.
  83840. */
  83841. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  83842. /**
  83843. * The min limit of the emission direction.
  83844. */
  83845. direction1: Vector3;
  83846. /**
  83847. * The max limit of the emission direction.
  83848. */
  83849. direction2: Vector3;
  83850. /**
  83851. * Creates a new instance SphereDirectedParticleEmitter
  83852. * @param radius the radius of the emission sphere (1 by default)
  83853. * @param direction1 the min limit of the emission direction (up vector by default)
  83854. * @param direction2 the max limit of the emission direction (up vector by default)
  83855. */
  83856. constructor(radius?: number,
  83857. /**
  83858. * The min limit of the emission direction.
  83859. */
  83860. direction1?: Vector3,
  83861. /**
  83862. * The max limit of the emission direction.
  83863. */
  83864. direction2?: Vector3);
  83865. /**
  83866. * Called by the particle System when the direction is computed for the created particle.
  83867. * @param worldMatrix is the world matrix of the particle system
  83868. * @param directionToUpdate is the direction vector to update with the result
  83869. * @param particle is the particle we are computed the direction for
  83870. */
  83871. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83872. /**
  83873. * Clones the current emitter and returns a copy of it
  83874. * @returns the new emitter
  83875. */
  83876. clone(): SphereDirectedParticleEmitter;
  83877. /**
  83878. * Called by the GPUParticleSystem to setup the update shader
  83879. * @param effect defines the update shader
  83880. */
  83881. applyToShader(effect: Effect): void;
  83882. /**
  83883. * Returns a string to use to update the GPU particles update shader
  83884. * @returns a string containng the defines string
  83885. */
  83886. getEffectDefines(): string;
  83887. /**
  83888. * Returns the string "SphereDirectedParticleEmitter"
  83889. * @returns a string containing the class name
  83890. */
  83891. getClassName(): string;
  83892. /**
  83893. * Serializes the particle system to a JSON object.
  83894. * @returns the JSON object
  83895. */
  83896. serialize(): any;
  83897. /**
  83898. * Parse properties from a JSON object
  83899. * @param serializationObject defines the JSON object
  83900. */
  83901. parse(serializationObject: any): void;
  83902. }
  83903. }
  83904. declare module BABYLON {
  83905. /**
  83906. * Interface representing a particle system in Babylon.js.
  83907. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  83908. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  83909. */
  83910. export interface IParticleSystem {
  83911. /**
  83912. * List of animations used by the particle system.
  83913. */
  83914. animations: Animation[];
  83915. /**
  83916. * The id of the Particle system.
  83917. */
  83918. id: string;
  83919. /**
  83920. * The name of the Particle system.
  83921. */
  83922. name: string;
  83923. /**
  83924. * The emitter represents the Mesh or position we are attaching the particle system to.
  83925. */
  83926. emitter: Nullable<AbstractMesh | Vector3>;
  83927. /**
  83928. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  83929. */
  83930. isBillboardBased: boolean;
  83931. /**
  83932. * The rendering group used by the Particle system to chose when to render.
  83933. */
  83934. renderingGroupId: number;
  83935. /**
  83936. * The layer mask we are rendering the particles through.
  83937. */
  83938. layerMask: number;
  83939. /**
  83940. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  83941. */
  83942. updateSpeed: number;
  83943. /**
  83944. * The amount of time the particle system is running (depends of the overall update speed).
  83945. */
  83946. targetStopDuration: number;
  83947. /**
  83948. * The texture used to render each particle. (this can be a spritesheet)
  83949. */
  83950. particleTexture: Nullable<Texture>;
  83951. /**
  83952. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  83953. */
  83954. blendMode: number;
  83955. /**
  83956. * Minimum life time of emitting particles.
  83957. */
  83958. minLifeTime: number;
  83959. /**
  83960. * Maximum life time of emitting particles.
  83961. */
  83962. maxLifeTime: number;
  83963. /**
  83964. * Minimum Size of emitting particles.
  83965. */
  83966. minSize: number;
  83967. /**
  83968. * Maximum Size of emitting particles.
  83969. */
  83970. maxSize: number;
  83971. /**
  83972. * Minimum scale of emitting particles on X axis.
  83973. */
  83974. minScaleX: number;
  83975. /**
  83976. * Maximum scale of emitting particles on X axis.
  83977. */
  83978. maxScaleX: number;
  83979. /**
  83980. * Minimum scale of emitting particles on Y axis.
  83981. */
  83982. minScaleY: number;
  83983. /**
  83984. * Maximum scale of emitting particles on Y axis.
  83985. */
  83986. maxScaleY: number;
  83987. /**
  83988. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  83989. */
  83990. color1: Color4;
  83991. /**
  83992. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  83993. */
  83994. color2: Color4;
  83995. /**
  83996. * Color the particle will have at the end of its lifetime.
  83997. */
  83998. colorDead: Color4;
  83999. /**
  84000. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  84001. */
  84002. emitRate: number;
  84003. /**
  84004. * You can use gravity if you want to give an orientation to your particles.
  84005. */
  84006. gravity: Vector3;
  84007. /**
  84008. * Minimum power of emitting particles.
  84009. */
  84010. minEmitPower: number;
  84011. /**
  84012. * Maximum power of emitting particles.
  84013. */
  84014. maxEmitPower: number;
  84015. /**
  84016. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  84017. */
  84018. minAngularSpeed: number;
  84019. /**
  84020. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  84021. */
  84022. maxAngularSpeed: number;
  84023. /**
  84024. * Gets or sets the minimal initial rotation in radians.
  84025. */
  84026. minInitialRotation: number;
  84027. /**
  84028. * Gets or sets the maximal initial rotation in radians.
  84029. */
  84030. maxInitialRotation: number;
  84031. /**
  84032. * The particle emitter type defines the emitter used by the particle system.
  84033. * It can be for example box, sphere, or cone...
  84034. */
  84035. particleEmitterType: Nullable<IParticleEmitterType>;
  84036. /**
  84037. * Defines the delay in milliseconds before starting the system (0 by default)
  84038. */
  84039. startDelay: number;
  84040. /**
  84041. * 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
  84042. */
  84043. preWarmCycles: number;
  84044. /**
  84045. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  84046. */
  84047. preWarmStepOffset: number;
  84048. /**
  84049. * 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)
  84050. */
  84051. spriteCellChangeSpeed: number;
  84052. /**
  84053. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  84054. */
  84055. startSpriteCellID: number;
  84056. /**
  84057. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  84058. */
  84059. endSpriteCellID: number;
  84060. /**
  84061. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  84062. */
  84063. spriteCellWidth: number;
  84064. /**
  84065. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  84066. */
  84067. spriteCellHeight: number;
  84068. /**
  84069. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  84070. */
  84071. spriteRandomStartCell: boolean;
  84072. /**
  84073. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  84074. */
  84075. isAnimationSheetEnabled: boolean;
  84076. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  84077. translationPivot: Vector2;
  84078. /**
  84079. * Gets or sets a texture used to add random noise to particle positions
  84080. */
  84081. noiseTexture: Nullable<BaseTexture>;
  84082. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  84083. noiseStrength: Vector3;
  84084. /**
  84085. * Gets or sets the billboard mode to use when isBillboardBased = true.
  84086. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  84087. */
  84088. billboardMode: number;
  84089. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  84090. limitVelocityDamping: number;
  84091. /**
  84092. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  84093. */
  84094. beginAnimationOnStart: boolean;
  84095. /**
  84096. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  84097. */
  84098. beginAnimationFrom: number;
  84099. /**
  84100. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  84101. */
  84102. beginAnimationTo: number;
  84103. /**
  84104. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  84105. */
  84106. beginAnimationLoop: boolean;
  84107. /**
  84108. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  84109. */
  84110. disposeOnStop: boolean;
  84111. /**
  84112. * Gets the maximum number of particles active at the same time.
  84113. * @returns The max number of active particles.
  84114. */
  84115. getCapacity(): number;
  84116. /**
  84117. * Gets if the system has been started. (Note: this will still be true after stop is called)
  84118. * @returns True if it has been started, otherwise false.
  84119. */
  84120. isStarted(): boolean;
  84121. /**
  84122. * Animates the particle system for this frame.
  84123. */
  84124. animate(): void;
  84125. /**
  84126. * Renders the particle system in its current state.
  84127. * @returns the current number of particles
  84128. */
  84129. render(): number;
  84130. /**
  84131. * Dispose the particle system and frees its associated resources.
  84132. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  84133. */
  84134. dispose(disposeTexture?: boolean): void;
  84135. /**
  84136. * Clones the particle system.
  84137. * @param name The name of the cloned object
  84138. * @param newEmitter The new emitter to use
  84139. * @returns the cloned particle system
  84140. */
  84141. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  84142. /**
  84143. * Serializes the particle system to a JSON object.
  84144. * @returns the JSON object
  84145. */
  84146. serialize(): any;
  84147. /**
  84148. * Rebuild the particle system
  84149. */
  84150. rebuild(): void;
  84151. /**
  84152. * Starts the particle system and begins to emit
  84153. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  84154. */
  84155. start(delay?: number): void;
  84156. /**
  84157. * Stops the particle system.
  84158. */
  84159. stop(): void;
  84160. /**
  84161. * Remove all active particles
  84162. */
  84163. reset(): void;
  84164. /**
  84165. * Is this system ready to be used/rendered
  84166. * @return true if the system is ready
  84167. */
  84168. isReady(): boolean;
  84169. /**
  84170. * Adds a new color gradient
  84171. * @param gradient defines the gradient to use (between 0 and 1)
  84172. * @param color1 defines the color to affect to the specified gradient
  84173. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  84174. * @returns the current particle system
  84175. */
  84176. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  84177. /**
  84178. * Remove a specific color gradient
  84179. * @param gradient defines the gradient to remove
  84180. * @returns the current particle system
  84181. */
  84182. removeColorGradient(gradient: number): IParticleSystem;
  84183. /**
  84184. * Adds a new size gradient
  84185. * @param gradient defines the gradient to use (between 0 and 1)
  84186. * @param factor defines the size factor to affect to the specified gradient
  84187. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84188. * @returns the current particle system
  84189. */
  84190. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84191. /**
  84192. * Remove a specific size gradient
  84193. * @param gradient defines the gradient to remove
  84194. * @returns the current particle system
  84195. */
  84196. removeSizeGradient(gradient: number): IParticleSystem;
  84197. /**
  84198. * Gets the current list of color gradients.
  84199. * You must use addColorGradient and removeColorGradient to udpate this list
  84200. * @returns the list of color gradients
  84201. */
  84202. getColorGradients(): Nullable<Array<ColorGradient>>;
  84203. /**
  84204. * Gets the current list of size gradients.
  84205. * You must use addSizeGradient and removeSizeGradient to udpate this list
  84206. * @returns the list of size gradients
  84207. */
  84208. getSizeGradients(): Nullable<Array<FactorGradient>>;
  84209. /**
  84210. * Gets the current list of angular speed gradients.
  84211. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  84212. * @returns the list of angular speed gradients
  84213. */
  84214. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  84215. /**
  84216. * Adds a new angular speed gradient
  84217. * @param gradient defines the gradient to use (between 0 and 1)
  84218. * @param factor defines the angular speed to affect to the specified gradient
  84219. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84220. * @returns the current particle system
  84221. */
  84222. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84223. /**
  84224. * Remove a specific angular speed gradient
  84225. * @param gradient defines the gradient to remove
  84226. * @returns the current particle system
  84227. */
  84228. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  84229. /**
  84230. * Gets the current list of velocity gradients.
  84231. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  84232. * @returns the list of velocity gradients
  84233. */
  84234. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  84235. /**
  84236. * Adds a new velocity gradient
  84237. * @param gradient defines the gradient to use (between 0 and 1)
  84238. * @param factor defines the velocity to affect to the specified gradient
  84239. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84240. * @returns the current particle system
  84241. */
  84242. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84243. /**
  84244. * Remove a specific velocity gradient
  84245. * @param gradient defines the gradient to remove
  84246. * @returns the current particle system
  84247. */
  84248. removeVelocityGradient(gradient: number): IParticleSystem;
  84249. /**
  84250. * Gets the current list of limit velocity gradients.
  84251. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  84252. * @returns the list of limit velocity gradients
  84253. */
  84254. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  84255. /**
  84256. * Adds a new limit velocity gradient
  84257. * @param gradient defines the gradient to use (between 0 and 1)
  84258. * @param factor defines the limit velocity to affect to the specified gradient
  84259. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84260. * @returns the current particle system
  84261. */
  84262. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84263. /**
  84264. * Remove a specific limit velocity gradient
  84265. * @param gradient defines the gradient to remove
  84266. * @returns the current particle system
  84267. */
  84268. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  84269. /**
  84270. * Adds a new drag gradient
  84271. * @param gradient defines the gradient to use (between 0 and 1)
  84272. * @param factor defines the drag to affect to the specified gradient
  84273. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84274. * @returns the current particle system
  84275. */
  84276. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84277. /**
  84278. * Remove a specific drag gradient
  84279. * @param gradient defines the gradient to remove
  84280. * @returns the current particle system
  84281. */
  84282. removeDragGradient(gradient: number): IParticleSystem;
  84283. /**
  84284. * Gets the current list of drag gradients.
  84285. * You must use addDragGradient and removeDragGradient to udpate this list
  84286. * @returns the list of drag gradients
  84287. */
  84288. getDragGradients(): Nullable<Array<FactorGradient>>;
  84289. /**
  84290. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  84291. * @param gradient defines the gradient to use (between 0 and 1)
  84292. * @param factor defines the emit rate to affect to the specified gradient
  84293. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84294. * @returns the current particle system
  84295. */
  84296. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84297. /**
  84298. * Remove a specific emit rate gradient
  84299. * @param gradient defines the gradient to remove
  84300. * @returns the current particle system
  84301. */
  84302. removeEmitRateGradient(gradient: number): IParticleSystem;
  84303. /**
  84304. * Gets the current list of emit rate gradients.
  84305. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  84306. * @returns the list of emit rate gradients
  84307. */
  84308. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  84309. /**
  84310. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  84311. * @param gradient defines the gradient to use (between 0 and 1)
  84312. * @param factor defines the start size to affect to the specified gradient
  84313. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84314. * @returns the current particle system
  84315. */
  84316. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84317. /**
  84318. * Remove a specific start size gradient
  84319. * @param gradient defines the gradient to remove
  84320. * @returns the current particle system
  84321. */
  84322. removeStartSizeGradient(gradient: number): IParticleSystem;
  84323. /**
  84324. * Gets the current list of start size gradients.
  84325. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  84326. * @returns the list of start size gradients
  84327. */
  84328. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  84329. /**
  84330. * Adds a new life time gradient
  84331. * @param gradient defines the gradient to use (between 0 and 1)
  84332. * @param factor defines the life time factor to affect to the specified gradient
  84333. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84334. * @returns the current particle system
  84335. */
  84336. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84337. /**
  84338. * Remove a specific life time gradient
  84339. * @param gradient defines the gradient to remove
  84340. * @returns the current particle system
  84341. */
  84342. removeLifeTimeGradient(gradient: number): IParticleSystem;
  84343. /**
  84344. * Gets the current list of life time gradients.
  84345. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  84346. * @returns the list of life time gradients
  84347. */
  84348. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  84349. /**
  84350. * Gets the current list of color gradients.
  84351. * You must use addColorGradient and removeColorGradient to udpate this list
  84352. * @returns the list of color gradients
  84353. */
  84354. getColorGradients(): Nullable<Array<ColorGradient>>;
  84355. /**
  84356. * Adds a new ramp gradient used to remap particle colors
  84357. * @param gradient defines the gradient to use (between 0 and 1)
  84358. * @param color defines the color to affect to the specified gradient
  84359. * @returns the current particle system
  84360. */
  84361. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  84362. /**
  84363. * Gets the current list of ramp gradients.
  84364. * You must use addRampGradient and removeRampGradient to udpate this list
  84365. * @returns the list of ramp gradients
  84366. */
  84367. getRampGradients(): Nullable<Array<Color3Gradient>>;
  84368. /** Gets or sets a boolean indicating that ramp gradients must be used
  84369. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  84370. */
  84371. useRampGradients: boolean;
  84372. /**
  84373. * Adds a new color remap gradient
  84374. * @param gradient defines the gradient to use (between 0 and 1)
  84375. * @param min defines the color remap minimal range
  84376. * @param max defines the color remap maximal range
  84377. * @returns the current particle system
  84378. */
  84379. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84380. /**
  84381. * Gets the current list of color remap gradients.
  84382. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  84383. * @returns the list of color remap gradients
  84384. */
  84385. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  84386. /**
  84387. * Adds a new alpha remap gradient
  84388. * @param gradient defines the gradient to use (between 0 and 1)
  84389. * @param min defines the alpha remap minimal range
  84390. * @param max defines the alpha remap maximal range
  84391. * @returns the current particle system
  84392. */
  84393. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84394. /**
  84395. * Gets the current list of alpha remap gradients.
  84396. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  84397. * @returns the list of alpha remap gradients
  84398. */
  84399. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  84400. /**
  84401. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  84402. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84403. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84404. * @returns the emitter
  84405. */
  84406. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  84407. /**
  84408. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  84409. * @param radius The radius of the hemisphere to emit from
  84410. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84411. * @returns the emitter
  84412. */
  84413. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  84414. /**
  84415. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  84416. * @param radius The radius of the sphere to emit from
  84417. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84418. * @returns the emitter
  84419. */
  84420. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  84421. /**
  84422. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  84423. * @param radius The radius of the sphere to emit from
  84424. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  84425. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  84426. * @returns the emitter
  84427. */
  84428. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  84429. /**
  84430. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  84431. * @param radius The radius of the emission cylinder
  84432. * @param height The height of the emission cylinder
  84433. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  84434. * @param directionRandomizer How much to randomize the particle direction [0-1]
  84435. * @returns the emitter
  84436. */
  84437. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  84438. /**
  84439. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  84440. * @param radius The radius of the cylinder to emit from
  84441. * @param height The height of the emission cylinder
  84442. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84443. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  84444. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  84445. * @returns the emitter
  84446. */
  84447. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  84448. /**
  84449. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  84450. * @param radius The radius of the cone to emit from
  84451. * @param angle The base angle of the cone
  84452. * @returns the emitter
  84453. */
  84454. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  84455. /**
  84456. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  84457. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84458. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84459. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84460. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84461. * @returns the emitter
  84462. */
  84463. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  84464. /**
  84465. * Get hosting scene
  84466. * @returns the scene
  84467. */
  84468. getScene(): Scene;
  84469. }
  84470. }
  84471. declare module BABYLON {
  84472. /**
  84473. * Creates an instance based on a source mesh.
  84474. */
  84475. export class InstancedMesh extends AbstractMesh {
  84476. private _sourceMesh;
  84477. private _currentLOD;
  84478. /** @hidden */
  84479. _indexInSourceMeshInstanceArray: number;
  84480. constructor(name: string, source: Mesh);
  84481. /**
  84482. * Returns the string "InstancedMesh".
  84483. */
  84484. getClassName(): string;
  84485. /** Gets the list of lights affecting that mesh */
  84486. readonly lightSources: Light[];
  84487. _resyncLightSources(): void;
  84488. _resyncLighSource(light: Light): void;
  84489. _removeLightSource(light: Light, dispose: boolean): void;
  84490. /**
  84491. * If the source mesh receives shadows
  84492. */
  84493. readonly receiveShadows: boolean;
  84494. /**
  84495. * The material of the source mesh
  84496. */
  84497. readonly material: Nullable<Material>;
  84498. /**
  84499. * Visibility of the source mesh
  84500. */
  84501. readonly visibility: number;
  84502. /**
  84503. * Skeleton of the source mesh
  84504. */
  84505. readonly skeleton: Nullable<Skeleton>;
  84506. /**
  84507. * Rendering ground id of the source mesh
  84508. */
  84509. renderingGroupId: number;
  84510. /**
  84511. * Returns the total number of vertices (integer).
  84512. */
  84513. getTotalVertices(): number;
  84514. /**
  84515. * Returns a positive integer : the total number of indices in this mesh geometry.
  84516. * @returns the numner of indices or zero if the mesh has no geometry.
  84517. */
  84518. getTotalIndices(): number;
  84519. /**
  84520. * The source mesh of the instance
  84521. */
  84522. readonly sourceMesh: Mesh;
  84523. /**
  84524. * Is this node ready to be used/rendered
  84525. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  84526. * @return {boolean} is it ready
  84527. */
  84528. isReady(completeCheck?: boolean): boolean;
  84529. /**
  84530. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  84531. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  84532. * @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.
  84533. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  84534. */
  84535. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  84536. /**
  84537. * Sets the vertex data of the mesh geometry for the requested `kind`.
  84538. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  84539. * The `data` are either a numeric array either a Float32Array.
  84540. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  84541. * 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).
  84542. * Note that a new underlying VertexBuffer object is created each call.
  84543. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  84544. *
  84545. * Possible `kind` values :
  84546. * - VertexBuffer.PositionKind
  84547. * - VertexBuffer.UVKind
  84548. * - VertexBuffer.UV2Kind
  84549. * - VertexBuffer.UV3Kind
  84550. * - VertexBuffer.UV4Kind
  84551. * - VertexBuffer.UV5Kind
  84552. * - VertexBuffer.UV6Kind
  84553. * - VertexBuffer.ColorKind
  84554. * - VertexBuffer.MatricesIndicesKind
  84555. * - VertexBuffer.MatricesIndicesExtraKind
  84556. * - VertexBuffer.MatricesWeightsKind
  84557. * - VertexBuffer.MatricesWeightsExtraKind
  84558. *
  84559. * Returns the Mesh.
  84560. */
  84561. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  84562. /**
  84563. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  84564. * If the mesh has no geometry, it is simply returned as it is.
  84565. * The `data` are either a numeric array either a Float32Array.
  84566. * No new underlying VertexBuffer object is created.
  84567. * 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.
  84568. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  84569. *
  84570. * Possible `kind` values :
  84571. * - VertexBuffer.PositionKind
  84572. * - VertexBuffer.UVKind
  84573. * - VertexBuffer.UV2Kind
  84574. * - VertexBuffer.UV3Kind
  84575. * - VertexBuffer.UV4Kind
  84576. * - VertexBuffer.UV5Kind
  84577. * - VertexBuffer.UV6Kind
  84578. * - VertexBuffer.ColorKind
  84579. * - VertexBuffer.MatricesIndicesKind
  84580. * - VertexBuffer.MatricesIndicesExtraKind
  84581. * - VertexBuffer.MatricesWeightsKind
  84582. * - VertexBuffer.MatricesWeightsExtraKind
  84583. *
  84584. * Returns the Mesh.
  84585. */
  84586. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  84587. /**
  84588. * Sets the mesh indices.
  84589. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  84590. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  84591. * This method creates a new index buffer each call.
  84592. * Returns the Mesh.
  84593. */
  84594. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  84595. /**
  84596. * Boolean : True if the mesh owns the requested kind of data.
  84597. */
  84598. isVerticesDataPresent(kind: string): boolean;
  84599. /**
  84600. * Returns an array of indices (IndicesArray).
  84601. */
  84602. getIndices(): Nullable<IndicesArray>;
  84603. readonly _positions: Nullable<Vector3[]>;
  84604. /**
  84605. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  84606. * This means the mesh underlying bounding box and sphere are recomputed.
  84607. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  84608. * @returns the current mesh
  84609. */
  84610. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  84611. /** @hidden */
  84612. _preActivate(): InstancedMesh;
  84613. /** @hidden */
  84614. _activate(renderId: number, intermediateRendering: boolean): boolean;
  84615. /** @hidden */
  84616. _postActivate(): void;
  84617. getWorldMatrix(): Matrix;
  84618. readonly isAnInstance: boolean;
  84619. /**
  84620. * Returns the current associated LOD AbstractMesh.
  84621. */
  84622. getLOD(camera: Camera): AbstractMesh;
  84623. /** @hidden */
  84624. _syncSubMeshes(): InstancedMesh;
  84625. /** @hidden */
  84626. _generatePointsArray(): boolean;
  84627. /**
  84628. * Creates a new InstancedMesh from the current mesh.
  84629. * - name (string) : the cloned mesh name
  84630. * - newParent (optional Node) : the optional Node to parent the clone to.
  84631. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  84632. *
  84633. * Returns the clone.
  84634. */
  84635. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  84636. /**
  84637. * Disposes the InstancedMesh.
  84638. * Returns nothing.
  84639. */
  84640. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  84641. }
  84642. }
  84643. declare module BABYLON {
  84644. /**
  84645. * Defines the options associated with the creation of a shader material.
  84646. */
  84647. export interface IShaderMaterialOptions {
  84648. /**
  84649. * Does the material work in alpha blend mode
  84650. */
  84651. needAlphaBlending: boolean;
  84652. /**
  84653. * Does the material work in alpha test mode
  84654. */
  84655. needAlphaTesting: boolean;
  84656. /**
  84657. * The list of attribute names used in the shader
  84658. */
  84659. attributes: string[];
  84660. /**
  84661. * The list of unifrom names used in the shader
  84662. */
  84663. uniforms: string[];
  84664. /**
  84665. * The list of UBO names used in the shader
  84666. */
  84667. uniformBuffers: string[];
  84668. /**
  84669. * The list of sampler names used in the shader
  84670. */
  84671. samplers: string[];
  84672. /**
  84673. * The list of defines used in the shader
  84674. */
  84675. defines: string[];
  84676. }
  84677. /**
  84678. * 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.
  84679. *
  84680. * This returned material effects how the mesh will look based on the code in the shaders.
  84681. *
  84682. * @see http://doc.babylonjs.com/how_to/shader_material
  84683. */
  84684. export class ShaderMaterial extends Material {
  84685. private _shaderPath;
  84686. private _options;
  84687. private _textures;
  84688. private _textureArrays;
  84689. private _floats;
  84690. private _ints;
  84691. private _floatsArrays;
  84692. private _colors3;
  84693. private _colors3Arrays;
  84694. private _colors4;
  84695. private _colors4Arrays;
  84696. private _vectors2;
  84697. private _vectors3;
  84698. private _vectors4;
  84699. private _matrices;
  84700. private _matrices3x3;
  84701. private _matrices2x2;
  84702. private _vectors2Arrays;
  84703. private _vectors3Arrays;
  84704. private _vectors4Arrays;
  84705. private _cachedWorldViewMatrix;
  84706. private _cachedWorldViewProjectionMatrix;
  84707. private _renderId;
  84708. /**
  84709. * Instantiate a new shader material.
  84710. * 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.
  84711. * This returned material effects how the mesh will look based on the code in the shaders.
  84712. * @see http://doc.babylonjs.com/how_to/shader_material
  84713. * @param name Define the name of the material in the scene
  84714. * @param scene Define the scene the material belongs to
  84715. * @param shaderPath Defines the route to the shader code in one of three ways:
  84716. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  84717. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  84718. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  84719. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  84720. * @param options Define the options used to create the shader
  84721. */
  84722. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  84723. /**
  84724. * Gets the options used to compile the shader.
  84725. * They can be modified to trigger a new compilation
  84726. */
  84727. readonly options: IShaderMaterialOptions;
  84728. /**
  84729. * Gets the current class name of the material e.g. "ShaderMaterial"
  84730. * Mainly use in serialization.
  84731. * @returns the class name
  84732. */
  84733. getClassName(): string;
  84734. /**
  84735. * Specifies if the material will require alpha blending
  84736. * @returns a boolean specifying if alpha blending is needed
  84737. */
  84738. needAlphaBlending(): boolean;
  84739. /**
  84740. * Specifies if this material should be rendered in alpha test mode
  84741. * @returns a boolean specifying if an alpha test is needed.
  84742. */
  84743. needAlphaTesting(): boolean;
  84744. private _checkUniform;
  84745. /**
  84746. * Set a texture in the shader.
  84747. * @param name Define the name of the uniform samplers as defined in the shader
  84748. * @param texture Define the texture to bind to this sampler
  84749. * @return the material itself allowing "fluent" like uniform updates
  84750. */
  84751. setTexture(name: string, texture: Texture): ShaderMaterial;
  84752. /**
  84753. * Set a texture array in the shader.
  84754. * @param name Define the name of the uniform sampler array as defined in the shader
  84755. * @param textures Define the list of textures to bind to this sampler
  84756. * @return the material itself allowing "fluent" like uniform updates
  84757. */
  84758. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  84759. /**
  84760. * Set a float in the shader.
  84761. * @param name Define the name of the uniform as defined in the shader
  84762. * @param value Define the value to give to the uniform
  84763. * @return the material itself allowing "fluent" like uniform updates
  84764. */
  84765. setFloat(name: string, value: number): ShaderMaterial;
  84766. /**
  84767. * Set a int in the shader.
  84768. * @param name Define the name of the uniform as defined in the shader
  84769. * @param value Define the value to give to the uniform
  84770. * @return the material itself allowing "fluent" like uniform updates
  84771. */
  84772. setInt(name: string, value: number): ShaderMaterial;
  84773. /**
  84774. * Set an array of floats in the shader.
  84775. * @param name Define the name of the uniform as defined in the shader
  84776. * @param value Define the value to give to the uniform
  84777. * @return the material itself allowing "fluent" like uniform updates
  84778. */
  84779. setFloats(name: string, value: number[]): ShaderMaterial;
  84780. /**
  84781. * Set a vec3 in the shader from a Color3.
  84782. * @param name Define the name of the uniform as defined in the shader
  84783. * @param value Define the value to give to the uniform
  84784. * @return the material itself allowing "fluent" like uniform updates
  84785. */
  84786. setColor3(name: string, value: Color3): ShaderMaterial;
  84787. /**
  84788. * Set a vec3 array in the shader from a Color3 array.
  84789. * @param name Define the name of the uniform as defined in the shader
  84790. * @param value Define the value to give to the uniform
  84791. * @return the material itself allowing "fluent" like uniform updates
  84792. */
  84793. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  84794. /**
  84795. * Set a vec4 in the shader from a Color4.
  84796. * @param name Define the name of the uniform as defined in the shader
  84797. * @param value Define the value to give to the uniform
  84798. * @return the material itself allowing "fluent" like uniform updates
  84799. */
  84800. setColor4(name: string, value: Color4): ShaderMaterial;
  84801. /**
  84802. * Set a vec4 array in the shader from a Color4 array.
  84803. * @param name Define the name of the uniform as defined in the shader
  84804. * @param value Define the value to give to the uniform
  84805. * @return the material itself allowing "fluent" like uniform updates
  84806. */
  84807. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  84808. /**
  84809. * Set a vec2 in the shader from a Vector2.
  84810. * @param name Define the name of the uniform as defined in the shader
  84811. * @param value Define the value to give to the uniform
  84812. * @return the material itself allowing "fluent" like uniform updates
  84813. */
  84814. setVector2(name: string, value: Vector2): ShaderMaterial;
  84815. /**
  84816. * Set a vec3 in the shader from a Vector3.
  84817. * @param name Define the name of the uniform as defined in the shader
  84818. * @param value Define the value to give to the uniform
  84819. * @return the material itself allowing "fluent" like uniform updates
  84820. */
  84821. setVector3(name: string, value: Vector3): ShaderMaterial;
  84822. /**
  84823. * Set a vec4 in the shader from a Vector4.
  84824. * @param name Define the name of the uniform as defined in the shader
  84825. * @param value Define the value to give to the uniform
  84826. * @return the material itself allowing "fluent" like uniform updates
  84827. */
  84828. setVector4(name: string, value: Vector4): ShaderMaterial;
  84829. /**
  84830. * Set a mat4 in the shader from a Matrix.
  84831. * @param name Define the name of the uniform as defined in the shader
  84832. * @param value Define the value to give to the uniform
  84833. * @return the material itself allowing "fluent" like uniform updates
  84834. */
  84835. setMatrix(name: string, value: Matrix): ShaderMaterial;
  84836. /**
  84837. * Set a mat3 in the shader from a Float32Array.
  84838. * @param name Define the name of the uniform as defined in the shader
  84839. * @param value Define the value to give to the uniform
  84840. * @return the material itself allowing "fluent" like uniform updates
  84841. */
  84842. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  84843. /**
  84844. * Set a mat2 in the shader from a Float32Array.
  84845. * @param name Define the name of the uniform as defined in the shader
  84846. * @param value Define the value to give to the uniform
  84847. * @return the material itself allowing "fluent" like uniform updates
  84848. */
  84849. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  84850. /**
  84851. * Set a vec2 array in the shader from a number array.
  84852. * @param name Define the name of the uniform as defined in the shader
  84853. * @param value Define the value to give to the uniform
  84854. * @return the material itself allowing "fluent" like uniform updates
  84855. */
  84856. setArray2(name: string, value: number[]): ShaderMaterial;
  84857. /**
  84858. * Set a vec3 array in the shader from a number array.
  84859. * @param name Define the name of the uniform as defined in the shader
  84860. * @param value Define the value to give to the uniform
  84861. * @return the material itself allowing "fluent" like uniform updates
  84862. */
  84863. setArray3(name: string, value: number[]): ShaderMaterial;
  84864. /**
  84865. * Set a vec4 array in the shader from a number array.
  84866. * @param name Define the name of the uniform as defined in the shader
  84867. * @param value Define the value to give to the uniform
  84868. * @return the material itself allowing "fluent" like uniform updates
  84869. */
  84870. setArray4(name: string, value: number[]): ShaderMaterial;
  84871. private _checkCache;
  84872. /**
  84873. * Specifies that the submesh is ready to be used
  84874. * @param mesh defines the mesh to check
  84875. * @param subMesh defines which submesh to check
  84876. * @param useInstances specifies that instances should be used
  84877. * @returns a boolean indicating that the submesh is ready or not
  84878. */
  84879. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  84880. /**
  84881. * Checks if the material is ready to render the requested mesh
  84882. * @param mesh Define the mesh to render
  84883. * @param useInstances Define whether or not the material is used with instances
  84884. * @returns true if ready, otherwise false
  84885. */
  84886. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  84887. /**
  84888. * Binds the world matrix to the material
  84889. * @param world defines the world transformation matrix
  84890. */
  84891. bindOnlyWorldMatrix(world: Matrix): void;
  84892. /**
  84893. * Binds the material to the mesh
  84894. * @param world defines the world transformation matrix
  84895. * @param mesh defines the mesh to bind the material to
  84896. */
  84897. bind(world: Matrix, mesh?: Mesh): void;
  84898. /**
  84899. * Gets the active textures from the material
  84900. * @returns an array of textures
  84901. */
  84902. getActiveTextures(): BaseTexture[];
  84903. /**
  84904. * Specifies if the material uses a texture
  84905. * @param texture defines the texture to check against the material
  84906. * @returns a boolean specifying if the material uses the texture
  84907. */
  84908. hasTexture(texture: BaseTexture): boolean;
  84909. /**
  84910. * Makes a duplicate of the material, and gives it a new name
  84911. * @param name defines the new name for the duplicated material
  84912. * @returns the cloned material
  84913. */
  84914. clone(name: string): ShaderMaterial;
  84915. /**
  84916. * Disposes the material
  84917. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  84918. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  84919. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  84920. */
  84921. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  84922. /**
  84923. * Serializes this material in a JSON representation
  84924. * @returns the serialized material object
  84925. */
  84926. serialize(): any;
  84927. /**
  84928. * Creates a shader material from parsed shader material data
  84929. * @param source defines the JSON represnetation of the material
  84930. * @param scene defines the hosting scene
  84931. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  84932. * @returns a new material
  84933. */
  84934. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  84935. }
  84936. }
  84937. declare module BABYLON {
  84938. /** @hidden */
  84939. export var colorPixelShader: {
  84940. name: string;
  84941. shader: string;
  84942. };
  84943. }
  84944. declare module BABYLON {
  84945. /** @hidden */
  84946. export var colorVertexShader: {
  84947. name: string;
  84948. shader: string;
  84949. };
  84950. }
  84951. declare module BABYLON {
  84952. /**
  84953. * Line mesh
  84954. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  84955. */
  84956. export class LinesMesh extends Mesh {
  84957. /**
  84958. * If vertex color should be applied to the mesh
  84959. */
  84960. readonly useVertexColor?: boolean | undefined;
  84961. /**
  84962. * If vertex alpha should be applied to the mesh
  84963. */
  84964. readonly useVertexAlpha?: boolean | undefined;
  84965. /**
  84966. * Color of the line (Default: White)
  84967. */
  84968. color: Color3;
  84969. /**
  84970. * Alpha of the line (Default: 1)
  84971. */
  84972. alpha: number;
  84973. /**
  84974. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  84975. * This margin is expressed in world space coordinates, so its value may vary.
  84976. * Default value is 0.1
  84977. */
  84978. intersectionThreshold: number;
  84979. private _colorShader;
  84980. private color4;
  84981. /**
  84982. * Creates a new LinesMesh
  84983. * @param name defines the name
  84984. * @param scene defines the hosting scene
  84985. * @param parent defines the parent mesh if any
  84986. * @param source defines the optional source LinesMesh used to clone data from
  84987. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  84988. * When false, achieved by calling a clone(), also passing False.
  84989. * This will make creation of children, recursive.
  84990. * @param useVertexColor defines if this LinesMesh supports vertex color
  84991. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  84992. */
  84993. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  84994. /**
  84995. * If vertex color should be applied to the mesh
  84996. */
  84997. useVertexColor?: boolean | undefined,
  84998. /**
  84999. * If vertex alpha should be applied to the mesh
  85000. */
  85001. useVertexAlpha?: boolean | undefined);
  85002. private _addClipPlaneDefine;
  85003. private _removeClipPlaneDefine;
  85004. isReady(): boolean;
  85005. /**
  85006. * Returns the string "LineMesh"
  85007. */
  85008. getClassName(): string;
  85009. /**
  85010. * @hidden
  85011. */
  85012. /**
  85013. * @hidden
  85014. */
  85015. material: Material;
  85016. /**
  85017. * @hidden
  85018. */
  85019. readonly checkCollisions: boolean;
  85020. /** @hidden */
  85021. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  85022. /** @hidden */
  85023. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  85024. /**
  85025. * Disposes of the line mesh
  85026. * @param doNotRecurse If children should be disposed
  85027. */
  85028. dispose(doNotRecurse?: boolean): void;
  85029. /**
  85030. * Returns a new LineMesh object cloned from the current one.
  85031. */
  85032. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  85033. /**
  85034. * Creates a new InstancedLinesMesh object from the mesh model.
  85035. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  85036. * @param name defines the name of the new instance
  85037. * @returns a new InstancedLinesMesh
  85038. */
  85039. createInstance(name: string): InstancedLinesMesh;
  85040. }
  85041. /**
  85042. * Creates an instance based on a source LinesMesh
  85043. */
  85044. export class InstancedLinesMesh extends InstancedMesh {
  85045. /**
  85046. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  85047. * This margin is expressed in world space coordinates, so its value may vary.
  85048. * Initilized with the intersectionThreshold value of the source LinesMesh
  85049. */
  85050. intersectionThreshold: number;
  85051. constructor(name: string, source: LinesMesh);
  85052. /**
  85053. * Returns the string "InstancedLinesMesh".
  85054. */
  85055. getClassName(): string;
  85056. }
  85057. }
  85058. declare module BABYLON {
  85059. /** @hidden */
  85060. export var linePixelShader: {
  85061. name: string;
  85062. shader: string;
  85063. };
  85064. }
  85065. declare module BABYLON {
  85066. /** @hidden */
  85067. export var lineVertexShader: {
  85068. name: string;
  85069. shader: string;
  85070. };
  85071. }
  85072. declare module BABYLON {
  85073. interface AbstractMesh {
  85074. /**
  85075. * Gets the edgesRenderer associated with the mesh
  85076. */
  85077. edgesRenderer: Nullable<EdgesRenderer>;
  85078. }
  85079. interface LinesMesh {
  85080. /**
  85081. * Enables the edge rendering mode on the mesh.
  85082. * This mode makes the mesh edges visible
  85083. * @param epsilon defines the maximal distance between two angles to detect a face
  85084. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  85085. * @returns the currentAbstractMesh
  85086. * @see https://www.babylonjs-playground.com/#19O9TU#0
  85087. */
  85088. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  85089. }
  85090. interface InstancedLinesMesh {
  85091. /**
  85092. * Enables the edge rendering mode on the mesh.
  85093. * This mode makes the mesh edges visible
  85094. * @param epsilon defines the maximal distance between two angles to detect a face
  85095. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  85096. * @returns the current InstancedLinesMesh
  85097. * @see https://www.babylonjs-playground.com/#19O9TU#0
  85098. */
  85099. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  85100. }
  85101. /**
  85102. * Defines the minimum contract an Edges renderer should follow.
  85103. */
  85104. export interface IEdgesRenderer extends IDisposable {
  85105. /**
  85106. * Gets or sets a boolean indicating if the edgesRenderer is active
  85107. */
  85108. isEnabled: boolean;
  85109. /**
  85110. * Renders the edges of the attached mesh,
  85111. */
  85112. render(): void;
  85113. /**
  85114. * Checks wether or not the edges renderer is ready to render.
  85115. * @return true if ready, otherwise false.
  85116. */
  85117. isReady(): boolean;
  85118. }
  85119. /**
  85120. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  85121. */
  85122. export class EdgesRenderer implements IEdgesRenderer {
  85123. /**
  85124. * Define the size of the edges with an orthographic camera
  85125. */
  85126. edgesWidthScalerForOrthographic: number;
  85127. /**
  85128. * Define the size of the edges with a perspective camera
  85129. */
  85130. edgesWidthScalerForPerspective: number;
  85131. protected _source: AbstractMesh;
  85132. protected _linesPositions: number[];
  85133. protected _linesNormals: number[];
  85134. protected _linesIndices: number[];
  85135. protected _epsilon: number;
  85136. protected _indicesCount: number;
  85137. protected _lineShader: ShaderMaterial;
  85138. protected _ib: DataBuffer;
  85139. protected _buffers: {
  85140. [key: string]: Nullable<VertexBuffer>;
  85141. };
  85142. protected _checkVerticesInsteadOfIndices: boolean;
  85143. private _meshRebuildObserver;
  85144. private _meshDisposeObserver;
  85145. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  85146. isEnabled: boolean;
  85147. /**
  85148. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  85149. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  85150. * @param source Mesh used to create edges
  85151. * @param epsilon sum of angles in adjacency to check for edge
  85152. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  85153. * @param generateEdgesLines - should generate Lines or only prepare resources.
  85154. */
  85155. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  85156. protected _prepareRessources(): void;
  85157. /** @hidden */
  85158. _rebuild(): void;
  85159. /**
  85160. * Releases the required resources for the edges renderer
  85161. */
  85162. dispose(): void;
  85163. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  85164. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  85165. /**
  85166. * Checks if the pair of p0 and p1 is en edge
  85167. * @param faceIndex
  85168. * @param edge
  85169. * @param faceNormals
  85170. * @param p0
  85171. * @param p1
  85172. * @private
  85173. */
  85174. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  85175. /**
  85176. * push line into the position, normal and index buffer
  85177. * @protected
  85178. */
  85179. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  85180. /**
  85181. * Generates lines edges from adjacencjes
  85182. * @private
  85183. */
  85184. _generateEdgesLines(): void;
  85185. /**
  85186. * Checks wether or not the edges renderer is ready to render.
  85187. * @return true if ready, otherwise false.
  85188. */
  85189. isReady(): boolean;
  85190. /**
  85191. * Renders the edges of the attached mesh,
  85192. */
  85193. render(): void;
  85194. }
  85195. /**
  85196. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  85197. */
  85198. export class LineEdgesRenderer extends EdgesRenderer {
  85199. /**
  85200. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  85201. * @param source LineMesh used to generate edges
  85202. * @param epsilon not important (specified angle for edge detection)
  85203. * @param checkVerticesInsteadOfIndices not important for LineMesh
  85204. */
  85205. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  85206. /**
  85207. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  85208. */
  85209. _generateEdgesLines(): void;
  85210. }
  85211. }
  85212. declare module BABYLON {
  85213. /**
  85214. * This represents the object necessary to create a rendering group.
  85215. * This is exclusively used and created by the rendering manager.
  85216. * To modify the behavior, you use the available helpers in your scene or meshes.
  85217. * @hidden
  85218. */
  85219. export class RenderingGroup {
  85220. index: number;
  85221. private static _zeroVector;
  85222. private _scene;
  85223. private _opaqueSubMeshes;
  85224. private _transparentSubMeshes;
  85225. private _alphaTestSubMeshes;
  85226. private _depthOnlySubMeshes;
  85227. private _particleSystems;
  85228. private _spriteManagers;
  85229. private _opaqueSortCompareFn;
  85230. private _alphaTestSortCompareFn;
  85231. private _transparentSortCompareFn;
  85232. private _renderOpaque;
  85233. private _renderAlphaTest;
  85234. private _renderTransparent;
  85235. /** @hidden */
  85236. _edgesRenderers: SmartArray<IEdgesRenderer>;
  85237. onBeforeTransparentRendering: () => void;
  85238. /**
  85239. * Set the opaque sort comparison function.
  85240. * If null the sub meshes will be render in the order they were created
  85241. */
  85242. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  85243. /**
  85244. * Set the alpha test sort comparison function.
  85245. * If null the sub meshes will be render in the order they were created
  85246. */
  85247. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  85248. /**
  85249. * Set the transparent sort comparison function.
  85250. * If null the sub meshes will be render in the order they were created
  85251. */
  85252. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  85253. /**
  85254. * Creates a new rendering group.
  85255. * @param index The rendering group index
  85256. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  85257. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  85258. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  85259. */
  85260. 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>);
  85261. /**
  85262. * Render all the sub meshes contained in the group.
  85263. * @param customRenderFunction Used to override the default render behaviour of the group.
  85264. * @returns true if rendered some submeshes.
  85265. */
  85266. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  85267. /**
  85268. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  85269. * @param subMeshes The submeshes to render
  85270. */
  85271. private renderOpaqueSorted;
  85272. /**
  85273. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  85274. * @param subMeshes The submeshes to render
  85275. */
  85276. private renderAlphaTestSorted;
  85277. /**
  85278. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  85279. * @param subMeshes The submeshes to render
  85280. */
  85281. private renderTransparentSorted;
  85282. /**
  85283. * Renders the submeshes in a specified order.
  85284. * @param subMeshes The submeshes to sort before render
  85285. * @param sortCompareFn The comparison function use to sort
  85286. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  85287. * @param transparent Specifies to activate blending if true
  85288. */
  85289. private static renderSorted;
  85290. /**
  85291. * Renders the submeshes in the order they were dispatched (no sort applied).
  85292. * @param subMeshes The submeshes to render
  85293. */
  85294. private static renderUnsorted;
  85295. /**
  85296. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  85297. * are rendered back to front if in the same alpha index.
  85298. *
  85299. * @param a The first submesh
  85300. * @param b The second submesh
  85301. * @returns The result of the comparison
  85302. */
  85303. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  85304. /**
  85305. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  85306. * are rendered back to front.
  85307. *
  85308. * @param a The first submesh
  85309. * @param b The second submesh
  85310. * @returns The result of the comparison
  85311. */
  85312. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  85313. /**
  85314. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  85315. * are rendered front to back (prevent overdraw).
  85316. *
  85317. * @param a The first submesh
  85318. * @param b The second submesh
  85319. * @returns The result of the comparison
  85320. */
  85321. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  85322. /**
  85323. * Resets the different lists of submeshes to prepare a new frame.
  85324. */
  85325. prepare(): void;
  85326. dispose(): void;
  85327. /**
  85328. * Inserts the submesh in its correct queue depending on its material.
  85329. * @param subMesh The submesh to dispatch
  85330. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  85331. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  85332. */
  85333. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  85334. dispatchSprites(spriteManager: ISpriteManager): void;
  85335. dispatchParticles(particleSystem: IParticleSystem): void;
  85336. private _renderParticles;
  85337. private _renderSprites;
  85338. }
  85339. }
  85340. declare module BABYLON {
  85341. /**
  85342. * Interface describing the different options available in the rendering manager
  85343. * regarding Auto Clear between groups.
  85344. */
  85345. export interface IRenderingManagerAutoClearSetup {
  85346. /**
  85347. * Defines whether or not autoclear is enable.
  85348. */
  85349. autoClear: boolean;
  85350. /**
  85351. * Defines whether or not to autoclear the depth buffer.
  85352. */
  85353. depth: boolean;
  85354. /**
  85355. * Defines whether or not to autoclear the stencil buffer.
  85356. */
  85357. stencil: boolean;
  85358. }
  85359. /**
  85360. * This class is used by the onRenderingGroupObservable
  85361. */
  85362. export class RenderingGroupInfo {
  85363. /**
  85364. * The Scene that being rendered
  85365. */
  85366. scene: Scene;
  85367. /**
  85368. * The camera currently used for the rendering pass
  85369. */
  85370. camera: Nullable<Camera>;
  85371. /**
  85372. * The ID of the renderingGroup being processed
  85373. */
  85374. renderingGroupId: number;
  85375. }
  85376. /**
  85377. * This is the manager responsible of all the rendering for meshes sprites and particles.
  85378. * It is enable to manage the different groups as well as the different necessary sort functions.
  85379. * This should not be used directly aside of the few static configurations
  85380. */
  85381. export class RenderingManager {
  85382. /**
  85383. * The max id used for rendering groups (not included)
  85384. */
  85385. static MAX_RENDERINGGROUPS: number;
  85386. /**
  85387. * The min id used for rendering groups (included)
  85388. */
  85389. static MIN_RENDERINGGROUPS: number;
  85390. /**
  85391. * Used to globally prevent autoclearing scenes.
  85392. */
  85393. static AUTOCLEAR: boolean;
  85394. /**
  85395. * @hidden
  85396. */
  85397. _useSceneAutoClearSetup: boolean;
  85398. private _scene;
  85399. private _renderingGroups;
  85400. private _depthStencilBufferAlreadyCleaned;
  85401. private _autoClearDepthStencil;
  85402. private _customOpaqueSortCompareFn;
  85403. private _customAlphaTestSortCompareFn;
  85404. private _customTransparentSortCompareFn;
  85405. private _renderingGroupInfo;
  85406. /**
  85407. * Instantiates a new rendering group for a particular scene
  85408. * @param scene Defines the scene the groups belongs to
  85409. */
  85410. constructor(scene: Scene);
  85411. private _clearDepthStencilBuffer;
  85412. /**
  85413. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  85414. * @hidden
  85415. */
  85416. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  85417. /**
  85418. * Resets the different information of the group to prepare a new frame
  85419. * @hidden
  85420. */
  85421. reset(): void;
  85422. /**
  85423. * Dispose and release the group and its associated resources.
  85424. * @hidden
  85425. */
  85426. dispose(): void;
  85427. /**
  85428. * Clear the info related to rendering groups preventing retention points during dispose.
  85429. */
  85430. freeRenderingGroups(): void;
  85431. private _prepareRenderingGroup;
  85432. /**
  85433. * Add a sprite manager to the rendering manager in order to render it this frame.
  85434. * @param spriteManager Define the sprite manager to render
  85435. */
  85436. dispatchSprites(spriteManager: ISpriteManager): void;
  85437. /**
  85438. * Add a particle system to the rendering manager in order to render it this frame.
  85439. * @param particleSystem Define the particle system to render
  85440. */
  85441. dispatchParticles(particleSystem: IParticleSystem): void;
  85442. /**
  85443. * Add a submesh to the manager in order to render it this frame
  85444. * @param subMesh The submesh to dispatch
  85445. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  85446. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  85447. */
  85448. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  85449. /**
  85450. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  85451. * This allowed control for front to back rendering or reversly depending of the special needs.
  85452. *
  85453. * @param renderingGroupId The rendering group id corresponding to its index
  85454. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  85455. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  85456. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  85457. */
  85458. 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;
  85459. /**
  85460. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  85461. *
  85462. * @param renderingGroupId The rendering group id corresponding to its index
  85463. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  85464. * @param depth Automatically clears depth between groups if true and autoClear is true.
  85465. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  85466. */
  85467. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  85468. /**
  85469. * Gets the current auto clear configuration for one rendering group of the rendering
  85470. * manager.
  85471. * @param index the rendering group index to get the information for
  85472. * @returns The auto clear setup for the requested rendering group
  85473. */
  85474. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  85475. }
  85476. }
  85477. declare module BABYLON {
  85478. /**
  85479. * This Helps creating a texture that will be created from a camera in your scene.
  85480. * It is basically a dynamic texture that could be used to create special effects for instance.
  85481. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  85482. */
  85483. export class RenderTargetTexture extends Texture {
  85484. isCube: boolean;
  85485. /**
  85486. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  85487. */
  85488. static readonly REFRESHRATE_RENDER_ONCE: number;
  85489. /**
  85490. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  85491. */
  85492. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  85493. /**
  85494. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  85495. * the central point of your effect and can save a lot of performances.
  85496. */
  85497. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  85498. /**
  85499. * Use this predicate to dynamically define the list of mesh you want to render.
  85500. * If set, the renderList property will be overwritten.
  85501. */
  85502. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  85503. private _renderList;
  85504. /**
  85505. * Use this list to define the list of mesh you want to render.
  85506. */
  85507. renderList: Nullable<Array<AbstractMesh>>;
  85508. private _hookArray;
  85509. /**
  85510. * Define if particles should be rendered in your texture.
  85511. */
  85512. renderParticles: boolean;
  85513. /**
  85514. * Define if sprites should be rendered in your texture.
  85515. */
  85516. renderSprites: boolean;
  85517. /**
  85518. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  85519. */
  85520. coordinatesMode: number;
  85521. /**
  85522. * Define the camera used to render the texture.
  85523. */
  85524. activeCamera: Nullable<Camera>;
  85525. /**
  85526. * Override the render function of the texture with your own one.
  85527. */
  85528. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  85529. /**
  85530. * Define if camera post processes should be use while rendering the texture.
  85531. */
  85532. useCameraPostProcesses: boolean;
  85533. /**
  85534. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  85535. */
  85536. ignoreCameraViewport: boolean;
  85537. private _postProcessManager;
  85538. private _postProcesses;
  85539. private _resizeObserver;
  85540. /**
  85541. * An event triggered when the texture is unbind.
  85542. */
  85543. onBeforeBindObservable: Observable<RenderTargetTexture>;
  85544. /**
  85545. * An event triggered when the texture is unbind.
  85546. */
  85547. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  85548. private _onAfterUnbindObserver;
  85549. /**
  85550. * Set a after unbind callback in the texture.
  85551. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  85552. */
  85553. onAfterUnbind: () => void;
  85554. /**
  85555. * An event triggered before rendering the texture
  85556. */
  85557. onBeforeRenderObservable: Observable<number>;
  85558. private _onBeforeRenderObserver;
  85559. /**
  85560. * Set a before render callback in the texture.
  85561. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  85562. */
  85563. onBeforeRender: (faceIndex: number) => void;
  85564. /**
  85565. * An event triggered after rendering the texture
  85566. */
  85567. onAfterRenderObservable: Observable<number>;
  85568. private _onAfterRenderObserver;
  85569. /**
  85570. * Set a after render callback in the texture.
  85571. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  85572. */
  85573. onAfterRender: (faceIndex: number) => void;
  85574. /**
  85575. * An event triggered after the texture clear
  85576. */
  85577. onClearObservable: Observable<Engine>;
  85578. private _onClearObserver;
  85579. /**
  85580. * Set a clear callback in the texture.
  85581. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  85582. */
  85583. onClear: (Engine: Engine) => void;
  85584. /**
  85585. * An event triggered when the texture is resized.
  85586. */
  85587. onResizeObservable: Observable<RenderTargetTexture>;
  85588. /**
  85589. * Define the clear color of the Render Target if it should be different from the scene.
  85590. */
  85591. clearColor: Color4;
  85592. protected _size: number | {
  85593. width: number;
  85594. height: number;
  85595. };
  85596. protected _initialSizeParameter: number | {
  85597. width: number;
  85598. height: number;
  85599. } | {
  85600. ratio: number;
  85601. };
  85602. protected _sizeRatio: Nullable<number>;
  85603. /** @hidden */
  85604. _generateMipMaps: boolean;
  85605. protected _renderingManager: RenderingManager;
  85606. /** @hidden */
  85607. _waitingRenderList: string[];
  85608. protected _doNotChangeAspectRatio: boolean;
  85609. protected _currentRefreshId: number;
  85610. protected _refreshRate: number;
  85611. protected _textureMatrix: Matrix;
  85612. protected _samples: number;
  85613. protected _renderTargetOptions: RenderTargetCreationOptions;
  85614. /**
  85615. * Gets render target creation options that were used.
  85616. */
  85617. readonly renderTargetOptions: RenderTargetCreationOptions;
  85618. protected _engine: Engine;
  85619. protected _onRatioRescale(): void;
  85620. /**
  85621. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  85622. * It must define where the camera used to render the texture is set
  85623. */
  85624. boundingBoxPosition: Vector3;
  85625. private _boundingBoxSize;
  85626. /**
  85627. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  85628. * When defined, the cubemap will switch to local mode
  85629. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  85630. * @example https://www.babylonjs-playground.com/#RNASML
  85631. */
  85632. boundingBoxSize: Vector3;
  85633. /**
  85634. * In case the RTT has been created with a depth texture, get the associated
  85635. * depth texture.
  85636. * Otherwise, return null.
  85637. */
  85638. depthStencilTexture: Nullable<InternalTexture>;
  85639. /**
  85640. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  85641. * or used a shadow, depth texture...
  85642. * @param name The friendly name of the texture
  85643. * @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)
  85644. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  85645. * @param generateMipMaps True if mip maps need to be generated after render.
  85646. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  85647. * @param type The type of the buffer in the RTT (int, half float, float...)
  85648. * @param isCube True if a cube texture needs to be created
  85649. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  85650. * @param generateDepthBuffer True to generate a depth buffer
  85651. * @param generateStencilBuffer True to generate a stencil buffer
  85652. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  85653. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  85654. * @param delayAllocation if the texture allocation should be delayed (default: false)
  85655. */
  85656. constructor(name: string, size: number | {
  85657. width: number;
  85658. height: number;
  85659. } | {
  85660. ratio: number;
  85661. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  85662. /**
  85663. * Creates a depth stencil texture.
  85664. * This is only available in WebGL 2 or with the depth texture extension available.
  85665. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  85666. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  85667. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  85668. */
  85669. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  85670. private _processSizeParameter;
  85671. /**
  85672. * Define the number of samples to use in case of MSAA.
  85673. * It defaults to one meaning no MSAA has been enabled.
  85674. */
  85675. samples: number;
  85676. /**
  85677. * Resets the refresh counter of the texture and start bak from scratch.
  85678. * Could be useful to regenerate the texture if it is setup to render only once.
  85679. */
  85680. resetRefreshCounter(): void;
  85681. /**
  85682. * Define the refresh rate of the texture or the rendering frequency.
  85683. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  85684. */
  85685. refreshRate: number;
  85686. /**
  85687. * Adds a post process to the render target rendering passes.
  85688. * @param postProcess define the post process to add
  85689. */
  85690. addPostProcess(postProcess: PostProcess): void;
  85691. /**
  85692. * Clear all the post processes attached to the render target
  85693. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  85694. */
  85695. clearPostProcesses(dispose?: boolean): void;
  85696. /**
  85697. * Remove one of the post process from the list of attached post processes to the texture
  85698. * @param postProcess define the post process to remove from the list
  85699. */
  85700. removePostProcess(postProcess: PostProcess): void;
  85701. /** @hidden */
  85702. _shouldRender(): boolean;
  85703. /**
  85704. * Gets the actual render size of the texture.
  85705. * @returns the width of the render size
  85706. */
  85707. getRenderSize(): number;
  85708. /**
  85709. * Gets the actual render width of the texture.
  85710. * @returns the width of the render size
  85711. */
  85712. getRenderWidth(): number;
  85713. /**
  85714. * Gets the actual render height of the texture.
  85715. * @returns the height of the render size
  85716. */
  85717. getRenderHeight(): number;
  85718. /**
  85719. * Get if the texture can be rescaled or not.
  85720. */
  85721. readonly canRescale: boolean;
  85722. /**
  85723. * Resize the texture using a ratio.
  85724. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  85725. */
  85726. scale(ratio: number): void;
  85727. /**
  85728. * Get the texture reflection matrix used to rotate/transform the reflection.
  85729. * @returns the reflection matrix
  85730. */
  85731. getReflectionTextureMatrix(): Matrix;
  85732. /**
  85733. * Resize the texture to a new desired size.
  85734. * Be carrefull as it will recreate all the data in the new texture.
  85735. * @param size Define the new size. It can be:
  85736. * - a number for squared texture,
  85737. * - an object containing { width: number, height: number }
  85738. * - or an object containing a ratio { ratio: number }
  85739. */
  85740. resize(size: number | {
  85741. width: number;
  85742. height: number;
  85743. } | {
  85744. ratio: number;
  85745. }): void;
  85746. /**
  85747. * Renders all the objects from the render list into the texture.
  85748. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  85749. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  85750. */
  85751. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  85752. private _bestReflectionRenderTargetDimension;
  85753. /**
  85754. * @hidden
  85755. * @param faceIndex face index to bind to if this is a cubetexture
  85756. */
  85757. _bindFrameBuffer(faceIndex?: number): void;
  85758. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  85759. private renderToTarget;
  85760. /**
  85761. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  85762. * This allowed control for front to back rendering or reversly depending of the special needs.
  85763. *
  85764. * @param renderingGroupId The rendering group id corresponding to its index
  85765. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  85766. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  85767. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  85768. */
  85769. 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;
  85770. /**
  85771. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  85772. *
  85773. * @param renderingGroupId The rendering group id corresponding to its index
  85774. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  85775. */
  85776. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  85777. /**
  85778. * Clones the texture.
  85779. * @returns the cloned texture
  85780. */
  85781. clone(): RenderTargetTexture;
  85782. /**
  85783. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  85784. * @returns The JSON representation of the texture
  85785. */
  85786. serialize(): any;
  85787. /**
  85788. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  85789. */
  85790. disposeFramebufferObjects(): void;
  85791. /**
  85792. * Dispose the texture and release its associated resources.
  85793. */
  85794. dispose(): void;
  85795. /** @hidden */
  85796. _rebuild(): void;
  85797. /**
  85798. * Clear the info related to rendering groups preventing retention point in material dispose.
  85799. */
  85800. freeRenderingGroups(): void;
  85801. /**
  85802. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  85803. * @returns the view count
  85804. */
  85805. getViewCount(): number;
  85806. }
  85807. }
  85808. declare module BABYLON {
  85809. /**
  85810. * Base class for the main features of a material in Babylon.js
  85811. */
  85812. export class Material implements IAnimatable {
  85813. /**
  85814. * Returns the triangle fill mode
  85815. */
  85816. static readonly TriangleFillMode: number;
  85817. /**
  85818. * Returns the wireframe mode
  85819. */
  85820. static readonly WireFrameFillMode: number;
  85821. /**
  85822. * Returns the point fill mode
  85823. */
  85824. static readonly PointFillMode: number;
  85825. /**
  85826. * Returns the point list draw mode
  85827. */
  85828. static readonly PointListDrawMode: number;
  85829. /**
  85830. * Returns the line list draw mode
  85831. */
  85832. static readonly LineListDrawMode: number;
  85833. /**
  85834. * Returns the line loop draw mode
  85835. */
  85836. static readonly LineLoopDrawMode: number;
  85837. /**
  85838. * Returns the line strip draw mode
  85839. */
  85840. static readonly LineStripDrawMode: number;
  85841. /**
  85842. * Returns the triangle strip draw mode
  85843. */
  85844. static readonly TriangleStripDrawMode: number;
  85845. /**
  85846. * Returns the triangle fan draw mode
  85847. */
  85848. static readonly TriangleFanDrawMode: number;
  85849. /**
  85850. * Stores the clock-wise side orientation
  85851. */
  85852. static readonly ClockWiseSideOrientation: number;
  85853. /**
  85854. * Stores the counter clock-wise side orientation
  85855. */
  85856. static readonly CounterClockWiseSideOrientation: number;
  85857. /**
  85858. * The dirty texture flag value
  85859. */
  85860. static readonly TextureDirtyFlag: number;
  85861. /**
  85862. * The dirty light flag value
  85863. */
  85864. static readonly LightDirtyFlag: number;
  85865. /**
  85866. * The dirty fresnel flag value
  85867. */
  85868. static readonly FresnelDirtyFlag: number;
  85869. /**
  85870. * The dirty attribute flag value
  85871. */
  85872. static readonly AttributesDirtyFlag: number;
  85873. /**
  85874. * The dirty misc flag value
  85875. */
  85876. static readonly MiscDirtyFlag: number;
  85877. /**
  85878. * The all dirty flag value
  85879. */
  85880. static readonly AllDirtyFlag: number;
  85881. /**
  85882. * The ID of the material
  85883. */
  85884. id: string;
  85885. /**
  85886. * Gets or sets the unique id of the material
  85887. */
  85888. uniqueId: number;
  85889. /**
  85890. * The name of the material
  85891. */
  85892. name: string;
  85893. /**
  85894. * Gets or sets user defined metadata
  85895. */
  85896. metadata: any;
  85897. /**
  85898. * For internal use only. Please do not use.
  85899. */
  85900. reservedDataStore: any;
  85901. /**
  85902. * Specifies if the ready state should be checked on each call
  85903. */
  85904. checkReadyOnEveryCall: boolean;
  85905. /**
  85906. * Specifies if the ready state should be checked once
  85907. */
  85908. checkReadyOnlyOnce: boolean;
  85909. /**
  85910. * The state of the material
  85911. */
  85912. state: string;
  85913. /**
  85914. * The alpha value of the material
  85915. */
  85916. protected _alpha: number;
  85917. /**
  85918. * List of inspectable custom properties (used by the Inspector)
  85919. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  85920. */
  85921. inspectableCustomProperties: IInspectable[];
  85922. /**
  85923. * Sets the alpha value of the material
  85924. */
  85925. /**
  85926. * Gets the alpha value of the material
  85927. */
  85928. alpha: number;
  85929. /**
  85930. * Specifies if back face culling is enabled
  85931. */
  85932. protected _backFaceCulling: boolean;
  85933. /**
  85934. * Sets the back-face culling state
  85935. */
  85936. /**
  85937. * Gets the back-face culling state
  85938. */
  85939. backFaceCulling: boolean;
  85940. /**
  85941. * Stores the value for side orientation
  85942. */
  85943. sideOrientation: number;
  85944. /**
  85945. * Callback triggered when the material is compiled
  85946. */
  85947. onCompiled: Nullable<(effect: Effect) => void>;
  85948. /**
  85949. * Callback triggered when an error occurs
  85950. */
  85951. onError: Nullable<(effect: Effect, errors: string) => void>;
  85952. /**
  85953. * Callback triggered to get the render target textures
  85954. */
  85955. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  85956. /**
  85957. * Gets a boolean indicating that current material needs to register RTT
  85958. */
  85959. readonly hasRenderTargetTextures: boolean;
  85960. /**
  85961. * Specifies if the material should be serialized
  85962. */
  85963. doNotSerialize: boolean;
  85964. /**
  85965. * @hidden
  85966. */
  85967. _storeEffectOnSubMeshes: boolean;
  85968. /**
  85969. * Stores the animations for the material
  85970. */
  85971. animations: Nullable<Array<Animation>>;
  85972. /**
  85973. * An event triggered when the material is disposed
  85974. */
  85975. onDisposeObservable: Observable<Material>;
  85976. /**
  85977. * An observer which watches for dispose events
  85978. */
  85979. private _onDisposeObserver;
  85980. private _onUnBindObservable;
  85981. /**
  85982. * Called during a dispose event
  85983. */
  85984. onDispose: () => void;
  85985. private _onBindObservable;
  85986. /**
  85987. * An event triggered when the material is bound
  85988. */
  85989. readonly onBindObservable: Observable<AbstractMesh>;
  85990. /**
  85991. * An observer which watches for bind events
  85992. */
  85993. private _onBindObserver;
  85994. /**
  85995. * Called during a bind event
  85996. */
  85997. onBind: (Mesh: AbstractMesh) => void;
  85998. /**
  85999. * An event triggered when the material is unbound
  86000. */
  86001. readonly onUnBindObservable: Observable<Material>;
  86002. /**
  86003. * Stores the value of the alpha mode
  86004. */
  86005. private _alphaMode;
  86006. /**
  86007. * Sets the value of the alpha mode.
  86008. *
  86009. * | Value | Type | Description |
  86010. * | --- | --- | --- |
  86011. * | 0 | ALPHA_DISABLE | |
  86012. * | 1 | ALPHA_ADD | |
  86013. * | 2 | ALPHA_COMBINE | |
  86014. * | 3 | ALPHA_SUBTRACT | |
  86015. * | 4 | ALPHA_MULTIPLY | |
  86016. * | 5 | ALPHA_MAXIMIZED | |
  86017. * | 6 | ALPHA_ONEONE | |
  86018. * | 7 | ALPHA_PREMULTIPLIED | |
  86019. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  86020. * | 9 | ALPHA_INTERPOLATE | |
  86021. * | 10 | ALPHA_SCREENMODE | |
  86022. *
  86023. */
  86024. /**
  86025. * Gets the value of the alpha mode
  86026. */
  86027. alphaMode: number;
  86028. /**
  86029. * Stores the state of the need depth pre-pass value
  86030. */
  86031. private _needDepthPrePass;
  86032. /**
  86033. * Sets the need depth pre-pass value
  86034. */
  86035. /**
  86036. * Gets the depth pre-pass value
  86037. */
  86038. needDepthPrePass: boolean;
  86039. /**
  86040. * Specifies if depth writing should be disabled
  86041. */
  86042. disableDepthWrite: boolean;
  86043. /**
  86044. * Specifies if depth writing should be forced
  86045. */
  86046. forceDepthWrite: boolean;
  86047. /**
  86048. * Specifies if there should be a separate pass for culling
  86049. */
  86050. separateCullingPass: boolean;
  86051. /**
  86052. * Stores the state specifing if fog should be enabled
  86053. */
  86054. private _fogEnabled;
  86055. /**
  86056. * Sets the state for enabling fog
  86057. */
  86058. /**
  86059. * Gets the value of the fog enabled state
  86060. */
  86061. fogEnabled: boolean;
  86062. /**
  86063. * Stores the size of points
  86064. */
  86065. pointSize: number;
  86066. /**
  86067. * Stores the z offset value
  86068. */
  86069. zOffset: number;
  86070. /**
  86071. * Gets a value specifying if wireframe mode is enabled
  86072. */
  86073. /**
  86074. * Sets the state of wireframe mode
  86075. */
  86076. wireframe: boolean;
  86077. /**
  86078. * Gets the value specifying if point clouds are enabled
  86079. */
  86080. /**
  86081. * Sets the state of point cloud mode
  86082. */
  86083. pointsCloud: boolean;
  86084. /**
  86085. * Gets the material fill mode
  86086. */
  86087. /**
  86088. * Sets the material fill mode
  86089. */
  86090. fillMode: number;
  86091. /**
  86092. * @hidden
  86093. * Stores the effects for the material
  86094. */
  86095. _effect: Nullable<Effect>;
  86096. /**
  86097. * @hidden
  86098. * Specifies if the material was previously ready
  86099. */
  86100. _wasPreviouslyReady: boolean;
  86101. /**
  86102. * Specifies if uniform buffers should be used
  86103. */
  86104. private _useUBO;
  86105. /**
  86106. * Stores a reference to the scene
  86107. */
  86108. private _scene;
  86109. /**
  86110. * Stores the fill mode state
  86111. */
  86112. private _fillMode;
  86113. /**
  86114. * Specifies if the depth write state should be cached
  86115. */
  86116. private _cachedDepthWriteState;
  86117. /**
  86118. * Stores the uniform buffer
  86119. */
  86120. protected _uniformBuffer: UniformBuffer;
  86121. /** @hidden */
  86122. _indexInSceneMaterialArray: number;
  86123. /** @hidden */
  86124. meshMap: Nullable<{
  86125. [id: string]: AbstractMesh | undefined;
  86126. }>;
  86127. /**
  86128. * Creates a material instance
  86129. * @param name defines the name of the material
  86130. * @param scene defines the scene to reference
  86131. * @param doNotAdd specifies if the material should be added to the scene
  86132. */
  86133. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  86134. /**
  86135. * Returns a string representation of the current material
  86136. * @param fullDetails defines a boolean indicating which levels of logging is desired
  86137. * @returns a string with material information
  86138. */
  86139. toString(fullDetails?: boolean): string;
  86140. /**
  86141. * Gets the class name of the material
  86142. * @returns a string with the class name of the material
  86143. */
  86144. getClassName(): string;
  86145. /**
  86146. * Specifies if updates for the material been locked
  86147. */
  86148. readonly isFrozen: boolean;
  86149. /**
  86150. * Locks updates for the material
  86151. */
  86152. freeze(): void;
  86153. /**
  86154. * Unlocks updates for the material
  86155. */
  86156. unfreeze(): void;
  86157. /**
  86158. * Specifies if the material is ready to be used
  86159. * @param mesh defines the mesh to check
  86160. * @param useInstances specifies if instances should be used
  86161. * @returns a boolean indicating if the material is ready to be used
  86162. */
  86163. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  86164. /**
  86165. * Specifies that the submesh is ready to be used
  86166. * @param mesh defines the mesh to check
  86167. * @param subMesh defines which submesh to check
  86168. * @param useInstances specifies that instances should be used
  86169. * @returns a boolean indicating that the submesh is ready or not
  86170. */
  86171. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  86172. /**
  86173. * Returns the material effect
  86174. * @returns the effect associated with the material
  86175. */
  86176. getEffect(): Nullable<Effect>;
  86177. /**
  86178. * Returns the current scene
  86179. * @returns a Scene
  86180. */
  86181. getScene(): Scene;
  86182. /**
  86183. * Specifies if the material will require alpha blending
  86184. * @returns a boolean specifying if alpha blending is needed
  86185. */
  86186. needAlphaBlending(): boolean;
  86187. /**
  86188. * Specifies if the mesh will require alpha blending
  86189. * @param mesh defines the mesh to check
  86190. * @returns a boolean specifying if alpha blending is needed for the mesh
  86191. */
  86192. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  86193. /**
  86194. * Specifies if this material should be rendered in alpha test mode
  86195. * @returns a boolean specifying if an alpha test is needed.
  86196. */
  86197. needAlphaTesting(): boolean;
  86198. /**
  86199. * Gets the texture used for the alpha test
  86200. * @returns the texture to use for alpha testing
  86201. */
  86202. getAlphaTestTexture(): Nullable<BaseTexture>;
  86203. /**
  86204. * Marks the material to indicate that it needs to be re-calculated
  86205. */
  86206. markDirty(): void;
  86207. /** @hidden */
  86208. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  86209. /**
  86210. * Binds the material to the mesh
  86211. * @param world defines the world transformation matrix
  86212. * @param mesh defines the mesh to bind the material to
  86213. */
  86214. bind(world: Matrix, mesh?: Mesh): void;
  86215. /**
  86216. * Binds the submesh to the material
  86217. * @param world defines the world transformation matrix
  86218. * @param mesh defines the mesh containing the submesh
  86219. * @param subMesh defines the submesh to bind the material to
  86220. */
  86221. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  86222. /**
  86223. * Binds the world matrix to the material
  86224. * @param world defines the world transformation matrix
  86225. */
  86226. bindOnlyWorldMatrix(world: Matrix): void;
  86227. /**
  86228. * Binds the scene's uniform buffer to the effect.
  86229. * @param effect defines the effect to bind to the scene uniform buffer
  86230. * @param sceneUbo defines the uniform buffer storing scene data
  86231. */
  86232. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  86233. /**
  86234. * Binds the view matrix to the effect
  86235. * @param effect defines the effect to bind the view matrix to
  86236. */
  86237. bindView(effect: Effect): void;
  86238. /**
  86239. * Binds the view projection matrix to the effect
  86240. * @param effect defines the effect to bind the view projection matrix to
  86241. */
  86242. bindViewProjection(effect: Effect): void;
  86243. /**
  86244. * Specifies if material alpha testing should be turned on for the mesh
  86245. * @param mesh defines the mesh to check
  86246. */
  86247. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  86248. /**
  86249. * Processes to execute after binding the material to a mesh
  86250. * @param mesh defines the rendered mesh
  86251. */
  86252. protected _afterBind(mesh?: Mesh): void;
  86253. /**
  86254. * Unbinds the material from the mesh
  86255. */
  86256. unbind(): void;
  86257. /**
  86258. * Gets the active textures from the material
  86259. * @returns an array of textures
  86260. */
  86261. getActiveTextures(): BaseTexture[];
  86262. /**
  86263. * Specifies if the material uses a texture
  86264. * @param texture defines the texture to check against the material
  86265. * @returns a boolean specifying if the material uses the texture
  86266. */
  86267. hasTexture(texture: BaseTexture): boolean;
  86268. /**
  86269. * Makes a duplicate of the material, and gives it a new name
  86270. * @param name defines the new name for the duplicated material
  86271. * @returns the cloned material
  86272. */
  86273. clone(name: string): Nullable<Material>;
  86274. /**
  86275. * Gets the meshes bound to the material
  86276. * @returns an array of meshes bound to the material
  86277. */
  86278. getBindedMeshes(): AbstractMesh[];
  86279. /**
  86280. * Force shader compilation
  86281. * @param mesh defines the mesh associated with this material
  86282. * @param onCompiled defines a function to execute once the material is compiled
  86283. * @param options defines the options to configure the compilation
  86284. */
  86285. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  86286. clipPlane: boolean;
  86287. }>): void;
  86288. /**
  86289. * Force shader compilation
  86290. * @param mesh defines the mesh that will use this material
  86291. * @param options defines additional options for compiling the shaders
  86292. * @returns a promise that resolves when the compilation completes
  86293. */
  86294. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  86295. clipPlane: boolean;
  86296. }>): Promise<void>;
  86297. private static readonly _AllDirtyCallBack;
  86298. private static readonly _ImageProcessingDirtyCallBack;
  86299. private static readonly _TextureDirtyCallBack;
  86300. private static readonly _FresnelDirtyCallBack;
  86301. private static readonly _MiscDirtyCallBack;
  86302. private static readonly _LightsDirtyCallBack;
  86303. private static readonly _AttributeDirtyCallBack;
  86304. private static _FresnelAndMiscDirtyCallBack;
  86305. private static _TextureAndMiscDirtyCallBack;
  86306. private static readonly _DirtyCallbackArray;
  86307. private static readonly _RunDirtyCallBacks;
  86308. /**
  86309. * Marks a define in the material to indicate that it needs to be re-computed
  86310. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  86311. */
  86312. markAsDirty(flag: number): void;
  86313. /**
  86314. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  86315. * @param func defines a function which checks material defines against the submeshes
  86316. */
  86317. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  86318. /**
  86319. * Indicates that we need to re-calculated for all submeshes
  86320. */
  86321. protected _markAllSubMeshesAsAllDirty(): void;
  86322. /**
  86323. * Indicates that image processing needs to be re-calculated for all submeshes
  86324. */
  86325. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  86326. /**
  86327. * Indicates that textures need to be re-calculated for all submeshes
  86328. */
  86329. protected _markAllSubMeshesAsTexturesDirty(): void;
  86330. /**
  86331. * Indicates that fresnel needs to be re-calculated for all submeshes
  86332. */
  86333. protected _markAllSubMeshesAsFresnelDirty(): void;
  86334. /**
  86335. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  86336. */
  86337. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  86338. /**
  86339. * Indicates that lights need to be re-calculated for all submeshes
  86340. */
  86341. protected _markAllSubMeshesAsLightsDirty(): void;
  86342. /**
  86343. * Indicates that attributes need to be re-calculated for all submeshes
  86344. */
  86345. protected _markAllSubMeshesAsAttributesDirty(): void;
  86346. /**
  86347. * Indicates that misc needs to be re-calculated for all submeshes
  86348. */
  86349. protected _markAllSubMeshesAsMiscDirty(): void;
  86350. /**
  86351. * Indicates that textures and misc need to be re-calculated for all submeshes
  86352. */
  86353. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  86354. /**
  86355. * Disposes the material
  86356. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  86357. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  86358. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  86359. */
  86360. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  86361. /** @hidden */
  86362. private releaseVertexArrayObject;
  86363. /**
  86364. * Serializes this material
  86365. * @returns the serialized material object
  86366. */
  86367. serialize(): any;
  86368. /**
  86369. * Creates a material from parsed material data
  86370. * @param parsedMaterial defines parsed material data
  86371. * @param scene defines the hosting scene
  86372. * @param rootUrl defines the root URL to use to load textures
  86373. * @returns a new material
  86374. */
  86375. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  86376. }
  86377. }
  86378. declare module BABYLON {
  86379. /**
  86380. * A multi-material is used to apply different materials to different parts of the same object without the need of
  86381. * separate meshes. This can be use to improve performances.
  86382. * @see http://doc.babylonjs.com/how_to/multi_materials
  86383. */
  86384. export class MultiMaterial extends Material {
  86385. private _subMaterials;
  86386. /**
  86387. * Gets or Sets the list of Materials used within the multi material.
  86388. * They need to be ordered according to the submeshes order in the associated mesh
  86389. */
  86390. subMaterials: Nullable<Material>[];
  86391. /**
  86392. * Function used to align with Node.getChildren()
  86393. * @returns the list of Materials used within the multi material
  86394. */
  86395. getChildren(): Nullable<Material>[];
  86396. /**
  86397. * Instantiates a new Multi Material
  86398. * A multi-material is used to apply different materials to different parts of the same object without the need of
  86399. * separate meshes. This can be use to improve performances.
  86400. * @see http://doc.babylonjs.com/how_to/multi_materials
  86401. * @param name Define the name in the scene
  86402. * @param scene Define the scene the material belongs to
  86403. */
  86404. constructor(name: string, scene: Scene);
  86405. private _hookArray;
  86406. /**
  86407. * Get one of the submaterial by its index in the submaterials array
  86408. * @param index The index to look the sub material at
  86409. * @returns The Material if the index has been defined
  86410. */
  86411. getSubMaterial(index: number): Nullable<Material>;
  86412. /**
  86413. * Get the list of active textures for the whole sub materials list.
  86414. * @returns All the textures that will be used during the rendering
  86415. */
  86416. getActiveTextures(): BaseTexture[];
  86417. /**
  86418. * Gets the current class name of the material e.g. "MultiMaterial"
  86419. * Mainly use in serialization.
  86420. * @returns the class name
  86421. */
  86422. getClassName(): string;
  86423. /**
  86424. * Checks if the material is ready to render the requested sub mesh
  86425. * @param mesh Define the mesh the submesh belongs to
  86426. * @param subMesh Define the sub mesh to look readyness for
  86427. * @param useInstances Define whether or not the material is used with instances
  86428. * @returns true if ready, otherwise false
  86429. */
  86430. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  86431. /**
  86432. * Clones the current material and its related sub materials
  86433. * @param name Define the name of the newly cloned material
  86434. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  86435. * @returns the cloned material
  86436. */
  86437. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  86438. /**
  86439. * Serializes the materials into a JSON representation.
  86440. * @returns the JSON representation
  86441. */
  86442. serialize(): any;
  86443. /**
  86444. * Dispose the material and release its associated resources
  86445. * @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)
  86446. * @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)
  86447. * @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)
  86448. */
  86449. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  86450. /**
  86451. * Creates a MultiMaterial from parsed MultiMaterial data.
  86452. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  86453. * @param scene defines the hosting scene
  86454. * @returns a new MultiMaterial
  86455. */
  86456. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  86457. }
  86458. }
  86459. declare module BABYLON {
  86460. /**
  86461. * Base class for submeshes
  86462. */
  86463. export class BaseSubMesh {
  86464. /** @hidden */
  86465. _materialDefines: Nullable<MaterialDefines>;
  86466. /** @hidden */
  86467. _materialEffect: Nullable<Effect>;
  86468. /**
  86469. * Gets associated effect
  86470. */
  86471. readonly effect: Nullable<Effect>;
  86472. /**
  86473. * Sets associated effect (effect used to render this submesh)
  86474. * @param effect defines the effect to associate with
  86475. * @param defines defines the set of defines used to compile this effect
  86476. */
  86477. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  86478. }
  86479. /**
  86480. * Defines a subdivision inside a mesh
  86481. */
  86482. export class SubMesh extends BaseSubMesh implements ICullable {
  86483. /** the material index to use */
  86484. materialIndex: number;
  86485. /** vertex index start */
  86486. verticesStart: number;
  86487. /** vertices count */
  86488. verticesCount: number;
  86489. /** index start */
  86490. indexStart: number;
  86491. /** indices count */
  86492. indexCount: number;
  86493. /** @hidden */
  86494. _linesIndexCount: number;
  86495. private _mesh;
  86496. private _renderingMesh;
  86497. private _boundingInfo;
  86498. private _linesIndexBuffer;
  86499. /** @hidden */
  86500. _lastColliderWorldVertices: Nullable<Vector3[]>;
  86501. /** @hidden */
  86502. _trianglePlanes: Plane[];
  86503. /** @hidden */
  86504. _lastColliderTransformMatrix: Nullable<Matrix>;
  86505. /** @hidden */
  86506. _renderId: number;
  86507. /** @hidden */
  86508. _alphaIndex: number;
  86509. /** @hidden */
  86510. _distanceToCamera: number;
  86511. /** @hidden */
  86512. _id: number;
  86513. private _currentMaterial;
  86514. /**
  86515. * Add a new submesh to a mesh
  86516. * @param materialIndex defines the material index to use
  86517. * @param verticesStart defines vertex index start
  86518. * @param verticesCount defines vertices count
  86519. * @param indexStart defines index start
  86520. * @param indexCount defines indices count
  86521. * @param mesh defines the parent mesh
  86522. * @param renderingMesh defines an optional rendering mesh
  86523. * @param createBoundingBox defines if bounding box should be created for this submesh
  86524. * @returns the new submesh
  86525. */
  86526. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  86527. /**
  86528. * Creates a new submesh
  86529. * @param materialIndex defines the material index to use
  86530. * @param verticesStart defines vertex index start
  86531. * @param verticesCount defines vertices count
  86532. * @param indexStart defines index start
  86533. * @param indexCount defines indices count
  86534. * @param mesh defines the parent mesh
  86535. * @param renderingMesh defines an optional rendering mesh
  86536. * @param createBoundingBox defines if bounding box should be created for this submesh
  86537. */
  86538. constructor(
  86539. /** the material index to use */
  86540. materialIndex: number,
  86541. /** vertex index start */
  86542. verticesStart: number,
  86543. /** vertices count */
  86544. verticesCount: number,
  86545. /** index start */
  86546. indexStart: number,
  86547. /** indices count */
  86548. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  86549. /**
  86550. * Returns true if this submesh covers the entire parent mesh
  86551. * @ignorenaming
  86552. */
  86553. readonly IsGlobal: boolean;
  86554. /**
  86555. * Returns the submesh BoudingInfo object
  86556. * @returns current bounding info (or mesh's one if the submesh is global)
  86557. */
  86558. getBoundingInfo(): BoundingInfo;
  86559. /**
  86560. * Sets the submesh BoundingInfo
  86561. * @param boundingInfo defines the new bounding info to use
  86562. * @returns the SubMesh
  86563. */
  86564. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  86565. /**
  86566. * Returns the mesh of the current submesh
  86567. * @return the parent mesh
  86568. */
  86569. getMesh(): AbstractMesh;
  86570. /**
  86571. * Returns the rendering mesh of the submesh
  86572. * @returns the rendering mesh (could be different from parent mesh)
  86573. */
  86574. getRenderingMesh(): Mesh;
  86575. /**
  86576. * Returns the submesh material
  86577. * @returns null or the current material
  86578. */
  86579. getMaterial(): Nullable<Material>;
  86580. /**
  86581. * Sets a new updated BoundingInfo object to the submesh
  86582. * @param data defines an optional position array to use to determine the bounding info
  86583. * @returns the SubMesh
  86584. */
  86585. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  86586. /** @hidden */
  86587. _checkCollision(collider: Collider): boolean;
  86588. /**
  86589. * Updates the submesh BoundingInfo
  86590. * @param world defines the world matrix to use to update the bounding info
  86591. * @returns the submesh
  86592. */
  86593. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  86594. /**
  86595. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  86596. * @param frustumPlanes defines the frustum planes
  86597. * @returns true if the submesh is intersecting with the frustum
  86598. */
  86599. isInFrustum(frustumPlanes: Plane[]): boolean;
  86600. /**
  86601. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  86602. * @param frustumPlanes defines the frustum planes
  86603. * @returns true if the submesh is inside the frustum
  86604. */
  86605. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  86606. /**
  86607. * Renders the submesh
  86608. * @param enableAlphaMode defines if alpha needs to be used
  86609. * @returns the submesh
  86610. */
  86611. render(enableAlphaMode: boolean): SubMesh;
  86612. /**
  86613. * @hidden
  86614. */
  86615. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  86616. /**
  86617. * Checks if the submesh intersects with a ray
  86618. * @param ray defines the ray to test
  86619. * @returns true is the passed ray intersects the submesh bounding box
  86620. */
  86621. canIntersects(ray: Ray): boolean;
  86622. /**
  86623. * Intersects current submesh with a ray
  86624. * @param ray defines the ray to test
  86625. * @param positions defines mesh's positions array
  86626. * @param indices defines mesh's indices array
  86627. * @param fastCheck defines if only bounding info should be used
  86628. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  86629. * @returns intersection info or null if no intersection
  86630. */
  86631. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  86632. /** @hidden */
  86633. private _intersectLines;
  86634. /** @hidden */
  86635. private _intersectUnIndexedLines;
  86636. /** @hidden */
  86637. private _intersectTriangles;
  86638. /** @hidden */
  86639. private _intersectUnIndexedTriangles;
  86640. /** @hidden */
  86641. _rebuild(): void;
  86642. /**
  86643. * Creates a new submesh from the passed mesh
  86644. * @param newMesh defines the new hosting mesh
  86645. * @param newRenderingMesh defines an optional rendering mesh
  86646. * @returns the new submesh
  86647. */
  86648. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  86649. /**
  86650. * Release associated resources
  86651. */
  86652. dispose(): void;
  86653. /**
  86654. * Gets the class name
  86655. * @returns the string "SubMesh".
  86656. */
  86657. getClassName(): string;
  86658. /**
  86659. * Creates a new submesh from indices data
  86660. * @param materialIndex the index of the main mesh material
  86661. * @param startIndex the index where to start the copy in the mesh indices array
  86662. * @param indexCount the number of indices to copy then from the startIndex
  86663. * @param mesh the main mesh to create the submesh from
  86664. * @param renderingMesh the optional rendering mesh
  86665. * @returns a new submesh
  86666. */
  86667. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  86668. }
  86669. }
  86670. declare module BABYLON {
  86671. /**
  86672. * Class used to represent data loading progression
  86673. */
  86674. export class SceneLoaderFlags {
  86675. private static _ForceFullSceneLoadingForIncremental;
  86676. private static _ShowLoadingScreen;
  86677. private static _CleanBoneMatrixWeights;
  86678. private static _loggingLevel;
  86679. /**
  86680. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  86681. */
  86682. static ForceFullSceneLoadingForIncremental: boolean;
  86683. /**
  86684. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  86685. */
  86686. static ShowLoadingScreen: boolean;
  86687. /**
  86688. * Defines the current logging level (while loading the scene)
  86689. * @ignorenaming
  86690. */
  86691. static loggingLevel: number;
  86692. /**
  86693. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  86694. */
  86695. static CleanBoneMatrixWeights: boolean;
  86696. }
  86697. }
  86698. declare module BABYLON {
  86699. /**
  86700. * Class used to store geometry data (vertex buffers + index buffer)
  86701. */
  86702. export class Geometry implements IGetSetVerticesData {
  86703. /**
  86704. * Gets or sets the ID of the geometry
  86705. */
  86706. id: string;
  86707. /**
  86708. * Gets or sets the unique ID of the geometry
  86709. */
  86710. uniqueId: number;
  86711. /**
  86712. * Gets the delay loading state of the geometry (none by default which means not delayed)
  86713. */
  86714. delayLoadState: number;
  86715. /**
  86716. * Gets the file containing the data to load when running in delay load state
  86717. */
  86718. delayLoadingFile: Nullable<string>;
  86719. /**
  86720. * Callback called when the geometry is updated
  86721. */
  86722. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  86723. private _scene;
  86724. private _engine;
  86725. private _meshes;
  86726. private _totalVertices;
  86727. /** @hidden */
  86728. _indices: IndicesArray;
  86729. /** @hidden */
  86730. _vertexBuffers: {
  86731. [key: string]: VertexBuffer;
  86732. };
  86733. private _isDisposed;
  86734. private _extend;
  86735. private _boundingBias;
  86736. /** @hidden */
  86737. _delayInfo: Array<string>;
  86738. private _indexBuffer;
  86739. private _indexBufferIsUpdatable;
  86740. /** @hidden */
  86741. _boundingInfo: Nullable<BoundingInfo>;
  86742. /** @hidden */
  86743. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  86744. /** @hidden */
  86745. _softwareSkinningFrameId: number;
  86746. private _vertexArrayObjects;
  86747. private _updatable;
  86748. /** @hidden */
  86749. _positions: Nullable<Vector3[]>;
  86750. /**
  86751. * 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
  86752. */
  86753. /**
  86754. * 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
  86755. */
  86756. boundingBias: Vector2;
  86757. /**
  86758. * Static function used to attach a new empty geometry to a mesh
  86759. * @param mesh defines the mesh to attach the geometry to
  86760. * @returns the new Geometry
  86761. */
  86762. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  86763. /**
  86764. * Creates a new geometry
  86765. * @param id defines the unique ID
  86766. * @param scene defines the hosting scene
  86767. * @param vertexData defines the VertexData used to get geometry data
  86768. * @param updatable defines if geometry must be updatable (false by default)
  86769. * @param mesh defines the mesh that will be associated with the geometry
  86770. */
  86771. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  86772. /**
  86773. * Gets the current extend of the geometry
  86774. */
  86775. readonly extend: {
  86776. minimum: Vector3;
  86777. maximum: Vector3;
  86778. };
  86779. /**
  86780. * Gets the hosting scene
  86781. * @returns the hosting Scene
  86782. */
  86783. getScene(): Scene;
  86784. /**
  86785. * Gets the hosting engine
  86786. * @returns the hosting Engine
  86787. */
  86788. getEngine(): Engine;
  86789. /**
  86790. * Defines if the geometry is ready to use
  86791. * @returns true if the geometry is ready to be used
  86792. */
  86793. isReady(): boolean;
  86794. /**
  86795. * Gets a value indicating that the geometry should not be serialized
  86796. */
  86797. readonly doNotSerialize: boolean;
  86798. /** @hidden */
  86799. _rebuild(): void;
  86800. /**
  86801. * Affects all geometry data in one call
  86802. * @param vertexData defines the geometry data
  86803. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  86804. */
  86805. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  86806. /**
  86807. * Set specific vertex data
  86808. * @param kind defines the data kind (Position, normal, etc...)
  86809. * @param data defines the vertex data to use
  86810. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  86811. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  86812. */
  86813. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  86814. /**
  86815. * Removes a specific vertex data
  86816. * @param kind defines the data kind (Position, normal, etc...)
  86817. */
  86818. removeVerticesData(kind: string): void;
  86819. /**
  86820. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  86821. * @param buffer defines the vertex buffer to use
  86822. * @param totalVertices defines the total number of vertices for position kind (could be null)
  86823. */
  86824. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  86825. /**
  86826. * Update a specific vertex buffer
  86827. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  86828. * It will do nothing if the buffer is not updatable
  86829. * @param kind defines the data kind (Position, normal, etc...)
  86830. * @param data defines the data to use
  86831. * @param offset defines the offset in the target buffer where to store the data
  86832. * @param useBytes set to true if the offset is in bytes
  86833. */
  86834. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  86835. /**
  86836. * Update a specific vertex buffer
  86837. * This function will create a new buffer if the current one is not updatable
  86838. * @param kind defines the data kind (Position, normal, etc...)
  86839. * @param data defines the data to use
  86840. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  86841. */
  86842. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  86843. private _updateBoundingInfo;
  86844. /** @hidden */
  86845. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  86846. /**
  86847. * Gets total number of vertices
  86848. * @returns the total number of vertices
  86849. */
  86850. getTotalVertices(): number;
  86851. /**
  86852. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  86853. * @param kind defines the data kind (Position, normal, etc...)
  86854. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  86855. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  86856. * @returns a float array containing vertex data
  86857. */
  86858. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  86859. /**
  86860. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  86861. * @param kind defines the data kind (Position, normal, etc...)
  86862. * @returns true if the vertex buffer with the specified kind is updatable
  86863. */
  86864. isVertexBufferUpdatable(kind: string): boolean;
  86865. /**
  86866. * Gets a specific vertex buffer
  86867. * @param kind defines the data kind (Position, normal, etc...)
  86868. * @returns a VertexBuffer
  86869. */
  86870. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  86871. /**
  86872. * Returns all vertex buffers
  86873. * @return an object holding all vertex buffers indexed by kind
  86874. */
  86875. getVertexBuffers(): Nullable<{
  86876. [key: string]: VertexBuffer;
  86877. }>;
  86878. /**
  86879. * Gets a boolean indicating if specific vertex buffer is present
  86880. * @param kind defines the data kind (Position, normal, etc...)
  86881. * @returns true if data is present
  86882. */
  86883. isVerticesDataPresent(kind: string): boolean;
  86884. /**
  86885. * Gets a list of all attached data kinds (Position, normal, etc...)
  86886. * @returns a list of string containing all kinds
  86887. */
  86888. getVerticesDataKinds(): string[];
  86889. /**
  86890. * Update index buffer
  86891. * @param indices defines the indices to store in the index buffer
  86892. * @param offset defines the offset in the target buffer where to store the data
  86893. * @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)
  86894. */
  86895. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  86896. /**
  86897. * Creates a new index buffer
  86898. * @param indices defines the indices to store in the index buffer
  86899. * @param totalVertices defines the total number of vertices (could be null)
  86900. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  86901. */
  86902. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  86903. /**
  86904. * Return the total number of indices
  86905. * @returns the total number of indices
  86906. */
  86907. getTotalIndices(): number;
  86908. /**
  86909. * Gets the index buffer array
  86910. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  86911. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  86912. * @returns the index buffer array
  86913. */
  86914. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  86915. /**
  86916. * Gets the index buffer
  86917. * @return the index buffer
  86918. */
  86919. getIndexBuffer(): Nullable<DataBuffer>;
  86920. /** @hidden */
  86921. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  86922. /**
  86923. * Release the associated resources for a specific mesh
  86924. * @param mesh defines the source mesh
  86925. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  86926. */
  86927. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  86928. /**
  86929. * Apply current geometry to a given mesh
  86930. * @param mesh defines the mesh to apply geometry to
  86931. */
  86932. applyToMesh(mesh: Mesh): void;
  86933. private _updateExtend;
  86934. private _applyToMesh;
  86935. private notifyUpdate;
  86936. /**
  86937. * Load the geometry if it was flagged as delay loaded
  86938. * @param scene defines the hosting scene
  86939. * @param onLoaded defines a callback called when the geometry is loaded
  86940. */
  86941. load(scene: Scene, onLoaded?: () => void): void;
  86942. private _queueLoad;
  86943. /**
  86944. * Invert the geometry to move from a right handed system to a left handed one.
  86945. */
  86946. toLeftHanded(): void;
  86947. /** @hidden */
  86948. _resetPointsArrayCache(): void;
  86949. /** @hidden */
  86950. _generatePointsArray(): boolean;
  86951. /**
  86952. * Gets a value indicating if the geometry is disposed
  86953. * @returns true if the geometry was disposed
  86954. */
  86955. isDisposed(): boolean;
  86956. private _disposeVertexArrayObjects;
  86957. /**
  86958. * Free all associated resources
  86959. */
  86960. dispose(): void;
  86961. /**
  86962. * Clone the current geometry into a new geometry
  86963. * @param id defines the unique ID of the new geometry
  86964. * @returns a new geometry object
  86965. */
  86966. copy(id: string): Geometry;
  86967. /**
  86968. * Serialize the current geometry info (and not the vertices data) into a JSON object
  86969. * @return a JSON representation of the current geometry data (without the vertices data)
  86970. */
  86971. serialize(): any;
  86972. private toNumberArray;
  86973. /**
  86974. * Serialize all vertices data into a JSON oject
  86975. * @returns a JSON representation of the current geometry data
  86976. */
  86977. serializeVerticeData(): any;
  86978. /**
  86979. * Extracts a clone of a mesh geometry
  86980. * @param mesh defines the source mesh
  86981. * @param id defines the unique ID of the new geometry object
  86982. * @returns the new geometry object
  86983. */
  86984. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  86985. /**
  86986. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  86987. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  86988. * Be aware Math.random() could cause collisions, but:
  86989. * "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"
  86990. * @returns a string containing a new GUID
  86991. */
  86992. static RandomId(): string;
  86993. /** @hidden */
  86994. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  86995. private static _CleanMatricesWeights;
  86996. /**
  86997. * Create a new geometry from persisted data (Using .babylon file format)
  86998. * @param parsedVertexData defines the persisted data
  86999. * @param scene defines the hosting scene
  87000. * @param rootUrl defines the root url to use to load assets (like delayed data)
  87001. * @returns the new geometry object
  87002. */
  87003. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  87004. }
  87005. }
  87006. declare module BABYLON {
  87007. /**
  87008. * Define an interface for all classes that will get and set the data on vertices
  87009. */
  87010. export interface IGetSetVerticesData {
  87011. /**
  87012. * Gets a boolean indicating if specific vertex data is present
  87013. * @param kind defines the vertex data kind to use
  87014. * @returns true is data kind is present
  87015. */
  87016. isVerticesDataPresent(kind: string): boolean;
  87017. /**
  87018. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  87019. * @param kind defines the data kind (Position, normal, etc...)
  87020. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  87021. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  87022. * @returns a float array containing vertex data
  87023. */
  87024. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  87025. /**
  87026. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  87027. * @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.
  87028. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  87029. * @returns the indices array or an empty array if the mesh has no geometry
  87030. */
  87031. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  87032. /**
  87033. * Set specific vertex data
  87034. * @param kind defines the data kind (Position, normal, etc...)
  87035. * @param data defines the vertex data to use
  87036. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  87037. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  87038. */
  87039. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  87040. /**
  87041. * Update a specific associated vertex buffer
  87042. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  87043. * - VertexBuffer.PositionKind
  87044. * - VertexBuffer.UVKind
  87045. * - VertexBuffer.UV2Kind
  87046. * - VertexBuffer.UV3Kind
  87047. * - VertexBuffer.UV4Kind
  87048. * - VertexBuffer.UV5Kind
  87049. * - VertexBuffer.UV6Kind
  87050. * - VertexBuffer.ColorKind
  87051. * - VertexBuffer.MatricesIndicesKind
  87052. * - VertexBuffer.MatricesIndicesExtraKind
  87053. * - VertexBuffer.MatricesWeightsKind
  87054. * - VertexBuffer.MatricesWeightsExtraKind
  87055. * @param data defines the data source
  87056. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  87057. * @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)
  87058. */
  87059. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  87060. /**
  87061. * Creates a new index buffer
  87062. * @param indices defines the indices to store in the index buffer
  87063. * @param totalVertices defines the total number of vertices (could be null)
  87064. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  87065. */
  87066. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  87067. }
  87068. /**
  87069. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  87070. */
  87071. export class VertexData {
  87072. /**
  87073. * Mesh side orientation : usually the external or front surface
  87074. */
  87075. static readonly FRONTSIDE: number;
  87076. /**
  87077. * Mesh side orientation : usually the internal or back surface
  87078. */
  87079. static readonly BACKSIDE: number;
  87080. /**
  87081. * Mesh side orientation : both internal and external or front and back surfaces
  87082. */
  87083. static readonly DOUBLESIDE: number;
  87084. /**
  87085. * Mesh side orientation : by default, `FRONTSIDE`
  87086. */
  87087. static readonly DEFAULTSIDE: number;
  87088. /**
  87089. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  87090. */
  87091. positions: Nullable<FloatArray>;
  87092. /**
  87093. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  87094. */
  87095. normals: Nullable<FloatArray>;
  87096. /**
  87097. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  87098. */
  87099. tangents: Nullable<FloatArray>;
  87100. /**
  87101. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  87102. */
  87103. uvs: Nullable<FloatArray>;
  87104. /**
  87105. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  87106. */
  87107. uvs2: Nullable<FloatArray>;
  87108. /**
  87109. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  87110. */
  87111. uvs3: Nullable<FloatArray>;
  87112. /**
  87113. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  87114. */
  87115. uvs4: Nullable<FloatArray>;
  87116. /**
  87117. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  87118. */
  87119. uvs5: Nullable<FloatArray>;
  87120. /**
  87121. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  87122. */
  87123. uvs6: Nullable<FloatArray>;
  87124. /**
  87125. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  87126. */
  87127. colors: Nullable<FloatArray>;
  87128. /**
  87129. * 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).
  87130. */
  87131. matricesIndices: Nullable<FloatArray>;
  87132. /**
  87133. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  87134. */
  87135. matricesWeights: Nullable<FloatArray>;
  87136. /**
  87137. * An array extending the number of possible indices
  87138. */
  87139. matricesIndicesExtra: Nullable<FloatArray>;
  87140. /**
  87141. * An array extending the number of possible weights when the number of indices is extended
  87142. */
  87143. matricesWeightsExtra: Nullable<FloatArray>;
  87144. /**
  87145. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  87146. */
  87147. indices: Nullable<IndicesArray>;
  87148. /**
  87149. * Uses the passed data array to set the set the values for the specified kind of data
  87150. * @param data a linear array of floating numbers
  87151. * @param kind the type of data that is being set, eg positions, colors etc
  87152. */
  87153. set(data: FloatArray, kind: string): void;
  87154. /**
  87155. * Associates the vertexData to the passed Mesh.
  87156. * Sets it as updatable or not (default `false`)
  87157. * @param mesh the mesh the vertexData is applied to
  87158. * @param updatable when used and having the value true allows new data to update the vertexData
  87159. * @returns the VertexData
  87160. */
  87161. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  87162. /**
  87163. * Associates the vertexData to the passed Geometry.
  87164. * Sets it as updatable or not (default `false`)
  87165. * @param geometry the geometry the vertexData is applied to
  87166. * @param updatable when used and having the value true allows new data to update the vertexData
  87167. * @returns VertexData
  87168. */
  87169. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  87170. /**
  87171. * Updates the associated mesh
  87172. * @param mesh the mesh to be updated
  87173. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  87174. * @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
  87175. * @returns VertexData
  87176. */
  87177. updateMesh(mesh: Mesh): VertexData;
  87178. /**
  87179. * Updates the associated geometry
  87180. * @param geometry the geometry to be updated
  87181. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  87182. * @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
  87183. * @returns VertexData.
  87184. */
  87185. updateGeometry(geometry: Geometry): VertexData;
  87186. private _applyTo;
  87187. private _update;
  87188. /**
  87189. * Transforms each position and each normal of the vertexData according to the passed Matrix
  87190. * @param matrix the transforming matrix
  87191. * @returns the VertexData
  87192. */
  87193. transform(matrix: Matrix): VertexData;
  87194. /**
  87195. * Merges the passed VertexData into the current one
  87196. * @param other the VertexData to be merged into the current one
  87197. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  87198. * @returns the modified VertexData
  87199. */
  87200. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  87201. private _mergeElement;
  87202. private _validate;
  87203. /**
  87204. * Serializes the VertexData
  87205. * @returns a serialized object
  87206. */
  87207. serialize(): any;
  87208. /**
  87209. * Extracts the vertexData from a mesh
  87210. * @param mesh the mesh from which to extract the VertexData
  87211. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  87212. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  87213. * @returns the object VertexData associated to the passed mesh
  87214. */
  87215. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  87216. /**
  87217. * Extracts the vertexData from the geometry
  87218. * @param geometry the geometry from which to extract the VertexData
  87219. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  87220. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  87221. * @returns the object VertexData associated to the passed mesh
  87222. */
  87223. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  87224. private static _ExtractFrom;
  87225. /**
  87226. * Creates the VertexData for a Ribbon
  87227. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  87228. * * pathArray array of paths, each of which an array of successive Vector3
  87229. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  87230. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  87231. * * 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
  87232. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87233. * * 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)
  87234. * * 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)
  87235. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  87236. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  87237. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  87238. * @returns the VertexData of the ribbon
  87239. */
  87240. static CreateRibbon(options: {
  87241. pathArray: Vector3[][];
  87242. closeArray?: boolean;
  87243. closePath?: boolean;
  87244. offset?: number;
  87245. sideOrientation?: number;
  87246. frontUVs?: Vector4;
  87247. backUVs?: Vector4;
  87248. invertUV?: boolean;
  87249. uvs?: Vector2[];
  87250. colors?: Color4[];
  87251. }): VertexData;
  87252. /**
  87253. * Creates the VertexData for a box
  87254. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87255. * * size sets the width, height and depth of the box to the value of size, optional default 1
  87256. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  87257. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  87258. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  87259. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  87260. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  87261. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87262. * * 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)
  87263. * * 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)
  87264. * @returns the VertexData of the box
  87265. */
  87266. static CreateBox(options: {
  87267. size?: number;
  87268. width?: number;
  87269. height?: number;
  87270. depth?: number;
  87271. faceUV?: Vector4[];
  87272. faceColors?: Color4[];
  87273. sideOrientation?: number;
  87274. frontUVs?: Vector4;
  87275. backUVs?: Vector4;
  87276. }): VertexData;
  87277. /**
  87278. * Creates the VertexData for a tiled box
  87279. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87280. * * faceTiles sets the pattern, tile size and number of tiles for a face
  87281. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  87282. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  87283. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87284. * @returns the VertexData of the box
  87285. */
  87286. static CreateTiledBox(options: {
  87287. pattern?: number;
  87288. width?: number;
  87289. height?: number;
  87290. depth?: number;
  87291. tileSize?: number;
  87292. tileWidth?: number;
  87293. tileHeight?: number;
  87294. alignHorizontal?: number;
  87295. alignVertical?: number;
  87296. faceUV?: Vector4[];
  87297. faceColors?: Color4[];
  87298. sideOrientation?: number;
  87299. }): VertexData;
  87300. /**
  87301. * Creates the VertexData for a tiled plane
  87302. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87303. * * pattern a limited pattern arrangement depending on the number
  87304. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  87305. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  87306. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  87307. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87308. * * 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)
  87309. * * 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)
  87310. * @returns the VertexData of the tiled plane
  87311. */
  87312. static CreateTiledPlane(options: {
  87313. pattern?: number;
  87314. tileSize?: number;
  87315. tileWidth?: number;
  87316. tileHeight?: number;
  87317. size?: number;
  87318. width?: number;
  87319. height?: number;
  87320. alignHorizontal?: number;
  87321. alignVertical?: number;
  87322. sideOrientation?: number;
  87323. frontUVs?: Vector4;
  87324. backUVs?: Vector4;
  87325. }): VertexData;
  87326. /**
  87327. * Creates the VertexData for an ellipsoid, defaults to a sphere
  87328. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87329. * * segments sets the number of horizontal strips optional, default 32
  87330. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  87331. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  87332. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  87333. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  87334. * * 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
  87335. * * 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
  87336. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87337. * * 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)
  87338. * * 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)
  87339. * @returns the VertexData of the ellipsoid
  87340. */
  87341. static CreateSphere(options: {
  87342. segments?: number;
  87343. diameter?: number;
  87344. diameterX?: number;
  87345. diameterY?: number;
  87346. diameterZ?: number;
  87347. arc?: number;
  87348. slice?: number;
  87349. sideOrientation?: number;
  87350. frontUVs?: Vector4;
  87351. backUVs?: Vector4;
  87352. }): VertexData;
  87353. /**
  87354. * Creates the VertexData for a cylinder, cone or prism
  87355. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87356. * * height sets the height (y direction) of the cylinder, optional, default 2
  87357. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  87358. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  87359. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  87360. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  87361. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  87362. * * 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
  87363. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  87364. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  87365. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  87366. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  87367. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87368. * * 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)
  87369. * * 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)
  87370. * @returns the VertexData of the cylinder, cone or prism
  87371. */
  87372. static CreateCylinder(options: {
  87373. height?: number;
  87374. diameterTop?: number;
  87375. diameterBottom?: number;
  87376. diameter?: number;
  87377. tessellation?: number;
  87378. subdivisions?: number;
  87379. arc?: number;
  87380. faceColors?: Color4[];
  87381. faceUV?: Vector4[];
  87382. hasRings?: boolean;
  87383. enclose?: boolean;
  87384. sideOrientation?: number;
  87385. frontUVs?: Vector4;
  87386. backUVs?: Vector4;
  87387. }): VertexData;
  87388. /**
  87389. * Creates the VertexData for a torus
  87390. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87391. * * diameter the diameter of the torus, optional default 1
  87392. * * thickness the diameter of the tube forming the torus, optional default 0.5
  87393. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  87394. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87395. * * 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)
  87396. * * 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)
  87397. * @returns the VertexData of the torus
  87398. */
  87399. static CreateTorus(options: {
  87400. diameter?: number;
  87401. thickness?: number;
  87402. tessellation?: number;
  87403. sideOrientation?: number;
  87404. frontUVs?: Vector4;
  87405. backUVs?: Vector4;
  87406. }): VertexData;
  87407. /**
  87408. * Creates the VertexData of the LineSystem
  87409. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  87410. * - lines an array of lines, each line being an array of successive Vector3
  87411. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  87412. * @returns the VertexData of the LineSystem
  87413. */
  87414. static CreateLineSystem(options: {
  87415. lines: Vector3[][];
  87416. colors?: Nullable<Color4[][]>;
  87417. }): VertexData;
  87418. /**
  87419. * Create the VertexData for a DashedLines
  87420. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  87421. * - points an array successive Vector3
  87422. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  87423. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  87424. * - dashNb the intended total number of dashes, optional, default 200
  87425. * @returns the VertexData for the DashedLines
  87426. */
  87427. static CreateDashedLines(options: {
  87428. points: Vector3[];
  87429. dashSize?: number;
  87430. gapSize?: number;
  87431. dashNb?: number;
  87432. }): VertexData;
  87433. /**
  87434. * Creates the VertexData for a Ground
  87435. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  87436. * - width the width (x direction) of the ground, optional, default 1
  87437. * - height the height (z direction) of the ground, optional, default 1
  87438. * - subdivisions the number of subdivisions per side, optional, default 1
  87439. * @returns the VertexData of the Ground
  87440. */
  87441. static CreateGround(options: {
  87442. width?: number;
  87443. height?: number;
  87444. subdivisions?: number;
  87445. subdivisionsX?: number;
  87446. subdivisionsY?: number;
  87447. }): VertexData;
  87448. /**
  87449. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  87450. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  87451. * * xmin the ground minimum X coordinate, optional, default -1
  87452. * * zmin the ground minimum Z coordinate, optional, default -1
  87453. * * xmax the ground maximum X coordinate, optional, default 1
  87454. * * zmax the ground maximum Z coordinate, optional, default 1
  87455. * * 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}
  87456. * * 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}
  87457. * @returns the VertexData of the TiledGround
  87458. */
  87459. static CreateTiledGround(options: {
  87460. xmin: number;
  87461. zmin: number;
  87462. xmax: number;
  87463. zmax: number;
  87464. subdivisions?: {
  87465. w: number;
  87466. h: number;
  87467. };
  87468. precision?: {
  87469. w: number;
  87470. h: number;
  87471. };
  87472. }): VertexData;
  87473. /**
  87474. * Creates the VertexData of the Ground designed from a heightmap
  87475. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  87476. * * width the width (x direction) of the ground
  87477. * * height the height (z direction) of the ground
  87478. * * subdivisions the number of subdivisions per side
  87479. * * minHeight the minimum altitude on the ground, optional, default 0
  87480. * * maxHeight the maximum altitude on the ground, optional default 1
  87481. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  87482. * * buffer the array holding the image color data
  87483. * * bufferWidth the width of image
  87484. * * bufferHeight the height of image
  87485. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  87486. * @returns the VertexData of the Ground designed from a heightmap
  87487. */
  87488. static CreateGroundFromHeightMap(options: {
  87489. width: number;
  87490. height: number;
  87491. subdivisions: number;
  87492. minHeight: number;
  87493. maxHeight: number;
  87494. colorFilter: Color3;
  87495. buffer: Uint8Array;
  87496. bufferWidth: number;
  87497. bufferHeight: number;
  87498. alphaFilter: number;
  87499. }): VertexData;
  87500. /**
  87501. * Creates the VertexData for a Plane
  87502. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  87503. * * size sets the width and height of the plane to the value of size, optional default 1
  87504. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  87505. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  87506. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87507. * * 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)
  87508. * * 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)
  87509. * @returns the VertexData of the box
  87510. */
  87511. static CreatePlane(options: {
  87512. size?: number;
  87513. width?: number;
  87514. height?: number;
  87515. sideOrientation?: number;
  87516. frontUVs?: Vector4;
  87517. backUVs?: Vector4;
  87518. }): VertexData;
  87519. /**
  87520. * Creates the VertexData of the Disc or regular Polygon
  87521. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  87522. * * radius the radius of the disc, optional default 0.5
  87523. * * tessellation the number of polygon sides, optional, default 64
  87524. * * 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
  87525. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87526. * * 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)
  87527. * * 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)
  87528. * @returns the VertexData of the box
  87529. */
  87530. static CreateDisc(options: {
  87531. radius?: number;
  87532. tessellation?: number;
  87533. arc?: number;
  87534. sideOrientation?: number;
  87535. frontUVs?: Vector4;
  87536. backUVs?: Vector4;
  87537. }): VertexData;
  87538. /**
  87539. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  87540. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  87541. * @param polygon a mesh built from polygonTriangulation.build()
  87542. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87543. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  87544. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  87545. * @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)
  87546. * @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)
  87547. * @returns the VertexData of the Polygon
  87548. */
  87549. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  87550. /**
  87551. * Creates the VertexData of the IcoSphere
  87552. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  87553. * * radius the radius of the IcoSphere, optional default 1
  87554. * * radiusX allows stretching in the x direction, optional, default radius
  87555. * * radiusY allows stretching in the y direction, optional, default radius
  87556. * * radiusZ allows stretching in the z direction, optional, default radius
  87557. * * flat when true creates a flat shaded mesh, optional, default true
  87558. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  87559. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87560. * * 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)
  87561. * * 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)
  87562. * @returns the VertexData of the IcoSphere
  87563. */
  87564. static CreateIcoSphere(options: {
  87565. radius?: number;
  87566. radiusX?: number;
  87567. radiusY?: number;
  87568. radiusZ?: number;
  87569. flat?: boolean;
  87570. subdivisions?: number;
  87571. sideOrientation?: number;
  87572. frontUVs?: Vector4;
  87573. backUVs?: Vector4;
  87574. }): VertexData;
  87575. /**
  87576. * Creates the VertexData for a Polyhedron
  87577. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  87578. * * type provided types are:
  87579. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  87580. * * 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)
  87581. * * size the size of the IcoSphere, optional default 1
  87582. * * sizeX allows stretching in the x direction, optional, default size
  87583. * * sizeY allows stretching in the y direction, optional, default size
  87584. * * sizeZ allows stretching in the z direction, optional, default size
  87585. * * 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
  87586. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  87587. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  87588. * * flat when true creates a flat shaded mesh, optional, default true
  87589. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  87590. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87591. * * 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)
  87592. * * 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)
  87593. * @returns the VertexData of the Polyhedron
  87594. */
  87595. static CreatePolyhedron(options: {
  87596. type?: number;
  87597. size?: number;
  87598. sizeX?: number;
  87599. sizeY?: number;
  87600. sizeZ?: number;
  87601. custom?: any;
  87602. faceUV?: Vector4[];
  87603. faceColors?: Color4[];
  87604. flat?: boolean;
  87605. sideOrientation?: number;
  87606. frontUVs?: Vector4;
  87607. backUVs?: Vector4;
  87608. }): VertexData;
  87609. /**
  87610. * Creates the VertexData for a TorusKnot
  87611. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  87612. * * radius the radius of the torus knot, optional, default 2
  87613. * * tube the thickness of the tube, optional, default 0.5
  87614. * * radialSegments the number of sides on each tube segments, optional, default 32
  87615. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  87616. * * p the number of windings around the z axis, optional, default 2
  87617. * * q the number of windings around the x axis, optional, default 3
  87618. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87619. * * 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)
  87620. * * 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)
  87621. * @returns the VertexData of the Torus Knot
  87622. */
  87623. static CreateTorusKnot(options: {
  87624. radius?: number;
  87625. tube?: number;
  87626. radialSegments?: number;
  87627. tubularSegments?: number;
  87628. p?: number;
  87629. q?: number;
  87630. sideOrientation?: number;
  87631. frontUVs?: Vector4;
  87632. backUVs?: Vector4;
  87633. }): VertexData;
  87634. /**
  87635. * Compute normals for given positions and indices
  87636. * @param positions an array of vertex positions, [...., x, y, z, ......]
  87637. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  87638. * @param normals an array of vertex normals, [...., x, y, z, ......]
  87639. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  87640. * * facetNormals : optional array of facet normals (vector3)
  87641. * * facetPositions : optional array of facet positions (vector3)
  87642. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  87643. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  87644. * * bInfo : optional bounding info, required for facetPartitioning computation
  87645. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  87646. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  87647. * * useRightHandedSystem: optional boolean to for right handed system computation
  87648. * * depthSort : optional boolean to enable the facet depth sort computation
  87649. * * distanceTo : optional Vector3 to compute the facet depth from this location
  87650. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  87651. */
  87652. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  87653. facetNormals?: any;
  87654. facetPositions?: any;
  87655. facetPartitioning?: any;
  87656. ratio?: number;
  87657. bInfo?: any;
  87658. bbSize?: Vector3;
  87659. subDiv?: any;
  87660. useRightHandedSystem?: boolean;
  87661. depthSort?: boolean;
  87662. distanceTo?: Vector3;
  87663. depthSortedFacets?: any;
  87664. }): void;
  87665. /** @hidden */
  87666. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  87667. /**
  87668. * Applies VertexData created from the imported parameters to the geometry
  87669. * @param parsedVertexData the parsed data from an imported file
  87670. * @param geometry the geometry to apply the VertexData to
  87671. */
  87672. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  87673. }
  87674. }
  87675. declare module BABYLON {
  87676. /**
  87677. * Defines a target to use with MorphTargetManager
  87678. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  87679. */
  87680. export class MorphTarget implements IAnimatable {
  87681. /** defines the name of the target */
  87682. name: string;
  87683. /**
  87684. * Gets or sets the list of animations
  87685. */
  87686. animations: Animation[];
  87687. private _scene;
  87688. private _positions;
  87689. private _normals;
  87690. private _tangents;
  87691. private _uvs;
  87692. private _influence;
  87693. /**
  87694. * Observable raised when the influence changes
  87695. */
  87696. onInfluenceChanged: Observable<boolean>;
  87697. /** @hidden */
  87698. _onDataLayoutChanged: Observable<void>;
  87699. /**
  87700. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  87701. */
  87702. influence: number;
  87703. /**
  87704. * Gets or sets the id of the morph Target
  87705. */
  87706. id: string;
  87707. private _animationPropertiesOverride;
  87708. /**
  87709. * Gets or sets the animation properties override
  87710. */
  87711. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  87712. /**
  87713. * Creates a new MorphTarget
  87714. * @param name defines the name of the target
  87715. * @param influence defines the influence to use
  87716. * @param scene defines the scene the morphtarget belongs to
  87717. */
  87718. constructor(
  87719. /** defines the name of the target */
  87720. name: string, influence?: number, scene?: Nullable<Scene>);
  87721. /**
  87722. * Gets a boolean defining if the target contains position data
  87723. */
  87724. readonly hasPositions: boolean;
  87725. /**
  87726. * Gets a boolean defining if the target contains normal data
  87727. */
  87728. readonly hasNormals: boolean;
  87729. /**
  87730. * Gets a boolean defining if the target contains tangent data
  87731. */
  87732. readonly hasTangents: boolean;
  87733. /**
  87734. * Gets a boolean defining if the target contains texture coordinates data
  87735. */
  87736. readonly hasUVs: boolean;
  87737. /**
  87738. * Affects position data to this target
  87739. * @param data defines the position data to use
  87740. */
  87741. setPositions(data: Nullable<FloatArray>): void;
  87742. /**
  87743. * Gets the position data stored in this target
  87744. * @returns a FloatArray containing the position data (or null if not present)
  87745. */
  87746. getPositions(): Nullable<FloatArray>;
  87747. /**
  87748. * Affects normal data to this target
  87749. * @param data defines the normal data to use
  87750. */
  87751. setNormals(data: Nullable<FloatArray>): void;
  87752. /**
  87753. * Gets the normal data stored in this target
  87754. * @returns a FloatArray containing the normal data (or null if not present)
  87755. */
  87756. getNormals(): Nullable<FloatArray>;
  87757. /**
  87758. * Affects tangent data to this target
  87759. * @param data defines the tangent data to use
  87760. */
  87761. setTangents(data: Nullable<FloatArray>): void;
  87762. /**
  87763. * Gets the tangent data stored in this target
  87764. * @returns a FloatArray containing the tangent data (or null if not present)
  87765. */
  87766. getTangents(): Nullable<FloatArray>;
  87767. /**
  87768. * Affects texture coordinates data to this target
  87769. * @param data defines the texture coordinates data to use
  87770. */
  87771. setUVs(data: Nullable<FloatArray>): void;
  87772. /**
  87773. * Gets the texture coordinates data stored in this target
  87774. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  87775. */
  87776. getUVs(): Nullable<FloatArray>;
  87777. /**
  87778. * Serializes the current target into a Serialization object
  87779. * @returns the serialized object
  87780. */
  87781. serialize(): any;
  87782. /**
  87783. * Returns the string "MorphTarget"
  87784. * @returns "MorphTarget"
  87785. */
  87786. getClassName(): string;
  87787. /**
  87788. * Creates a new target from serialized data
  87789. * @param serializationObject defines the serialized data to use
  87790. * @returns a new MorphTarget
  87791. */
  87792. static Parse(serializationObject: any): MorphTarget;
  87793. /**
  87794. * Creates a MorphTarget from mesh data
  87795. * @param mesh defines the source mesh
  87796. * @param name defines the name to use for the new target
  87797. * @param influence defines the influence to attach to the target
  87798. * @returns a new MorphTarget
  87799. */
  87800. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  87801. }
  87802. }
  87803. declare module BABYLON {
  87804. /**
  87805. * This class is used to deform meshes using morphing between different targets
  87806. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  87807. */
  87808. export class MorphTargetManager {
  87809. private _targets;
  87810. private _targetInfluenceChangedObservers;
  87811. private _targetDataLayoutChangedObservers;
  87812. private _activeTargets;
  87813. private _scene;
  87814. private _influences;
  87815. private _supportsNormals;
  87816. private _supportsTangents;
  87817. private _supportsUVs;
  87818. private _vertexCount;
  87819. private _uniqueId;
  87820. private _tempInfluences;
  87821. /**
  87822. * Gets or sets a boolean indicating if normals must be morphed
  87823. */
  87824. enableNormalMorphing: boolean;
  87825. /**
  87826. * Gets or sets a boolean indicating if tangents must be morphed
  87827. */
  87828. enableTangentMorphing: boolean;
  87829. /**
  87830. * Gets or sets a boolean indicating if UV must be morphed
  87831. */
  87832. enableUVMorphing: boolean;
  87833. /**
  87834. * Creates a new MorphTargetManager
  87835. * @param scene defines the current scene
  87836. */
  87837. constructor(scene?: Nullable<Scene>);
  87838. /**
  87839. * Gets the unique ID of this manager
  87840. */
  87841. readonly uniqueId: number;
  87842. /**
  87843. * Gets the number of vertices handled by this manager
  87844. */
  87845. readonly vertexCount: number;
  87846. /**
  87847. * Gets a boolean indicating if this manager supports morphing of normals
  87848. */
  87849. readonly supportsNormals: boolean;
  87850. /**
  87851. * Gets a boolean indicating if this manager supports morphing of tangents
  87852. */
  87853. readonly supportsTangents: boolean;
  87854. /**
  87855. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  87856. */
  87857. readonly supportsUVs: boolean;
  87858. /**
  87859. * Gets the number of targets stored in this manager
  87860. */
  87861. readonly numTargets: number;
  87862. /**
  87863. * Gets the number of influencers (ie. the number of targets with influences > 0)
  87864. */
  87865. readonly numInfluencers: number;
  87866. /**
  87867. * Gets the list of influences (one per target)
  87868. */
  87869. readonly influences: Float32Array;
  87870. /**
  87871. * Gets the active target at specified index. An active target is a target with an influence > 0
  87872. * @param index defines the index to check
  87873. * @returns the requested target
  87874. */
  87875. getActiveTarget(index: number): MorphTarget;
  87876. /**
  87877. * Gets the target at specified index
  87878. * @param index defines the index to check
  87879. * @returns the requested target
  87880. */
  87881. getTarget(index: number): MorphTarget;
  87882. /**
  87883. * Add a new target to this manager
  87884. * @param target defines the target to add
  87885. */
  87886. addTarget(target: MorphTarget): void;
  87887. /**
  87888. * Removes a target from the manager
  87889. * @param target defines the target to remove
  87890. */
  87891. removeTarget(target: MorphTarget): void;
  87892. /**
  87893. * Serializes the current manager into a Serialization object
  87894. * @returns the serialized object
  87895. */
  87896. serialize(): any;
  87897. private _syncActiveTargets;
  87898. /**
  87899. * Syncrhonize the targets with all the meshes using this morph target manager
  87900. */
  87901. synchronize(): void;
  87902. /**
  87903. * Creates a new MorphTargetManager from serialized data
  87904. * @param serializationObject defines the serialized data
  87905. * @param scene defines the hosting scene
  87906. * @returns the new MorphTargetManager
  87907. */
  87908. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  87909. }
  87910. }
  87911. declare module BABYLON {
  87912. /**
  87913. * Class used to represent a specific level of detail of a mesh
  87914. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  87915. */
  87916. export class MeshLODLevel {
  87917. /** Defines the distance where this level should start being displayed */
  87918. distance: number;
  87919. /** Defines the mesh to use to render this level */
  87920. mesh: Nullable<Mesh>;
  87921. /**
  87922. * Creates a new LOD level
  87923. * @param distance defines the distance where this level should star being displayed
  87924. * @param mesh defines the mesh to use to render this level
  87925. */
  87926. constructor(
  87927. /** Defines the distance where this level should start being displayed */
  87928. distance: number,
  87929. /** Defines the mesh to use to render this level */
  87930. mesh: Nullable<Mesh>);
  87931. }
  87932. }
  87933. declare module BABYLON {
  87934. /**
  87935. * Mesh representing the gorund
  87936. */
  87937. export class GroundMesh extends Mesh {
  87938. /** If octree should be generated */
  87939. generateOctree: boolean;
  87940. private _heightQuads;
  87941. /** @hidden */
  87942. _subdivisionsX: number;
  87943. /** @hidden */
  87944. _subdivisionsY: number;
  87945. /** @hidden */
  87946. _width: number;
  87947. /** @hidden */
  87948. _height: number;
  87949. /** @hidden */
  87950. _minX: number;
  87951. /** @hidden */
  87952. _maxX: number;
  87953. /** @hidden */
  87954. _minZ: number;
  87955. /** @hidden */
  87956. _maxZ: number;
  87957. constructor(name: string, scene: Scene);
  87958. /**
  87959. * "GroundMesh"
  87960. * @returns "GroundMesh"
  87961. */
  87962. getClassName(): string;
  87963. /**
  87964. * The minimum of x and y subdivisions
  87965. */
  87966. readonly subdivisions: number;
  87967. /**
  87968. * X subdivisions
  87969. */
  87970. readonly subdivisionsX: number;
  87971. /**
  87972. * Y subdivisions
  87973. */
  87974. readonly subdivisionsY: number;
  87975. /**
  87976. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  87977. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  87978. * @param chunksCount the number of subdivisions for x and y
  87979. * @param octreeBlocksSize (Default: 32)
  87980. */
  87981. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  87982. /**
  87983. * Returns a height (y) value in the Worl system :
  87984. * the ground altitude at the coordinates (x, z) expressed in the World system.
  87985. * @param x x coordinate
  87986. * @param z z coordinate
  87987. * @returns the ground y position if (x, z) are outside the ground surface.
  87988. */
  87989. getHeightAtCoordinates(x: number, z: number): number;
  87990. /**
  87991. * Returns a normalized vector (Vector3) orthogonal to the ground
  87992. * at the ground coordinates (x, z) expressed in the World system.
  87993. * @param x x coordinate
  87994. * @param z z coordinate
  87995. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  87996. */
  87997. getNormalAtCoordinates(x: number, z: number): Vector3;
  87998. /**
  87999. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  88000. * at the ground coordinates (x, z) expressed in the World system.
  88001. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  88002. * @param x x coordinate
  88003. * @param z z coordinate
  88004. * @param ref vector to store the result
  88005. * @returns the GroundMesh.
  88006. */
  88007. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  88008. /**
  88009. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  88010. * if the ground has been updated.
  88011. * This can be used in the render loop.
  88012. * @returns the GroundMesh.
  88013. */
  88014. updateCoordinateHeights(): GroundMesh;
  88015. private _getFacetAt;
  88016. private _initHeightQuads;
  88017. private _computeHeightQuads;
  88018. /**
  88019. * Serializes this ground mesh
  88020. * @param serializationObject object to write serialization to
  88021. */
  88022. serialize(serializationObject: any): void;
  88023. /**
  88024. * Parses a serialized ground mesh
  88025. * @param parsedMesh the serialized mesh
  88026. * @param scene the scene to create the ground mesh in
  88027. * @returns the created ground mesh
  88028. */
  88029. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  88030. }
  88031. }
  88032. declare module BABYLON {
  88033. /**
  88034. * Interface for Physics-Joint data
  88035. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88036. */
  88037. export interface PhysicsJointData {
  88038. /**
  88039. * The main pivot of the joint
  88040. */
  88041. mainPivot?: Vector3;
  88042. /**
  88043. * The connected pivot of the joint
  88044. */
  88045. connectedPivot?: Vector3;
  88046. /**
  88047. * The main axis of the joint
  88048. */
  88049. mainAxis?: Vector3;
  88050. /**
  88051. * The connected axis of the joint
  88052. */
  88053. connectedAxis?: Vector3;
  88054. /**
  88055. * The collision of the joint
  88056. */
  88057. collision?: boolean;
  88058. /**
  88059. * Native Oimo/Cannon/Energy data
  88060. */
  88061. nativeParams?: any;
  88062. }
  88063. /**
  88064. * This is a holder class for the physics joint created by the physics plugin
  88065. * It holds a set of functions to control the underlying joint
  88066. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88067. */
  88068. export class PhysicsJoint {
  88069. /**
  88070. * The type of the physics joint
  88071. */
  88072. type: number;
  88073. /**
  88074. * The data for the physics joint
  88075. */
  88076. jointData: PhysicsJointData;
  88077. private _physicsJoint;
  88078. protected _physicsPlugin: IPhysicsEnginePlugin;
  88079. /**
  88080. * Initializes the physics joint
  88081. * @param type The type of the physics joint
  88082. * @param jointData The data for the physics joint
  88083. */
  88084. constructor(
  88085. /**
  88086. * The type of the physics joint
  88087. */
  88088. type: number,
  88089. /**
  88090. * The data for the physics joint
  88091. */
  88092. jointData: PhysicsJointData);
  88093. /**
  88094. * Gets the physics joint
  88095. */
  88096. /**
  88097. * Sets the physics joint
  88098. */
  88099. physicsJoint: any;
  88100. /**
  88101. * Sets the physics plugin
  88102. */
  88103. physicsPlugin: IPhysicsEnginePlugin;
  88104. /**
  88105. * Execute a function that is physics-plugin specific.
  88106. * @param {Function} func the function that will be executed.
  88107. * It accepts two parameters: the physics world and the physics joint
  88108. */
  88109. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  88110. /**
  88111. * Distance-Joint type
  88112. */
  88113. static DistanceJoint: number;
  88114. /**
  88115. * Hinge-Joint type
  88116. */
  88117. static HingeJoint: number;
  88118. /**
  88119. * Ball-and-Socket joint type
  88120. */
  88121. static BallAndSocketJoint: number;
  88122. /**
  88123. * Wheel-Joint type
  88124. */
  88125. static WheelJoint: number;
  88126. /**
  88127. * Slider-Joint type
  88128. */
  88129. static SliderJoint: number;
  88130. /**
  88131. * Prismatic-Joint type
  88132. */
  88133. static PrismaticJoint: number;
  88134. /**
  88135. * Universal-Joint type
  88136. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  88137. */
  88138. static UniversalJoint: number;
  88139. /**
  88140. * Hinge-Joint 2 type
  88141. */
  88142. static Hinge2Joint: number;
  88143. /**
  88144. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  88145. */
  88146. static PointToPointJoint: number;
  88147. /**
  88148. * Spring-Joint type
  88149. */
  88150. static SpringJoint: number;
  88151. /**
  88152. * Lock-Joint type
  88153. */
  88154. static LockJoint: number;
  88155. }
  88156. /**
  88157. * A class representing a physics distance joint
  88158. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88159. */
  88160. export class DistanceJoint extends PhysicsJoint {
  88161. /**
  88162. *
  88163. * @param jointData The data for the Distance-Joint
  88164. */
  88165. constructor(jointData: DistanceJointData);
  88166. /**
  88167. * Update the predefined distance.
  88168. * @param maxDistance The maximum preferred distance
  88169. * @param minDistance The minimum preferred distance
  88170. */
  88171. updateDistance(maxDistance: number, minDistance?: number): void;
  88172. }
  88173. /**
  88174. * Represents a Motor-Enabled Joint
  88175. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88176. */
  88177. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  88178. /**
  88179. * Initializes the Motor-Enabled Joint
  88180. * @param type The type of the joint
  88181. * @param jointData The physica joint data for the joint
  88182. */
  88183. constructor(type: number, jointData: PhysicsJointData);
  88184. /**
  88185. * Set the motor values.
  88186. * Attention, this function is plugin specific. Engines won't react 100% the same.
  88187. * @param force the force to apply
  88188. * @param maxForce max force for this motor.
  88189. */
  88190. setMotor(force?: number, maxForce?: number): void;
  88191. /**
  88192. * Set the motor's limits.
  88193. * Attention, this function is plugin specific. Engines won't react 100% the same.
  88194. * @param upperLimit The upper limit of the motor
  88195. * @param lowerLimit The lower limit of the motor
  88196. */
  88197. setLimit(upperLimit: number, lowerLimit?: number): void;
  88198. }
  88199. /**
  88200. * This class represents a single physics Hinge-Joint
  88201. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88202. */
  88203. export class HingeJoint extends MotorEnabledJoint {
  88204. /**
  88205. * Initializes the Hinge-Joint
  88206. * @param jointData The joint data for the Hinge-Joint
  88207. */
  88208. constructor(jointData: PhysicsJointData);
  88209. /**
  88210. * Set the motor values.
  88211. * Attention, this function is plugin specific. Engines won't react 100% the same.
  88212. * @param {number} force the force to apply
  88213. * @param {number} maxForce max force for this motor.
  88214. */
  88215. setMotor(force?: number, maxForce?: number): void;
  88216. /**
  88217. * Set the motor's limits.
  88218. * Attention, this function is plugin specific. Engines won't react 100% the same.
  88219. * @param upperLimit The upper limit of the motor
  88220. * @param lowerLimit The lower limit of the motor
  88221. */
  88222. setLimit(upperLimit: number, lowerLimit?: number): void;
  88223. }
  88224. /**
  88225. * This class represents a dual hinge physics joint (same as wheel joint)
  88226. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88227. */
  88228. export class Hinge2Joint extends MotorEnabledJoint {
  88229. /**
  88230. * Initializes the Hinge2-Joint
  88231. * @param jointData The joint data for the Hinge2-Joint
  88232. */
  88233. constructor(jointData: PhysicsJointData);
  88234. /**
  88235. * Set the motor values.
  88236. * Attention, this function is plugin specific. Engines won't react 100% the same.
  88237. * @param {number} targetSpeed the speed the motor is to reach
  88238. * @param {number} maxForce max force for this motor.
  88239. * @param {motorIndex} the motor's index, 0 or 1.
  88240. */
  88241. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  88242. /**
  88243. * Set the motor limits.
  88244. * Attention, this function is plugin specific. Engines won't react 100% the same.
  88245. * @param {number} upperLimit the upper limit
  88246. * @param {number} lowerLimit lower limit
  88247. * @param {motorIndex} the motor's index, 0 or 1.
  88248. */
  88249. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  88250. }
  88251. /**
  88252. * Interface for a motor enabled joint
  88253. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88254. */
  88255. export interface IMotorEnabledJoint {
  88256. /**
  88257. * Physics joint
  88258. */
  88259. physicsJoint: any;
  88260. /**
  88261. * Sets the motor of the motor-enabled joint
  88262. * @param force The force of the motor
  88263. * @param maxForce The maximum force of the motor
  88264. * @param motorIndex The index of the motor
  88265. */
  88266. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  88267. /**
  88268. * Sets the limit of the motor
  88269. * @param upperLimit The upper limit of the motor
  88270. * @param lowerLimit The lower limit of the motor
  88271. * @param motorIndex The index of the motor
  88272. */
  88273. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  88274. }
  88275. /**
  88276. * Joint data for a Distance-Joint
  88277. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88278. */
  88279. export interface DistanceJointData extends PhysicsJointData {
  88280. /**
  88281. * Max distance the 2 joint objects can be apart
  88282. */
  88283. maxDistance: number;
  88284. }
  88285. /**
  88286. * Joint data from a spring joint
  88287. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88288. */
  88289. export interface SpringJointData extends PhysicsJointData {
  88290. /**
  88291. * Length of the spring
  88292. */
  88293. length: number;
  88294. /**
  88295. * Stiffness of the spring
  88296. */
  88297. stiffness: number;
  88298. /**
  88299. * Damping of the spring
  88300. */
  88301. damping: number;
  88302. /** this callback will be called when applying the force to the impostors. */
  88303. forceApplicationCallback: () => void;
  88304. }
  88305. }
  88306. declare module BABYLON {
  88307. /**
  88308. * Holds the data for the raycast result
  88309. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88310. */
  88311. export class PhysicsRaycastResult {
  88312. private _hasHit;
  88313. private _hitDistance;
  88314. private _hitNormalWorld;
  88315. private _hitPointWorld;
  88316. private _rayFromWorld;
  88317. private _rayToWorld;
  88318. /**
  88319. * Gets if there was a hit
  88320. */
  88321. readonly hasHit: boolean;
  88322. /**
  88323. * Gets the distance from the hit
  88324. */
  88325. readonly hitDistance: number;
  88326. /**
  88327. * Gets the hit normal/direction in the world
  88328. */
  88329. readonly hitNormalWorld: Vector3;
  88330. /**
  88331. * Gets the hit point in the world
  88332. */
  88333. readonly hitPointWorld: Vector3;
  88334. /**
  88335. * Gets the ray "start point" of the ray in the world
  88336. */
  88337. readonly rayFromWorld: Vector3;
  88338. /**
  88339. * Gets the ray "end point" of the ray in the world
  88340. */
  88341. readonly rayToWorld: Vector3;
  88342. /**
  88343. * Sets the hit data (normal & point in world space)
  88344. * @param hitNormalWorld defines the normal in world space
  88345. * @param hitPointWorld defines the point in world space
  88346. */
  88347. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  88348. /**
  88349. * Sets the distance from the start point to the hit point
  88350. * @param distance
  88351. */
  88352. setHitDistance(distance: number): void;
  88353. /**
  88354. * Calculates the distance manually
  88355. */
  88356. calculateHitDistance(): void;
  88357. /**
  88358. * Resets all the values to default
  88359. * @param from The from point on world space
  88360. * @param to The to point on world space
  88361. */
  88362. reset(from?: Vector3, to?: Vector3): void;
  88363. }
  88364. /**
  88365. * Interface for the size containing width and height
  88366. */
  88367. interface IXYZ {
  88368. /**
  88369. * X
  88370. */
  88371. x: number;
  88372. /**
  88373. * Y
  88374. */
  88375. y: number;
  88376. /**
  88377. * Z
  88378. */
  88379. z: number;
  88380. }
  88381. }
  88382. declare module BABYLON {
  88383. /**
  88384. * Interface used to describe a physics joint
  88385. */
  88386. export interface PhysicsImpostorJoint {
  88387. /** Defines the main impostor to which the joint is linked */
  88388. mainImpostor: PhysicsImpostor;
  88389. /** Defines the impostor that is connected to the main impostor using this joint */
  88390. connectedImpostor: PhysicsImpostor;
  88391. /** Defines the joint itself */
  88392. joint: PhysicsJoint;
  88393. }
  88394. /** @hidden */
  88395. export interface IPhysicsEnginePlugin {
  88396. world: any;
  88397. name: string;
  88398. setGravity(gravity: Vector3): void;
  88399. setTimeStep(timeStep: number): void;
  88400. getTimeStep(): number;
  88401. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  88402. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  88403. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  88404. generatePhysicsBody(impostor: PhysicsImpostor): void;
  88405. removePhysicsBody(impostor: PhysicsImpostor): void;
  88406. generateJoint(joint: PhysicsImpostorJoint): void;
  88407. removeJoint(joint: PhysicsImpostorJoint): void;
  88408. isSupported(): boolean;
  88409. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  88410. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  88411. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  88412. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  88413. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  88414. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  88415. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  88416. getBodyMass(impostor: PhysicsImpostor): number;
  88417. getBodyFriction(impostor: PhysicsImpostor): number;
  88418. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  88419. getBodyRestitution(impostor: PhysicsImpostor): number;
  88420. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  88421. getBodyPressure?(impostor: PhysicsImpostor): number;
  88422. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  88423. getBodyStiffness?(impostor: PhysicsImpostor): number;
  88424. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  88425. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  88426. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  88427. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  88428. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  88429. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  88430. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  88431. sleepBody(impostor: PhysicsImpostor): void;
  88432. wakeUpBody(impostor: PhysicsImpostor): void;
  88433. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  88434. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  88435. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  88436. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  88437. getRadius(impostor: PhysicsImpostor): number;
  88438. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  88439. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  88440. dispose(): void;
  88441. }
  88442. /**
  88443. * Interface used to define a physics engine
  88444. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  88445. */
  88446. export interface IPhysicsEngine {
  88447. /**
  88448. * Gets the gravity vector used by the simulation
  88449. */
  88450. gravity: Vector3;
  88451. /**
  88452. * Sets the gravity vector used by the simulation
  88453. * @param gravity defines the gravity vector to use
  88454. */
  88455. setGravity(gravity: Vector3): void;
  88456. /**
  88457. * Set the time step of the physics engine.
  88458. * Default is 1/60.
  88459. * To slow it down, enter 1/600 for example.
  88460. * To speed it up, 1/30
  88461. * @param newTimeStep the new timestep to apply to this world.
  88462. */
  88463. setTimeStep(newTimeStep: number): void;
  88464. /**
  88465. * Get the time step of the physics engine.
  88466. * @returns the current time step
  88467. */
  88468. getTimeStep(): number;
  88469. /**
  88470. * Release all resources
  88471. */
  88472. dispose(): void;
  88473. /**
  88474. * Gets the name of the current physics plugin
  88475. * @returns the name of the plugin
  88476. */
  88477. getPhysicsPluginName(): string;
  88478. /**
  88479. * Adding a new impostor for the impostor tracking.
  88480. * This will be done by the impostor itself.
  88481. * @param impostor the impostor to add
  88482. */
  88483. addImpostor(impostor: PhysicsImpostor): void;
  88484. /**
  88485. * Remove an impostor from the engine.
  88486. * This impostor and its mesh will not longer be updated by the physics engine.
  88487. * @param impostor the impostor to remove
  88488. */
  88489. removeImpostor(impostor: PhysicsImpostor): void;
  88490. /**
  88491. * Add a joint to the physics engine
  88492. * @param mainImpostor defines the main impostor to which the joint is added.
  88493. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  88494. * @param joint defines the joint that will connect both impostors.
  88495. */
  88496. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  88497. /**
  88498. * Removes a joint from the simulation
  88499. * @param mainImpostor defines the impostor used with the joint
  88500. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  88501. * @param joint defines the joint to remove
  88502. */
  88503. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  88504. /**
  88505. * Gets the current plugin used to run the simulation
  88506. * @returns current plugin
  88507. */
  88508. getPhysicsPlugin(): IPhysicsEnginePlugin;
  88509. /**
  88510. * Gets the list of physic impostors
  88511. * @returns an array of PhysicsImpostor
  88512. */
  88513. getImpostors(): Array<PhysicsImpostor>;
  88514. /**
  88515. * Gets the impostor for a physics enabled object
  88516. * @param object defines the object impersonated by the impostor
  88517. * @returns the PhysicsImpostor or null if not found
  88518. */
  88519. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  88520. /**
  88521. * Gets the impostor for a physics body object
  88522. * @param body defines physics body used by the impostor
  88523. * @returns the PhysicsImpostor or null if not found
  88524. */
  88525. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  88526. /**
  88527. * Does a raycast in the physics world
  88528. * @param from when should the ray start?
  88529. * @param to when should the ray end?
  88530. * @returns PhysicsRaycastResult
  88531. */
  88532. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  88533. /**
  88534. * Called by the scene. No need to call it.
  88535. * @param delta defines the timespam between frames
  88536. */
  88537. _step(delta: number): void;
  88538. }
  88539. }
  88540. declare module BABYLON {
  88541. /**
  88542. * The interface for the physics imposter parameters
  88543. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88544. */
  88545. export interface PhysicsImpostorParameters {
  88546. /**
  88547. * The mass of the physics imposter
  88548. */
  88549. mass: number;
  88550. /**
  88551. * The friction of the physics imposter
  88552. */
  88553. friction?: number;
  88554. /**
  88555. * The coefficient of restitution of the physics imposter
  88556. */
  88557. restitution?: number;
  88558. /**
  88559. * The native options of the physics imposter
  88560. */
  88561. nativeOptions?: any;
  88562. /**
  88563. * Specifies if the parent should be ignored
  88564. */
  88565. ignoreParent?: boolean;
  88566. /**
  88567. * Specifies if bi-directional transformations should be disabled
  88568. */
  88569. disableBidirectionalTransformation?: boolean;
  88570. /**
  88571. * The pressure inside the physics imposter, soft object only
  88572. */
  88573. pressure?: number;
  88574. /**
  88575. * The stiffness the physics imposter, soft object only
  88576. */
  88577. stiffness?: number;
  88578. /**
  88579. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  88580. */
  88581. velocityIterations?: number;
  88582. /**
  88583. * The number of iterations used in maintaining consistent vertex positions, soft object only
  88584. */
  88585. positionIterations?: number;
  88586. /**
  88587. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  88588. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  88589. * Add to fix multiple points
  88590. */
  88591. fixedPoints?: number;
  88592. /**
  88593. * The collision margin around a soft object
  88594. */
  88595. margin?: number;
  88596. /**
  88597. * The collision margin around a soft object
  88598. */
  88599. damping?: number;
  88600. /**
  88601. * The path for a rope based on an extrusion
  88602. */
  88603. path?: any;
  88604. /**
  88605. * The shape of an extrusion used for a rope based on an extrusion
  88606. */
  88607. shape?: any;
  88608. }
  88609. /**
  88610. * Interface for a physics-enabled object
  88611. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88612. */
  88613. export interface IPhysicsEnabledObject {
  88614. /**
  88615. * The position of the physics-enabled object
  88616. */
  88617. position: Vector3;
  88618. /**
  88619. * The rotation of the physics-enabled object
  88620. */
  88621. rotationQuaternion: Nullable<Quaternion>;
  88622. /**
  88623. * The scale of the physics-enabled object
  88624. */
  88625. scaling: Vector3;
  88626. /**
  88627. * The rotation of the physics-enabled object
  88628. */
  88629. rotation?: Vector3;
  88630. /**
  88631. * The parent of the physics-enabled object
  88632. */
  88633. parent?: any;
  88634. /**
  88635. * The bounding info of the physics-enabled object
  88636. * @returns The bounding info of the physics-enabled object
  88637. */
  88638. getBoundingInfo(): BoundingInfo;
  88639. /**
  88640. * Computes the world matrix
  88641. * @param force Specifies if the world matrix should be computed by force
  88642. * @returns A world matrix
  88643. */
  88644. computeWorldMatrix(force: boolean): Matrix;
  88645. /**
  88646. * Gets the world matrix
  88647. * @returns A world matrix
  88648. */
  88649. getWorldMatrix?(): Matrix;
  88650. /**
  88651. * Gets the child meshes
  88652. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  88653. * @returns An array of abstract meshes
  88654. */
  88655. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  88656. /**
  88657. * Gets the vertex data
  88658. * @param kind The type of vertex data
  88659. * @returns A nullable array of numbers, or a float32 array
  88660. */
  88661. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  88662. /**
  88663. * Gets the indices from the mesh
  88664. * @returns A nullable array of index arrays
  88665. */
  88666. getIndices?(): Nullable<IndicesArray>;
  88667. /**
  88668. * Gets the scene from the mesh
  88669. * @returns the indices array or null
  88670. */
  88671. getScene?(): Scene;
  88672. /**
  88673. * Gets the absolute position from the mesh
  88674. * @returns the absolute position
  88675. */
  88676. getAbsolutePosition(): Vector3;
  88677. /**
  88678. * Gets the absolute pivot point from the mesh
  88679. * @returns the absolute pivot point
  88680. */
  88681. getAbsolutePivotPoint(): Vector3;
  88682. /**
  88683. * Rotates the mesh
  88684. * @param axis The axis of rotation
  88685. * @param amount The amount of rotation
  88686. * @param space The space of the rotation
  88687. * @returns The rotation transform node
  88688. */
  88689. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  88690. /**
  88691. * Translates the mesh
  88692. * @param axis The axis of translation
  88693. * @param distance The distance of translation
  88694. * @param space The space of the translation
  88695. * @returns The transform node
  88696. */
  88697. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  88698. /**
  88699. * Sets the absolute position of the mesh
  88700. * @param absolutePosition The absolute position of the mesh
  88701. * @returns The transform node
  88702. */
  88703. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  88704. /**
  88705. * Gets the class name of the mesh
  88706. * @returns The class name
  88707. */
  88708. getClassName(): string;
  88709. }
  88710. /**
  88711. * Represents a physics imposter
  88712. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88713. */
  88714. export class PhysicsImpostor {
  88715. /**
  88716. * The physics-enabled object used as the physics imposter
  88717. */
  88718. object: IPhysicsEnabledObject;
  88719. /**
  88720. * The type of the physics imposter
  88721. */
  88722. type: number;
  88723. private _options;
  88724. private _scene?;
  88725. /**
  88726. * The default object size of the imposter
  88727. */
  88728. static DEFAULT_OBJECT_SIZE: Vector3;
  88729. /**
  88730. * The identity quaternion of the imposter
  88731. */
  88732. static IDENTITY_QUATERNION: Quaternion;
  88733. /** @hidden */
  88734. _pluginData: any;
  88735. private _physicsEngine;
  88736. private _physicsBody;
  88737. private _bodyUpdateRequired;
  88738. private _onBeforePhysicsStepCallbacks;
  88739. private _onAfterPhysicsStepCallbacks;
  88740. /** @hidden */
  88741. _onPhysicsCollideCallbacks: Array<{
  88742. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  88743. otherImpostors: Array<PhysicsImpostor>;
  88744. }>;
  88745. private _deltaPosition;
  88746. private _deltaRotation;
  88747. private _deltaRotationConjugated;
  88748. /** @hidden */
  88749. _isFromLine: boolean;
  88750. private _parent;
  88751. private _isDisposed;
  88752. private static _tmpVecs;
  88753. private static _tmpQuat;
  88754. /**
  88755. * Specifies if the physics imposter is disposed
  88756. */
  88757. readonly isDisposed: boolean;
  88758. /**
  88759. * Gets the mass of the physics imposter
  88760. */
  88761. mass: number;
  88762. /**
  88763. * Gets the coefficient of friction
  88764. */
  88765. /**
  88766. * Sets the coefficient of friction
  88767. */
  88768. friction: number;
  88769. /**
  88770. * Gets the coefficient of restitution
  88771. */
  88772. /**
  88773. * Sets the coefficient of restitution
  88774. */
  88775. restitution: number;
  88776. /**
  88777. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  88778. */
  88779. /**
  88780. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  88781. */
  88782. pressure: number;
  88783. /**
  88784. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  88785. */
  88786. /**
  88787. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  88788. */
  88789. stiffness: number;
  88790. /**
  88791. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  88792. */
  88793. /**
  88794. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  88795. */
  88796. velocityIterations: number;
  88797. /**
  88798. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  88799. */
  88800. /**
  88801. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  88802. */
  88803. positionIterations: number;
  88804. /**
  88805. * The unique id of the physics imposter
  88806. * set by the physics engine when adding this impostor to the array
  88807. */
  88808. uniqueId: number;
  88809. /**
  88810. * @hidden
  88811. */
  88812. soft: boolean;
  88813. /**
  88814. * @hidden
  88815. */
  88816. segments: number;
  88817. private _joints;
  88818. /**
  88819. * Initializes the physics imposter
  88820. * @param object The physics-enabled object used as the physics imposter
  88821. * @param type The type of the physics imposter
  88822. * @param _options The options for the physics imposter
  88823. * @param _scene The Babylon scene
  88824. */
  88825. constructor(
  88826. /**
  88827. * The physics-enabled object used as the physics imposter
  88828. */
  88829. object: IPhysicsEnabledObject,
  88830. /**
  88831. * The type of the physics imposter
  88832. */
  88833. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  88834. /**
  88835. * This function will completly initialize this impostor.
  88836. * It will create a new body - but only if this mesh has no parent.
  88837. * If it has, this impostor will not be used other than to define the impostor
  88838. * of the child mesh.
  88839. * @hidden
  88840. */
  88841. _init(): void;
  88842. private _getPhysicsParent;
  88843. /**
  88844. * Should a new body be generated.
  88845. * @returns boolean specifying if body initialization is required
  88846. */
  88847. isBodyInitRequired(): boolean;
  88848. /**
  88849. * Sets the updated scaling
  88850. * @param updated Specifies if the scaling is updated
  88851. */
  88852. setScalingUpdated(): void;
  88853. /**
  88854. * Force a regeneration of this or the parent's impostor's body.
  88855. * Use under cautious - This will remove all joints already implemented.
  88856. */
  88857. forceUpdate(): void;
  88858. /**
  88859. * Gets the body that holds this impostor. Either its own, or its parent.
  88860. */
  88861. /**
  88862. * Set the physics body. Used mainly by the physics engine/plugin
  88863. */
  88864. physicsBody: any;
  88865. /**
  88866. * Get the parent of the physics imposter
  88867. * @returns Physics imposter or null
  88868. */
  88869. /**
  88870. * Sets the parent of the physics imposter
  88871. */
  88872. parent: Nullable<PhysicsImpostor>;
  88873. /**
  88874. * Resets the update flags
  88875. */
  88876. resetUpdateFlags(): void;
  88877. /**
  88878. * Gets the object extend size
  88879. * @returns the object extend size
  88880. */
  88881. getObjectExtendSize(): Vector3;
  88882. /**
  88883. * Gets the object center
  88884. * @returns The object center
  88885. */
  88886. getObjectCenter(): Vector3;
  88887. /**
  88888. * Get a specific parametes from the options parameter
  88889. * @param paramName The object parameter name
  88890. * @returns The object parameter
  88891. */
  88892. getParam(paramName: string): any;
  88893. /**
  88894. * Sets a specific parameter in the options given to the physics plugin
  88895. * @param paramName The parameter name
  88896. * @param value The value of the parameter
  88897. */
  88898. setParam(paramName: string, value: number): void;
  88899. /**
  88900. * Specifically change the body's mass option. Won't recreate the physics body object
  88901. * @param mass The mass of the physics imposter
  88902. */
  88903. setMass(mass: number): void;
  88904. /**
  88905. * Gets the linear velocity
  88906. * @returns linear velocity or null
  88907. */
  88908. getLinearVelocity(): Nullable<Vector3>;
  88909. /**
  88910. * Sets the linear velocity
  88911. * @param velocity linear velocity or null
  88912. */
  88913. setLinearVelocity(velocity: Nullable<Vector3>): void;
  88914. /**
  88915. * Gets the angular velocity
  88916. * @returns angular velocity or null
  88917. */
  88918. getAngularVelocity(): Nullable<Vector3>;
  88919. /**
  88920. * Sets the angular velocity
  88921. * @param velocity The velocity or null
  88922. */
  88923. setAngularVelocity(velocity: Nullable<Vector3>): void;
  88924. /**
  88925. * Execute a function with the physics plugin native code
  88926. * Provide a function the will have two variables - the world object and the physics body object
  88927. * @param func The function to execute with the physics plugin native code
  88928. */
  88929. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  88930. /**
  88931. * Register a function that will be executed before the physics world is stepping forward
  88932. * @param func The function to execute before the physics world is stepped forward
  88933. */
  88934. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  88935. /**
  88936. * Unregister a function that will be executed before the physics world is stepping forward
  88937. * @param func The function to execute before the physics world is stepped forward
  88938. */
  88939. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  88940. /**
  88941. * Register a function that will be executed after the physics step
  88942. * @param func The function to execute after physics step
  88943. */
  88944. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  88945. /**
  88946. * Unregisters a function that will be executed after the physics step
  88947. * @param func The function to execute after physics step
  88948. */
  88949. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  88950. /**
  88951. * register a function that will be executed when this impostor collides against a different body
  88952. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  88953. * @param func Callback that is executed on collision
  88954. */
  88955. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  88956. /**
  88957. * Unregisters the physics imposter on contact
  88958. * @param collideAgainst The physics object to collide against
  88959. * @param func Callback to execute on collision
  88960. */
  88961. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  88962. private _tmpQuat;
  88963. private _tmpQuat2;
  88964. /**
  88965. * Get the parent rotation
  88966. * @returns The parent rotation
  88967. */
  88968. getParentsRotation(): Quaternion;
  88969. /**
  88970. * this function is executed by the physics engine.
  88971. */
  88972. beforeStep: () => void;
  88973. /**
  88974. * this function is executed by the physics engine
  88975. */
  88976. afterStep: () => void;
  88977. /**
  88978. * Legacy collision detection event support
  88979. */
  88980. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  88981. /**
  88982. * event and body object due to cannon's event-based architecture.
  88983. */
  88984. onCollide: (e: {
  88985. body: any;
  88986. }) => void;
  88987. /**
  88988. * Apply a force
  88989. * @param force The force to apply
  88990. * @param contactPoint The contact point for the force
  88991. * @returns The physics imposter
  88992. */
  88993. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  88994. /**
  88995. * Apply an impulse
  88996. * @param force The impulse force
  88997. * @param contactPoint The contact point for the impulse force
  88998. * @returns The physics imposter
  88999. */
  89000. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  89001. /**
  89002. * A help function to create a joint
  89003. * @param otherImpostor A physics imposter used to create a joint
  89004. * @param jointType The type of joint
  89005. * @param jointData The data for the joint
  89006. * @returns The physics imposter
  89007. */
  89008. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  89009. /**
  89010. * Add a joint to this impostor with a different impostor
  89011. * @param otherImpostor A physics imposter used to add a joint
  89012. * @param joint The joint to add
  89013. * @returns The physics imposter
  89014. */
  89015. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  89016. /**
  89017. * Add an anchor to a cloth impostor
  89018. * @param otherImpostor rigid impostor to anchor to
  89019. * @param width ratio across width from 0 to 1
  89020. * @param height ratio up height from 0 to 1
  89021. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  89022. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  89023. * @returns impostor the soft imposter
  89024. */
  89025. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  89026. /**
  89027. * Add a hook to a rope impostor
  89028. * @param otherImpostor rigid impostor to anchor to
  89029. * @param length ratio across rope from 0 to 1
  89030. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  89031. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  89032. * @returns impostor the rope imposter
  89033. */
  89034. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  89035. /**
  89036. * Will keep this body still, in a sleep mode.
  89037. * @returns the physics imposter
  89038. */
  89039. sleep(): PhysicsImpostor;
  89040. /**
  89041. * Wake the body up.
  89042. * @returns The physics imposter
  89043. */
  89044. wakeUp(): PhysicsImpostor;
  89045. /**
  89046. * Clones the physics imposter
  89047. * @param newObject The physics imposter clones to this physics-enabled object
  89048. * @returns A nullable physics imposter
  89049. */
  89050. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  89051. /**
  89052. * Disposes the physics imposter
  89053. */
  89054. dispose(): void;
  89055. /**
  89056. * Sets the delta position
  89057. * @param position The delta position amount
  89058. */
  89059. setDeltaPosition(position: Vector3): void;
  89060. /**
  89061. * Sets the delta rotation
  89062. * @param rotation The delta rotation amount
  89063. */
  89064. setDeltaRotation(rotation: Quaternion): void;
  89065. /**
  89066. * Gets the box size of the physics imposter and stores the result in the input parameter
  89067. * @param result Stores the box size
  89068. * @returns The physics imposter
  89069. */
  89070. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  89071. /**
  89072. * Gets the radius of the physics imposter
  89073. * @returns Radius of the physics imposter
  89074. */
  89075. getRadius(): number;
  89076. /**
  89077. * Sync a bone with this impostor
  89078. * @param bone The bone to sync to the impostor.
  89079. * @param boneMesh The mesh that the bone is influencing.
  89080. * @param jointPivot The pivot of the joint / bone in local space.
  89081. * @param distToJoint Optional distance from the impostor to the joint.
  89082. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  89083. */
  89084. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  89085. /**
  89086. * Sync impostor to a bone
  89087. * @param bone The bone that the impostor will be synced to.
  89088. * @param boneMesh The mesh that the bone is influencing.
  89089. * @param jointPivot The pivot of the joint / bone in local space.
  89090. * @param distToJoint Optional distance from the impostor to the joint.
  89091. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  89092. * @param boneAxis Optional vector3 axis the bone is aligned with
  89093. */
  89094. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  89095. /**
  89096. * No-Imposter type
  89097. */
  89098. static NoImpostor: number;
  89099. /**
  89100. * Sphere-Imposter type
  89101. */
  89102. static SphereImpostor: number;
  89103. /**
  89104. * Box-Imposter type
  89105. */
  89106. static BoxImpostor: number;
  89107. /**
  89108. * Plane-Imposter type
  89109. */
  89110. static PlaneImpostor: number;
  89111. /**
  89112. * Mesh-imposter type
  89113. */
  89114. static MeshImpostor: number;
  89115. /**
  89116. * Capsule-Impostor type (Ammo.js plugin only)
  89117. */
  89118. static CapsuleImpostor: number;
  89119. /**
  89120. * Cylinder-Imposter type
  89121. */
  89122. static CylinderImpostor: number;
  89123. /**
  89124. * Particle-Imposter type
  89125. */
  89126. static ParticleImpostor: number;
  89127. /**
  89128. * Heightmap-Imposter type
  89129. */
  89130. static HeightmapImpostor: number;
  89131. /**
  89132. * ConvexHull-Impostor type (Ammo.js plugin only)
  89133. */
  89134. static ConvexHullImpostor: number;
  89135. /**
  89136. * Rope-Imposter type
  89137. */
  89138. static RopeImpostor: number;
  89139. /**
  89140. * Cloth-Imposter type
  89141. */
  89142. static ClothImpostor: number;
  89143. /**
  89144. * Softbody-Imposter type
  89145. */
  89146. static SoftbodyImpostor: number;
  89147. }
  89148. }
  89149. declare module BABYLON {
  89150. /**
  89151. * @hidden
  89152. **/
  89153. export class _CreationDataStorage {
  89154. closePath?: boolean;
  89155. closeArray?: boolean;
  89156. idx: number[];
  89157. dashSize: number;
  89158. gapSize: number;
  89159. path3D: Path3D;
  89160. pathArray: Vector3[][];
  89161. arc: number;
  89162. radius: number;
  89163. cap: number;
  89164. tessellation: number;
  89165. }
  89166. /**
  89167. * @hidden
  89168. **/
  89169. class _InstanceDataStorage {
  89170. visibleInstances: any;
  89171. batchCache: _InstancesBatch;
  89172. instancesBufferSize: number;
  89173. instancesBuffer: Nullable<Buffer>;
  89174. instancesData: Float32Array;
  89175. overridenInstanceCount: number;
  89176. isFrozen: boolean;
  89177. previousBatch: Nullable<_InstancesBatch>;
  89178. hardwareInstancedRendering: boolean;
  89179. sideOrientation: number;
  89180. }
  89181. /**
  89182. * @hidden
  89183. **/
  89184. export class _InstancesBatch {
  89185. mustReturn: boolean;
  89186. visibleInstances: Nullable<InstancedMesh[]>[];
  89187. renderSelf: boolean[];
  89188. hardwareInstancedRendering: boolean[];
  89189. }
  89190. /**
  89191. * Class used to represent renderable models
  89192. */
  89193. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  89194. /**
  89195. * Mesh side orientation : usually the external or front surface
  89196. */
  89197. static readonly FRONTSIDE: number;
  89198. /**
  89199. * Mesh side orientation : usually the internal or back surface
  89200. */
  89201. static readonly BACKSIDE: number;
  89202. /**
  89203. * Mesh side orientation : both internal and external or front and back surfaces
  89204. */
  89205. static readonly DOUBLESIDE: number;
  89206. /**
  89207. * Mesh side orientation : by default, `FRONTSIDE`
  89208. */
  89209. static readonly DEFAULTSIDE: number;
  89210. /**
  89211. * Mesh cap setting : no cap
  89212. */
  89213. static readonly NO_CAP: number;
  89214. /**
  89215. * Mesh cap setting : one cap at the beginning of the mesh
  89216. */
  89217. static readonly CAP_START: number;
  89218. /**
  89219. * Mesh cap setting : one cap at the end of the mesh
  89220. */
  89221. static readonly CAP_END: number;
  89222. /**
  89223. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  89224. */
  89225. static readonly CAP_ALL: number;
  89226. /**
  89227. * Mesh pattern setting : no flip or rotate
  89228. */
  89229. static readonly NO_FLIP: number;
  89230. /**
  89231. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  89232. */
  89233. static readonly FLIP_TILE: number;
  89234. /**
  89235. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  89236. */
  89237. static readonly ROTATE_TILE: number;
  89238. /**
  89239. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  89240. */
  89241. static readonly FLIP_ROW: number;
  89242. /**
  89243. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  89244. */
  89245. static readonly ROTATE_ROW: number;
  89246. /**
  89247. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  89248. */
  89249. static readonly FLIP_N_ROTATE_TILE: number;
  89250. /**
  89251. * Mesh pattern setting : rotate pattern and rotate
  89252. */
  89253. static readonly FLIP_N_ROTATE_ROW: number;
  89254. /**
  89255. * Mesh tile positioning : part tiles same on left/right or top/bottom
  89256. */
  89257. static readonly CENTER: number;
  89258. /**
  89259. * Mesh tile positioning : part tiles on left
  89260. */
  89261. static readonly LEFT: number;
  89262. /**
  89263. * Mesh tile positioning : part tiles on right
  89264. */
  89265. static readonly RIGHT: number;
  89266. /**
  89267. * Mesh tile positioning : part tiles on top
  89268. */
  89269. static readonly TOP: number;
  89270. /**
  89271. * Mesh tile positioning : part tiles on bottom
  89272. */
  89273. static readonly BOTTOM: number;
  89274. /**
  89275. * Gets the default side orientation.
  89276. * @param orientation the orientation to value to attempt to get
  89277. * @returns the default orientation
  89278. * @hidden
  89279. */
  89280. static _GetDefaultSideOrientation(orientation?: number): number;
  89281. private _internalMeshDataInfo;
  89282. /**
  89283. * An event triggered before rendering the mesh
  89284. */
  89285. readonly onBeforeRenderObservable: Observable<Mesh>;
  89286. /**
  89287. * An event triggered before binding the mesh
  89288. */
  89289. readonly onBeforeBindObservable: Observable<Mesh>;
  89290. /**
  89291. * An event triggered after rendering the mesh
  89292. */
  89293. readonly onAfterRenderObservable: Observable<Mesh>;
  89294. /**
  89295. * An event triggered before drawing the mesh
  89296. */
  89297. readonly onBeforeDrawObservable: Observable<Mesh>;
  89298. private _onBeforeDrawObserver;
  89299. /**
  89300. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  89301. */
  89302. onBeforeDraw: () => void;
  89303. readonly hasInstances: boolean;
  89304. /**
  89305. * Gets the delay loading state of the mesh (when delay loading is turned on)
  89306. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  89307. */
  89308. delayLoadState: number;
  89309. /**
  89310. * Gets the list of instances created from this mesh
  89311. * it is not supposed to be modified manually.
  89312. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  89313. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  89314. */
  89315. instances: InstancedMesh[];
  89316. /**
  89317. * Gets the file containing delay loading data for this mesh
  89318. */
  89319. delayLoadingFile: string;
  89320. /** @hidden */
  89321. _binaryInfo: any;
  89322. /**
  89323. * User defined function used to change how LOD level selection is done
  89324. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  89325. */
  89326. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  89327. /**
  89328. * Gets or sets the morph target manager
  89329. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  89330. */
  89331. morphTargetManager: Nullable<MorphTargetManager>;
  89332. /** @hidden */
  89333. _creationDataStorage: Nullable<_CreationDataStorage>;
  89334. /** @hidden */
  89335. _geometry: Nullable<Geometry>;
  89336. /** @hidden */
  89337. _delayInfo: Array<string>;
  89338. /** @hidden */
  89339. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  89340. /** @hidden */
  89341. _instanceDataStorage: _InstanceDataStorage;
  89342. private _effectiveMaterial;
  89343. /** @hidden */
  89344. _shouldGenerateFlatShading: boolean;
  89345. /** @hidden */
  89346. _originalBuilderSideOrientation: number;
  89347. /**
  89348. * Use this property to change the original side orientation defined at construction time
  89349. */
  89350. overrideMaterialSideOrientation: Nullable<number>;
  89351. /**
  89352. * Gets the source mesh (the one used to clone this one from)
  89353. */
  89354. readonly source: Nullable<Mesh>;
  89355. /**
  89356. * Gets or sets a boolean indicating that this mesh does not use index buffer
  89357. */
  89358. isUnIndexed: boolean;
  89359. /**
  89360. * @constructor
  89361. * @param name The value used by scene.getMeshByName() to do a lookup.
  89362. * @param scene The scene to add this mesh to.
  89363. * @param parent The parent of this mesh, if it has one
  89364. * @param source An optional Mesh from which geometry is shared, cloned.
  89365. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  89366. * When false, achieved by calling a clone(), also passing False.
  89367. * This will make creation of children, recursive.
  89368. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  89369. */
  89370. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  89371. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  89372. /**
  89373. * Gets the class name
  89374. * @returns the string "Mesh".
  89375. */
  89376. getClassName(): string;
  89377. /** @hidden */
  89378. readonly _isMesh: boolean;
  89379. /**
  89380. * Returns a description of this mesh
  89381. * @param fullDetails define if full details about this mesh must be used
  89382. * @returns a descriptive string representing this mesh
  89383. */
  89384. toString(fullDetails?: boolean): string;
  89385. /** @hidden */
  89386. _unBindEffect(): void;
  89387. /**
  89388. * Gets a boolean indicating if this mesh has LOD
  89389. */
  89390. readonly hasLODLevels: boolean;
  89391. /**
  89392. * Gets the list of MeshLODLevel associated with the current mesh
  89393. * @returns an array of MeshLODLevel
  89394. */
  89395. getLODLevels(): MeshLODLevel[];
  89396. private _sortLODLevels;
  89397. /**
  89398. * Add a mesh as LOD level triggered at the given distance.
  89399. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  89400. * @param distance The distance from the center of the object to show this level
  89401. * @param mesh The mesh to be added as LOD level (can be null)
  89402. * @return This mesh (for chaining)
  89403. */
  89404. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  89405. /**
  89406. * Returns the LOD level mesh at the passed distance or null if not found.
  89407. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  89408. * @param distance The distance from the center of the object to show this level
  89409. * @returns a Mesh or `null`
  89410. */
  89411. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  89412. /**
  89413. * Remove a mesh from the LOD array
  89414. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  89415. * @param mesh defines the mesh to be removed
  89416. * @return This mesh (for chaining)
  89417. */
  89418. removeLODLevel(mesh: Mesh): Mesh;
  89419. /**
  89420. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  89421. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  89422. * @param camera defines the camera to use to compute distance
  89423. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  89424. * @return This mesh (for chaining)
  89425. */
  89426. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  89427. /**
  89428. * Gets the mesh internal Geometry object
  89429. */
  89430. readonly geometry: Nullable<Geometry>;
  89431. /**
  89432. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  89433. * @returns the total number of vertices
  89434. */
  89435. getTotalVertices(): number;
  89436. /**
  89437. * Returns the content of an associated vertex buffer
  89438. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  89439. * - VertexBuffer.PositionKind
  89440. * - VertexBuffer.UVKind
  89441. * - VertexBuffer.UV2Kind
  89442. * - VertexBuffer.UV3Kind
  89443. * - VertexBuffer.UV4Kind
  89444. * - VertexBuffer.UV5Kind
  89445. * - VertexBuffer.UV6Kind
  89446. * - VertexBuffer.ColorKind
  89447. * - VertexBuffer.MatricesIndicesKind
  89448. * - VertexBuffer.MatricesIndicesExtraKind
  89449. * - VertexBuffer.MatricesWeightsKind
  89450. * - VertexBuffer.MatricesWeightsExtraKind
  89451. * @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
  89452. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  89453. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  89454. */
  89455. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  89456. /**
  89457. * Returns the mesh VertexBuffer object from the requested `kind`
  89458. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  89459. * - VertexBuffer.PositionKind
  89460. * - VertexBuffer.NormalKind
  89461. * - VertexBuffer.UVKind
  89462. * - VertexBuffer.UV2Kind
  89463. * - VertexBuffer.UV3Kind
  89464. * - VertexBuffer.UV4Kind
  89465. * - VertexBuffer.UV5Kind
  89466. * - VertexBuffer.UV6Kind
  89467. * - VertexBuffer.ColorKind
  89468. * - VertexBuffer.MatricesIndicesKind
  89469. * - VertexBuffer.MatricesIndicesExtraKind
  89470. * - VertexBuffer.MatricesWeightsKind
  89471. * - VertexBuffer.MatricesWeightsExtraKind
  89472. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  89473. */
  89474. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  89475. /**
  89476. * Tests if a specific vertex buffer is associated with this mesh
  89477. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  89478. * - VertexBuffer.PositionKind
  89479. * - VertexBuffer.NormalKind
  89480. * - VertexBuffer.UVKind
  89481. * - VertexBuffer.UV2Kind
  89482. * - VertexBuffer.UV3Kind
  89483. * - VertexBuffer.UV4Kind
  89484. * - VertexBuffer.UV5Kind
  89485. * - VertexBuffer.UV6Kind
  89486. * - VertexBuffer.ColorKind
  89487. * - VertexBuffer.MatricesIndicesKind
  89488. * - VertexBuffer.MatricesIndicesExtraKind
  89489. * - VertexBuffer.MatricesWeightsKind
  89490. * - VertexBuffer.MatricesWeightsExtraKind
  89491. * @returns a boolean
  89492. */
  89493. isVerticesDataPresent(kind: string): boolean;
  89494. /**
  89495. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  89496. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  89497. * - VertexBuffer.PositionKind
  89498. * - VertexBuffer.UVKind
  89499. * - VertexBuffer.UV2Kind
  89500. * - VertexBuffer.UV3Kind
  89501. * - VertexBuffer.UV4Kind
  89502. * - VertexBuffer.UV5Kind
  89503. * - VertexBuffer.UV6Kind
  89504. * - VertexBuffer.ColorKind
  89505. * - VertexBuffer.MatricesIndicesKind
  89506. * - VertexBuffer.MatricesIndicesExtraKind
  89507. * - VertexBuffer.MatricesWeightsKind
  89508. * - VertexBuffer.MatricesWeightsExtraKind
  89509. * @returns a boolean
  89510. */
  89511. isVertexBufferUpdatable(kind: string): boolean;
  89512. /**
  89513. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  89514. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  89515. * - VertexBuffer.PositionKind
  89516. * - VertexBuffer.NormalKind
  89517. * - VertexBuffer.UVKind
  89518. * - VertexBuffer.UV2Kind
  89519. * - VertexBuffer.UV3Kind
  89520. * - VertexBuffer.UV4Kind
  89521. * - VertexBuffer.UV5Kind
  89522. * - VertexBuffer.UV6Kind
  89523. * - VertexBuffer.ColorKind
  89524. * - VertexBuffer.MatricesIndicesKind
  89525. * - VertexBuffer.MatricesIndicesExtraKind
  89526. * - VertexBuffer.MatricesWeightsKind
  89527. * - VertexBuffer.MatricesWeightsExtraKind
  89528. * @returns an array of strings
  89529. */
  89530. getVerticesDataKinds(): string[];
  89531. /**
  89532. * Returns a positive integer : the total number of indices in this mesh geometry.
  89533. * @returns the numner of indices or zero if the mesh has no geometry.
  89534. */
  89535. getTotalIndices(): number;
  89536. /**
  89537. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  89538. * @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.
  89539. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  89540. * @returns the indices array or an empty array if the mesh has no geometry
  89541. */
  89542. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  89543. readonly isBlocked: boolean;
  89544. /**
  89545. * Determine if the current mesh is ready to be rendered
  89546. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  89547. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  89548. * @returns true if all associated assets are ready (material, textures, shaders)
  89549. */
  89550. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  89551. /**
  89552. * 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.
  89553. */
  89554. readonly areNormalsFrozen: boolean;
  89555. /**
  89556. * 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.
  89557. * @returns the current mesh
  89558. */
  89559. freezeNormals(): Mesh;
  89560. /**
  89561. * 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
  89562. * @returns the current mesh
  89563. */
  89564. unfreezeNormals(): Mesh;
  89565. /**
  89566. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  89567. */
  89568. overridenInstanceCount: number;
  89569. /** @hidden */
  89570. _preActivate(): Mesh;
  89571. /** @hidden */
  89572. _preActivateForIntermediateRendering(renderId: number): Mesh;
  89573. /** @hidden */
  89574. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  89575. /**
  89576. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  89577. * This means the mesh underlying bounding box and sphere are recomputed.
  89578. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  89579. * @returns the current mesh
  89580. */
  89581. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  89582. /** @hidden */
  89583. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  89584. /**
  89585. * This function will subdivide the mesh into multiple submeshes
  89586. * @param count defines the expected number of submeshes
  89587. */
  89588. subdivide(count: number): void;
  89589. /**
  89590. * Copy a FloatArray into a specific associated vertex buffer
  89591. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  89592. * - VertexBuffer.PositionKind
  89593. * - VertexBuffer.UVKind
  89594. * - VertexBuffer.UV2Kind
  89595. * - VertexBuffer.UV3Kind
  89596. * - VertexBuffer.UV4Kind
  89597. * - VertexBuffer.UV5Kind
  89598. * - VertexBuffer.UV6Kind
  89599. * - VertexBuffer.ColorKind
  89600. * - VertexBuffer.MatricesIndicesKind
  89601. * - VertexBuffer.MatricesIndicesExtraKind
  89602. * - VertexBuffer.MatricesWeightsKind
  89603. * - VertexBuffer.MatricesWeightsExtraKind
  89604. * @param data defines the data source
  89605. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  89606. * @param stride defines the data stride size (can be null)
  89607. * @returns the current mesh
  89608. */
  89609. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  89610. /**
  89611. * Flags an associated vertex buffer as updatable
  89612. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  89613. * - VertexBuffer.PositionKind
  89614. * - VertexBuffer.UVKind
  89615. * - VertexBuffer.UV2Kind
  89616. * - VertexBuffer.UV3Kind
  89617. * - VertexBuffer.UV4Kind
  89618. * - VertexBuffer.UV5Kind
  89619. * - VertexBuffer.UV6Kind
  89620. * - VertexBuffer.ColorKind
  89621. * - VertexBuffer.MatricesIndicesKind
  89622. * - VertexBuffer.MatricesIndicesExtraKind
  89623. * - VertexBuffer.MatricesWeightsKind
  89624. * - VertexBuffer.MatricesWeightsExtraKind
  89625. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  89626. */
  89627. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  89628. /**
  89629. * Sets the mesh global Vertex Buffer
  89630. * @param buffer defines the buffer to use
  89631. * @returns the current mesh
  89632. */
  89633. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  89634. /**
  89635. * Update a specific associated vertex buffer
  89636. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  89637. * - VertexBuffer.PositionKind
  89638. * - VertexBuffer.UVKind
  89639. * - VertexBuffer.UV2Kind
  89640. * - VertexBuffer.UV3Kind
  89641. * - VertexBuffer.UV4Kind
  89642. * - VertexBuffer.UV5Kind
  89643. * - VertexBuffer.UV6Kind
  89644. * - VertexBuffer.ColorKind
  89645. * - VertexBuffer.MatricesIndicesKind
  89646. * - VertexBuffer.MatricesIndicesExtraKind
  89647. * - VertexBuffer.MatricesWeightsKind
  89648. * - VertexBuffer.MatricesWeightsExtraKind
  89649. * @param data defines the data source
  89650. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  89651. * @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)
  89652. * @returns the current mesh
  89653. */
  89654. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  89655. /**
  89656. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  89657. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  89658. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  89659. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  89660. * @returns the current mesh
  89661. */
  89662. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  89663. /**
  89664. * Creates a un-shared specific occurence of the geometry for the mesh.
  89665. * @returns the current mesh
  89666. */
  89667. makeGeometryUnique(): Mesh;
  89668. /**
  89669. * Set the index buffer of this mesh
  89670. * @param indices defines the source data
  89671. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  89672. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  89673. * @returns the current mesh
  89674. */
  89675. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  89676. /**
  89677. * Update the current index buffer
  89678. * @param indices defines the source data
  89679. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  89680. * @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)
  89681. * @returns the current mesh
  89682. */
  89683. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  89684. /**
  89685. * Invert the geometry to move from a right handed system to a left handed one.
  89686. * @returns the current mesh
  89687. */
  89688. toLeftHanded(): Mesh;
  89689. /** @hidden */
  89690. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  89691. /** @hidden */
  89692. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  89693. /**
  89694. * Registers for this mesh a javascript function called just before the rendering process
  89695. * @param func defines the function to call before rendering this mesh
  89696. * @returns the current mesh
  89697. */
  89698. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  89699. /**
  89700. * Disposes a previously registered javascript function called before the rendering
  89701. * @param func defines the function to remove
  89702. * @returns the current mesh
  89703. */
  89704. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  89705. /**
  89706. * Registers for this mesh a javascript function called just after the rendering is complete
  89707. * @param func defines the function to call after rendering this mesh
  89708. * @returns the current mesh
  89709. */
  89710. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  89711. /**
  89712. * Disposes a previously registered javascript function called after the rendering.
  89713. * @param func defines the function to remove
  89714. * @returns the current mesh
  89715. */
  89716. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  89717. /** @hidden */
  89718. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  89719. /** @hidden */
  89720. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  89721. /** @hidden */
  89722. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  89723. /** @hidden */
  89724. _rebuild(): void;
  89725. /** @hidden */
  89726. _freeze(): void;
  89727. /** @hidden */
  89728. _unFreeze(): void;
  89729. /**
  89730. * 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
  89731. * @param subMesh defines the subMesh to render
  89732. * @param enableAlphaMode defines if alpha mode can be changed
  89733. * @returns the current mesh
  89734. */
  89735. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  89736. private _onBeforeDraw;
  89737. /**
  89738. * Renormalize the mesh and patch it up if there are no weights
  89739. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  89740. * However in the case of zero weights then we set just a single influence to 1.
  89741. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  89742. */
  89743. cleanMatrixWeights(): void;
  89744. private normalizeSkinFourWeights;
  89745. private normalizeSkinWeightsAndExtra;
  89746. /**
  89747. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  89748. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  89749. * the user know there was an issue with importing the mesh
  89750. * @returns a validation object with skinned, valid and report string
  89751. */
  89752. validateSkinning(): {
  89753. skinned: boolean;
  89754. valid: boolean;
  89755. report: string;
  89756. };
  89757. /** @hidden */
  89758. _checkDelayState(): Mesh;
  89759. private _queueLoad;
  89760. /**
  89761. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  89762. * A mesh is in the frustum if its bounding box intersects the frustum
  89763. * @param frustumPlanes defines the frustum to test
  89764. * @returns true if the mesh is in the frustum planes
  89765. */
  89766. isInFrustum(frustumPlanes: Plane[]): boolean;
  89767. /**
  89768. * Sets the mesh material by the material or multiMaterial `id` property
  89769. * @param id is a string identifying the material or the multiMaterial
  89770. * @returns the current mesh
  89771. */
  89772. setMaterialByID(id: string): Mesh;
  89773. /**
  89774. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  89775. * @returns an array of IAnimatable
  89776. */
  89777. getAnimatables(): IAnimatable[];
  89778. /**
  89779. * Modifies the mesh geometry according to the passed transformation matrix.
  89780. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  89781. * The mesh normals are modified using the same transformation.
  89782. * Note that, under the hood, this method sets a new VertexBuffer each call.
  89783. * @param transform defines the transform matrix to use
  89784. * @see http://doc.babylonjs.com/resources/baking_transformations
  89785. * @returns the current mesh
  89786. */
  89787. bakeTransformIntoVertices(transform: Matrix): Mesh;
  89788. /**
  89789. * Modifies the mesh geometry according to its own current World Matrix.
  89790. * The mesh World Matrix is then reset.
  89791. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  89792. * Note that, under the hood, this method sets a new VertexBuffer each call.
  89793. * @see http://doc.babylonjs.com/resources/baking_transformations
  89794. * @returns the current mesh
  89795. */
  89796. bakeCurrentTransformIntoVertices(): Mesh;
  89797. /** @hidden */
  89798. readonly _positions: Nullable<Vector3[]>;
  89799. /** @hidden */
  89800. _resetPointsArrayCache(): Mesh;
  89801. /** @hidden */
  89802. _generatePointsArray(): boolean;
  89803. /**
  89804. * Returns a new Mesh object generated from the current mesh properties.
  89805. * This method must not get confused with createInstance()
  89806. * @param name is a string, the name given to the new mesh
  89807. * @param newParent can be any Node object (default `null`)
  89808. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  89809. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  89810. * @returns a new mesh
  89811. */
  89812. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  89813. /**
  89814. * Releases resources associated with this mesh.
  89815. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  89816. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  89817. */
  89818. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  89819. /**
  89820. * Modifies the mesh geometry according to a displacement map.
  89821. * 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.
  89822. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  89823. * @param url is a string, the URL from the image file is to be downloaded.
  89824. * @param minHeight is the lower limit of the displacement.
  89825. * @param maxHeight is the upper limit of the displacement.
  89826. * @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.
  89827. * @param uvOffset is an optional vector2 used to offset UV.
  89828. * @param uvScale is an optional vector2 used to scale UV.
  89829. * @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.
  89830. * @returns the Mesh.
  89831. */
  89832. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  89833. /**
  89834. * Modifies the mesh geometry according to a displacementMap buffer.
  89835. * 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.
  89836. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  89837. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  89838. * @param heightMapWidth is the width of the buffer image.
  89839. * @param heightMapHeight is the height of the buffer image.
  89840. * @param minHeight is the lower limit of the displacement.
  89841. * @param maxHeight is the upper limit of the displacement.
  89842. * @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.
  89843. * @param uvOffset is an optional vector2 used to offset UV.
  89844. * @param uvScale is an optional vector2 used to scale UV.
  89845. * @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.
  89846. * @returns the Mesh.
  89847. */
  89848. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  89849. /**
  89850. * Modify the mesh to get a flat shading rendering.
  89851. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  89852. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  89853. * @returns current mesh
  89854. */
  89855. convertToFlatShadedMesh(): Mesh;
  89856. /**
  89857. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  89858. * In other words, more vertices, no more indices and a single bigger VBO.
  89859. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  89860. * @returns current mesh
  89861. */
  89862. convertToUnIndexedMesh(): Mesh;
  89863. /**
  89864. * Inverses facet orientations.
  89865. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  89866. * @param flipNormals will also inverts the normals
  89867. * @returns current mesh
  89868. */
  89869. flipFaces(flipNormals?: boolean): Mesh;
  89870. /**
  89871. * Increase the number of facets and hence vertices in a mesh
  89872. * Vertex normals are interpolated from existing vertex normals
  89873. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  89874. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  89875. */
  89876. increaseVertices(numberPerEdge: number): void;
  89877. /**
  89878. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  89879. * This will undo any application of covertToFlatShadedMesh
  89880. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  89881. */
  89882. forceSharedVertices(): void;
  89883. /** @hidden */
  89884. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  89885. /** @hidden */
  89886. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  89887. /**
  89888. * Creates a new InstancedMesh object from the mesh model.
  89889. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  89890. * @param name defines the name of the new instance
  89891. * @returns a new InstancedMesh
  89892. */
  89893. createInstance(name: string): InstancedMesh;
  89894. /**
  89895. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  89896. * After this call, all the mesh instances have the same submeshes than the current mesh.
  89897. * @returns the current mesh
  89898. */
  89899. synchronizeInstances(): Mesh;
  89900. /**
  89901. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  89902. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  89903. * This should be used together with the simplification to avoid disappearing triangles.
  89904. * @param successCallback an optional success callback to be called after the optimization finished.
  89905. * @returns the current mesh
  89906. */
  89907. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  89908. /**
  89909. * Serialize current mesh
  89910. * @param serializationObject defines the object which will receive the serialization data
  89911. */
  89912. serialize(serializationObject: any): void;
  89913. /** @hidden */
  89914. _syncGeometryWithMorphTargetManager(): void;
  89915. /** @hidden */
  89916. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  89917. /**
  89918. * Returns a new Mesh object parsed from the source provided.
  89919. * @param parsedMesh is the source
  89920. * @param scene defines the hosting scene
  89921. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  89922. * @returns a new Mesh
  89923. */
  89924. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  89925. /**
  89926. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  89927. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  89928. * @param name defines the name of the mesh to create
  89929. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  89930. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  89931. * @param closePath creates a seam between the first and the last points of each path of the path array
  89932. * @param offset is taken in account only if the `pathArray` is containing a single path
  89933. * @param scene defines the hosting scene
  89934. * @param updatable defines if the mesh must be flagged as updatable
  89935. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89936. * @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)
  89937. * @returns a new Mesh
  89938. */
  89939. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  89940. /**
  89941. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  89942. * @param name defines the name of the mesh to create
  89943. * @param radius sets the radius size (float) of the polygon (default 0.5)
  89944. * @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
  89945. * @param scene defines the hosting scene
  89946. * @param updatable defines if the mesh must be flagged as updatable
  89947. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89948. * @returns a new Mesh
  89949. */
  89950. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  89951. /**
  89952. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  89953. * @param name defines the name of the mesh to create
  89954. * @param size sets the size (float) of each box side (default 1)
  89955. * @param scene defines the hosting scene
  89956. * @param updatable defines if the mesh must be flagged as updatable
  89957. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89958. * @returns a new Mesh
  89959. */
  89960. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  89961. /**
  89962. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  89963. * @param name defines the name of the mesh to create
  89964. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  89965. * @param diameter sets the diameter size (float) of the sphere (default 1)
  89966. * @param scene defines the hosting scene
  89967. * @param updatable defines if the mesh must be flagged as updatable
  89968. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89969. * @returns a new Mesh
  89970. */
  89971. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  89972. /**
  89973. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  89974. * @param name defines the name of the mesh to create
  89975. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  89976. * @param diameter sets the diameter size (float) of the sphere (default 1)
  89977. * @param scene defines the hosting scene
  89978. * @returns a new Mesh
  89979. */
  89980. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  89981. /**
  89982. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  89983. * @param name defines the name of the mesh to create
  89984. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  89985. * @param diameterTop set the top cap diameter (floats, default 1)
  89986. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  89987. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  89988. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  89989. * @param scene defines the hosting scene
  89990. * @param updatable defines if the mesh must be flagged as updatable
  89991. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89992. * @returns a new Mesh
  89993. */
  89994. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  89995. /**
  89996. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  89997. * @param name defines the name of the mesh to create
  89998. * @param diameter sets the diameter size (float) of the torus (default 1)
  89999. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  90000. * @param tessellation sets the number of torus sides (postive integer, default 16)
  90001. * @param scene defines the hosting scene
  90002. * @param updatable defines if the mesh must be flagged as updatable
  90003. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90004. * @returns a new Mesh
  90005. */
  90006. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  90007. /**
  90008. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  90009. * @param name defines the name of the mesh to create
  90010. * @param radius sets the global radius size (float) of the torus knot (default 2)
  90011. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  90012. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  90013. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  90014. * @param p the number of windings on X axis (positive integers, default 2)
  90015. * @param q the number of windings on Y axis (positive integers, default 3)
  90016. * @param scene defines the hosting scene
  90017. * @param updatable defines if the mesh must be flagged as updatable
  90018. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90019. * @returns a new Mesh
  90020. */
  90021. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  90022. /**
  90023. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  90024. * @param name defines the name of the mesh to create
  90025. * @param points is an array successive Vector3
  90026. * @param scene defines the hosting scene
  90027. * @param updatable defines if the mesh must be flagged as updatable
  90028. * @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).
  90029. * @returns a new Mesh
  90030. */
  90031. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  90032. /**
  90033. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  90034. * @param name defines the name of the mesh to create
  90035. * @param points is an array successive Vector3
  90036. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  90037. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  90038. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  90039. * @param scene defines the hosting scene
  90040. * @param updatable defines if the mesh must be flagged as updatable
  90041. * @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)
  90042. * @returns a new Mesh
  90043. */
  90044. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  90045. /**
  90046. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  90047. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  90048. * 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.
  90049. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90050. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  90051. * Remember you can only change the shape positions, not their number when updating a polygon.
  90052. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  90053. * @param name defines the name of the mesh to create
  90054. * @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
  90055. * @param scene defines the hosting scene
  90056. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  90057. * @param updatable defines if the mesh must be flagged as updatable
  90058. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90059. * @param earcutInjection can be used to inject your own earcut reference
  90060. * @returns a new Mesh
  90061. */
  90062. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  90063. /**
  90064. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  90065. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  90066. * @param name defines the name of the mesh to create
  90067. * @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
  90068. * @param depth defines the height of extrusion
  90069. * @param scene defines the hosting scene
  90070. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  90071. * @param updatable defines if the mesh must be flagged as updatable
  90072. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90073. * @param earcutInjection can be used to inject your own earcut reference
  90074. * @returns a new Mesh
  90075. */
  90076. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  90077. /**
  90078. * Creates an extruded shape mesh.
  90079. * 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
  90080. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  90081. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  90082. * @param name defines the name of the mesh to create
  90083. * @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
  90084. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  90085. * @param scale is the value to scale the shape
  90086. * @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
  90087. * @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
  90088. * @param scene defines the hosting scene
  90089. * @param updatable defines if the mesh must be flagged as updatable
  90090. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90091. * @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)
  90092. * @returns a new Mesh
  90093. */
  90094. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  90095. /**
  90096. * Creates an custom extruded shape mesh.
  90097. * The custom extrusion is a parametric shape.
  90098. * It has no predefined shape. Its final shape will depend on the input parameters.
  90099. * Please consider using the same method from the MeshBuilder class instead
  90100. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  90101. * @param name defines the name of the mesh to create
  90102. * @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
  90103. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  90104. * @param scaleFunction is a custom Javascript function called on each path point
  90105. * @param rotationFunction is a custom Javascript function called on each path point
  90106. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  90107. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  90108. * @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
  90109. * @param scene defines the hosting scene
  90110. * @param updatable defines if the mesh must be flagged as updatable
  90111. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90112. * @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)
  90113. * @returns a new Mesh
  90114. */
  90115. 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;
  90116. /**
  90117. * Creates lathe mesh.
  90118. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  90119. * Please consider using the same method from the MeshBuilder class instead
  90120. * @param name defines the name of the mesh to create
  90121. * @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
  90122. * @param radius is the radius value of the lathe
  90123. * @param tessellation is the side number of the lathe.
  90124. * @param scene defines the hosting scene
  90125. * @param updatable defines if the mesh must be flagged as updatable
  90126. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90127. * @returns a new Mesh
  90128. */
  90129. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  90130. /**
  90131. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  90132. * @param name defines the name of the mesh to create
  90133. * @param size sets the size (float) of both sides of the plane at once (default 1)
  90134. * @param scene defines the hosting scene
  90135. * @param updatable defines if the mesh must be flagged as updatable
  90136. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90137. * @returns a new Mesh
  90138. */
  90139. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  90140. /**
  90141. * Creates a ground mesh.
  90142. * Please consider using the same method from the MeshBuilder class instead
  90143. * @param name defines the name of the mesh to create
  90144. * @param width set the width of the ground
  90145. * @param height set the height of the ground
  90146. * @param subdivisions sets the number of subdivisions per side
  90147. * @param scene defines the hosting scene
  90148. * @param updatable defines if the mesh must be flagged as updatable
  90149. * @returns a new Mesh
  90150. */
  90151. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  90152. /**
  90153. * Creates a tiled ground mesh.
  90154. * Please consider using the same method from the MeshBuilder class instead
  90155. * @param name defines the name of the mesh to create
  90156. * @param xmin set the ground minimum X coordinate
  90157. * @param zmin set the ground minimum Y coordinate
  90158. * @param xmax set the ground maximum X coordinate
  90159. * @param zmax set the ground maximum Z coordinate
  90160. * @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
  90161. * @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
  90162. * @param scene defines the hosting scene
  90163. * @param updatable defines if the mesh must be flagged as updatable
  90164. * @returns a new Mesh
  90165. */
  90166. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  90167. w: number;
  90168. h: number;
  90169. }, precision: {
  90170. w: number;
  90171. h: number;
  90172. }, scene: Scene, updatable?: boolean): Mesh;
  90173. /**
  90174. * Creates a ground mesh from a height map.
  90175. * Please consider using the same method from the MeshBuilder class instead
  90176. * @see http://doc.babylonjs.com/babylon101/height_map
  90177. * @param name defines the name of the mesh to create
  90178. * @param url sets the URL of the height map image resource
  90179. * @param width set the ground width size
  90180. * @param height set the ground height size
  90181. * @param subdivisions sets the number of subdivision per side
  90182. * @param minHeight is the minimum altitude on the ground
  90183. * @param maxHeight is the maximum altitude on the ground
  90184. * @param scene defines the hosting scene
  90185. * @param updatable defines if the mesh must be flagged as updatable
  90186. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  90187. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  90188. * @returns a new Mesh
  90189. */
  90190. 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;
  90191. /**
  90192. * Creates a tube mesh.
  90193. * The tube is a parametric shape.
  90194. * It has no predefined shape. Its final shape will depend on the input parameters.
  90195. * Please consider using the same method from the MeshBuilder class instead
  90196. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  90197. * @param name defines the name of the mesh to create
  90198. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  90199. * @param radius sets the tube radius size
  90200. * @param tessellation is the number of sides on the tubular surface
  90201. * @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
  90202. * @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
  90203. * @param scene defines the hosting scene
  90204. * @param updatable defines if the mesh must be flagged as updatable
  90205. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90206. * @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)
  90207. * @returns a new Mesh
  90208. */
  90209. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  90210. (i: number, distance: number): number;
  90211. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  90212. /**
  90213. * Creates a polyhedron mesh.
  90214. * Please consider using the same method from the MeshBuilder class instead.
  90215. * * 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
  90216. * * The parameter `size` (positive float, default 1) sets the polygon size
  90217. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  90218. * * 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`
  90219. * * 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
  90220. * * 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)`)
  90221. * * 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
  90222. * * 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
  90223. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90224. * * If you create a double-sided mesh, you can choose what parts of 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
  90225. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90226. * @param name defines the name of the mesh to create
  90227. * @param options defines the options used to create the mesh
  90228. * @param scene defines the hosting scene
  90229. * @returns a new Mesh
  90230. */
  90231. static CreatePolyhedron(name: string, options: {
  90232. type?: number;
  90233. size?: number;
  90234. sizeX?: number;
  90235. sizeY?: number;
  90236. sizeZ?: number;
  90237. custom?: any;
  90238. faceUV?: Vector4[];
  90239. faceColors?: Color4[];
  90240. updatable?: boolean;
  90241. sideOrientation?: number;
  90242. }, scene: Scene): Mesh;
  90243. /**
  90244. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  90245. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  90246. * * 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`)
  90247. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  90248. * * 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
  90249. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90250. * * If you create a double-sided mesh, you can choose what parts of 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
  90251. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90252. * @param name defines the name of the mesh
  90253. * @param options defines the options used to create the mesh
  90254. * @param scene defines the hosting scene
  90255. * @returns a new Mesh
  90256. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  90257. */
  90258. static CreateIcoSphere(name: string, options: {
  90259. radius?: number;
  90260. flat?: boolean;
  90261. subdivisions?: number;
  90262. sideOrientation?: number;
  90263. updatable?: boolean;
  90264. }, scene: Scene): Mesh;
  90265. /**
  90266. * Creates a decal mesh.
  90267. * Please consider using the same method from the MeshBuilder class instead.
  90268. * A decal is a mesh usually applied as a model onto the surface of another mesh
  90269. * @param name defines the name of the mesh
  90270. * @param sourceMesh defines the mesh receiving the decal
  90271. * @param position sets the position of the decal in world coordinates
  90272. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  90273. * @param size sets the decal scaling
  90274. * @param angle sets the angle to rotate the decal
  90275. * @returns a new Mesh
  90276. */
  90277. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  90278. /**
  90279. * Prepare internal position array for software CPU skinning
  90280. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  90281. */
  90282. setPositionsForCPUSkinning(): Float32Array;
  90283. /**
  90284. * Prepare internal normal array for software CPU skinning
  90285. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  90286. */
  90287. setNormalsForCPUSkinning(): Float32Array;
  90288. /**
  90289. * Updates the vertex buffer by applying transformation from the bones
  90290. * @param skeleton defines the skeleton to apply to current mesh
  90291. * @returns the current mesh
  90292. */
  90293. applySkeleton(skeleton: Skeleton): Mesh;
  90294. /**
  90295. * 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
  90296. * @param meshes defines the list of meshes to scan
  90297. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  90298. */
  90299. static MinMax(meshes: AbstractMesh[]): {
  90300. min: Vector3;
  90301. max: Vector3;
  90302. };
  90303. /**
  90304. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  90305. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  90306. * @returns a vector3
  90307. */
  90308. static Center(meshesOrMinMaxVector: {
  90309. min: Vector3;
  90310. max: Vector3;
  90311. } | AbstractMesh[]): Vector3;
  90312. /**
  90313. * Merge the array of meshes into a single mesh for performance reasons.
  90314. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  90315. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  90316. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  90317. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  90318. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  90319. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  90320. * @returns a new mesh
  90321. */
  90322. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  90323. /** @hidden */
  90324. addInstance(instance: InstancedMesh): void;
  90325. /** @hidden */
  90326. removeInstance(instance: InstancedMesh): void;
  90327. }
  90328. }
  90329. declare module BABYLON {
  90330. /**
  90331. * This is the base class of all the camera used in the application.
  90332. * @see http://doc.babylonjs.com/features/cameras
  90333. */
  90334. export class Camera extends Node {
  90335. /** @hidden */
  90336. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  90337. /**
  90338. * This is the default projection mode used by the cameras.
  90339. * It helps recreating a feeling of perspective and better appreciate depth.
  90340. * This is the best way to simulate real life cameras.
  90341. */
  90342. static readonly PERSPECTIVE_CAMERA: number;
  90343. /**
  90344. * This helps creating camera with an orthographic mode.
  90345. * 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.
  90346. */
  90347. static readonly ORTHOGRAPHIC_CAMERA: number;
  90348. /**
  90349. * This is the default FOV mode for perspective cameras.
  90350. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  90351. */
  90352. static readonly FOVMODE_VERTICAL_FIXED: number;
  90353. /**
  90354. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  90355. */
  90356. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  90357. /**
  90358. * This specifies ther is no need for a camera rig.
  90359. * Basically only one eye is rendered corresponding to the camera.
  90360. */
  90361. static readonly RIG_MODE_NONE: number;
  90362. /**
  90363. * Simulates a camera Rig with one blue eye and one red eye.
  90364. * This can be use with 3d blue and red glasses.
  90365. */
  90366. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  90367. /**
  90368. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  90369. */
  90370. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  90371. /**
  90372. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  90373. */
  90374. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  90375. /**
  90376. * Defines that both eyes of the camera will be rendered over under each other.
  90377. */
  90378. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  90379. /**
  90380. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  90381. */
  90382. static readonly RIG_MODE_VR: number;
  90383. /**
  90384. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  90385. */
  90386. static readonly RIG_MODE_WEBVR: number;
  90387. /**
  90388. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  90389. */
  90390. static readonly RIG_MODE_CUSTOM: number;
  90391. /**
  90392. * Defines if by default attaching controls should prevent the default javascript event to continue.
  90393. */
  90394. static ForceAttachControlToAlwaysPreventDefault: boolean;
  90395. /**
  90396. * Define the input manager associated with the camera.
  90397. */
  90398. inputs: CameraInputsManager<Camera>;
  90399. /** @hidden */
  90400. _position: Vector3;
  90401. /**
  90402. * Define the current local position of the camera in the scene
  90403. */
  90404. position: Vector3;
  90405. /**
  90406. * The vector the camera should consider as up.
  90407. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  90408. */
  90409. upVector: Vector3;
  90410. /**
  90411. * Define the current limit on the left side for an orthographic camera
  90412. * In scene unit
  90413. */
  90414. orthoLeft: Nullable<number>;
  90415. /**
  90416. * Define the current limit on the right side for an orthographic camera
  90417. * In scene unit
  90418. */
  90419. orthoRight: Nullable<number>;
  90420. /**
  90421. * Define the current limit on the bottom side for an orthographic camera
  90422. * In scene unit
  90423. */
  90424. orthoBottom: Nullable<number>;
  90425. /**
  90426. * Define the current limit on the top side for an orthographic camera
  90427. * In scene unit
  90428. */
  90429. orthoTop: Nullable<number>;
  90430. /**
  90431. * Field Of View is set in Radians. (default is 0.8)
  90432. */
  90433. fov: number;
  90434. /**
  90435. * Define the minimum distance the camera can see from.
  90436. * This is important to note that the depth buffer are not infinite and the closer it starts
  90437. * the more your scene might encounter depth fighting issue.
  90438. */
  90439. minZ: number;
  90440. /**
  90441. * Define the maximum distance the camera can see to.
  90442. * This is important to note that the depth buffer are not infinite and the further it end
  90443. * the more your scene might encounter depth fighting issue.
  90444. */
  90445. maxZ: number;
  90446. /**
  90447. * Define the default inertia of the camera.
  90448. * This helps giving a smooth feeling to the camera movement.
  90449. */
  90450. inertia: number;
  90451. /**
  90452. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  90453. */
  90454. mode: number;
  90455. /**
  90456. * Define wether the camera is intermediate.
  90457. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  90458. */
  90459. isIntermediate: boolean;
  90460. /**
  90461. * Define the viewport of the camera.
  90462. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  90463. */
  90464. viewport: Viewport;
  90465. /**
  90466. * Restricts the camera to viewing objects with the same layerMask.
  90467. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  90468. */
  90469. layerMask: number;
  90470. /**
  90471. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  90472. */
  90473. fovMode: number;
  90474. /**
  90475. * Rig mode of the camera.
  90476. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  90477. * This is normally controlled byt the camera themselves as internal use.
  90478. */
  90479. cameraRigMode: number;
  90480. /**
  90481. * Defines the distance between both "eyes" in case of a RIG
  90482. */
  90483. interaxialDistance: number;
  90484. /**
  90485. * Defines if stereoscopic rendering is done side by side or over under.
  90486. */
  90487. isStereoscopicSideBySide: boolean;
  90488. /**
  90489. * 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
  90490. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  90491. * else in the scene. (Eg. security camera)
  90492. *
  90493. * 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)
  90494. */
  90495. customRenderTargets: RenderTargetTexture[];
  90496. /**
  90497. * When set, the camera will render to this render target instead of the default canvas
  90498. *
  90499. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  90500. */
  90501. outputRenderTarget: Nullable<RenderTargetTexture>;
  90502. /**
  90503. * Observable triggered when the camera view matrix has changed.
  90504. */
  90505. onViewMatrixChangedObservable: Observable<Camera>;
  90506. /**
  90507. * Observable triggered when the camera Projection matrix has changed.
  90508. */
  90509. onProjectionMatrixChangedObservable: Observable<Camera>;
  90510. /**
  90511. * Observable triggered when the inputs have been processed.
  90512. */
  90513. onAfterCheckInputsObservable: Observable<Camera>;
  90514. /**
  90515. * Observable triggered when reset has been called and applied to the camera.
  90516. */
  90517. onRestoreStateObservable: Observable<Camera>;
  90518. /** @hidden */
  90519. _cameraRigParams: any;
  90520. /** @hidden */
  90521. _rigCameras: Camera[];
  90522. /** @hidden */
  90523. _rigPostProcess: Nullable<PostProcess>;
  90524. protected _webvrViewMatrix: Matrix;
  90525. /** @hidden */
  90526. _skipRendering: boolean;
  90527. /** @hidden */
  90528. _projectionMatrix: Matrix;
  90529. /** @hidden */
  90530. _postProcesses: Nullable<PostProcess>[];
  90531. /** @hidden */
  90532. _activeMeshes: SmartArray<AbstractMesh>;
  90533. protected _globalPosition: Vector3;
  90534. /** @hidden */
  90535. _computedViewMatrix: Matrix;
  90536. private _doNotComputeProjectionMatrix;
  90537. private _transformMatrix;
  90538. private _frustumPlanes;
  90539. private _refreshFrustumPlanes;
  90540. private _storedFov;
  90541. private _stateStored;
  90542. /**
  90543. * Instantiates a new camera object.
  90544. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  90545. * @see http://doc.babylonjs.com/features/cameras
  90546. * @param name Defines the name of the camera in the scene
  90547. * @param position Defines the position of the camera
  90548. * @param scene Defines the scene the camera belongs too
  90549. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  90550. */
  90551. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  90552. /**
  90553. * Store current camera state (fov, position, etc..)
  90554. * @returns the camera
  90555. */
  90556. storeState(): Camera;
  90557. /**
  90558. * Restores the camera state values if it has been stored. You must call storeState() first
  90559. */
  90560. protected _restoreStateValues(): boolean;
  90561. /**
  90562. * Restored camera state. You must call storeState() first.
  90563. * @returns true if restored and false otherwise
  90564. */
  90565. restoreState(): boolean;
  90566. /**
  90567. * Gets the class name of the camera.
  90568. * @returns the class name
  90569. */
  90570. getClassName(): string;
  90571. /** @hidden */
  90572. readonly _isCamera: boolean;
  90573. /**
  90574. * Gets a string representation of the camera useful for debug purpose.
  90575. * @param fullDetails Defines that a more verboe level of logging is required
  90576. * @returns the string representation
  90577. */
  90578. toString(fullDetails?: boolean): string;
  90579. /**
  90580. * Gets the current world space position of the camera.
  90581. */
  90582. readonly globalPosition: Vector3;
  90583. /**
  90584. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  90585. * @returns the active meshe list
  90586. */
  90587. getActiveMeshes(): SmartArray<AbstractMesh>;
  90588. /**
  90589. * Check wether a mesh is part of the current active mesh list of the camera
  90590. * @param mesh Defines the mesh to check
  90591. * @returns true if active, false otherwise
  90592. */
  90593. isActiveMesh(mesh: Mesh): boolean;
  90594. /**
  90595. * Is this camera ready to be used/rendered
  90596. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  90597. * @return true if the camera is ready
  90598. */
  90599. isReady(completeCheck?: boolean): boolean;
  90600. /** @hidden */
  90601. _initCache(): void;
  90602. /** @hidden */
  90603. _updateCache(ignoreParentClass?: boolean): void;
  90604. /** @hidden */
  90605. _isSynchronized(): boolean;
  90606. /** @hidden */
  90607. _isSynchronizedViewMatrix(): boolean;
  90608. /** @hidden */
  90609. _isSynchronizedProjectionMatrix(): boolean;
  90610. /**
  90611. * Attach the input controls to a specific dom element to get the input from.
  90612. * @param element Defines the element the controls should be listened from
  90613. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90614. */
  90615. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  90616. /**
  90617. * Detach the current controls from the specified dom element.
  90618. * @param element Defines the element to stop listening the inputs from
  90619. */
  90620. detachControl(element: HTMLElement): void;
  90621. /**
  90622. * Update the camera state according to the different inputs gathered during the frame.
  90623. */
  90624. update(): void;
  90625. /** @hidden */
  90626. _checkInputs(): void;
  90627. /** @hidden */
  90628. readonly rigCameras: Camera[];
  90629. /**
  90630. * Gets the post process used by the rig cameras
  90631. */
  90632. readonly rigPostProcess: Nullable<PostProcess>;
  90633. /**
  90634. * Internal, gets the first post proces.
  90635. * @returns the first post process to be run on this camera.
  90636. */
  90637. _getFirstPostProcess(): Nullable<PostProcess>;
  90638. private _cascadePostProcessesToRigCams;
  90639. /**
  90640. * Attach a post process to the camera.
  90641. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  90642. * @param postProcess The post process to attach to the camera
  90643. * @param insertAt The position of the post process in case several of them are in use in the scene
  90644. * @returns the position the post process has been inserted at
  90645. */
  90646. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  90647. /**
  90648. * Detach a post process to the camera.
  90649. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  90650. * @param postProcess The post process to detach from the camera
  90651. */
  90652. detachPostProcess(postProcess: PostProcess): void;
  90653. /**
  90654. * Gets the current world matrix of the camera
  90655. */
  90656. getWorldMatrix(): Matrix;
  90657. /** @hidden */
  90658. _getViewMatrix(): Matrix;
  90659. /**
  90660. * Gets the current view matrix of the camera.
  90661. * @param force forces the camera to recompute the matrix without looking at the cached state
  90662. * @returns the view matrix
  90663. */
  90664. getViewMatrix(force?: boolean): Matrix;
  90665. /**
  90666. * Freeze the projection matrix.
  90667. * It will prevent the cache check of the camera projection compute and can speed up perf
  90668. * if no parameter of the camera are meant to change
  90669. * @param projection Defines manually a projection if necessary
  90670. */
  90671. freezeProjectionMatrix(projection?: Matrix): void;
  90672. /**
  90673. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  90674. */
  90675. unfreezeProjectionMatrix(): void;
  90676. /**
  90677. * Gets the current projection matrix of the camera.
  90678. * @param force forces the camera to recompute the matrix without looking at the cached state
  90679. * @returns the projection matrix
  90680. */
  90681. getProjectionMatrix(force?: boolean): Matrix;
  90682. /**
  90683. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  90684. * @returns a Matrix
  90685. */
  90686. getTransformationMatrix(): Matrix;
  90687. private _updateFrustumPlanes;
  90688. /**
  90689. * Checks if a cullable object (mesh...) is in the camera frustum
  90690. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  90691. * @param target The object to check
  90692. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  90693. * @returns true if the object is in frustum otherwise false
  90694. */
  90695. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  90696. /**
  90697. * Checks if a cullable object (mesh...) is in the camera frustum
  90698. * Unlike isInFrustum this cheks the full bounding box
  90699. * @param target The object to check
  90700. * @returns true if the object is in frustum otherwise false
  90701. */
  90702. isCompletelyInFrustum(target: ICullable): boolean;
  90703. /**
  90704. * Gets a ray in the forward direction from the camera.
  90705. * @param length Defines the length of the ray to create
  90706. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  90707. * @param origin Defines the start point of the ray which defaults to the camera position
  90708. * @returns the forward ray
  90709. */
  90710. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  90711. /**
  90712. * Releases resources associated with this node.
  90713. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90714. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90715. */
  90716. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90717. /** @hidden */
  90718. _isLeftCamera: boolean;
  90719. /**
  90720. * Gets the left camera of a rig setup in case of Rigged Camera
  90721. */
  90722. readonly isLeftCamera: boolean;
  90723. /** @hidden */
  90724. _isRightCamera: boolean;
  90725. /**
  90726. * Gets the right camera of a rig setup in case of Rigged Camera
  90727. */
  90728. readonly isRightCamera: boolean;
  90729. /**
  90730. * Gets the left camera of a rig setup in case of Rigged Camera
  90731. */
  90732. readonly leftCamera: Nullable<FreeCamera>;
  90733. /**
  90734. * Gets the right camera of a rig setup in case of Rigged Camera
  90735. */
  90736. readonly rightCamera: Nullable<FreeCamera>;
  90737. /**
  90738. * Gets the left camera target of a rig setup in case of Rigged Camera
  90739. * @returns the target position
  90740. */
  90741. getLeftTarget(): Nullable<Vector3>;
  90742. /**
  90743. * Gets the right camera target of a rig setup in case of Rigged Camera
  90744. * @returns the target position
  90745. */
  90746. getRightTarget(): Nullable<Vector3>;
  90747. /**
  90748. * @hidden
  90749. */
  90750. setCameraRigMode(mode: number, rigParams: any): void;
  90751. /** @hidden */
  90752. static _setStereoscopicRigMode(camera: Camera): void;
  90753. /** @hidden */
  90754. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  90755. /** @hidden */
  90756. static _setVRRigMode(camera: Camera, rigParams: any): void;
  90757. /** @hidden */
  90758. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  90759. /** @hidden */
  90760. _getVRProjectionMatrix(): Matrix;
  90761. protected _updateCameraRotationMatrix(): void;
  90762. protected _updateWebVRCameraRotationMatrix(): void;
  90763. /**
  90764. * This function MUST be overwritten by the different WebVR cameras available.
  90765. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  90766. * @hidden
  90767. */
  90768. _getWebVRProjectionMatrix(): Matrix;
  90769. /**
  90770. * This function MUST be overwritten by the different WebVR cameras available.
  90771. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  90772. * @hidden
  90773. */
  90774. _getWebVRViewMatrix(): Matrix;
  90775. /** @hidden */
  90776. setCameraRigParameter(name: string, value: any): void;
  90777. /**
  90778. * needs to be overridden by children so sub has required properties to be copied
  90779. * @hidden
  90780. */
  90781. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  90782. /**
  90783. * May need to be overridden by children
  90784. * @hidden
  90785. */
  90786. _updateRigCameras(): void;
  90787. /** @hidden */
  90788. _setupInputs(): void;
  90789. /**
  90790. * Serialiaze the camera setup to a json represention
  90791. * @returns the JSON representation
  90792. */
  90793. serialize(): any;
  90794. /**
  90795. * Clones the current camera.
  90796. * @param name The cloned camera name
  90797. * @returns the cloned camera
  90798. */
  90799. clone(name: string): Camera;
  90800. /**
  90801. * Gets the direction of the camera relative to a given local axis.
  90802. * @param localAxis Defines the reference axis to provide a relative direction.
  90803. * @return the direction
  90804. */
  90805. getDirection(localAxis: Vector3): Vector3;
  90806. /**
  90807. * Returns the current camera absolute rotation
  90808. */
  90809. readonly absoluteRotation: Quaternion;
  90810. /**
  90811. * Gets the direction of the camera relative to a given local axis into a passed vector.
  90812. * @param localAxis Defines the reference axis to provide a relative direction.
  90813. * @param result Defines the vector to store the result in
  90814. */
  90815. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  90816. /**
  90817. * Gets a camera constructor for a given camera type
  90818. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  90819. * @param name The name of the camera the result will be able to instantiate
  90820. * @param scene The scene the result will construct the camera in
  90821. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  90822. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  90823. * @returns a factory method to construc the camera
  90824. */
  90825. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  90826. /**
  90827. * Compute the world matrix of the camera.
  90828. * @returns the camera workd matrix
  90829. */
  90830. computeWorldMatrix(): Matrix;
  90831. /**
  90832. * Parse a JSON and creates the camera from the parsed information
  90833. * @param parsedCamera The JSON to parse
  90834. * @param scene The scene to instantiate the camera in
  90835. * @returns the newly constructed camera
  90836. */
  90837. static Parse(parsedCamera: any, scene: Scene): Camera;
  90838. }
  90839. }
  90840. declare module BABYLON {
  90841. /**
  90842. * Class containing static functions to help procedurally build meshes
  90843. */
  90844. export class DiscBuilder {
  90845. /**
  90846. * Creates a plane polygonal mesh. By default, this is a disc
  90847. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  90848. * * 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
  90849. * * 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
  90850. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  90851. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  90852. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90853. * @param name defines the name of the mesh
  90854. * @param options defines the options used to create the mesh
  90855. * @param scene defines the hosting scene
  90856. * @returns the plane polygonal mesh
  90857. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  90858. */
  90859. static CreateDisc(name: string, options: {
  90860. radius?: number;
  90861. tessellation?: number;
  90862. arc?: number;
  90863. updatable?: boolean;
  90864. sideOrientation?: number;
  90865. frontUVs?: Vector4;
  90866. backUVs?: Vector4;
  90867. }, scene?: Nullable<Scene>): Mesh;
  90868. }
  90869. }
  90870. declare module BABYLON {
  90871. /**
  90872. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  90873. *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.
  90874. * The SPS is also a particle system. It provides some methods to manage the particles.
  90875. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  90876. *
  90877. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  90878. */
  90879. export class SolidParticleSystem implements IDisposable {
  90880. /**
  90881. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  90882. * Example : var p = SPS.particles[i];
  90883. */
  90884. particles: SolidParticle[];
  90885. /**
  90886. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  90887. */
  90888. nbParticles: number;
  90889. /**
  90890. * If the particles must ever face the camera (default false). Useful for planar particles.
  90891. */
  90892. billboard: boolean;
  90893. /**
  90894. * Recompute normals when adding a shape
  90895. */
  90896. recomputeNormals: boolean;
  90897. /**
  90898. * This a counter ofr your own usage. It's not set by any SPS functions.
  90899. */
  90900. counter: number;
  90901. /**
  90902. * The SPS name. This name is also given to the underlying mesh.
  90903. */
  90904. name: string;
  90905. /**
  90906. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  90907. */
  90908. mesh: Mesh;
  90909. /**
  90910. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  90911. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  90912. */
  90913. vars: any;
  90914. /**
  90915. * This array is populated when the SPS is set as 'pickable'.
  90916. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  90917. * Each element of this array is an object `{idx: int, faceId: int}`.
  90918. * `idx` is the picked particle index in the `SPS.particles` array
  90919. * `faceId` is the picked face index counted within this particle.
  90920. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  90921. */
  90922. pickedParticles: {
  90923. idx: number;
  90924. faceId: number;
  90925. }[];
  90926. /**
  90927. * This array is populated when `enableDepthSort` is set to true.
  90928. * Each element of this array is an instance of the class DepthSortedParticle.
  90929. */
  90930. depthSortedParticles: DepthSortedParticle[];
  90931. /**
  90932. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  90933. * @hidden
  90934. */
  90935. _bSphereOnly: boolean;
  90936. /**
  90937. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  90938. * @hidden
  90939. */
  90940. _bSphereRadiusFactor: number;
  90941. private _scene;
  90942. private _positions;
  90943. private _indices;
  90944. private _normals;
  90945. private _colors;
  90946. private _uvs;
  90947. private _indices32;
  90948. private _positions32;
  90949. private _normals32;
  90950. private _fixedNormal32;
  90951. private _colors32;
  90952. private _uvs32;
  90953. private _index;
  90954. private _updatable;
  90955. private _pickable;
  90956. private _isVisibilityBoxLocked;
  90957. private _alwaysVisible;
  90958. private _depthSort;
  90959. private _shapeCounter;
  90960. private _copy;
  90961. private _color;
  90962. private _computeParticleColor;
  90963. private _computeParticleTexture;
  90964. private _computeParticleRotation;
  90965. private _computeParticleVertex;
  90966. private _computeBoundingBox;
  90967. private _depthSortParticles;
  90968. private _camera;
  90969. private _mustUnrotateFixedNormals;
  90970. private _particlesIntersect;
  90971. private _needs32Bits;
  90972. /**
  90973. * Creates a SPS (Solid Particle System) object.
  90974. * @param name (String) is the SPS name, this will be the underlying mesh name.
  90975. * @param scene (Scene) is the scene in which the SPS is added.
  90976. * @param options defines the options of the sps e.g.
  90977. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  90978. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  90979. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  90980. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  90981. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  90982. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  90983. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  90984. */
  90985. constructor(name: string, scene: Scene, options?: {
  90986. updatable?: boolean;
  90987. isPickable?: boolean;
  90988. enableDepthSort?: boolean;
  90989. particleIntersection?: boolean;
  90990. boundingSphereOnly?: boolean;
  90991. bSphereRadiusFactor?: number;
  90992. });
  90993. /**
  90994. * Builds the SPS underlying mesh. Returns a standard Mesh.
  90995. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  90996. * @returns the created mesh
  90997. */
  90998. buildMesh(): Mesh;
  90999. /**
  91000. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  91001. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  91002. * Thus the particles generated from `digest()` have their property `position` set yet.
  91003. * @param mesh ( Mesh ) is the mesh to be digested
  91004. * @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
  91005. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  91006. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  91007. * @returns the current SPS
  91008. */
  91009. digest(mesh: Mesh, options?: {
  91010. facetNb?: number;
  91011. number?: number;
  91012. delta?: number;
  91013. }): SolidParticleSystem;
  91014. private _unrotateFixedNormals;
  91015. private _resetCopy;
  91016. private _meshBuilder;
  91017. private _posToShape;
  91018. private _uvsToShapeUV;
  91019. private _addParticle;
  91020. /**
  91021. * Adds some particles to the SPS from the model shape. Returns the shape id.
  91022. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  91023. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  91024. * @param nb (positive integer) the number of particles to be created from this model
  91025. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  91026. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  91027. * @returns the number of shapes in the system
  91028. */
  91029. addShape(mesh: Mesh, nb: number, options?: {
  91030. positionFunction?: any;
  91031. vertexFunction?: any;
  91032. }): number;
  91033. private _rebuildParticle;
  91034. /**
  91035. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  91036. * @returns the SPS.
  91037. */
  91038. rebuildMesh(): SolidParticleSystem;
  91039. /**
  91040. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  91041. * This method calls `updateParticle()` for each particle of the SPS.
  91042. * For an animated SPS, it is usually called within the render loop.
  91043. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  91044. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  91045. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  91046. * @returns the SPS.
  91047. */
  91048. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  91049. /**
  91050. * Disposes the SPS.
  91051. */
  91052. dispose(): void;
  91053. /**
  91054. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  91055. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  91056. * @returns the SPS.
  91057. */
  91058. refreshVisibleSize(): SolidParticleSystem;
  91059. /**
  91060. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  91061. * @param size the size (float) of the visibility box
  91062. * note : this doesn't lock the SPS mesh bounding box.
  91063. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  91064. */
  91065. setVisibilityBox(size: number): void;
  91066. /**
  91067. * Gets whether the SPS as always visible or not
  91068. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  91069. */
  91070. /**
  91071. * Sets the SPS as always visible or not
  91072. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  91073. */
  91074. isAlwaysVisible: boolean;
  91075. /**
  91076. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  91077. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  91078. */
  91079. /**
  91080. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  91081. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  91082. */
  91083. isVisibilityBoxLocked: boolean;
  91084. /**
  91085. * Tells to `setParticles()` to compute the particle rotations or not.
  91086. * Default value : true. The SPS is faster when it's set to false.
  91087. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  91088. */
  91089. /**
  91090. * Gets if `setParticles()` computes the particle rotations or not.
  91091. * Default value : true. The SPS is faster when it's set to false.
  91092. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  91093. */
  91094. computeParticleRotation: boolean;
  91095. /**
  91096. * Tells to `setParticles()` to compute the particle colors or not.
  91097. * Default value : true. The SPS is faster when it's set to false.
  91098. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  91099. */
  91100. /**
  91101. * Gets if `setParticles()` computes the particle colors or not.
  91102. * Default value : true. The SPS is faster when it's set to false.
  91103. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  91104. */
  91105. computeParticleColor: boolean;
  91106. /**
  91107. * Gets if `setParticles()` computes the particle textures or not.
  91108. * Default value : true. The SPS is faster when it's set to false.
  91109. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  91110. */
  91111. computeParticleTexture: boolean;
  91112. /**
  91113. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  91114. * Default value : false. The SPS is faster when it's set to false.
  91115. * Note : the particle custom vertex positions aren't stored values.
  91116. */
  91117. /**
  91118. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  91119. * Default value : false. The SPS is faster when it's set to false.
  91120. * Note : the particle custom vertex positions aren't stored values.
  91121. */
  91122. computeParticleVertex: boolean;
  91123. /**
  91124. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  91125. */
  91126. /**
  91127. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  91128. */
  91129. computeBoundingBox: boolean;
  91130. /**
  91131. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  91132. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  91133. * Default : `true`
  91134. */
  91135. /**
  91136. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  91137. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  91138. * Default : `true`
  91139. */
  91140. depthSortParticles: boolean;
  91141. /**
  91142. * This function does nothing. It may be overwritten to set all the particle first values.
  91143. * The SPS doesn't call this function, you may have to call it by your own.
  91144. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  91145. */
  91146. initParticles(): void;
  91147. /**
  91148. * This function does nothing. It may be overwritten to recycle a particle.
  91149. * The SPS doesn't call this function, you may have to call it by your own.
  91150. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  91151. * @param particle The particle to recycle
  91152. * @returns the recycled particle
  91153. */
  91154. recycleParticle(particle: SolidParticle): SolidParticle;
  91155. /**
  91156. * Updates a particle : this function should be overwritten by the user.
  91157. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  91158. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  91159. * @example : just set a particle position or velocity and recycle conditions
  91160. * @param particle The particle to update
  91161. * @returns the updated particle
  91162. */
  91163. updateParticle(particle: SolidParticle): SolidParticle;
  91164. /**
  91165. * Updates a vertex of a particle : it can be overwritten by the user.
  91166. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  91167. * @param particle the current particle
  91168. * @param vertex the current index of the current particle
  91169. * @param pt the index of the current vertex in the particle shape
  91170. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  91171. * @example : just set a vertex particle position
  91172. * @returns the updated vertex
  91173. */
  91174. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  91175. /**
  91176. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  91177. * This does nothing and may be overwritten by the user.
  91178. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  91179. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  91180. * @param update the boolean update value actually passed to setParticles()
  91181. */
  91182. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  91183. /**
  91184. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  91185. * This will be passed three parameters.
  91186. * This does nothing and may be overwritten by the user.
  91187. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  91188. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  91189. * @param update the boolean update value actually passed to setParticles()
  91190. */
  91191. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  91192. }
  91193. }
  91194. declare module BABYLON {
  91195. /**
  91196. * Represents one particle of a solid particle system.
  91197. */
  91198. export class SolidParticle {
  91199. /**
  91200. * particle global index
  91201. */
  91202. idx: number;
  91203. /**
  91204. * The color of the particle
  91205. */
  91206. color: Nullable<Color4>;
  91207. /**
  91208. * The world space position of the particle.
  91209. */
  91210. position: Vector3;
  91211. /**
  91212. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  91213. */
  91214. rotation: Vector3;
  91215. /**
  91216. * The world space rotation quaternion of the particle.
  91217. */
  91218. rotationQuaternion: Nullable<Quaternion>;
  91219. /**
  91220. * The scaling of the particle.
  91221. */
  91222. scaling: Vector3;
  91223. /**
  91224. * The uvs of the particle.
  91225. */
  91226. uvs: Vector4;
  91227. /**
  91228. * The current speed of the particle.
  91229. */
  91230. velocity: Vector3;
  91231. /**
  91232. * The pivot point in the particle local space.
  91233. */
  91234. pivot: Vector3;
  91235. /**
  91236. * Must the particle be translated from its pivot point in its local space ?
  91237. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  91238. * Default : false
  91239. */
  91240. translateFromPivot: boolean;
  91241. /**
  91242. * Is the particle active or not ?
  91243. */
  91244. alive: boolean;
  91245. /**
  91246. * Is the particle visible or not ?
  91247. */
  91248. isVisible: boolean;
  91249. /**
  91250. * Index of this particle in the global "positions" array (Internal use)
  91251. * @hidden
  91252. */
  91253. _pos: number;
  91254. /**
  91255. * @hidden Index of this particle in the global "indices" array (Internal use)
  91256. */
  91257. _ind: number;
  91258. /**
  91259. * @hidden ModelShape of this particle (Internal use)
  91260. */
  91261. _model: ModelShape;
  91262. /**
  91263. * ModelShape id of this particle
  91264. */
  91265. shapeId: number;
  91266. /**
  91267. * Index of the particle in its shape id
  91268. */
  91269. idxInShape: number;
  91270. /**
  91271. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  91272. */
  91273. _modelBoundingInfo: BoundingInfo;
  91274. /**
  91275. * @hidden Particle BoundingInfo object (Internal use)
  91276. */
  91277. _boundingInfo: BoundingInfo;
  91278. /**
  91279. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  91280. */
  91281. _sps: SolidParticleSystem;
  91282. /**
  91283. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  91284. */
  91285. _stillInvisible: boolean;
  91286. /**
  91287. * @hidden Last computed particle rotation matrix
  91288. */
  91289. _rotationMatrix: number[];
  91290. /**
  91291. * Parent particle Id, if any.
  91292. * Default null.
  91293. */
  91294. parentId: Nullable<number>;
  91295. /**
  91296. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  91297. * The possible values are :
  91298. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  91299. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  91300. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  91301. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  91302. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  91303. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  91304. * */
  91305. cullingStrategy: number;
  91306. /**
  91307. * @hidden Internal global position in the SPS.
  91308. */
  91309. _globalPosition: Vector3;
  91310. /**
  91311. * Creates a Solid Particle object.
  91312. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  91313. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  91314. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  91315. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  91316. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  91317. * @param shapeId (integer) is the model shape identifier in the SPS.
  91318. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  91319. * @param sps defines the sps it is associated to
  91320. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  91321. */
  91322. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  91323. /**
  91324. * Legacy support, changed scale to scaling
  91325. */
  91326. /**
  91327. * Legacy support, changed scale to scaling
  91328. */
  91329. scale: Vector3;
  91330. /**
  91331. * Legacy support, changed quaternion to rotationQuaternion
  91332. */
  91333. /**
  91334. * Legacy support, changed quaternion to rotationQuaternion
  91335. */
  91336. quaternion: Nullable<Quaternion>;
  91337. /**
  91338. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  91339. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  91340. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  91341. * @returns true if it intersects
  91342. */
  91343. intersectsMesh(target: Mesh | SolidParticle): boolean;
  91344. /**
  91345. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  91346. * A particle is in the frustum if its bounding box intersects the frustum
  91347. * @param frustumPlanes defines the frustum to test
  91348. * @returns true if the particle is in the frustum planes
  91349. */
  91350. isInFrustum(frustumPlanes: Plane[]): boolean;
  91351. /**
  91352. * get the rotation matrix of the particle
  91353. * @hidden
  91354. */
  91355. getRotationMatrix(m: Matrix): void;
  91356. }
  91357. /**
  91358. * Represents the shape of the model used by one particle of a solid particle system.
  91359. * SPS internal tool, don't use it manually.
  91360. */
  91361. export class ModelShape {
  91362. /**
  91363. * The shape id
  91364. * @hidden
  91365. */
  91366. shapeID: number;
  91367. /**
  91368. * flat array of model positions (internal use)
  91369. * @hidden
  91370. */
  91371. _shape: Vector3[];
  91372. /**
  91373. * flat array of model UVs (internal use)
  91374. * @hidden
  91375. */
  91376. _shapeUV: number[];
  91377. /**
  91378. * length of the shape in the model indices array (internal use)
  91379. * @hidden
  91380. */
  91381. _indicesLength: number;
  91382. /**
  91383. * Custom position function (internal use)
  91384. * @hidden
  91385. */
  91386. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  91387. /**
  91388. * Custom vertex function (internal use)
  91389. * @hidden
  91390. */
  91391. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  91392. /**
  91393. * 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.
  91394. * SPS internal tool, don't use it manually.
  91395. * @hidden
  91396. */
  91397. constructor(id: number, shape: Vector3[], indicesLength: number, shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  91398. }
  91399. /**
  91400. * Represents a Depth Sorted Particle in the solid particle system.
  91401. */
  91402. export class DepthSortedParticle {
  91403. /**
  91404. * Index of the particle in the "indices" array
  91405. */
  91406. ind: number;
  91407. /**
  91408. * Length of the particle shape in the "indices" array
  91409. */
  91410. indicesLength: number;
  91411. /**
  91412. * Squared distance from the particle to the camera
  91413. */
  91414. sqDistance: number;
  91415. }
  91416. }
  91417. declare module BABYLON {
  91418. /**
  91419. * @hidden
  91420. */
  91421. export class _MeshCollisionData {
  91422. _checkCollisions: boolean;
  91423. _collisionMask: number;
  91424. _collisionGroup: number;
  91425. _collider: Nullable<Collider>;
  91426. _oldPositionForCollisions: Vector3;
  91427. _diffPositionForCollisions: Vector3;
  91428. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  91429. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  91430. }
  91431. }
  91432. declare module BABYLON {
  91433. /** @hidden */
  91434. class _FacetDataStorage {
  91435. facetPositions: Vector3[];
  91436. facetNormals: Vector3[];
  91437. facetPartitioning: number[][];
  91438. facetNb: number;
  91439. partitioningSubdivisions: number;
  91440. partitioningBBoxRatio: number;
  91441. facetDataEnabled: boolean;
  91442. facetParameters: any;
  91443. bbSize: Vector3;
  91444. subDiv: {
  91445. max: number;
  91446. X: number;
  91447. Y: number;
  91448. Z: number;
  91449. };
  91450. facetDepthSort: boolean;
  91451. facetDepthSortEnabled: boolean;
  91452. depthSortedIndices: IndicesArray;
  91453. depthSortedFacets: {
  91454. ind: number;
  91455. sqDistance: number;
  91456. }[];
  91457. facetDepthSortFunction: (f1: {
  91458. ind: number;
  91459. sqDistance: number;
  91460. }, f2: {
  91461. ind: number;
  91462. sqDistance: number;
  91463. }) => number;
  91464. facetDepthSortFrom: Vector3;
  91465. facetDepthSortOrigin: Vector3;
  91466. invertedMatrix: Matrix;
  91467. }
  91468. /**
  91469. * @hidden
  91470. **/
  91471. class _InternalAbstractMeshDataInfo {
  91472. _hasVertexAlpha: boolean;
  91473. _useVertexColors: boolean;
  91474. _numBoneInfluencers: number;
  91475. _applyFog: boolean;
  91476. _receiveShadows: boolean;
  91477. _facetData: _FacetDataStorage;
  91478. _visibility: number;
  91479. _skeleton: Nullable<Skeleton>;
  91480. _layerMask: number;
  91481. _computeBonesUsingShaders: boolean;
  91482. _isActive: boolean;
  91483. _onlyForInstances: boolean;
  91484. _isActiveIntermediate: boolean;
  91485. _onlyForInstancesIntermediate: boolean;
  91486. }
  91487. /**
  91488. * Class used to store all common mesh properties
  91489. */
  91490. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  91491. /** No occlusion */
  91492. static OCCLUSION_TYPE_NONE: number;
  91493. /** Occlusion set to optimisitic */
  91494. static OCCLUSION_TYPE_OPTIMISTIC: number;
  91495. /** Occlusion set to strict */
  91496. static OCCLUSION_TYPE_STRICT: number;
  91497. /** Use an accurante occlusion algorithm */
  91498. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  91499. /** Use a conservative occlusion algorithm */
  91500. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  91501. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  91502. * Test order :
  91503. * Is the bounding sphere outside the frustum ?
  91504. * If not, are the bounding box vertices outside the frustum ?
  91505. * It not, then the cullable object is in the frustum.
  91506. */
  91507. static readonly CULLINGSTRATEGY_STANDARD: number;
  91508. /** Culling strategy : Bounding Sphere Only.
  91509. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  91510. * It's also less accurate than the standard because some not visible objects can still be selected.
  91511. * Test : is the bounding sphere outside the frustum ?
  91512. * If not, then the cullable object is in the frustum.
  91513. */
  91514. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  91515. /** Culling strategy : Optimistic Inclusion.
  91516. * This in an inclusion test first, then the standard exclusion test.
  91517. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  91518. * 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.
  91519. * Anyway, it's as accurate as the standard strategy.
  91520. * Test :
  91521. * Is the cullable object bounding sphere center in the frustum ?
  91522. * If not, apply the default culling strategy.
  91523. */
  91524. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  91525. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  91526. * This in an inclusion test first, then the bounding sphere only exclusion test.
  91527. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  91528. * 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.
  91529. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  91530. * Test :
  91531. * Is the cullable object bounding sphere center in the frustum ?
  91532. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  91533. */
  91534. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  91535. /**
  91536. * No billboard
  91537. */
  91538. static readonly BILLBOARDMODE_NONE: number;
  91539. /** Billboard on X axis */
  91540. static readonly BILLBOARDMODE_X: number;
  91541. /** Billboard on Y axis */
  91542. static readonly BILLBOARDMODE_Y: number;
  91543. /** Billboard on Z axis */
  91544. static readonly BILLBOARDMODE_Z: number;
  91545. /** Billboard on all axes */
  91546. static readonly BILLBOARDMODE_ALL: number;
  91547. /** Billboard on using position instead of orientation */
  91548. static readonly BILLBOARDMODE_USE_POSITION: number;
  91549. /** @hidden */
  91550. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  91551. /**
  91552. * The culling strategy to use to check whether the mesh must be rendered or not.
  91553. * This value can be changed at any time and will be used on the next render mesh selection.
  91554. * The possible values are :
  91555. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  91556. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  91557. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  91558. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  91559. * Please read each static variable documentation to get details about the culling process.
  91560. * */
  91561. cullingStrategy: number;
  91562. /**
  91563. * Gets the number of facets in the mesh
  91564. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  91565. */
  91566. readonly facetNb: number;
  91567. /**
  91568. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  91569. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  91570. */
  91571. partitioningSubdivisions: number;
  91572. /**
  91573. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  91574. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  91575. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  91576. */
  91577. partitioningBBoxRatio: number;
  91578. /**
  91579. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  91580. * Works only for updatable meshes.
  91581. * Doesn't work with multi-materials
  91582. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  91583. */
  91584. mustDepthSortFacets: boolean;
  91585. /**
  91586. * The location (Vector3) where the facet depth sort must be computed from.
  91587. * By default, the active camera position.
  91588. * Used only when facet depth sort is enabled
  91589. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  91590. */
  91591. facetDepthSortFrom: Vector3;
  91592. /**
  91593. * gets a boolean indicating if facetData is enabled
  91594. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  91595. */
  91596. readonly isFacetDataEnabled: boolean;
  91597. /** @hidden */
  91598. _updateNonUniformScalingState(value: boolean): boolean;
  91599. /**
  91600. * An event triggered when this mesh collides with another one
  91601. */
  91602. onCollideObservable: Observable<AbstractMesh>;
  91603. /** Set a function to call when this mesh collides with another one */
  91604. onCollide: () => void;
  91605. /**
  91606. * An event triggered when the collision's position changes
  91607. */
  91608. onCollisionPositionChangeObservable: Observable<Vector3>;
  91609. /** Set a function to call when the collision's position changes */
  91610. onCollisionPositionChange: () => void;
  91611. /**
  91612. * An event triggered when material is changed
  91613. */
  91614. onMaterialChangedObservable: Observable<AbstractMesh>;
  91615. /**
  91616. * Gets or sets the orientation for POV movement & rotation
  91617. */
  91618. definedFacingForward: boolean;
  91619. /** @hidden */
  91620. _occlusionQuery: Nullable<WebGLQuery>;
  91621. /** @hidden */
  91622. _renderingGroup: Nullable<RenderingGroup>;
  91623. /**
  91624. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  91625. */
  91626. /**
  91627. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  91628. */
  91629. visibility: number;
  91630. /** Gets or sets the alpha index used to sort transparent meshes
  91631. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  91632. */
  91633. alphaIndex: number;
  91634. /**
  91635. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  91636. */
  91637. isVisible: boolean;
  91638. /**
  91639. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  91640. */
  91641. isPickable: boolean;
  91642. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  91643. showSubMeshesBoundingBox: boolean;
  91644. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  91645. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  91646. */
  91647. isBlocker: boolean;
  91648. /**
  91649. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  91650. */
  91651. enablePointerMoveEvents: boolean;
  91652. /**
  91653. * Specifies the rendering group id for this mesh (0 by default)
  91654. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  91655. */
  91656. renderingGroupId: number;
  91657. private _material;
  91658. /** Gets or sets current material */
  91659. material: Nullable<Material>;
  91660. /**
  91661. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  91662. * @see http://doc.babylonjs.com/babylon101/shadows
  91663. */
  91664. receiveShadows: boolean;
  91665. /** Defines color to use when rendering outline */
  91666. outlineColor: Color3;
  91667. /** Define width to use when rendering outline */
  91668. outlineWidth: number;
  91669. /** Defines color to use when rendering overlay */
  91670. overlayColor: Color3;
  91671. /** Defines alpha to use when rendering overlay */
  91672. overlayAlpha: number;
  91673. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  91674. hasVertexAlpha: boolean;
  91675. /** 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) */
  91676. useVertexColors: boolean;
  91677. /**
  91678. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  91679. */
  91680. computeBonesUsingShaders: boolean;
  91681. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  91682. numBoneInfluencers: number;
  91683. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  91684. applyFog: boolean;
  91685. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  91686. useOctreeForRenderingSelection: boolean;
  91687. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  91688. useOctreeForPicking: boolean;
  91689. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  91690. useOctreeForCollisions: boolean;
  91691. /**
  91692. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  91693. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  91694. */
  91695. layerMask: number;
  91696. /**
  91697. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  91698. */
  91699. alwaysSelectAsActiveMesh: boolean;
  91700. /**
  91701. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  91702. */
  91703. doNotSyncBoundingInfo: boolean;
  91704. /**
  91705. * Gets or sets the current action manager
  91706. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91707. */
  91708. actionManager: Nullable<AbstractActionManager>;
  91709. private _meshCollisionData;
  91710. /**
  91711. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  91712. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91713. */
  91714. ellipsoid: Vector3;
  91715. /**
  91716. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  91717. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91718. */
  91719. ellipsoidOffset: Vector3;
  91720. /**
  91721. * Gets or sets a collision mask used to mask collisions (default is -1).
  91722. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  91723. */
  91724. collisionMask: number;
  91725. /**
  91726. * Gets or sets the current collision group mask (-1 by default).
  91727. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  91728. */
  91729. collisionGroup: number;
  91730. /**
  91731. * Defines edge width used when edgesRenderer is enabled
  91732. * @see https://www.babylonjs-playground.com/#10OJSG#13
  91733. */
  91734. edgesWidth: number;
  91735. /**
  91736. * Defines edge color used when edgesRenderer is enabled
  91737. * @see https://www.babylonjs-playground.com/#10OJSG#13
  91738. */
  91739. edgesColor: Color4;
  91740. /** @hidden */
  91741. _edgesRenderer: Nullable<IEdgesRenderer>;
  91742. /** @hidden */
  91743. _masterMesh: Nullable<AbstractMesh>;
  91744. /** @hidden */
  91745. _boundingInfo: Nullable<BoundingInfo>;
  91746. /** @hidden */
  91747. _renderId: number;
  91748. /**
  91749. * Gets or sets the list of subMeshes
  91750. * @see http://doc.babylonjs.com/how_to/multi_materials
  91751. */
  91752. subMeshes: SubMesh[];
  91753. /** @hidden */
  91754. _intersectionsInProgress: AbstractMesh[];
  91755. /** @hidden */
  91756. _unIndexed: boolean;
  91757. /** @hidden */
  91758. _lightSources: Light[];
  91759. /** Gets the list of lights affecting that mesh */
  91760. readonly lightSources: Light[];
  91761. /** @hidden */
  91762. readonly _positions: Nullable<Vector3[]>;
  91763. /** @hidden */
  91764. _waitingData: {
  91765. lods: Nullable<any>;
  91766. actions: Nullable<any>;
  91767. freezeWorldMatrix: Nullable<boolean>;
  91768. };
  91769. /** @hidden */
  91770. _bonesTransformMatrices: Nullable<Float32Array>;
  91771. /** @hidden */
  91772. _transformMatrixTexture: Nullable<RawTexture>;
  91773. /**
  91774. * Gets or sets a skeleton to apply skining transformations
  91775. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  91776. */
  91777. skeleton: Nullable<Skeleton>;
  91778. /**
  91779. * An event triggered when the mesh is rebuilt.
  91780. */
  91781. onRebuildObservable: Observable<AbstractMesh>;
  91782. /**
  91783. * Creates a new AbstractMesh
  91784. * @param name defines the name of the mesh
  91785. * @param scene defines the hosting scene
  91786. */
  91787. constructor(name: string, scene?: Nullable<Scene>);
  91788. /**
  91789. * Returns the string "AbstractMesh"
  91790. * @returns "AbstractMesh"
  91791. */
  91792. getClassName(): string;
  91793. /**
  91794. * Gets a string representation of the current mesh
  91795. * @param fullDetails defines a boolean indicating if full details must be included
  91796. * @returns a string representation of the current mesh
  91797. */
  91798. toString(fullDetails?: boolean): string;
  91799. /**
  91800. * @hidden
  91801. */
  91802. protected _getEffectiveParent(): Nullable<Node>;
  91803. /** @hidden */
  91804. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  91805. /** @hidden */
  91806. _rebuild(): void;
  91807. /** @hidden */
  91808. _resyncLightSources(): void;
  91809. /** @hidden */
  91810. _resyncLighSource(light: Light): void;
  91811. /** @hidden */
  91812. _unBindEffect(): void;
  91813. /** @hidden */
  91814. _removeLightSource(light: Light, dispose: boolean): void;
  91815. private _markSubMeshesAsDirty;
  91816. /** @hidden */
  91817. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  91818. /** @hidden */
  91819. _markSubMeshesAsAttributesDirty(): void;
  91820. /** @hidden */
  91821. _markSubMeshesAsMiscDirty(): void;
  91822. /**
  91823. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  91824. */
  91825. scaling: Vector3;
  91826. /**
  91827. * Returns true if the mesh is blocked. Implemented by child classes
  91828. */
  91829. readonly isBlocked: boolean;
  91830. /**
  91831. * Returns the mesh itself by default. Implemented by child classes
  91832. * @param camera defines the camera to use to pick the right LOD level
  91833. * @returns the currentAbstractMesh
  91834. */
  91835. getLOD(camera: Camera): Nullable<AbstractMesh>;
  91836. /**
  91837. * Returns 0 by default. Implemented by child classes
  91838. * @returns an integer
  91839. */
  91840. getTotalVertices(): number;
  91841. /**
  91842. * Returns a positive integer : the total number of indices in this mesh geometry.
  91843. * @returns the numner of indices or zero if the mesh has no geometry.
  91844. */
  91845. getTotalIndices(): number;
  91846. /**
  91847. * Returns null by default. Implemented by child classes
  91848. * @returns null
  91849. */
  91850. getIndices(): Nullable<IndicesArray>;
  91851. /**
  91852. * Returns the array of the requested vertex data kind. Implemented by child classes
  91853. * @param kind defines the vertex data kind to use
  91854. * @returns null
  91855. */
  91856. getVerticesData(kind: string): Nullable<FloatArray>;
  91857. /**
  91858. * Sets the vertex data of the mesh geometry for the requested `kind`.
  91859. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  91860. * Note that a new underlying VertexBuffer object is created each call.
  91861. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  91862. * @param kind defines vertex data kind:
  91863. * * VertexBuffer.PositionKind
  91864. * * VertexBuffer.UVKind
  91865. * * VertexBuffer.UV2Kind
  91866. * * VertexBuffer.UV3Kind
  91867. * * VertexBuffer.UV4Kind
  91868. * * VertexBuffer.UV5Kind
  91869. * * VertexBuffer.UV6Kind
  91870. * * VertexBuffer.ColorKind
  91871. * * VertexBuffer.MatricesIndicesKind
  91872. * * VertexBuffer.MatricesIndicesExtraKind
  91873. * * VertexBuffer.MatricesWeightsKind
  91874. * * VertexBuffer.MatricesWeightsExtraKind
  91875. * @param data defines the data source
  91876. * @param updatable defines if the data must be flagged as updatable (or static)
  91877. * @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
  91878. * @returns the current mesh
  91879. */
  91880. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  91881. /**
  91882. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  91883. * If the mesh has no geometry, it is simply returned as it is.
  91884. * @param kind defines vertex data kind:
  91885. * * VertexBuffer.PositionKind
  91886. * * VertexBuffer.UVKind
  91887. * * VertexBuffer.UV2Kind
  91888. * * VertexBuffer.UV3Kind
  91889. * * VertexBuffer.UV4Kind
  91890. * * VertexBuffer.UV5Kind
  91891. * * VertexBuffer.UV6Kind
  91892. * * VertexBuffer.ColorKind
  91893. * * VertexBuffer.MatricesIndicesKind
  91894. * * VertexBuffer.MatricesIndicesExtraKind
  91895. * * VertexBuffer.MatricesWeightsKind
  91896. * * VertexBuffer.MatricesWeightsExtraKind
  91897. * @param data defines the data source
  91898. * @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
  91899. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  91900. * @returns the current mesh
  91901. */
  91902. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  91903. /**
  91904. * Sets the mesh indices,
  91905. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  91906. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  91907. * @param totalVertices Defines the total number of vertices
  91908. * @returns the current mesh
  91909. */
  91910. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  91911. /**
  91912. * Gets a boolean indicating if specific vertex data is present
  91913. * @param kind defines the vertex data kind to use
  91914. * @returns true is data kind is present
  91915. */
  91916. isVerticesDataPresent(kind: string): boolean;
  91917. /**
  91918. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  91919. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  91920. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  91921. * @returns a BoundingInfo
  91922. */
  91923. getBoundingInfo(): BoundingInfo;
  91924. /**
  91925. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  91926. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  91927. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  91928. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  91929. * @returns the current mesh
  91930. */
  91931. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  91932. /**
  91933. * Overwrite the current bounding info
  91934. * @param boundingInfo defines the new bounding info
  91935. * @returns the current mesh
  91936. */
  91937. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  91938. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  91939. readonly useBones: boolean;
  91940. /** @hidden */
  91941. _preActivate(): void;
  91942. /** @hidden */
  91943. _preActivateForIntermediateRendering(renderId: number): void;
  91944. /** @hidden */
  91945. _activate(renderId: number, intermediateRendering: boolean): boolean;
  91946. /** @hidden */
  91947. _postActivate(): void;
  91948. /** @hidden */
  91949. _freeze(): void;
  91950. /** @hidden */
  91951. _unFreeze(): void;
  91952. /**
  91953. * Gets the current world matrix
  91954. * @returns a Matrix
  91955. */
  91956. getWorldMatrix(): Matrix;
  91957. /** @hidden */
  91958. _getWorldMatrixDeterminant(): number;
  91959. /**
  91960. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  91961. */
  91962. readonly isAnInstance: boolean;
  91963. /**
  91964. * Gets a boolean indicating if this mesh has instances
  91965. */
  91966. readonly hasInstances: boolean;
  91967. /**
  91968. * Perform relative position change from the point of view of behind the front of the mesh.
  91969. * This is performed taking into account the meshes current rotation, so you do not have to care.
  91970. * Supports definition of mesh facing forward or backward
  91971. * @param amountRight defines the distance on the right axis
  91972. * @param amountUp defines the distance on the up axis
  91973. * @param amountForward defines the distance on the forward axis
  91974. * @returns the current mesh
  91975. */
  91976. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  91977. /**
  91978. * Calculate relative position change from the point of view of behind the front of the mesh.
  91979. * This is performed taking into account the meshes current rotation, so you do not have to care.
  91980. * Supports definition of mesh facing forward or backward
  91981. * @param amountRight defines the distance on the right axis
  91982. * @param amountUp defines the distance on the up axis
  91983. * @param amountForward defines the distance on the forward axis
  91984. * @returns the new displacement vector
  91985. */
  91986. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  91987. /**
  91988. * Perform relative rotation change from the point of view of behind the front of the mesh.
  91989. * Supports definition of mesh facing forward or backward
  91990. * @param flipBack defines the flip
  91991. * @param twirlClockwise defines the twirl
  91992. * @param tiltRight defines the tilt
  91993. * @returns the current mesh
  91994. */
  91995. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  91996. /**
  91997. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  91998. * Supports definition of mesh facing forward or backward.
  91999. * @param flipBack defines the flip
  92000. * @param twirlClockwise defines the twirl
  92001. * @param tiltRight defines the tilt
  92002. * @returns the new rotation vector
  92003. */
  92004. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  92005. /**
  92006. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  92007. * This means the mesh underlying bounding box and sphere are recomputed.
  92008. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  92009. * @returns the current mesh
  92010. */
  92011. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  92012. /** @hidden */
  92013. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  92014. /** @hidden */
  92015. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  92016. /** @hidden */
  92017. _updateBoundingInfo(): AbstractMesh;
  92018. /** @hidden */
  92019. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  92020. /** @hidden */
  92021. protected _afterComputeWorldMatrix(): void;
  92022. /** @hidden */
  92023. readonly _effectiveMesh: AbstractMesh;
  92024. /**
  92025. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  92026. * A mesh is in the frustum if its bounding box intersects the frustum
  92027. * @param frustumPlanes defines the frustum to test
  92028. * @returns true if the mesh is in the frustum planes
  92029. */
  92030. isInFrustum(frustumPlanes: Plane[]): boolean;
  92031. /**
  92032. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  92033. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  92034. * @param frustumPlanes defines the frustum to test
  92035. * @returns true if the mesh is completely in the frustum planes
  92036. */
  92037. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  92038. /**
  92039. * True if the mesh intersects another mesh or a SolidParticle object
  92040. * @param mesh defines a target mesh or SolidParticle to test
  92041. * @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)
  92042. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  92043. * @returns true if there is an intersection
  92044. */
  92045. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  92046. /**
  92047. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  92048. * @param point defines the point to test
  92049. * @returns true if there is an intersection
  92050. */
  92051. intersectsPoint(point: Vector3): boolean;
  92052. /**
  92053. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  92054. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92055. */
  92056. checkCollisions: boolean;
  92057. /**
  92058. * Gets Collider object used to compute collisions (not physics)
  92059. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92060. */
  92061. readonly collider: Nullable<Collider>;
  92062. /**
  92063. * Move the mesh using collision engine
  92064. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92065. * @param displacement defines the requested displacement vector
  92066. * @returns the current mesh
  92067. */
  92068. moveWithCollisions(displacement: Vector3): AbstractMesh;
  92069. private _onCollisionPositionChange;
  92070. /** @hidden */
  92071. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  92072. /** @hidden */
  92073. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  92074. /** @hidden */
  92075. _checkCollision(collider: Collider): AbstractMesh;
  92076. /** @hidden */
  92077. _generatePointsArray(): boolean;
  92078. /**
  92079. * Checks if the passed Ray intersects with the mesh
  92080. * @param ray defines the ray to use
  92081. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  92082. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  92083. * @returns the picking info
  92084. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  92085. */
  92086. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  92087. /**
  92088. * Clones the current mesh
  92089. * @param name defines the mesh name
  92090. * @param newParent defines the new mesh parent
  92091. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  92092. * @returns the new mesh
  92093. */
  92094. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  92095. /**
  92096. * Disposes all the submeshes of the current meshnp
  92097. * @returns the current mesh
  92098. */
  92099. releaseSubMeshes(): AbstractMesh;
  92100. /**
  92101. * Releases resources associated with this abstract mesh.
  92102. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  92103. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  92104. */
  92105. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  92106. /**
  92107. * Adds the passed mesh as a child to the current mesh
  92108. * @param mesh defines the child mesh
  92109. * @returns the current mesh
  92110. */
  92111. addChild(mesh: AbstractMesh): AbstractMesh;
  92112. /**
  92113. * Removes the passed mesh from the current mesh children list
  92114. * @param mesh defines the child mesh
  92115. * @returns the current mesh
  92116. */
  92117. removeChild(mesh: AbstractMesh): AbstractMesh;
  92118. /** @hidden */
  92119. private _initFacetData;
  92120. /**
  92121. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  92122. * This method can be called within the render loop.
  92123. * 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
  92124. * @returns the current mesh
  92125. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92126. */
  92127. updateFacetData(): AbstractMesh;
  92128. /**
  92129. * Returns the facetLocalNormals array.
  92130. * The normals are expressed in the mesh local spac
  92131. * @returns an array of Vector3
  92132. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92133. */
  92134. getFacetLocalNormals(): Vector3[];
  92135. /**
  92136. * Returns the facetLocalPositions array.
  92137. * The facet positions are expressed in the mesh local space
  92138. * @returns an array of Vector3
  92139. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92140. */
  92141. getFacetLocalPositions(): Vector3[];
  92142. /**
  92143. * Returns the facetLocalPartioning array
  92144. * @returns an array of array of numbers
  92145. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92146. */
  92147. getFacetLocalPartitioning(): number[][];
  92148. /**
  92149. * Returns the i-th facet position in the world system.
  92150. * This method allocates a new Vector3 per call
  92151. * @param i defines the facet index
  92152. * @returns a new Vector3
  92153. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92154. */
  92155. getFacetPosition(i: number): Vector3;
  92156. /**
  92157. * Sets the reference Vector3 with the i-th facet position in the world system
  92158. * @param i defines the facet index
  92159. * @param ref defines the target vector
  92160. * @returns the current mesh
  92161. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92162. */
  92163. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  92164. /**
  92165. * Returns the i-th facet normal in the world system.
  92166. * This method allocates a new Vector3 per call
  92167. * @param i defines the facet index
  92168. * @returns a new Vector3
  92169. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92170. */
  92171. getFacetNormal(i: number): Vector3;
  92172. /**
  92173. * Sets the reference Vector3 with the i-th facet normal in the world system
  92174. * @param i defines the facet index
  92175. * @param ref defines the target vector
  92176. * @returns the current mesh
  92177. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92178. */
  92179. getFacetNormalToRef(i: number, ref: Vector3): this;
  92180. /**
  92181. * 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)
  92182. * @param x defines x coordinate
  92183. * @param y defines y coordinate
  92184. * @param z defines z coordinate
  92185. * @returns the array of facet indexes
  92186. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92187. */
  92188. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  92189. /**
  92190. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  92191. * @param projected sets as the (x,y,z) world projection on the facet
  92192. * @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
  92193. * @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
  92194. * @param x defines x coordinate
  92195. * @param y defines y coordinate
  92196. * @param z defines z coordinate
  92197. * @returns the face index if found (or null instead)
  92198. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92199. */
  92200. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  92201. /**
  92202. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  92203. * @param projected sets as the (x,y,z) local projection on the facet
  92204. * @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
  92205. * @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
  92206. * @param x defines x coordinate
  92207. * @param y defines y coordinate
  92208. * @param z defines z coordinate
  92209. * @returns the face index if found (or null instead)
  92210. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92211. */
  92212. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  92213. /**
  92214. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  92215. * @returns the parameters
  92216. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92217. */
  92218. getFacetDataParameters(): any;
  92219. /**
  92220. * Disables the feature FacetData and frees the related memory
  92221. * @returns the current mesh
  92222. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92223. */
  92224. disableFacetData(): AbstractMesh;
  92225. /**
  92226. * Updates the AbstractMesh indices array
  92227. * @param indices defines the data source
  92228. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  92229. * @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)
  92230. * @returns the current mesh
  92231. */
  92232. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  92233. /**
  92234. * Creates new normals data for the mesh
  92235. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  92236. * @returns the current mesh
  92237. */
  92238. createNormals(updatable: boolean): AbstractMesh;
  92239. /**
  92240. * Align the mesh with a normal
  92241. * @param normal defines the normal to use
  92242. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  92243. * @returns the current mesh
  92244. */
  92245. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  92246. /** @hidden */
  92247. _checkOcclusionQuery(): boolean;
  92248. /**
  92249. * Disables the mesh edge rendering mode
  92250. * @returns the currentAbstractMesh
  92251. */
  92252. disableEdgesRendering(): AbstractMesh;
  92253. /**
  92254. * Enables the edge rendering mode on the mesh.
  92255. * This mode makes the mesh edges visible
  92256. * @param epsilon defines the maximal distance between two angles to detect a face
  92257. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  92258. * @returns the currentAbstractMesh
  92259. * @see https://www.babylonjs-playground.com/#19O9TU#0
  92260. */
  92261. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  92262. }
  92263. }
  92264. declare module BABYLON {
  92265. /**
  92266. * Interface used to define ActionEvent
  92267. */
  92268. export interface IActionEvent {
  92269. /** The mesh or sprite that triggered the action */
  92270. source: any;
  92271. /** The X mouse cursor position at the time of the event */
  92272. pointerX: number;
  92273. /** The Y mouse cursor position at the time of the event */
  92274. pointerY: number;
  92275. /** The mesh that is currently pointed at (can be null) */
  92276. meshUnderPointer: Nullable<AbstractMesh>;
  92277. /** the original (browser) event that triggered the ActionEvent */
  92278. sourceEvent?: any;
  92279. /** additional data for the event */
  92280. additionalData?: any;
  92281. }
  92282. /**
  92283. * ActionEvent is the event being sent when an action is triggered.
  92284. */
  92285. export class ActionEvent implements IActionEvent {
  92286. /** The mesh or sprite that triggered the action */
  92287. source: any;
  92288. /** The X mouse cursor position at the time of the event */
  92289. pointerX: number;
  92290. /** The Y mouse cursor position at the time of the event */
  92291. pointerY: number;
  92292. /** The mesh that is currently pointed at (can be null) */
  92293. meshUnderPointer: Nullable<AbstractMesh>;
  92294. /** the original (browser) event that triggered the ActionEvent */
  92295. sourceEvent?: any;
  92296. /** additional data for the event */
  92297. additionalData?: any;
  92298. /**
  92299. * Creates a new ActionEvent
  92300. * @param source The mesh or sprite that triggered the action
  92301. * @param pointerX The X mouse cursor position at the time of the event
  92302. * @param pointerY The Y mouse cursor position at the time of the event
  92303. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  92304. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  92305. * @param additionalData additional data for the event
  92306. */
  92307. constructor(
  92308. /** The mesh or sprite that triggered the action */
  92309. source: any,
  92310. /** The X mouse cursor position at the time of the event */
  92311. pointerX: number,
  92312. /** The Y mouse cursor position at the time of the event */
  92313. pointerY: number,
  92314. /** The mesh that is currently pointed at (can be null) */
  92315. meshUnderPointer: Nullable<AbstractMesh>,
  92316. /** the original (browser) event that triggered the ActionEvent */
  92317. sourceEvent?: any,
  92318. /** additional data for the event */
  92319. additionalData?: any);
  92320. /**
  92321. * Helper function to auto-create an ActionEvent from a source mesh.
  92322. * @param source The source mesh that triggered the event
  92323. * @param evt The original (browser) event
  92324. * @param additionalData additional data for the event
  92325. * @returns the new ActionEvent
  92326. */
  92327. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  92328. /**
  92329. * Helper function to auto-create an ActionEvent from a source sprite
  92330. * @param source The source sprite that triggered the event
  92331. * @param scene Scene associated with the sprite
  92332. * @param evt The original (browser) event
  92333. * @param additionalData additional data for the event
  92334. * @returns the new ActionEvent
  92335. */
  92336. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  92337. /**
  92338. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  92339. * @param scene the scene where the event occurred
  92340. * @param evt The original (browser) event
  92341. * @returns the new ActionEvent
  92342. */
  92343. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  92344. /**
  92345. * Helper function to auto-create an ActionEvent from a primitive
  92346. * @param prim defines the target primitive
  92347. * @param pointerPos defines the pointer position
  92348. * @param evt The original (browser) event
  92349. * @param additionalData additional data for the event
  92350. * @returns the new ActionEvent
  92351. */
  92352. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  92353. }
  92354. }
  92355. declare module BABYLON {
  92356. /**
  92357. * Abstract class used to decouple action Manager from scene and meshes.
  92358. * Do not instantiate.
  92359. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92360. */
  92361. export abstract class AbstractActionManager implements IDisposable {
  92362. /** Gets the list of active triggers */
  92363. static Triggers: {
  92364. [key: string]: number;
  92365. };
  92366. /** Gets the cursor to use when hovering items */
  92367. hoverCursor: string;
  92368. /** Gets the list of actions */
  92369. actions: IAction[];
  92370. /**
  92371. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  92372. */
  92373. isRecursive: boolean;
  92374. /**
  92375. * Releases all associated resources
  92376. */
  92377. abstract dispose(): void;
  92378. /**
  92379. * Does this action manager has pointer triggers
  92380. */
  92381. abstract readonly hasPointerTriggers: boolean;
  92382. /**
  92383. * Does this action manager has pick triggers
  92384. */
  92385. abstract readonly hasPickTriggers: boolean;
  92386. /**
  92387. * Process a specific trigger
  92388. * @param trigger defines the trigger to process
  92389. * @param evt defines the event details to be processed
  92390. */
  92391. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  92392. /**
  92393. * Does this action manager handles actions of any of the given triggers
  92394. * @param triggers defines the triggers to be tested
  92395. * @return a boolean indicating whether one (or more) of the triggers is handled
  92396. */
  92397. abstract hasSpecificTriggers(triggers: number[]): boolean;
  92398. /**
  92399. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  92400. * speed.
  92401. * @param triggerA defines the trigger to be tested
  92402. * @param triggerB defines the trigger to be tested
  92403. * @return a boolean indicating whether one (or more) of the triggers is handled
  92404. */
  92405. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  92406. /**
  92407. * Does this action manager handles actions of a given trigger
  92408. * @param trigger defines the trigger to be tested
  92409. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  92410. * @return whether the trigger is handled
  92411. */
  92412. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  92413. /**
  92414. * Serialize this manager to a JSON object
  92415. * @param name defines the property name to store this manager
  92416. * @returns a JSON representation of this manager
  92417. */
  92418. abstract serialize(name: string): any;
  92419. /**
  92420. * Registers an action to this action manager
  92421. * @param action defines the action to be registered
  92422. * @return the action amended (prepared) after registration
  92423. */
  92424. abstract registerAction(action: IAction): Nullable<IAction>;
  92425. /**
  92426. * Unregisters an action to this action manager
  92427. * @param action defines the action to be unregistered
  92428. * @return a boolean indicating whether the action has been unregistered
  92429. */
  92430. abstract unregisterAction(action: IAction): Boolean;
  92431. /**
  92432. * Does exist one action manager with at least one trigger
  92433. **/
  92434. static readonly HasTriggers: boolean;
  92435. /**
  92436. * Does exist one action manager with at least one pick trigger
  92437. **/
  92438. static readonly HasPickTriggers: boolean;
  92439. /**
  92440. * Does exist one action manager that handles actions of a given trigger
  92441. * @param trigger defines the trigger to be tested
  92442. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  92443. **/
  92444. static HasSpecificTrigger(trigger: number): boolean;
  92445. }
  92446. }
  92447. declare module BABYLON {
  92448. /**
  92449. * Defines how a node can be built from a string name.
  92450. */
  92451. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  92452. /**
  92453. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  92454. */
  92455. export class Node implements IBehaviorAware<Node> {
  92456. /** @hidden */
  92457. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  92458. private static _NodeConstructors;
  92459. /**
  92460. * Add a new node constructor
  92461. * @param type defines the type name of the node to construct
  92462. * @param constructorFunc defines the constructor function
  92463. */
  92464. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  92465. /**
  92466. * Returns a node constructor based on type name
  92467. * @param type defines the type name
  92468. * @param name defines the new node name
  92469. * @param scene defines the hosting scene
  92470. * @param options defines optional options to transmit to constructors
  92471. * @returns the new constructor or null
  92472. */
  92473. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  92474. /**
  92475. * Gets or sets the name of the node
  92476. */
  92477. name: string;
  92478. /**
  92479. * Gets or sets the id of the node
  92480. */
  92481. id: string;
  92482. /**
  92483. * Gets or sets the unique id of the node
  92484. */
  92485. uniqueId: number;
  92486. /**
  92487. * Gets or sets a string used to store user defined state for the node
  92488. */
  92489. state: string;
  92490. /**
  92491. * Gets or sets an object used to store user defined information for the node
  92492. */
  92493. metadata: any;
  92494. /**
  92495. * For internal use only. Please do not use.
  92496. */
  92497. reservedDataStore: any;
  92498. /**
  92499. * List of inspectable custom properties (used by the Inspector)
  92500. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  92501. */
  92502. inspectableCustomProperties: IInspectable[];
  92503. /**
  92504. * Gets or sets a boolean used to define if the node must be serialized
  92505. */
  92506. doNotSerialize: boolean;
  92507. /** @hidden */
  92508. _isDisposed: boolean;
  92509. /**
  92510. * Gets a list of Animations associated with the node
  92511. */
  92512. animations: Animation[];
  92513. protected _ranges: {
  92514. [name: string]: Nullable<AnimationRange>;
  92515. };
  92516. /**
  92517. * Callback raised when the node is ready to be used
  92518. */
  92519. onReady: Nullable<(node: Node) => void>;
  92520. private _isEnabled;
  92521. private _isParentEnabled;
  92522. private _isReady;
  92523. /** @hidden */
  92524. _currentRenderId: number;
  92525. private _parentUpdateId;
  92526. /** @hidden */
  92527. _childUpdateId: number;
  92528. /** @hidden */
  92529. _waitingParentId: Nullable<string>;
  92530. /** @hidden */
  92531. _scene: Scene;
  92532. /** @hidden */
  92533. _cache: any;
  92534. private _parentNode;
  92535. private _children;
  92536. /** @hidden */
  92537. _worldMatrix: Matrix;
  92538. /** @hidden */
  92539. _worldMatrixDeterminant: number;
  92540. /** @hidden */
  92541. _worldMatrixDeterminantIsDirty: boolean;
  92542. /** @hidden */
  92543. private _sceneRootNodesIndex;
  92544. /**
  92545. * Gets a boolean indicating if the node has been disposed
  92546. * @returns true if the node was disposed
  92547. */
  92548. isDisposed(): boolean;
  92549. /**
  92550. * Gets or sets the parent of the node (without keeping the current position in the scene)
  92551. * @see https://doc.babylonjs.com/how_to/parenting
  92552. */
  92553. parent: Nullable<Node>;
  92554. private addToSceneRootNodes;
  92555. private removeFromSceneRootNodes;
  92556. private _animationPropertiesOverride;
  92557. /**
  92558. * Gets or sets the animation properties override
  92559. */
  92560. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  92561. /**
  92562. * Gets a string idenfifying the name of the class
  92563. * @returns "Node" string
  92564. */
  92565. getClassName(): string;
  92566. /** @hidden */
  92567. readonly _isNode: boolean;
  92568. /**
  92569. * An event triggered when the mesh is disposed
  92570. */
  92571. onDisposeObservable: Observable<Node>;
  92572. private _onDisposeObserver;
  92573. /**
  92574. * Sets a callback that will be raised when the node will be disposed
  92575. */
  92576. onDispose: () => void;
  92577. /**
  92578. * Creates a new Node
  92579. * @param name the name and id to be given to this node
  92580. * @param scene the scene this node will be added to
  92581. * @param addToRootNodes the node will be added to scene.rootNodes
  92582. */
  92583. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  92584. /**
  92585. * Gets the scene of the node
  92586. * @returns a scene
  92587. */
  92588. getScene(): Scene;
  92589. /**
  92590. * Gets the engine of the node
  92591. * @returns a Engine
  92592. */
  92593. getEngine(): Engine;
  92594. private _behaviors;
  92595. /**
  92596. * Attach a behavior to the node
  92597. * @see http://doc.babylonjs.com/features/behaviour
  92598. * @param behavior defines the behavior to attach
  92599. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  92600. * @returns the current Node
  92601. */
  92602. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  92603. /**
  92604. * Remove an attached behavior
  92605. * @see http://doc.babylonjs.com/features/behaviour
  92606. * @param behavior defines the behavior to attach
  92607. * @returns the current Node
  92608. */
  92609. removeBehavior(behavior: Behavior<Node>): Node;
  92610. /**
  92611. * Gets the list of attached behaviors
  92612. * @see http://doc.babylonjs.com/features/behaviour
  92613. */
  92614. readonly behaviors: Behavior<Node>[];
  92615. /**
  92616. * Gets an attached behavior by name
  92617. * @param name defines the name of the behavior to look for
  92618. * @see http://doc.babylonjs.com/features/behaviour
  92619. * @returns null if behavior was not found else the requested behavior
  92620. */
  92621. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  92622. /**
  92623. * Returns the latest update of the World matrix
  92624. * @returns a Matrix
  92625. */
  92626. getWorldMatrix(): Matrix;
  92627. /** @hidden */
  92628. _getWorldMatrixDeterminant(): number;
  92629. /**
  92630. * Returns directly the latest state of the mesh World matrix.
  92631. * A Matrix is returned.
  92632. */
  92633. readonly worldMatrixFromCache: Matrix;
  92634. /** @hidden */
  92635. _initCache(): void;
  92636. /** @hidden */
  92637. updateCache(force?: boolean): void;
  92638. /** @hidden */
  92639. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  92640. /** @hidden */
  92641. _updateCache(ignoreParentClass?: boolean): void;
  92642. /** @hidden */
  92643. _isSynchronized(): boolean;
  92644. /** @hidden */
  92645. _markSyncedWithParent(): void;
  92646. /** @hidden */
  92647. isSynchronizedWithParent(): boolean;
  92648. /** @hidden */
  92649. isSynchronized(): boolean;
  92650. /**
  92651. * Is this node ready to be used/rendered
  92652. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  92653. * @return true if the node is ready
  92654. */
  92655. isReady(completeCheck?: boolean): boolean;
  92656. /**
  92657. * Is this node enabled?
  92658. * 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
  92659. * @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
  92660. * @return whether this node (and its parent) is enabled
  92661. */
  92662. isEnabled(checkAncestors?: boolean): boolean;
  92663. /** @hidden */
  92664. protected _syncParentEnabledState(): void;
  92665. /**
  92666. * Set the enabled state of this node
  92667. * @param value defines the new enabled state
  92668. */
  92669. setEnabled(value: boolean): void;
  92670. /**
  92671. * Is this node a descendant of the given node?
  92672. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  92673. * @param ancestor defines the parent node to inspect
  92674. * @returns a boolean indicating if this node is a descendant of the given node
  92675. */
  92676. isDescendantOf(ancestor: Node): boolean;
  92677. /** @hidden */
  92678. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  92679. /**
  92680. * Will return all nodes that have this node as ascendant
  92681. * @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
  92682. * @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
  92683. * @return all children nodes of all types
  92684. */
  92685. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  92686. /**
  92687. * Get all child-meshes of this node
  92688. * @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)
  92689. * @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
  92690. * @returns an array of AbstractMesh
  92691. */
  92692. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  92693. /**
  92694. * Get all direct children of this node
  92695. * @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
  92696. * @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)
  92697. * @returns an array of Node
  92698. */
  92699. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  92700. /** @hidden */
  92701. _setReady(state: boolean): void;
  92702. /**
  92703. * Get an animation by name
  92704. * @param name defines the name of the animation to look for
  92705. * @returns null if not found else the requested animation
  92706. */
  92707. getAnimationByName(name: string): Nullable<Animation>;
  92708. /**
  92709. * Creates an animation range for this node
  92710. * @param name defines the name of the range
  92711. * @param from defines the starting key
  92712. * @param to defines the end key
  92713. */
  92714. createAnimationRange(name: string, from: number, to: number): void;
  92715. /**
  92716. * Delete a specific animation range
  92717. * @param name defines the name of the range to delete
  92718. * @param deleteFrames defines if animation frames from the range must be deleted as well
  92719. */
  92720. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  92721. /**
  92722. * Get an animation range by name
  92723. * @param name defines the name of the animation range to look for
  92724. * @returns null if not found else the requested animation range
  92725. */
  92726. getAnimationRange(name: string): Nullable<AnimationRange>;
  92727. /**
  92728. * Gets the list of all animation ranges defined on this node
  92729. * @returns an array
  92730. */
  92731. getAnimationRanges(): Nullable<AnimationRange>[];
  92732. /**
  92733. * Will start the animation sequence
  92734. * @param name defines the range frames for animation sequence
  92735. * @param loop defines if the animation should loop (false by default)
  92736. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  92737. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  92738. * @returns the object created for this animation. If range does not exist, it will return null
  92739. */
  92740. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  92741. /**
  92742. * Serialize animation ranges into a JSON compatible object
  92743. * @returns serialization object
  92744. */
  92745. serializeAnimationRanges(): any;
  92746. /**
  92747. * Computes the world matrix of the node
  92748. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  92749. * @returns the world matrix
  92750. */
  92751. computeWorldMatrix(force?: boolean): Matrix;
  92752. /**
  92753. * Releases resources associated with this node.
  92754. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  92755. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  92756. */
  92757. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  92758. /**
  92759. * Parse animation range data from a serialization object and store them into a given node
  92760. * @param node defines where to store the animation ranges
  92761. * @param parsedNode defines the serialization object to read data from
  92762. * @param scene defines the hosting scene
  92763. */
  92764. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  92765. /**
  92766. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  92767. * @param includeDescendants Include bounding info from descendants as well (true by default)
  92768. * @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
  92769. * @returns the new bounding vectors
  92770. */
  92771. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  92772. min: Vector3;
  92773. max: Vector3;
  92774. };
  92775. }
  92776. }
  92777. declare module BABYLON {
  92778. /**
  92779. * @hidden
  92780. */
  92781. export class _IAnimationState {
  92782. key: number;
  92783. repeatCount: number;
  92784. workValue?: any;
  92785. loopMode?: number;
  92786. offsetValue?: any;
  92787. highLimitValue?: any;
  92788. }
  92789. /**
  92790. * Class used to store any kind of animation
  92791. */
  92792. export class Animation {
  92793. /**Name of the animation */
  92794. name: string;
  92795. /**Property to animate */
  92796. targetProperty: string;
  92797. /**The frames per second of the animation */
  92798. framePerSecond: number;
  92799. /**The data type of the animation */
  92800. dataType: number;
  92801. /**The loop mode of the animation */
  92802. loopMode?: number | undefined;
  92803. /**Specifies if blending should be enabled */
  92804. enableBlending?: boolean | undefined;
  92805. /**
  92806. * Use matrix interpolation instead of using direct key value when animating matrices
  92807. */
  92808. static AllowMatricesInterpolation: boolean;
  92809. /**
  92810. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  92811. */
  92812. static AllowMatrixDecomposeForInterpolation: boolean;
  92813. /**
  92814. * Stores the key frames of the animation
  92815. */
  92816. private _keys;
  92817. /**
  92818. * Stores the easing function of the animation
  92819. */
  92820. private _easingFunction;
  92821. /**
  92822. * @hidden Internal use only
  92823. */
  92824. _runtimeAnimations: RuntimeAnimation[];
  92825. /**
  92826. * The set of event that will be linked to this animation
  92827. */
  92828. private _events;
  92829. /**
  92830. * Stores an array of target property paths
  92831. */
  92832. targetPropertyPath: string[];
  92833. /**
  92834. * Stores the blending speed of the animation
  92835. */
  92836. blendingSpeed: number;
  92837. /**
  92838. * Stores the animation ranges for the animation
  92839. */
  92840. private _ranges;
  92841. /**
  92842. * @hidden Internal use
  92843. */
  92844. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  92845. /**
  92846. * Sets up an animation
  92847. * @param property The property to animate
  92848. * @param animationType The animation type to apply
  92849. * @param framePerSecond The frames per second of the animation
  92850. * @param easingFunction The easing function used in the animation
  92851. * @returns The created animation
  92852. */
  92853. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  92854. /**
  92855. * Create and start an animation on a node
  92856. * @param name defines the name of the global animation that will be run on all nodes
  92857. * @param node defines the root node where the animation will take place
  92858. * @param targetProperty defines property to animate
  92859. * @param framePerSecond defines the number of frame per second yo use
  92860. * @param totalFrame defines the number of frames in total
  92861. * @param from defines the initial value
  92862. * @param to defines the final value
  92863. * @param loopMode defines which loop mode you want to use (off by default)
  92864. * @param easingFunction defines the easing function to use (linear by default)
  92865. * @param onAnimationEnd defines the callback to call when animation end
  92866. * @returns the animatable created for this animation
  92867. */
  92868. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  92869. /**
  92870. * Create and start an animation on a node and its descendants
  92871. * @param name defines the name of the global animation that will be run on all nodes
  92872. * @param node defines the root node where the animation will take place
  92873. * @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
  92874. * @param targetProperty defines property to animate
  92875. * @param framePerSecond defines the number of frame per second to use
  92876. * @param totalFrame defines the number of frames in total
  92877. * @param from defines the initial value
  92878. * @param to defines the final value
  92879. * @param loopMode defines which loop mode you want to use (off by default)
  92880. * @param easingFunction defines the easing function to use (linear by default)
  92881. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  92882. * @returns the list of animatables created for all nodes
  92883. * @example https://www.babylonjs-playground.com/#MH0VLI
  92884. */
  92885. 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[]>;
  92886. /**
  92887. * Creates a new animation, merges it with the existing animations and starts it
  92888. * @param name Name of the animation
  92889. * @param node Node which contains the scene that begins the animations
  92890. * @param targetProperty Specifies which property to animate
  92891. * @param framePerSecond The frames per second of the animation
  92892. * @param totalFrame The total number of frames
  92893. * @param from The frame at the beginning of the animation
  92894. * @param to The frame at the end of the animation
  92895. * @param loopMode Specifies the loop mode of the animation
  92896. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  92897. * @param onAnimationEnd Callback to run once the animation is complete
  92898. * @returns Nullable animation
  92899. */
  92900. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  92901. /**
  92902. * Transition property of an host to the target Value
  92903. * @param property The property to transition
  92904. * @param targetValue The target Value of the property
  92905. * @param host The object where the property to animate belongs
  92906. * @param scene Scene used to run the animation
  92907. * @param frameRate Framerate (in frame/s) to use
  92908. * @param transition The transition type we want to use
  92909. * @param duration The duration of the animation, in milliseconds
  92910. * @param onAnimationEnd Callback trigger at the end of the animation
  92911. * @returns Nullable animation
  92912. */
  92913. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  92914. /**
  92915. * Return the array of runtime animations currently using this animation
  92916. */
  92917. readonly runtimeAnimations: RuntimeAnimation[];
  92918. /**
  92919. * Specifies if any of the runtime animations are currently running
  92920. */
  92921. readonly hasRunningRuntimeAnimations: boolean;
  92922. /**
  92923. * Initializes the animation
  92924. * @param name Name of the animation
  92925. * @param targetProperty Property to animate
  92926. * @param framePerSecond The frames per second of the animation
  92927. * @param dataType The data type of the animation
  92928. * @param loopMode The loop mode of the animation
  92929. * @param enableBlending Specifies if blending should be enabled
  92930. */
  92931. constructor(
  92932. /**Name of the animation */
  92933. name: string,
  92934. /**Property to animate */
  92935. targetProperty: string,
  92936. /**The frames per second of the animation */
  92937. framePerSecond: number,
  92938. /**The data type of the animation */
  92939. dataType: number,
  92940. /**The loop mode of the animation */
  92941. loopMode?: number | undefined,
  92942. /**Specifies if blending should be enabled */
  92943. enableBlending?: boolean | undefined);
  92944. /**
  92945. * Converts the animation to a string
  92946. * @param fullDetails support for multiple levels of logging within scene loading
  92947. * @returns String form of the animation
  92948. */
  92949. toString(fullDetails?: boolean): string;
  92950. /**
  92951. * Add an event to this animation
  92952. * @param event Event to add
  92953. */
  92954. addEvent(event: AnimationEvent): void;
  92955. /**
  92956. * Remove all events found at the given frame
  92957. * @param frame The frame to remove events from
  92958. */
  92959. removeEvents(frame: number): void;
  92960. /**
  92961. * Retrieves all the events from the animation
  92962. * @returns Events from the animation
  92963. */
  92964. getEvents(): AnimationEvent[];
  92965. /**
  92966. * Creates an animation range
  92967. * @param name Name of the animation range
  92968. * @param from Starting frame of the animation range
  92969. * @param to Ending frame of the animation
  92970. */
  92971. createRange(name: string, from: number, to: number): void;
  92972. /**
  92973. * Deletes an animation range by name
  92974. * @param name Name of the animation range to delete
  92975. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  92976. */
  92977. deleteRange(name: string, deleteFrames?: boolean): void;
  92978. /**
  92979. * Gets the animation range by name, or null if not defined
  92980. * @param name Name of the animation range
  92981. * @returns Nullable animation range
  92982. */
  92983. getRange(name: string): Nullable<AnimationRange>;
  92984. /**
  92985. * Gets the key frames from the animation
  92986. * @returns The key frames of the animation
  92987. */
  92988. getKeys(): Array<IAnimationKey>;
  92989. /**
  92990. * Gets the highest frame rate of the animation
  92991. * @returns Highest frame rate of the animation
  92992. */
  92993. getHighestFrame(): number;
  92994. /**
  92995. * Gets the easing function of the animation
  92996. * @returns Easing function of the animation
  92997. */
  92998. getEasingFunction(): IEasingFunction;
  92999. /**
  93000. * Sets the easing function of the animation
  93001. * @param easingFunction A custom mathematical formula for animation
  93002. */
  93003. setEasingFunction(easingFunction: EasingFunction): void;
  93004. /**
  93005. * Interpolates a scalar linearly
  93006. * @param startValue Start value of the animation curve
  93007. * @param endValue End value of the animation curve
  93008. * @param gradient Scalar amount to interpolate
  93009. * @returns Interpolated scalar value
  93010. */
  93011. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  93012. /**
  93013. * Interpolates a scalar cubically
  93014. * @param startValue Start value of the animation curve
  93015. * @param outTangent End tangent of the animation
  93016. * @param endValue End value of the animation curve
  93017. * @param inTangent Start tangent of the animation curve
  93018. * @param gradient Scalar amount to interpolate
  93019. * @returns Interpolated scalar value
  93020. */
  93021. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  93022. /**
  93023. * Interpolates a quaternion using a spherical linear interpolation
  93024. * @param startValue Start value of the animation curve
  93025. * @param endValue End value of the animation curve
  93026. * @param gradient Scalar amount to interpolate
  93027. * @returns Interpolated quaternion value
  93028. */
  93029. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  93030. /**
  93031. * Interpolates a quaternion cubically
  93032. * @param startValue Start value of the animation curve
  93033. * @param outTangent End tangent of the animation curve
  93034. * @param endValue End value of the animation curve
  93035. * @param inTangent Start tangent of the animation curve
  93036. * @param gradient Scalar amount to interpolate
  93037. * @returns Interpolated quaternion value
  93038. */
  93039. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  93040. /**
  93041. * Interpolates a Vector3 linearl
  93042. * @param startValue Start value of the animation curve
  93043. * @param endValue End value of the animation curve
  93044. * @param gradient Scalar amount to interpolate
  93045. * @returns Interpolated scalar value
  93046. */
  93047. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  93048. /**
  93049. * Interpolates a Vector3 cubically
  93050. * @param startValue Start value of the animation curve
  93051. * @param outTangent End tangent of the animation
  93052. * @param endValue End value of the animation curve
  93053. * @param inTangent Start tangent of the animation curve
  93054. * @param gradient Scalar amount to interpolate
  93055. * @returns InterpolatedVector3 value
  93056. */
  93057. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  93058. /**
  93059. * Interpolates a Vector2 linearly
  93060. * @param startValue Start value of the animation curve
  93061. * @param endValue End value of the animation curve
  93062. * @param gradient Scalar amount to interpolate
  93063. * @returns Interpolated Vector2 value
  93064. */
  93065. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  93066. /**
  93067. * Interpolates a Vector2 cubically
  93068. * @param startValue Start value of the animation curve
  93069. * @param outTangent End tangent of the animation
  93070. * @param endValue End value of the animation curve
  93071. * @param inTangent Start tangent of the animation curve
  93072. * @param gradient Scalar amount to interpolate
  93073. * @returns Interpolated Vector2 value
  93074. */
  93075. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  93076. /**
  93077. * Interpolates a size linearly
  93078. * @param startValue Start value of the animation curve
  93079. * @param endValue End value of the animation curve
  93080. * @param gradient Scalar amount to interpolate
  93081. * @returns Interpolated Size value
  93082. */
  93083. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  93084. /**
  93085. * Interpolates a Color3 linearly
  93086. * @param startValue Start value of the animation curve
  93087. * @param endValue End value of the animation curve
  93088. * @param gradient Scalar amount to interpolate
  93089. * @returns Interpolated Color3 value
  93090. */
  93091. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  93092. /**
  93093. * @hidden Internal use only
  93094. */
  93095. _getKeyValue(value: any): any;
  93096. /**
  93097. * @hidden Internal use only
  93098. */
  93099. _interpolate(currentFrame: number, state: _IAnimationState): any;
  93100. /**
  93101. * Defines the function to use to interpolate matrices
  93102. * @param startValue defines the start matrix
  93103. * @param endValue defines the end matrix
  93104. * @param gradient defines the gradient between both matrices
  93105. * @param result defines an optional target matrix where to store the interpolation
  93106. * @returns the interpolated matrix
  93107. */
  93108. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  93109. /**
  93110. * Makes a copy of the animation
  93111. * @returns Cloned animation
  93112. */
  93113. clone(): Animation;
  93114. /**
  93115. * Sets the key frames of the animation
  93116. * @param values The animation key frames to set
  93117. */
  93118. setKeys(values: Array<IAnimationKey>): void;
  93119. /**
  93120. * Serializes the animation to an object
  93121. * @returns Serialized object
  93122. */
  93123. serialize(): any;
  93124. /**
  93125. * Float animation type
  93126. */
  93127. private static _ANIMATIONTYPE_FLOAT;
  93128. /**
  93129. * Vector3 animation type
  93130. */
  93131. private static _ANIMATIONTYPE_VECTOR3;
  93132. /**
  93133. * Quaternion animation type
  93134. */
  93135. private static _ANIMATIONTYPE_QUATERNION;
  93136. /**
  93137. * Matrix animation type
  93138. */
  93139. private static _ANIMATIONTYPE_MATRIX;
  93140. /**
  93141. * Color3 animation type
  93142. */
  93143. private static _ANIMATIONTYPE_COLOR3;
  93144. /**
  93145. * Vector2 animation type
  93146. */
  93147. private static _ANIMATIONTYPE_VECTOR2;
  93148. /**
  93149. * Size animation type
  93150. */
  93151. private static _ANIMATIONTYPE_SIZE;
  93152. /**
  93153. * Relative Loop Mode
  93154. */
  93155. private static _ANIMATIONLOOPMODE_RELATIVE;
  93156. /**
  93157. * Cycle Loop Mode
  93158. */
  93159. private static _ANIMATIONLOOPMODE_CYCLE;
  93160. /**
  93161. * Constant Loop Mode
  93162. */
  93163. private static _ANIMATIONLOOPMODE_CONSTANT;
  93164. /**
  93165. * Get the float animation type
  93166. */
  93167. static readonly ANIMATIONTYPE_FLOAT: number;
  93168. /**
  93169. * Get the Vector3 animation type
  93170. */
  93171. static readonly ANIMATIONTYPE_VECTOR3: number;
  93172. /**
  93173. * Get the Vector2 animation type
  93174. */
  93175. static readonly ANIMATIONTYPE_VECTOR2: number;
  93176. /**
  93177. * Get the Size animation type
  93178. */
  93179. static readonly ANIMATIONTYPE_SIZE: number;
  93180. /**
  93181. * Get the Quaternion animation type
  93182. */
  93183. static readonly ANIMATIONTYPE_QUATERNION: number;
  93184. /**
  93185. * Get the Matrix animation type
  93186. */
  93187. static readonly ANIMATIONTYPE_MATRIX: number;
  93188. /**
  93189. * Get the Color3 animation type
  93190. */
  93191. static readonly ANIMATIONTYPE_COLOR3: number;
  93192. /**
  93193. * Get the Relative Loop Mode
  93194. */
  93195. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  93196. /**
  93197. * Get the Cycle Loop Mode
  93198. */
  93199. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  93200. /**
  93201. * Get the Constant Loop Mode
  93202. */
  93203. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  93204. /** @hidden */
  93205. static _UniversalLerp(left: any, right: any, amount: number): any;
  93206. /**
  93207. * Parses an animation object and creates an animation
  93208. * @param parsedAnimation Parsed animation object
  93209. * @returns Animation object
  93210. */
  93211. static Parse(parsedAnimation: any): Animation;
  93212. /**
  93213. * Appends the serialized animations from the source animations
  93214. * @param source Source containing the animations
  93215. * @param destination Target to store the animations
  93216. */
  93217. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  93218. }
  93219. }
  93220. declare module BABYLON {
  93221. /**
  93222. * Interface containing an array of animations
  93223. */
  93224. export interface IAnimatable {
  93225. /**
  93226. * Array of animations
  93227. */
  93228. animations: Nullable<Array<Animation>>;
  93229. }
  93230. }
  93231. declare module BABYLON {
  93232. /**
  93233. * This represents all the required information to add a fresnel effect on a material:
  93234. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  93235. */
  93236. export class FresnelParameters {
  93237. private _isEnabled;
  93238. /**
  93239. * Define if the fresnel effect is enable or not.
  93240. */
  93241. isEnabled: boolean;
  93242. /**
  93243. * Define the color used on edges (grazing angle)
  93244. */
  93245. leftColor: Color3;
  93246. /**
  93247. * Define the color used on center
  93248. */
  93249. rightColor: Color3;
  93250. /**
  93251. * Define bias applied to computed fresnel term
  93252. */
  93253. bias: number;
  93254. /**
  93255. * Defined the power exponent applied to fresnel term
  93256. */
  93257. power: number;
  93258. /**
  93259. * Clones the current fresnel and its valuues
  93260. * @returns a clone fresnel configuration
  93261. */
  93262. clone(): FresnelParameters;
  93263. /**
  93264. * Serializes the current fresnel parameters to a JSON representation.
  93265. * @return the JSON serialization
  93266. */
  93267. serialize(): any;
  93268. /**
  93269. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  93270. * @param parsedFresnelParameters Define the JSON representation
  93271. * @returns the parsed parameters
  93272. */
  93273. static Parse(parsedFresnelParameters: any): FresnelParameters;
  93274. }
  93275. }
  93276. declare module BABYLON {
  93277. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  93278. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93279. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93280. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93281. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93282. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93283. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93284. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93285. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93286. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93287. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93288. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93289. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93290. /**
  93291. * Decorator used to define property that can be serialized as reference to a camera
  93292. * @param sourceName defines the name of the property to decorate
  93293. */
  93294. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93295. /**
  93296. * Class used to help serialization objects
  93297. */
  93298. export class SerializationHelper {
  93299. /** @hidden */
  93300. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  93301. /** @hidden */
  93302. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  93303. /** @hidden */
  93304. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  93305. /** @hidden */
  93306. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  93307. /**
  93308. * Appends the serialized animations from the source animations
  93309. * @param source Source containing the animations
  93310. * @param destination Target to store the animations
  93311. */
  93312. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  93313. /**
  93314. * Static function used to serialized a specific entity
  93315. * @param entity defines the entity to serialize
  93316. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  93317. * @returns a JSON compatible object representing the serialization of the entity
  93318. */
  93319. static Serialize<T>(entity: T, serializationObject?: any): any;
  93320. /**
  93321. * Creates a new entity from a serialization data object
  93322. * @param creationFunction defines a function used to instanciated the new entity
  93323. * @param source defines the source serialization data
  93324. * @param scene defines the hosting scene
  93325. * @param rootUrl defines the root url for resources
  93326. * @returns a new entity
  93327. */
  93328. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  93329. /**
  93330. * Clones an object
  93331. * @param creationFunction defines the function used to instanciate the new object
  93332. * @param source defines the source object
  93333. * @returns the cloned object
  93334. */
  93335. static Clone<T>(creationFunction: () => T, source: T): T;
  93336. /**
  93337. * Instanciates a new object based on a source one (some data will be shared between both object)
  93338. * @param creationFunction defines the function used to instanciate the new object
  93339. * @param source defines the source object
  93340. * @returns the new object
  93341. */
  93342. static Instanciate<T>(creationFunction: () => T, source: T): T;
  93343. }
  93344. }
  93345. declare module BABYLON {
  93346. /**
  93347. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  93348. */
  93349. export interface CubeMapInfo {
  93350. /**
  93351. * The pixel array for the front face.
  93352. * This is stored in format, left to right, up to down format.
  93353. */
  93354. front: Nullable<ArrayBufferView>;
  93355. /**
  93356. * The pixel array for the back face.
  93357. * This is stored in format, left to right, up to down format.
  93358. */
  93359. back: Nullable<ArrayBufferView>;
  93360. /**
  93361. * The pixel array for the left face.
  93362. * This is stored in format, left to right, up to down format.
  93363. */
  93364. left: Nullable<ArrayBufferView>;
  93365. /**
  93366. * The pixel array for the right face.
  93367. * This is stored in format, left to right, up to down format.
  93368. */
  93369. right: Nullable<ArrayBufferView>;
  93370. /**
  93371. * The pixel array for the up face.
  93372. * This is stored in format, left to right, up to down format.
  93373. */
  93374. up: Nullable<ArrayBufferView>;
  93375. /**
  93376. * The pixel array for the down face.
  93377. * This is stored in format, left to right, up to down format.
  93378. */
  93379. down: Nullable<ArrayBufferView>;
  93380. /**
  93381. * The size of the cubemap stored.
  93382. *
  93383. * Each faces will be size * size pixels.
  93384. */
  93385. size: number;
  93386. /**
  93387. * The format of the texture.
  93388. *
  93389. * RGBA, RGB.
  93390. */
  93391. format: number;
  93392. /**
  93393. * The type of the texture data.
  93394. *
  93395. * UNSIGNED_INT, FLOAT.
  93396. */
  93397. type: number;
  93398. /**
  93399. * Specifies whether the texture is in gamma space.
  93400. */
  93401. gammaSpace: boolean;
  93402. }
  93403. /**
  93404. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  93405. */
  93406. export class PanoramaToCubeMapTools {
  93407. private static FACE_FRONT;
  93408. private static FACE_BACK;
  93409. private static FACE_RIGHT;
  93410. private static FACE_LEFT;
  93411. private static FACE_DOWN;
  93412. private static FACE_UP;
  93413. /**
  93414. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  93415. *
  93416. * @param float32Array The source data.
  93417. * @param inputWidth The width of the input panorama.
  93418. * @param inputHeight The height of the input panorama.
  93419. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  93420. * @return The cubemap data
  93421. */
  93422. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  93423. private static CreateCubemapTexture;
  93424. private static CalcProjectionSpherical;
  93425. }
  93426. }
  93427. declare module BABYLON {
  93428. /**
  93429. * Helper class dealing with the extraction of spherical polynomial dataArray
  93430. * from a cube map.
  93431. */
  93432. export class CubeMapToSphericalPolynomialTools {
  93433. private static FileFaces;
  93434. /**
  93435. * Converts a texture to the according Spherical Polynomial data.
  93436. * This extracts the first 3 orders only as they are the only one used in the lighting.
  93437. *
  93438. * @param texture The texture to extract the information from.
  93439. * @return The Spherical Polynomial data.
  93440. */
  93441. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  93442. /**
  93443. * Converts a cubemap to the according Spherical Polynomial data.
  93444. * This extracts the first 3 orders only as they are the only one used in the lighting.
  93445. *
  93446. * @param cubeInfo The Cube map to extract the information from.
  93447. * @return The Spherical Polynomial data.
  93448. */
  93449. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  93450. }
  93451. }
  93452. declare module BABYLON {
  93453. /**
  93454. * Class used to manipulate GUIDs
  93455. */
  93456. export class GUID {
  93457. /**
  93458. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  93459. * Be aware Math.random() could cause collisions, but:
  93460. * "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"
  93461. * @returns a pseudo random id
  93462. */
  93463. static RandomId(): string;
  93464. }
  93465. }
  93466. declare module BABYLON {
  93467. /**
  93468. * Base class of all the textures in babylon.
  93469. * It groups all the common properties the materials, post process, lights... might need
  93470. * in order to make a correct use of the texture.
  93471. */
  93472. export class BaseTexture implements IAnimatable {
  93473. /**
  93474. * Default anisotropic filtering level for the application.
  93475. * It is set to 4 as a good tradeoff between perf and quality.
  93476. */
  93477. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  93478. /**
  93479. * Gets or sets the unique id of the texture
  93480. */
  93481. uniqueId: number;
  93482. /**
  93483. * Define the name of the texture.
  93484. */
  93485. name: string;
  93486. /**
  93487. * Gets or sets an object used to store user defined information.
  93488. */
  93489. metadata: any;
  93490. /**
  93491. * For internal use only. Please do not use.
  93492. */
  93493. reservedDataStore: any;
  93494. private _hasAlpha;
  93495. /**
  93496. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  93497. */
  93498. hasAlpha: boolean;
  93499. /**
  93500. * Defines if the alpha value should be determined via the rgb values.
  93501. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  93502. */
  93503. getAlphaFromRGB: boolean;
  93504. /**
  93505. * Intensity or strength of the texture.
  93506. * It is commonly used by materials to fine tune the intensity of the texture
  93507. */
  93508. level: number;
  93509. /**
  93510. * Define the UV chanel to use starting from 0 and defaulting to 0.
  93511. * This is part of the texture as textures usually maps to one uv set.
  93512. */
  93513. coordinatesIndex: number;
  93514. private _coordinatesMode;
  93515. /**
  93516. * How a texture is mapped.
  93517. *
  93518. * | Value | Type | Description |
  93519. * | ----- | ----------------------------------- | ----------- |
  93520. * | 0 | EXPLICIT_MODE | |
  93521. * | 1 | SPHERICAL_MODE | |
  93522. * | 2 | PLANAR_MODE | |
  93523. * | 3 | CUBIC_MODE | |
  93524. * | 4 | PROJECTION_MODE | |
  93525. * | 5 | SKYBOX_MODE | |
  93526. * | 6 | INVCUBIC_MODE | |
  93527. * | 7 | EQUIRECTANGULAR_MODE | |
  93528. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  93529. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  93530. */
  93531. coordinatesMode: number;
  93532. /**
  93533. * | Value | Type | Description |
  93534. * | ----- | ------------------ | ----------- |
  93535. * | 0 | CLAMP_ADDRESSMODE | |
  93536. * | 1 | WRAP_ADDRESSMODE | |
  93537. * | 2 | MIRROR_ADDRESSMODE | |
  93538. */
  93539. wrapU: number;
  93540. /**
  93541. * | Value | Type | Description |
  93542. * | ----- | ------------------ | ----------- |
  93543. * | 0 | CLAMP_ADDRESSMODE | |
  93544. * | 1 | WRAP_ADDRESSMODE | |
  93545. * | 2 | MIRROR_ADDRESSMODE | |
  93546. */
  93547. wrapV: number;
  93548. /**
  93549. * | Value | Type | Description |
  93550. * | ----- | ------------------ | ----------- |
  93551. * | 0 | CLAMP_ADDRESSMODE | |
  93552. * | 1 | WRAP_ADDRESSMODE | |
  93553. * | 2 | MIRROR_ADDRESSMODE | |
  93554. */
  93555. wrapR: number;
  93556. /**
  93557. * With compliant hardware and browser (supporting anisotropic filtering)
  93558. * this defines the level of anisotropic filtering in the texture.
  93559. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  93560. */
  93561. anisotropicFilteringLevel: number;
  93562. /**
  93563. * Define if the texture is a cube texture or if false a 2d texture.
  93564. */
  93565. isCube: boolean;
  93566. /**
  93567. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  93568. */
  93569. is3D: boolean;
  93570. /**
  93571. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  93572. * HDR texture are usually stored in linear space.
  93573. * This only impacts the PBR and Background materials
  93574. */
  93575. gammaSpace: boolean;
  93576. /**
  93577. * Gets or sets whether or not the texture contains RGBD data.
  93578. */
  93579. isRGBD: boolean;
  93580. /**
  93581. * Is Z inverted in the texture (useful in a cube texture).
  93582. */
  93583. invertZ: boolean;
  93584. /**
  93585. * Are mip maps generated for this texture or not.
  93586. */
  93587. readonly noMipmap: boolean;
  93588. /**
  93589. * @hidden
  93590. */
  93591. lodLevelInAlpha: boolean;
  93592. /**
  93593. * With prefiltered texture, defined the offset used during the prefiltering steps.
  93594. */
  93595. lodGenerationOffset: number;
  93596. /**
  93597. * With prefiltered texture, defined the scale used during the prefiltering steps.
  93598. */
  93599. lodGenerationScale: number;
  93600. /**
  93601. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  93602. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  93603. * average roughness values.
  93604. */
  93605. linearSpecularLOD: boolean;
  93606. /**
  93607. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  93608. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  93609. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  93610. */
  93611. irradianceTexture: Nullable<BaseTexture>;
  93612. /**
  93613. * Define if the texture is a render target.
  93614. */
  93615. isRenderTarget: boolean;
  93616. /**
  93617. * Define the unique id of the texture in the scene.
  93618. */
  93619. readonly uid: string;
  93620. /**
  93621. * Return a string representation of the texture.
  93622. * @returns the texture as a string
  93623. */
  93624. toString(): string;
  93625. /**
  93626. * Get the class name of the texture.
  93627. * @returns "BaseTexture"
  93628. */
  93629. getClassName(): string;
  93630. /**
  93631. * Define the list of animation attached to the texture.
  93632. */
  93633. animations: Animation[];
  93634. /**
  93635. * An event triggered when the texture is disposed.
  93636. */
  93637. onDisposeObservable: Observable<BaseTexture>;
  93638. private _onDisposeObserver;
  93639. /**
  93640. * Callback triggered when the texture has been disposed.
  93641. * Kept for back compatibility, you can use the onDisposeObservable instead.
  93642. */
  93643. onDispose: () => void;
  93644. /**
  93645. * Define the current state of the loading sequence when in delayed load mode.
  93646. */
  93647. delayLoadState: number;
  93648. private _scene;
  93649. /** @hidden */
  93650. _texture: Nullable<InternalTexture>;
  93651. private _uid;
  93652. /**
  93653. * Define if the texture is preventinga material to render or not.
  93654. * If not and the texture is not ready, the engine will use a default black texture instead.
  93655. */
  93656. readonly isBlocking: boolean;
  93657. /**
  93658. * Instantiates a new BaseTexture.
  93659. * Base class of all the textures in babylon.
  93660. * It groups all the common properties the materials, post process, lights... might need
  93661. * in order to make a correct use of the texture.
  93662. * @param scene Define the scene the texture blongs to
  93663. */
  93664. constructor(scene: Nullable<Scene>);
  93665. /**
  93666. * Get the scene the texture belongs to.
  93667. * @returns the scene or null if undefined
  93668. */
  93669. getScene(): Nullable<Scene>;
  93670. /**
  93671. * Get the texture transform matrix used to offset tile the texture for istance.
  93672. * @returns the transformation matrix
  93673. */
  93674. getTextureMatrix(): Matrix;
  93675. /**
  93676. * Get the texture reflection matrix used to rotate/transform the reflection.
  93677. * @returns the reflection matrix
  93678. */
  93679. getReflectionTextureMatrix(): Matrix;
  93680. /**
  93681. * Get the underlying lower level texture from Babylon.
  93682. * @returns the insternal texture
  93683. */
  93684. getInternalTexture(): Nullable<InternalTexture>;
  93685. /**
  93686. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  93687. * @returns true if ready or not blocking
  93688. */
  93689. isReadyOrNotBlocking(): boolean;
  93690. /**
  93691. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  93692. * @returns true if fully ready
  93693. */
  93694. isReady(): boolean;
  93695. private _cachedSize;
  93696. /**
  93697. * Get the size of the texture.
  93698. * @returns the texture size.
  93699. */
  93700. getSize(): ISize;
  93701. /**
  93702. * Get the base size of the texture.
  93703. * It can be different from the size if the texture has been resized for POT for instance
  93704. * @returns the base size
  93705. */
  93706. getBaseSize(): ISize;
  93707. /**
  93708. * Update the sampling mode of the texture.
  93709. * Default is Trilinear mode.
  93710. *
  93711. * | Value | Type | Description |
  93712. * | ----- | ------------------ | ----------- |
  93713. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  93714. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  93715. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  93716. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  93717. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  93718. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  93719. * | 7 | NEAREST_LINEAR | |
  93720. * | 8 | NEAREST_NEAREST | |
  93721. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  93722. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  93723. * | 11 | LINEAR_LINEAR | |
  93724. * | 12 | LINEAR_NEAREST | |
  93725. *
  93726. * > _mag_: magnification filter (close to the viewer)
  93727. * > _min_: minification filter (far from the viewer)
  93728. * > _mip_: filter used between mip map levels
  93729. *@param samplingMode Define the new sampling mode of the texture
  93730. */
  93731. updateSamplingMode(samplingMode: number): void;
  93732. /**
  93733. * Scales the texture if is `canRescale()`
  93734. * @param ratio the resize factor we want to use to rescale
  93735. */
  93736. scale(ratio: number): void;
  93737. /**
  93738. * Get if the texture can rescale.
  93739. */
  93740. readonly canRescale: boolean;
  93741. /** @hidden */
  93742. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  93743. /** @hidden */
  93744. _rebuild(): void;
  93745. /**
  93746. * Triggers the load sequence in delayed load mode.
  93747. */
  93748. delayLoad(): void;
  93749. /**
  93750. * Clones the texture.
  93751. * @returns the cloned texture
  93752. */
  93753. clone(): Nullable<BaseTexture>;
  93754. /**
  93755. * Get the texture underlying type (INT, FLOAT...)
  93756. */
  93757. readonly textureType: number;
  93758. /**
  93759. * Get the texture underlying format (RGB, RGBA...)
  93760. */
  93761. readonly textureFormat: number;
  93762. /**
  93763. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  93764. * This will returns an RGBA array buffer containing either in values (0-255) or
  93765. * float values (0-1) depending of the underlying buffer type.
  93766. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  93767. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  93768. * @param buffer defines a user defined buffer to fill with data (can be null)
  93769. * @returns The Array buffer containing the pixels data.
  93770. */
  93771. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  93772. /**
  93773. * Release and destroy the underlying lower level texture aka internalTexture.
  93774. */
  93775. releaseInternalTexture(): void;
  93776. /**
  93777. * Get the polynomial representation of the texture data.
  93778. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  93779. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  93780. */
  93781. sphericalPolynomial: Nullable<SphericalPolynomial>;
  93782. /** @hidden */
  93783. readonly _lodTextureHigh: Nullable<BaseTexture>;
  93784. /** @hidden */
  93785. readonly _lodTextureMid: Nullable<BaseTexture>;
  93786. /** @hidden */
  93787. readonly _lodTextureLow: Nullable<BaseTexture>;
  93788. /**
  93789. * Dispose the texture and release its associated resources.
  93790. */
  93791. dispose(): void;
  93792. /**
  93793. * Serialize the texture into a JSON representation that can be parsed later on.
  93794. * @returns the JSON representation of the texture
  93795. */
  93796. serialize(): any;
  93797. /**
  93798. * Helper function to be called back once a list of texture contains only ready textures.
  93799. * @param textures Define the list of textures to wait for
  93800. * @param callback Define the callback triggered once the entire list will be ready
  93801. */
  93802. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  93803. }
  93804. }
  93805. declare module BABYLON {
  93806. /**
  93807. * Class used to store data associated with WebGL texture data for the engine
  93808. * This class should not be used directly
  93809. */
  93810. export class InternalTexture {
  93811. /** @hidden */
  93812. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  93813. /**
  93814. * The source of the texture data is unknown
  93815. */
  93816. static DATASOURCE_UNKNOWN: number;
  93817. /**
  93818. * Texture data comes from an URL
  93819. */
  93820. static DATASOURCE_URL: number;
  93821. /**
  93822. * Texture data is only used for temporary storage
  93823. */
  93824. static DATASOURCE_TEMP: number;
  93825. /**
  93826. * Texture data comes from raw data (ArrayBuffer)
  93827. */
  93828. static DATASOURCE_RAW: number;
  93829. /**
  93830. * Texture content is dynamic (video or dynamic texture)
  93831. */
  93832. static DATASOURCE_DYNAMIC: number;
  93833. /**
  93834. * Texture content is generated by rendering to it
  93835. */
  93836. static DATASOURCE_RENDERTARGET: number;
  93837. /**
  93838. * Texture content is part of a multi render target process
  93839. */
  93840. static DATASOURCE_MULTIRENDERTARGET: number;
  93841. /**
  93842. * Texture data comes from a cube data file
  93843. */
  93844. static DATASOURCE_CUBE: number;
  93845. /**
  93846. * Texture data comes from a raw cube data
  93847. */
  93848. static DATASOURCE_CUBERAW: number;
  93849. /**
  93850. * Texture data come from a prefiltered cube data file
  93851. */
  93852. static DATASOURCE_CUBEPREFILTERED: number;
  93853. /**
  93854. * Texture content is raw 3D data
  93855. */
  93856. static DATASOURCE_RAW3D: number;
  93857. /**
  93858. * Texture content is a depth texture
  93859. */
  93860. static DATASOURCE_DEPTHTEXTURE: number;
  93861. /**
  93862. * Texture data comes from a raw cube data encoded with RGBD
  93863. */
  93864. static DATASOURCE_CUBERAW_RGBD: number;
  93865. /**
  93866. * Defines if the texture is ready
  93867. */
  93868. isReady: boolean;
  93869. /**
  93870. * Defines if the texture is a cube texture
  93871. */
  93872. isCube: boolean;
  93873. /**
  93874. * Defines if the texture contains 3D data
  93875. */
  93876. is3D: boolean;
  93877. /**
  93878. * Defines if the texture contains multiview data
  93879. */
  93880. isMultiview: boolean;
  93881. /**
  93882. * Gets the URL used to load this texture
  93883. */
  93884. url: string;
  93885. /**
  93886. * Gets the sampling mode of the texture
  93887. */
  93888. samplingMode: number;
  93889. /**
  93890. * Gets a boolean indicating if the texture needs mipmaps generation
  93891. */
  93892. generateMipMaps: boolean;
  93893. /**
  93894. * Gets the number of samples used by the texture (WebGL2+ only)
  93895. */
  93896. samples: number;
  93897. /**
  93898. * Gets the type of the texture (int, float...)
  93899. */
  93900. type: number;
  93901. /**
  93902. * Gets the format of the texture (RGB, RGBA...)
  93903. */
  93904. format: number;
  93905. /**
  93906. * Observable called when the texture is loaded
  93907. */
  93908. onLoadedObservable: Observable<InternalTexture>;
  93909. /**
  93910. * Gets the width of the texture
  93911. */
  93912. width: number;
  93913. /**
  93914. * Gets the height of the texture
  93915. */
  93916. height: number;
  93917. /**
  93918. * Gets the depth of the texture
  93919. */
  93920. depth: number;
  93921. /**
  93922. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  93923. */
  93924. baseWidth: number;
  93925. /**
  93926. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  93927. */
  93928. baseHeight: number;
  93929. /**
  93930. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  93931. */
  93932. baseDepth: number;
  93933. /**
  93934. * Gets a boolean indicating if the texture is inverted on Y axis
  93935. */
  93936. invertY: boolean;
  93937. /** @hidden */
  93938. _invertVScale: boolean;
  93939. /** @hidden */
  93940. _associatedChannel: number;
  93941. /** @hidden */
  93942. _dataSource: number;
  93943. /** @hidden */
  93944. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  93945. /** @hidden */
  93946. _bufferView: Nullable<ArrayBufferView>;
  93947. /** @hidden */
  93948. _bufferViewArray: Nullable<ArrayBufferView[]>;
  93949. /** @hidden */
  93950. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  93951. /** @hidden */
  93952. _size: number;
  93953. /** @hidden */
  93954. _extension: string;
  93955. /** @hidden */
  93956. _files: Nullable<string[]>;
  93957. /** @hidden */
  93958. _workingCanvas: Nullable<HTMLCanvasElement>;
  93959. /** @hidden */
  93960. _workingContext: Nullable<CanvasRenderingContext2D>;
  93961. /** @hidden */
  93962. _framebuffer: Nullable<WebGLFramebuffer>;
  93963. /** @hidden */
  93964. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  93965. /** @hidden */
  93966. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  93967. /** @hidden */
  93968. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  93969. /** @hidden */
  93970. _attachments: Nullable<number[]>;
  93971. /** @hidden */
  93972. _cachedCoordinatesMode: Nullable<number>;
  93973. /** @hidden */
  93974. _cachedWrapU: Nullable<number>;
  93975. /** @hidden */
  93976. _cachedWrapV: Nullable<number>;
  93977. /** @hidden */
  93978. _cachedWrapR: Nullable<number>;
  93979. /** @hidden */
  93980. _cachedAnisotropicFilteringLevel: Nullable<number>;
  93981. /** @hidden */
  93982. _isDisabled: boolean;
  93983. /** @hidden */
  93984. _compression: Nullable<string>;
  93985. /** @hidden */
  93986. _generateStencilBuffer: boolean;
  93987. /** @hidden */
  93988. _generateDepthBuffer: boolean;
  93989. /** @hidden */
  93990. _comparisonFunction: number;
  93991. /** @hidden */
  93992. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  93993. /** @hidden */
  93994. _lodGenerationScale: number;
  93995. /** @hidden */
  93996. _lodGenerationOffset: number;
  93997. /** @hidden */
  93998. _colorTextureArray: Nullable<WebGLTexture>;
  93999. /** @hidden */
  94000. _depthStencilTextureArray: Nullable<WebGLTexture>;
  94001. /** @hidden */
  94002. _lodTextureHigh: Nullable<BaseTexture>;
  94003. /** @hidden */
  94004. _lodTextureMid: Nullable<BaseTexture>;
  94005. /** @hidden */
  94006. _lodTextureLow: Nullable<BaseTexture>;
  94007. /** @hidden */
  94008. _isRGBD: boolean;
  94009. /** @hidden */
  94010. _linearSpecularLOD: boolean;
  94011. /** @hidden */
  94012. _irradianceTexture: Nullable<BaseTexture>;
  94013. /** @hidden */
  94014. _webGLTexture: Nullable<WebGLTexture>;
  94015. /** @hidden */
  94016. _references: number;
  94017. private _engine;
  94018. /**
  94019. * Gets the Engine the texture belongs to.
  94020. * @returns The babylon engine
  94021. */
  94022. getEngine(): Engine;
  94023. /**
  94024. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  94025. */
  94026. readonly dataSource: number;
  94027. /**
  94028. * Creates a new InternalTexture
  94029. * @param engine defines the engine to use
  94030. * @param dataSource defines the type of data that will be used
  94031. * @param delayAllocation if the texture allocation should be delayed (default: false)
  94032. */
  94033. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  94034. /**
  94035. * Increments the number of references (ie. the number of Texture that point to it)
  94036. */
  94037. incrementReferences(): void;
  94038. /**
  94039. * Change the size of the texture (not the size of the content)
  94040. * @param width defines the new width
  94041. * @param height defines the new height
  94042. * @param depth defines the new depth (1 by default)
  94043. */
  94044. updateSize(width: int, height: int, depth?: int): void;
  94045. /** @hidden */
  94046. _rebuild(): void;
  94047. /** @hidden */
  94048. _swapAndDie(target: InternalTexture): void;
  94049. /**
  94050. * Dispose the current allocated resources
  94051. */
  94052. dispose(): void;
  94053. }
  94054. }
  94055. declare module BABYLON {
  94056. /**
  94057. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  94058. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  94059. */
  94060. export class EffectFallbacks {
  94061. private _defines;
  94062. private _currentRank;
  94063. private _maxRank;
  94064. private _mesh;
  94065. /**
  94066. * Removes the fallback from the bound mesh.
  94067. */
  94068. unBindMesh(): void;
  94069. /**
  94070. * Adds a fallback on the specified property.
  94071. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  94072. * @param define The name of the define in the shader
  94073. */
  94074. addFallback(rank: number, define: string): void;
  94075. /**
  94076. * Sets the mesh to use CPU skinning when needing to fallback.
  94077. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  94078. * @param mesh The mesh to use the fallbacks.
  94079. */
  94080. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  94081. /**
  94082. * Checks to see if more fallbacks are still availible.
  94083. */
  94084. readonly hasMoreFallbacks: boolean;
  94085. /**
  94086. * Removes the defines that should be removed when falling back.
  94087. * @param currentDefines defines the current define statements for the shader.
  94088. * @param effect defines the current effect we try to compile
  94089. * @returns The resulting defines with defines of the current rank removed.
  94090. */
  94091. reduce(currentDefines: string, effect: Effect): string;
  94092. }
  94093. /**
  94094. * Options to be used when creating an effect.
  94095. */
  94096. export class EffectCreationOptions {
  94097. /**
  94098. * Atrributes that will be used in the shader.
  94099. */
  94100. attributes: string[];
  94101. /**
  94102. * Uniform varible names that will be set in the shader.
  94103. */
  94104. uniformsNames: string[];
  94105. /**
  94106. * Uniform buffer varible names that will be set in the shader.
  94107. */
  94108. uniformBuffersNames: string[];
  94109. /**
  94110. * Sampler texture variable names that will be set in the shader.
  94111. */
  94112. samplers: string[];
  94113. /**
  94114. * Define statements that will be set in the shader.
  94115. */
  94116. defines: any;
  94117. /**
  94118. * Possible fallbacks for this effect to improve performance when needed.
  94119. */
  94120. fallbacks: Nullable<EffectFallbacks>;
  94121. /**
  94122. * Callback that will be called when the shader is compiled.
  94123. */
  94124. onCompiled: Nullable<(effect: Effect) => void>;
  94125. /**
  94126. * Callback that will be called if an error occurs during shader compilation.
  94127. */
  94128. onError: Nullable<(effect: Effect, errors: string) => void>;
  94129. /**
  94130. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  94131. */
  94132. indexParameters: any;
  94133. /**
  94134. * Max number of lights that can be used in the shader.
  94135. */
  94136. maxSimultaneousLights: number;
  94137. /**
  94138. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  94139. */
  94140. transformFeedbackVaryings: Nullable<string[]>;
  94141. }
  94142. /**
  94143. * Effect containing vertex and fragment shader that can be executed on an object.
  94144. */
  94145. export class Effect implements IDisposable {
  94146. /**
  94147. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  94148. */
  94149. static ShadersRepository: string;
  94150. /**
  94151. * Name of the effect.
  94152. */
  94153. name: any;
  94154. /**
  94155. * String container all the define statements that should be set on the shader.
  94156. */
  94157. defines: string;
  94158. /**
  94159. * Callback that will be called when the shader is compiled.
  94160. */
  94161. onCompiled: Nullable<(effect: Effect) => void>;
  94162. /**
  94163. * Callback that will be called if an error occurs during shader compilation.
  94164. */
  94165. onError: Nullable<(effect: Effect, errors: string) => void>;
  94166. /**
  94167. * Callback that will be called when effect is bound.
  94168. */
  94169. onBind: Nullable<(effect: Effect) => void>;
  94170. /**
  94171. * Unique ID of the effect.
  94172. */
  94173. uniqueId: number;
  94174. /**
  94175. * Observable that will be called when the shader is compiled.
  94176. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  94177. */
  94178. onCompileObservable: Observable<Effect>;
  94179. /**
  94180. * Observable that will be called if an error occurs during shader compilation.
  94181. */
  94182. onErrorObservable: Observable<Effect>;
  94183. /** @hidden */
  94184. _onBindObservable: Nullable<Observable<Effect>>;
  94185. /**
  94186. * Observable that will be called when effect is bound.
  94187. */
  94188. readonly onBindObservable: Observable<Effect>;
  94189. /** @hidden */
  94190. _bonesComputationForcedToCPU: boolean;
  94191. private static _uniqueIdSeed;
  94192. private _engine;
  94193. private _uniformBuffersNames;
  94194. private _uniformsNames;
  94195. private _samplerList;
  94196. private _samplers;
  94197. private _isReady;
  94198. private _compilationError;
  94199. private _attributesNames;
  94200. private _attributes;
  94201. private _uniforms;
  94202. /**
  94203. * Key for the effect.
  94204. * @hidden
  94205. */
  94206. _key: string;
  94207. private _indexParameters;
  94208. private _fallbacks;
  94209. private _vertexSourceCode;
  94210. private _fragmentSourceCode;
  94211. private _vertexSourceCodeOverride;
  94212. private _fragmentSourceCodeOverride;
  94213. private _transformFeedbackVaryings;
  94214. /**
  94215. * Compiled shader to webGL program.
  94216. * @hidden
  94217. */
  94218. _pipelineContext: Nullable<IPipelineContext>;
  94219. private _valueCache;
  94220. private static _baseCache;
  94221. /**
  94222. * Instantiates an effect.
  94223. * An effect can be used to create/manage/execute vertex and fragment shaders.
  94224. * @param baseName Name of the effect.
  94225. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  94226. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  94227. * @param samplers List of sampler variables that will be passed to the shader.
  94228. * @param engine Engine to be used to render the effect
  94229. * @param defines Define statements to be added to the shader.
  94230. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  94231. * @param onCompiled Callback that will be called when the shader is compiled.
  94232. * @param onError Callback that will be called if an error occurs during shader compilation.
  94233. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  94234. */
  94235. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: Nullable<string[]>, engine?: Engine, defines?: Nullable<string>, fallbacks?: Nullable<EffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  94236. private _useFinalCode;
  94237. /**
  94238. * Unique key for this effect
  94239. */
  94240. readonly key: string;
  94241. /**
  94242. * If the effect has been compiled and prepared.
  94243. * @returns if the effect is compiled and prepared.
  94244. */
  94245. isReady(): boolean;
  94246. private _isReadyInternal;
  94247. /**
  94248. * The engine the effect was initialized with.
  94249. * @returns the engine.
  94250. */
  94251. getEngine(): Engine;
  94252. /**
  94253. * The pipeline context for this effect
  94254. * @returns the associated pipeline context
  94255. */
  94256. getPipelineContext(): Nullable<IPipelineContext>;
  94257. /**
  94258. * The set of names of attribute variables for the shader.
  94259. * @returns An array of attribute names.
  94260. */
  94261. getAttributesNames(): string[];
  94262. /**
  94263. * Returns the attribute at the given index.
  94264. * @param index The index of the attribute.
  94265. * @returns The location of the attribute.
  94266. */
  94267. getAttributeLocation(index: number): number;
  94268. /**
  94269. * Returns the attribute based on the name of the variable.
  94270. * @param name of the attribute to look up.
  94271. * @returns the attribute location.
  94272. */
  94273. getAttributeLocationByName(name: string): number;
  94274. /**
  94275. * The number of attributes.
  94276. * @returns the numnber of attributes.
  94277. */
  94278. getAttributesCount(): number;
  94279. /**
  94280. * Gets the index of a uniform variable.
  94281. * @param uniformName of the uniform to look up.
  94282. * @returns the index.
  94283. */
  94284. getUniformIndex(uniformName: string): number;
  94285. /**
  94286. * Returns the attribute based on the name of the variable.
  94287. * @param uniformName of the uniform to look up.
  94288. * @returns the location of the uniform.
  94289. */
  94290. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  94291. /**
  94292. * Returns an array of sampler variable names
  94293. * @returns The array of sampler variable neames.
  94294. */
  94295. getSamplers(): string[];
  94296. /**
  94297. * The error from the last compilation.
  94298. * @returns the error string.
  94299. */
  94300. getCompilationError(): string;
  94301. /**
  94302. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  94303. * @param func The callback to be used.
  94304. */
  94305. executeWhenCompiled(func: (effect: Effect) => void): void;
  94306. private _checkIsReady;
  94307. /** @hidden */
  94308. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  94309. /** @hidden */
  94310. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  94311. /** @hidden */
  94312. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  94313. /**
  94314. * Recompiles the webGL program
  94315. * @param vertexSourceCode The source code for the vertex shader.
  94316. * @param fragmentSourceCode The source code for the fragment shader.
  94317. * @param onCompiled Callback called when completed.
  94318. * @param onError Callback called on error.
  94319. * @hidden
  94320. */
  94321. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  94322. /**
  94323. * Prepares the effect
  94324. * @hidden
  94325. */
  94326. _prepareEffect(): void;
  94327. private _processCompilationErrors;
  94328. /**
  94329. * Checks if the effect is supported. (Must be called after compilation)
  94330. */
  94331. readonly isSupported: boolean;
  94332. /**
  94333. * Binds a texture to the engine to be used as output of the shader.
  94334. * @param channel Name of the output variable.
  94335. * @param texture Texture to bind.
  94336. * @hidden
  94337. */
  94338. _bindTexture(channel: string, texture: InternalTexture): void;
  94339. /**
  94340. * Sets a texture on the engine to be used in the shader.
  94341. * @param channel Name of the sampler variable.
  94342. * @param texture Texture to set.
  94343. */
  94344. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  94345. /**
  94346. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  94347. * @param channel Name of the sampler variable.
  94348. * @param texture Texture to set.
  94349. */
  94350. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  94351. /**
  94352. * Sets an array of textures on the engine to be used in the shader.
  94353. * @param channel Name of the variable.
  94354. * @param textures Textures to set.
  94355. */
  94356. setTextureArray(channel: string, textures: BaseTexture[]): void;
  94357. /**
  94358. * 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)
  94359. * @param channel Name of the sampler variable.
  94360. * @param postProcess Post process to get the input texture from.
  94361. */
  94362. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  94363. /**
  94364. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  94365. * 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)
  94366. * @param channel Name of the sampler variable.
  94367. * @param postProcess Post process to get the output texture from.
  94368. */
  94369. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  94370. /** @hidden */
  94371. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  94372. /** @hidden */
  94373. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  94374. /** @hidden */
  94375. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  94376. /** @hidden */
  94377. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  94378. /**
  94379. * Binds a buffer to a uniform.
  94380. * @param buffer Buffer to bind.
  94381. * @param name Name of the uniform variable to bind to.
  94382. */
  94383. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  94384. /**
  94385. * Binds block to a uniform.
  94386. * @param blockName Name of the block to bind.
  94387. * @param index Index to bind.
  94388. */
  94389. bindUniformBlock(blockName: string, index: number): void;
  94390. /**
  94391. * Sets an interger value on a uniform variable.
  94392. * @param uniformName Name of the variable.
  94393. * @param value Value to be set.
  94394. * @returns this effect.
  94395. */
  94396. setInt(uniformName: string, value: number): Effect;
  94397. /**
  94398. * Sets an int array on a uniform variable.
  94399. * @param uniformName Name of the variable.
  94400. * @param array array to be set.
  94401. * @returns this effect.
  94402. */
  94403. setIntArray(uniformName: string, array: Int32Array): Effect;
  94404. /**
  94405. * 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)
  94406. * @param uniformName Name of the variable.
  94407. * @param array array to be set.
  94408. * @returns this effect.
  94409. */
  94410. setIntArray2(uniformName: string, array: Int32Array): Effect;
  94411. /**
  94412. * 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)
  94413. * @param uniformName Name of the variable.
  94414. * @param array array to be set.
  94415. * @returns this effect.
  94416. */
  94417. setIntArray3(uniformName: string, array: Int32Array): Effect;
  94418. /**
  94419. * 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)
  94420. * @param uniformName Name of the variable.
  94421. * @param array array to be set.
  94422. * @returns this effect.
  94423. */
  94424. setIntArray4(uniformName: string, array: Int32Array): Effect;
  94425. /**
  94426. * Sets an float array on a uniform variable.
  94427. * @param uniformName Name of the variable.
  94428. * @param array array to be set.
  94429. * @returns this effect.
  94430. */
  94431. setFloatArray(uniformName: string, array: Float32Array): Effect;
  94432. /**
  94433. * 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)
  94434. * @param uniformName Name of the variable.
  94435. * @param array array to be set.
  94436. * @returns this effect.
  94437. */
  94438. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  94439. /**
  94440. * 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)
  94441. * @param uniformName Name of the variable.
  94442. * @param array array to be set.
  94443. * @returns this effect.
  94444. */
  94445. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  94446. /**
  94447. * 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)
  94448. * @param uniformName Name of the variable.
  94449. * @param array array to be set.
  94450. * @returns this effect.
  94451. */
  94452. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  94453. /**
  94454. * Sets an array on a uniform variable.
  94455. * @param uniformName Name of the variable.
  94456. * @param array array to be set.
  94457. * @returns this effect.
  94458. */
  94459. setArray(uniformName: string, array: number[]): Effect;
  94460. /**
  94461. * 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)
  94462. * @param uniformName Name of the variable.
  94463. * @param array array to be set.
  94464. * @returns this effect.
  94465. */
  94466. setArray2(uniformName: string, array: number[]): Effect;
  94467. /**
  94468. * 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)
  94469. * @param uniformName Name of the variable.
  94470. * @param array array to be set.
  94471. * @returns this effect.
  94472. */
  94473. setArray3(uniformName: string, array: number[]): Effect;
  94474. /**
  94475. * 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)
  94476. * @param uniformName Name of the variable.
  94477. * @param array array to be set.
  94478. * @returns this effect.
  94479. */
  94480. setArray4(uniformName: string, array: number[]): Effect;
  94481. /**
  94482. * Sets matrices on a uniform variable.
  94483. * @param uniformName Name of the variable.
  94484. * @param matrices matrices to be set.
  94485. * @returns this effect.
  94486. */
  94487. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  94488. /**
  94489. * Sets matrix on a uniform variable.
  94490. * @param uniformName Name of the variable.
  94491. * @param matrix matrix to be set.
  94492. * @returns this effect.
  94493. */
  94494. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  94495. /**
  94496. * 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)
  94497. * @param uniformName Name of the variable.
  94498. * @param matrix matrix to be set.
  94499. * @returns this effect.
  94500. */
  94501. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  94502. /**
  94503. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  94504. * @param uniformName Name of the variable.
  94505. * @param matrix matrix to be set.
  94506. * @returns this effect.
  94507. */
  94508. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  94509. /**
  94510. * Sets a float on a uniform variable.
  94511. * @param uniformName Name of the variable.
  94512. * @param value value to be set.
  94513. * @returns this effect.
  94514. */
  94515. setFloat(uniformName: string, value: number): Effect;
  94516. /**
  94517. * Sets a boolean on a uniform variable.
  94518. * @param uniformName Name of the variable.
  94519. * @param bool value to be set.
  94520. * @returns this effect.
  94521. */
  94522. setBool(uniformName: string, bool: boolean): Effect;
  94523. /**
  94524. * Sets a Vector2 on a uniform variable.
  94525. * @param uniformName Name of the variable.
  94526. * @param vector2 vector2 to be set.
  94527. * @returns this effect.
  94528. */
  94529. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  94530. /**
  94531. * Sets a float2 on a uniform variable.
  94532. * @param uniformName Name of the variable.
  94533. * @param x First float in float2.
  94534. * @param y Second float in float2.
  94535. * @returns this effect.
  94536. */
  94537. setFloat2(uniformName: string, x: number, y: number): Effect;
  94538. /**
  94539. * Sets a Vector3 on a uniform variable.
  94540. * @param uniformName Name of the variable.
  94541. * @param vector3 Value to be set.
  94542. * @returns this effect.
  94543. */
  94544. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  94545. /**
  94546. * Sets a float3 on a uniform variable.
  94547. * @param uniformName Name of the variable.
  94548. * @param x First float in float3.
  94549. * @param y Second float in float3.
  94550. * @param z Third float in float3.
  94551. * @returns this effect.
  94552. */
  94553. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  94554. /**
  94555. * Sets a Vector4 on a uniform variable.
  94556. * @param uniformName Name of the variable.
  94557. * @param vector4 Value to be set.
  94558. * @returns this effect.
  94559. */
  94560. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  94561. /**
  94562. * Sets a float4 on a uniform variable.
  94563. * @param uniformName Name of the variable.
  94564. * @param x First float in float4.
  94565. * @param y Second float in float4.
  94566. * @param z Third float in float4.
  94567. * @param w Fourth float in float4.
  94568. * @returns this effect.
  94569. */
  94570. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  94571. /**
  94572. * Sets a Color3 on a uniform variable.
  94573. * @param uniformName Name of the variable.
  94574. * @param color3 Value to be set.
  94575. * @returns this effect.
  94576. */
  94577. setColor3(uniformName: string, color3: IColor3Like): Effect;
  94578. /**
  94579. * Sets a Color4 on a uniform variable.
  94580. * @param uniformName Name of the variable.
  94581. * @param color3 Value to be set.
  94582. * @param alpha Alpha value to be set.
  94583. * @returns this effect.
  94584. */
  94585. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  94586. /**
  94587. * Sets a Color4 on a uniform variable
  94588. * @param uniformName defines the name of the variable
  94589. * @param color4 defines the value to be set
  94590. * @returns this effect.
  94591. */
  94592. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  94593. /** Release all associated resources */
  94594. dispose(): void;
  94595. /**
  94596. * This function will add a new shader to the shader store
  94597. * @param name the name of the shader
  94598. * @param pixelShader optional pixel shader content
  94599. * @param vertexShader optional vertex shader content
  94600. */
  94601. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  94602. /**
  94603. * Store of each shader (The can be looked up using effect.key)
  94604. */
  94605. static ShadersStore: {
  94606. [key: string]: string;
  94607. };
  94608. /**
  94609. * Store of each included file for a shader (The can be looked up using effect.key)
  94610. */
  94611. static IncludesShadersStore: {
  94612. [key: string]: string;
  94613. };
  94614. /**
  94615. * Resets the cache of effects.
  94616. */
  94617. static ResetCache(): void;
  94618. }
  94619. }
  94620. declare module BABYLON {
  94621. /**
  94622. * Uniform buffer objects.
  94623. *
  94624. * Handles blocks of uniform on the GPU.
  94625. *
  94626. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  94627. *
  94628. * For more information, please refer to :
  94629. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  94630. */
  94631. export class UniformBuffer {
  94632. private _engine;
  94633. private _buffer;
  94634. private _data;
  94635. private _bufferData;
  94636. private _dynamic?;
  94637. private _uniformLocations;
  94638. private _uniformSizes;
  94639. private _uniformLocationPointer;
  94640. private _needSync;
  94641. private _noUBO;
  94642. private _currentEffect;
  94643. private static _MAX_UNIFORM_SIZE;
  94644. private static _tempBuffer;
  94645. /**
  94646. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  94647. * This is dynamic to allow compat with webgl 1 and 2.
  94648. * You will need to pass the name of the uniform as well as the value.
  94649. */
  94650. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  94651. /**
  94652. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  94653. * This is dynamic to allow compat with webgl 1 and 2.
  94654. * You will need to pass the name of the uniform as well as the value.
  94655. */
  94656. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  94657. /**
  94658. * Lambda to Update a single float in a uniform buffer.
  94659. * This is dynamic to allow compat with webgl 1 and 2.
  94660. * You will need to pass the name of the uniform as well as the value.
  94661. */
  94662. updateFloat: (name: string, x: number) => void;
  94663. /**
  94664. * Lambda to Update a vec2 of float in a uniform buffer.
  94665. * This is dynamic to allow compat with webgl 1 and 2.
  94666. * You will need to pass the name of the uniform as well as the value.
  94667. */
  94668. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  94669. /**
  94670. * Lambda to Update a vec3 of float in a uniform buffer.
  94671. * This is dynamic to allow compat with webgl 1 and 2.
  94672. * You will need to pass the name of the uniform as well as the value.
  94673. */
  94674. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  94675. /**
  94676. * Lambda to Update a vec4 of float in a uniform buffer.
  94677. * This is dynamic to allow compat with webgl 1 and 2.
  94678. * You will need to pass the name of the uniform as well as the value.
  94679. */
  94680. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  94681. /**
  94682. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  94683. * This is dynamic to allow compat with webgl 1 and 2.
  94684. * You will need to pass the name of the uniform as well as the value.
  94685. */
  94686. updateMatrix: (name: string, mat: Matrix) => void;
  94687. /**
  94688. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  94689. * This is dynamic to allow compat with webgl 1 and 2.
  94690. * You will need to pass the name of the uniform as well as the value.
  94691. */
  94692. updateVector3: (name: string, vector: Vector3) => void;
  94693. /**
  94694. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  94695. * This is dynamic to allow compat with webgl 1 and 2.
  94696. * You will need to pass the name of the uniform as well as the value.
  94697. */
  94698. updateVector4: (name: string, vector: Vector4) => void;
  94699. /**
  94700. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  94701. * This is dynamic to allow compat with webgl 1 and 2.
  94702. * You will need to pass the name of the uniform as well as the value.
  94703. */
  94704. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  94705. /**
  94706. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  94707. * This is dynamic to allow compat with webgl 1 and 2.
  94708. * You will need to pass the name of the uniform as well as the value.
  94709. */
  94710. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  94711. /**
  94712. * Instantiates a new Uniform buffer objects.
  94713. *
  94714. * Handles blocks of uniform on the GPU.
  94715. *
  94716. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  94717. *
  94718. * For more information, please refer to :
  94719. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  94720. * @param engine Define the engine the buffer is associated with
  94721. * @param data Define the data contained in the buffer
  94722. * @param dynamic Define if the buffer is updatable
  94723. */
  94724. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  94725. /**
  94726. * Indicates if the buffer is using the WebGL2 UBO implementation,
  94727. * or just falling back on setUniformXXX calls.
  94728. */
  94729. readonly useUbo: boolean;
  94730. /**
  94731. * Indicates if the WebGL underlying uniform buffer is in sync
  94732. * with the javascript cache data.
  94733. */
  94734. readonly isSync: boolean;
  94735. /**
  94736. * Indicates if the WebGL underlying uniform buffer is dynamic.
  94737. * Also, a dynamic UniformBuffer will disable cache verification and always
  94738. * update the underlying WebGL uniform buffer to the GPU.
  94739. * @returns if Dynamic, otherwise false
  94740. */
  94741. isDynamic(): boolean;
  94742. /**
  94743. * The data cache on JS side.
  94744. * @returns the underlying data as a float array
  94745. */
  94746. getData(): Float32Array;
  94747. /**
  94748. * The underlying WebGL Uniform buffer.
  94749. * @returns the webgl buffer
  94750. */
  94751. getBuffer(): Nullable<DataBuffer>;
  94752. /**
  94753. * std140 layout specifies how to align data within an UBO structure.
  94754. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  94755. * for specs.
  94756. */
  94757. private _fillAlignment;
  94758. /**
  94759. * Adds an uniform in the buffer.
  94760. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  94761. * for the layout to be correct !
  94762. * @param name Name of the uniform, as used in the uniform block in the shader.
  94763. * @param size Data size, or data directly.
  94764. */
  94765. addUniform(name: string, size: number | number[]): void;
  94766. /**
  94767. * Adds a Matrix 4x4 to the uniform buffer.
  94768. * @param name Name of the uniform, as used in the uniform block in the shader.
  94769. * @param mat A 4x4 matrix.
  94770. */
  94771. addMatrix(name: string, mat: Matrix): void;
  94772. /**
  94773. * Adds a vec2 to the uniform buffer.
  94774. * @param name Name of the uniform, as used in the uniform block in the shader.
  94775. * @param x Define the x component value of the vec2
  94776. * @param y Define the y component value of the vec2
  94777. */
  94778. addFloat2(name: string, x: number, y: number): void;
  94779. /**
  94780. * Adds a vec3 to the uniform buffer.
  94781. * @param name Name of the uniform, as used in the uniform block in the shader.
  94782. * @param x Define the x component value of the vec3
  94783. * @param y Define the y component value of the vec3
  94784. * @param z Define the z component value of the vec3
  94785. */
  94786. addFloat3(name: string, x: number, y: number, z: number): void;
  94787. /**
  94788. * Adds a vec3 to the uniform buffer.
  94789. * @param name Name of the uniform, as used in the uniform block in the shader.
  94790. * @param color Define the vec3 from a Color
  94791. */
  94792. addColor3(name: string, color: Color3): void;
  94793. /**
  94794. * Adds a vec4 to the uniform buffer.
  94795. * @param name Name of the uniform, as used in the uniform block in the shader.
  94796. * @param color Define the rgb components from a Color
  94797. * @param alpha Define the a component of the vec4
  94798. */
  94799. addColor4(name: string, color: Color3, alpha: number): void;
  94800. /**
  94801. * Adds a vec3 to the uniform buffer.
  94802. * @param name Name of the uniform, as used in the uniform block in the shader.
  94803. * @param vector Define the vec3 components from a Vector
  94804. */
  94805. addVector3(name: string, vector: Vector3): void;
  94806. /**
  94807. * Adds a Matrix 3x3 to the uniform buffer.
  94808. * @param name Name of the uniform, as used in the uniform block in the shader.
  94809. */
  94810. addMatrix3x3(name: string): void;
  94811. /**
  94812. * Adds a Matrix 2x2 to the uniform buffer.
  94813. * @param name Name of the uniform, as used in the uniform block in the shader.
  94814. */
  94815. addMatrix2x2(name: string): void;
  94816. /**
  94817. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  94818. */
  94819. create(): void;
  94820. /** @hidden */
  94821. _rebuild(): void;
  94822. /**
  94823. * Updates the WebGL Uniform Buffer on the GPU.
  94824. * If the `dynamic` flag is set to true, no cache comparison is done.
  94825. * Otherwise, the buffer will be updated only if the cache differs.
  94826. */
  94827. update(): void;
  94828. /**
  94829. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  94830. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  94831. * @param data Define the flattened data
  94832. * @param size Define the size of the data.
  94833. */
  94834. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  94835. private _valueCache;
  94836. private _cacheMatrix;
  94837. private _updateMatrix3x3ForUniform;
  94838. private _updateMatrix3x3ForEffect;
  94839. private _updateMatrix2x2ForEffect;
  94840. private _updateMatrix2x2ForUniform;
  94841. private _updateFloatForEffect;
  94842. private _updateFloatForUniform;
  94843. private _updateFloat2ForEffect;
  94844. private _updateFloat2ForUniform;
  94845. private _updateFloat3ForEffect;
  94846. private _updateFloat3ForUniform;
  94847. private _updateFloat4ForEffect;
  94848. private _updateFloat4ForUniform;
  94849. private _updateMatrixForEffect;
  94850. private _updateMatrixForUniform;
  94851. private _updateVector3ForEffect;
  94852. private _updateVector3ForUniform;
  94853. private _updateVector4ForEffect;
  94854. private _updateVector4ForUniform;
  94855. private _updateColor3ForEffect;
  94856. private _updateColor3ForUniform;
  94857. private _updateColor4ForEffect;
  94858. private _updateColor4ForUniform;
  94859. /**
  94860. * Sets a sampler uniform on the effect.
  94861. * @param name Define the name of the sampler.
  94862. * @param texture Define the texture to set in the sampler
  94863. */
  94864. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  94865. /**
  94866. * Directly updates the value of the uniform in the cache AND on the GPU.
  94867. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  94868. * @param data Define the flattened data
  94869. */
  94870. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  94871. /**
  94872. * Binds this uniform buffer to an effect.
  94873. * @param effect Define the effect to bind the buffer to
  94874. * @param name Name of the uniform block in the shader.
  94875. */
  94876. bindToEffect(effect: Effect, name: string): void;
  94877. /**
  94878. * Disposes the uniform buffer.
  94879. */
  94880. dispose(): void;
  94881. }
  94882. }
  94883. declare module BABYLON {
  94884. /**
  94885. * Class used to work with sound analyzer using fast fourier transform (FFT)
  94886. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94887. */
  94888. export class Analyser {
  94889. /**
  94890. * Gets or sets the smoothing
  94891. * @ignorenaming
  94892. */
  94893. SMOOTHING: number;
  94894. /**
  94895. * Gets or sets the FFT table size
  94896. * @ignorenaming
  94897. */
  94898. FFT_SIZE: number;
  94899. /**
  94900. * Gets or sets the bar graph amplitude
  94901. * @ignorenaming
  94902. */
  94903. BARGRAPHAMPLITUDE: number;
  94904. /**
  94905. * Gets or sets the position of the debug canvas
  94906. * @ignorenaming
  94907. */
  94908. DEBUGCANVASPOS: {
  94909. x: number;
  94910. y: number;
  94911. };
  94912. /**
  94913. * Gets or sets the debug canvas size
  94914. * @ignorenaming
  94915. */
  94916. DEBUGCANVASSIZE: {
  94917. width: number;
  94918. height: number;
  94919. };
  94920. private _byteFreqs;
  94921. private _byteTime;
  94922. private _floatFreqs;
  94923. private _webAudioAnalyser;
  94924. private _debugCanvas;
  94925. private _debugCanvasContext;
  94926. private _scene;
  94927. private _registerFunc;
  94928. private _audioEngine;
  94929. /**
  94930. * Creates a new analyser
  94931. * @param scene defines hosting scene
  94932. */
  94933. constructor(scene: Scene);
  94934. /**
  94935. * Get the number of data values you will have to play with for the visualization
  94936. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  94937. * @returns a number
  94938. */
  94939. getFrequencyBinCount(): number;
  94940. /**
  94941. * Gets the current frequency data as a byte array
  94942. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  94943. * @returns a Uint8Array
  94944. */
  94945. getByteFrequencyData(): Uint8Array;
  94946. /**
  94947. * Gets the current waveform as a byte array
  94948. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  94949. * @returns a Uint8Array
  94950. */
  94951. getByteTimeDomainData(): Uint8Array;
  94952. /**
  94953. * Gets the current frequency data as a float array
  94954. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  94955. * @returns a Float32Array
  94956. */
  94957. getFloatFrequencyData(): Float32Array;
  94958. /**
  94959. * Renders the debug canvas
  94960. */
  94961. drawDebugCanvas(): void;
  94962. /**
  94963. * Stops rendering the debug canvas and removes it
  94964. */
  94965. stopDebugCanvas(): void;
  94966. /**
  94967. * Connects two audio nodes
  94968. * @param inputAudioNode defines first node to connect
  94969. * @param outputAudioNode defines second node to connect
  94970. */
  94971. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  94972. /**
  94973. * Releases all associated resources
  94974. */
  94975. dispose(): void;
  94976. }
  94977. }
  94978. declare module BABYLON {
  94979. /**
  94980. * This represents an audio engine and it is responsible
  94981. * to play, synchronize and analyse sounds throughout the application.
  94982. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94983. */
  94984. export interface IAudioEngine extends IDisposable {
  94985. /**
  94986. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  94987. */
  94988. readonly canUseWebAudio: boolean;
  94989. /**
  94990. * Gets the current AudioContext if available.
  94991. */
  94992. readonly audioContext: Nullable<AudioContext>;
  94993. /**
  94994. * The master gain node defines the global audio volume of your audio engine.
  94995. */
  94996. readonly masterGain: GainNode;
  94997. /**
  94998. * Gets whether or not mp3 are supported by your browser.
  94999. */
  95000. readonly isMP3supported: boolean;
  95001. /**
  95002. * Gets whether or not ogg are supported by your browser.
  95003. */
  95004. readonly isOGGsupported: boolean;
  95005. /**
  95006. * Defines if Babylon should emit a warning if WebAudio is not supported.
  95007. * @ignoreNaming
  95008. */
  95009. WarnedWebAudioUnsupported: boolean;
  95010. /**
  95011. * Defines if the audio engine relies on a custom unlocked button.
  95012. * In this case, the embedded button will not be displayed.
  95013. */
  95014. useCustomUnlockedButton: boolean;
  95015. /**
  95016. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  95017. */
  95018. readonly unlocked: boolean;
  95019. /**
  95020. * Event raised when audio has been unlocked on the browser.
  95021. */
  95022. onAudioUnlockedObservable: Observable<AudioEngine>;
  95023. /**
  95024. * Event raised when audio has been locked on the browser.
  95025. */
  95026. onAudioLockedObservable: Observable<AudioEngine>;
  95027. /**
  95028. * Flags the audio engine in Locked state.
  95029. * This happens due to new browser policies preventing audio to autoplay.
  95030. */
  95031. lock(): void;
  95032. /**
  95033. * Unlocks the audio engine once a user action has been done on the dom.
  95034. * This is helpful to resume play once browser policies have been satisfied.
  95035. */
  95036. unlock(): void;
  95037. }
  95038. /**
  95039. * This represents the default audio engine used in babylon.
  95040. * It is responsible to play, synchronize and analyse sounds throughout the application.
  95041. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  95042. */
  95043. export class AudioEngine implements IAudioEngine {
  95044. private _audioContext;
  95045. private _audioContextInitialized;
  95046. private _muteButton;
  95047. private _hostElement;
  95048. /**
  95049. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  95050. */
  95051. canUseWebAudio: boolean;
  95052. /**
  95053. * The master gain node defines the global audio volume of your audio engine.
  95054. */
  95055. masterGain: GainNode;
  95056. /**
  95057. * Defines if Babylon should emit a warning if WebAudio is not supported.
  95058. * @ignoreNaming
  95059. */
  95060. WarnedWebAudioUnsupported: boolean;
  95061. /**
  95062. * Gets whether or not mp3 are supported by your browser.
  95063. */
  95064. isMP3supported: boolean;
  95065. /**
  95066. * Gets whether or not ogg are supported by your browser.
  95067. */
  95068. isOGGsupported: boolean;
  95069. /**
  95070. * Gets whether audio has been unlocked on the device.
  95071. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  95072. * a user interaction has happened.
  95073. */
  95074. unlocked: boolean;
  95075. /**
  95076. * Defines if the audio engine relies on a custom unlocked button.
  95077. * In this case, the embedded button will not be displayed.
  95078. */
  95079. useCustomUnlockedButton: boolean;
  95080. /**
  95081. * Event raised when audio has been unlocked on the browser.
  95082. */
  95083. onAudioUnlockedObservable: Observable<AudioEngine>;
  95084. /**
  95085. * Event raised when audio has been locked on the browser.
  95086. */
  95087. onAudioLockedObservable: Observable<AudioEngine>;
  95088. /**
  95089. * Gets the current AudioContext if available.
  95090. */
  95091. readonly audioContext: Nullable<AudioContext>;
  95092. private _connectedAnalyser;
  95093. /**
  95094. * Instantiates a new audio engine.
  95095. *
  95096. * There should be only one per page as some browsers restrict the number
  95097. * of audio contexts you can create.
  95098. * @param hostElement defines the host element where to display the mute icon if necessary
  95099. */
  95100. constructor(hostElement?: Nullable<HTMLElement>);
  95101. /**
  95102. * Flags the audio engine in Locked state.
  95103. * This happens due to new browser policies preventing audio to autoplay.
  95104. */
  95105. lock(): void;
  95106. /**
  95107. * Unlocks the audio engine once a user action has been done on the dom.
  95108. * This is helpful to resume play once browser policies have been satisfied.
  95109. */
  95110. unlock(): void;
  95111. private _resumeAudioContext;
  95112. private _initializeAudioContext;
  95113. private _tryToRun;
  95114. private _triggerRunningState;
  95115. private _triggerSuspendedState;
  95116. private _displayMuteButton;
  95117. private _moveButtonToTopLeft;
  95118. private _onResize;
  95119. private _hideMuteButton;
  95120. /**
  95121. * Destroy and release the resources associated with the audio ccontext.
  95122. */
  95123. dispose(): void;
  95124. /**
  95125. * Gets the global volume sets on the master gain.
  95126. * @returns the global volume if set or -1 otherwise
  95127. */
  95128. getGlobalVolume(): number;
  95129. /**
  95130. * Sets the global volume of your experience (sets on the master gain).
  95131. * @param newVolume Defines the new global volume of the application
  95132. */
  95133. setGlobalVolume(newVolume: number): void;
  95134. /**
  95135. * Connect the audio engine to an audio analyser allowing some amazing
  95136. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  95137. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  95138. * @param analyser The analyser to connect to the engine
  95139. */
  95140. connectToAnalyser(analyser: Analyser): void;
  95141. }
  95142. }
  95143. declare module BABYLON {
  95144. /**
  95145. * Interface used to present a loading screen while loading a scene
  95146. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95147. */
  95148. export interface ILoadingScreen {
  95149. /**
  95150. * Function called to display the loading screen
  95151. */
  95152. displayLoadingUI: () => void;
  95153. /**
  95154. * Function called to hide the loading screen
  95155. */
  95156. hideLoadingUI: () => void;
  95157. /**
  95158. * Gets or sets the color to use for the background
  95159. */
  95160. loadingUIBackgroundColor: string;
  95161. /**
  95162. * Gets or sets the text to display while loading
  95163. */
  95164. loadingUIText: string;
  95165. }
  95166. /**
  95167. * Class used for the default loading screen
  95168. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95169. */
  95170. export class DefaultLoadingScreen implements ILoadingScreen {
  95171. private _renderingCanvas;
  95172. private _loadingText;
  95173. private _loadingDivBackgroundColor;
  95174. private _loadingDiv;
  95175. private _loadingTextDiv;
  95176. /** Gets or sets the logo url to use for the default loading screen */
  95177. static DefaultLogoUrl: string;
  95178. /** Gets or sets the spinner url to use for the default loading screen */
  95179. static DefaultSpinnerUrl: string;
  95180. /**
  95181. * Creates a new default loading screen
  95182. * @param _renderingCanvas defines the canvas used to render the scene
  95183. * @param _loadingText defines the default text to display
  95184. * @param _loadingDivBackgroundColor defines the default background color
  95185. */
  95186. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  95187. /**
  95188. * Function called to display the loading screen
  95189. */
  95190. displayLoadingUI(): void;
  95191. /**
  95192. * Function called to hide the loading screen
  95193. */
  95194. hideLoadingUI(): void;
  95195. /**
  95196. * Gets or sets the text to display while loading
  95197. */
  95198. loadingUIText: string;
  95199. /**
  95200. * Gets or sets the color to use for the background
  95201. */
  95202. loadingUIBackgroundColor: string;
  95203. private _resizeLoadingUI;
  95204. }
  95205. }
  95206. declare module BABYLON {
  95207. /** @hidden */
  95208. export class WebGLPipelineContext implements IPipelineContext {
  95209. engine: Engine;
  95210. program: Nullable<WebGLProgram>;
  95211. context?: WebGLRenderingContext;
  95212. vertexShader?: WebGLShader;
  95213. fragmentShader?: WebGLShader;
  95214. isParallelCompiled: boolean;
  95215. onCompiled?: () => void;
  95216. transformFeedback?: WebGLTransformFeedback | null;
  95217. readonly isAsync: boolean;
  95218. readonly isReady: boolean;
  95219. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  95220. }
  95221. }
  95222. declare module BABYLON {
  95223. /** @hidden */
  95224. export class WebGLDataBuffer extends DataBuffer {
  95225. private _buffer;
  95226. constructor(resource: WebGLBuffer);
  95227. readonly underlyingResource: any;
  95228. }
  95229. }
  95230. declare module BABYLON {
  95231. /** @hidden */
  95232. export class WebGL2ShaderProcessor implements IShaderProcessor {
  95233. attributeProcessor(attribute: string): string;
  95234. varyingProcessor(varying: string, isFragment: boolean): string;
  95235. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  95236. }
  95237. }
  95238. declare module BABYLON {
  95239. /**
  95240. * This class is used to track a performance counter which is number based.
  95241. * The user has access to many properties which give statistics of different nature.
  95242. *
  95243. * The implementer can track two kinds of Performance Counter: time and count.
  95244. * 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.
  95245. * 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.
  95246. */
  95247. export class PerfCounter {
  95248. /**
  95249. * Gets or sets a global boolean to turn on and off all the counters
  95250. */
  95251. static Enabled: boolean;
  95252. /**
  95253. * Returns the smallest value ever
  95254. */
  95255. readonly min: number;
  95256. /**
  95257. * Returns the biggest value ever
  95258. */
  95259. readonly max: number;
  95260. /**
  95261. * Returns the average value since the performance counter is running
  95262. */
  95263. readonly average: number;
  95264. /**
  95265. * Returns the average value of the last second the counter was monitored
  95266. */
  95267. readonly lastSecAverage: number;
  95268. /**
  95269. * Returns the current value
  95270. */
  95271. readonly current: number;
  95272. /**
  95273. * Gets the accumulated total
  95274. */
  95275. readonly total: number;
  95276. /**
  95277. * Gets the total value count
  95278. */
  95279. readonly count: number;
  95280. /**
  95281. * Creates a new counter
  95282. */
  95283. constructor();
  95284. /**
  95285. * Call this method to start monitoring a new frame.
  95286. * 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.
  95287. */
  95288. fetchNewFrame(): void;
  95289. /**
  95290. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  95291. * @param newCount the count value to add to the monitored count
  95292. * @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.
  95293. */
  95294. addCount(newCount: number, fetchResult: boolean): void;
  95295. /**
  95296. * Start monitoring this performance counter
  95297. */
  95298. beginMonitoring(): void;
  95299. /**
  95300. * Compute the time lapsed since the previous beginMonitoring() call.
  95301. * @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
  95302. */
  95303. endMonitoring(newFrame?: boolean): void;
  95304. private _fetchResult;
  95305. private _startMonitoringTime;
  95306. private _min;
  95307. private _max;
  95308. private _average;
  95309. private _current;
  95310. private _totalValueCount;
  95311. private _totalAccumulated;
  95312. private _lastSecAverage;
  95313. private _lastSecAccumulated;
  95314. private _lastSecTime;
  95315. private _lastSecValueCount;
  95316. }
  95317. }
  95318. declare module BABYLON {
  95319. /**
  95320. * Interface for any object that can request an animation frame
  95321. */
  95322. export interface ICustomAnimationFrameRequester {
  95323. /**
  95324. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  95325. */
  95326. renderFunction?: Function;
  95327. /**
  95328. * Called to request the next frame to render to
  95329. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  95330. */
  95331. requestAnimationFrame: Function;
  95332. /**
  95333. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  95334. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  95335. */
  95336. requestID?: number;
  95337. }
  95338. }
  95339. declare module BABYLON {
  95340. /**
  95341. * Settings for finer control over video usage
  95342. */
  95343. export interface VideoTextureSettings {
  95344. /**
  95345. * Applies `autoplay` to video, if specified
  95346. */
  95347. autoPlay?: boolean;
  95348. /**
  95349. * Applies `loop` to video, if specified
  95350. */
  95351. loop?: boolean;
  95352. /**
  95353. * Automatically updates internal texture from video at every frame in the render loop
  95354. */
  95355. autoUpdateTexture: boolean;
  95356. /**
  95357. * Image src displayed during the video loading or until the user interacts with the video.
  95358. */
  95359. poster?: string;
  95360. }
  95361. /**
  95362. * If you want to display a video in your scene, this is the special texture for that.
  95363. * This special texture works similar to other textures, with the exception of a few parameters.
  95364. * @see https://doc.babylonjs.com/how_to/video_texture
  95365. */
  95366. export class VideoTexture extends Texture {
  95367. /**
  95368. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  95369. */
  95370. readonly autoUpdateTexture: boolean;
  95371. /**
  95372. * The video instance used by the texture internally
  95373. */
  95374. readonly video: HTMLVideoElement;
  95375. private _onUserActionRequestedObservable;
  95376. /**
  95377. * Event triggerd when a dom action is required by the user to play the video.
  95378. * This happens due to recent changes in browser policies preventing video to auto start.
  95379. */
  95380. readonly onUserActionRequestedObservable: Observable<Texture>;
  95381. private _generateMipMaps;
  95382. private _engine;
  95383. private _stillImageCaptured;
  95384. private _displayingPosterTexture;
  95385. private _settings;
  95386. private _createInternalTextureOnEvent;
  95387. private _frameId;
  95388. /**
  95389. * Creates a video texture.
  95390. * If you want to display a video in your scene, this is the special texture for that.
  95391. * This special texture works similar to other textures, with the exception of a few parameters.
  95392. * @see https://doc.babylonjs.com/how_to/video_texture
  95393. * @param name optional name, will detect from video source, if not defined
  95394. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  95395. * @param scene is obviously the current scene.
  95396. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  95397. * @param invertY is false by default but can be used to invert video on Y axis
  95398. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  95399. * @param settings allows finer control over video usage
  95400. */
  95401. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  95402. private _getName;
  95403. private _getVideo;
  95404. private _createInternalTexture;
  95405. private reset;
  95406. /**
  95407. * @hidden Internal method to initiate `update`.
  95408. */
  95409. _rebuild(): void;
  95410. /**
  95411. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  95412. */
  95413. update(): void;
  95414. /**
  95415. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  95416. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  95417. */
  95418. updateTexture(isVisible: boolean): void;
  95419. protected _updateInternalTexture: () => void;
  95420. /**
  95421. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  95422. * @param url New url.
  95423. */
  95424. updateURL(url: string): void;
  95425. /**
  95426. * Dispose the texture and release its associated resources.
  95427. */
  95428. dispose(): void;
  95429. /**
  95430. * Creates a video texture straight from a stream.
  95431. * @param scene Define the scene the texture should be created in
  95432. * @param stream Define the stream the texture should be created from
  95433. * @returns The created video texture as a promise
  95434. */
  95435. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  95436. /**
  95437. * Creates a video texture straight from your WebCam video feed.
  95438. * @param scene Define the scene the texture should be created in
  95439. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  95440. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  95441. * @returns The created video texture as a promise
  95442. */
  95443. static CreateFromWebCamAsync(scene: Scene, constraints: {
  95444. minWidth: number;
  95445. maxWidth: number;
  95446. minHeight: number;
  95447. maxHeight: number;
  95448. deviceId: string;
  95449. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  95450. /**
  95451. * Creates a video texture straight from your WebCam video feed.
  95452. * @param scene Define the scene the texture should be created in
  95453. * @param onReady Define a callback to triggered once the texture will be ready
  95454. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  95455. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  95456. */
  95457. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  95458. minWidth: number;
  95459. maxWidth: number;
  95460. minHeight: number;
  95461. maxHeight: number;
  95462. deviceId: string;
  95463. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  95464. }
  95465. }
  95466. declare module BABYLON {
  95467. /**
  95468. * Defines the interface used by objects containing a viewport (like a camera)
  95469. */
  95470. interface IViewportOwnerLike {
  95471. /**
  95472. * Gets or sets the viewport
  95473. */
  95474. viewport: IViewportLike;
  95475. }
  95476. /**
  95477. * Interface for attribute information associated with buffer instanciation
  95478. */
  95479. export class InstancingAttributeInfo {
  95480. /**
  95481. * Index/offset of the attribute in the vertex shader
  95482. */
  95483. index: number;
  95484. /**
  95485. * size of the attribute, 1, 2, 3 or 4
  95486. */
  95487. attributeSize: number;
  95488. /**
  95489. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  95490. * default is FLOAT
  95491. */
  95492. attribyteType: number;
  95493. /**
  95494. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  95495. */
  95496. normalized: boolean;
  95497. /**
  95498. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  95499. */
  95500. offset: number;
  95501. /**
  95502. * Name of the GLSL attribute, for debugging purpose only
  95503. */
  95504. attributeName: string;
  95505. }
  95506. /**
  95507. * Define options used to create a depth texture
  95508. */
  95509. export class DepthTextureCreationOptions {
  95510. /** Specifies whether or not a stencil should be allocated in the texture */
  95511. generateStencil?: boolean;
  95512. /** Specifies whether or not bilinear filtering is enable on the texture */
  95513. bilinearFiltering?: boolean;
  95514. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  95515. comparisonFunction?: number;
  95516. /** Specifies if the created texture is a cube texture */
  95517. isCube?: boolean;
  95518. }
  95519. /**
  95520. * Class used to describe the capabilities of the engine relatively to the current browser
  95521. */
  95522. export class EngineCapabilities {
  95523. /** Maximum textures units per fragment shader */
  95524. maxTexturesImageUnits: number;
  95525. /** Maximum texture units per vertex shader */
  95526. maxVertexTextureImageUnits: number;
  95527. /** Maximum textures units in the entire pipeline */
  95528. maxCombinedTexturesImageUnits: number;
  95529. /** Maximum texture size */
  95530. maxTextureSize: number;
  95531. /** Maximum cube texture size */
  95532. maxCubemapTextureSize: number;
  95533. /** Maximum render texture size */
  95534. maxRenderTextureSize: number;
  95535. /** Maximum number of vertex attributes */
  95536. maxVertexAttribs: number;
  95537. /** Maximum number of varyings */
  95538. maxVaryingVectors: number;
  95539. /** Maximum number of uniforms per vertex shader */
  95540. maxVertexUniformVectors: number;
  95541. /** Maximum number of uniforms per fragment shader */
  95542. maxFragmentUniformVectors: number;
  95543. /** Defines if standard derivates (dx/dy) are supported */
  95544. standardDerivatives: boolean;
  95545. /** Defines if s3tc texture compression is supported */
  95546. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  95547. /** Defines if pvrtc texture compression is supported */
  95548. pvrtc: any;
  95549. /** Defines if etc1 texture compression is supported */
  95550. etc1: any;
  95551. /** Defines if etc2 texture compression is supported */
  95552. etc2: any;
  95553. /** Defines if astc texture compression is supported */
  95554. astc: any;
  95555. /** Defines if float textures are supported */
  95556. textureFloat: boolean;
  95557. /** Defines if vertex array objects are supported */
  95558. vertexArrayObject: boolean;
  95559. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  95560. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  95561. /** Gets the maximum level of anisotropy supported */
  95562. maxAnisotropy: number;
  95563. /** Defines if instancing is supported */
  95564. instancedArrays: boolean;
  95565. /** Defines if 32 bits indices are supported */
  95566. uintIndices: boolean;
  95567. /** Defines if high precision shaders are supported */
  95568. highPrecisionShaderSupported: boolean;
  95569. /** Defines if depth reading in the fragment shader is supported */
  95570. fragmentDepthSupported: boolean;
  95571. /** Defines if float texture linear filtering is supported*/
  95572. textureFloatLinearFiltering: boolean;
  95573. /** Defines if rendering to float textures is supported */
  95574. textureFloatRender: boolean;
  95575. /** Defines if half float textures are supported*/
  95576. textureHalfFloat: boolean;
  95577. /** Defines if half float texture linear filtering is supported*/
  95578. textureHalfFloatLinearFiltering: boolean;
  95579. /** Defines if rendering to half float textures is supported */
  95580. textureHalfFloatRender: boolean;
  95581. /** Defines if textureLOD shader command is supported */
  95582. textureLOD: boolean;
  95583. /** Defines if draw buffers extension is supported */
  95584. drawBuffersExtension: boolean;
  95585. /** Defines if depth textures are supported */
  95586. depthTextureExtension: boolean;
  95587. /** Defines if float color buffer are supported */
  95588. colorBufferFloat: boolean;
  95589. /** Gets disjoint timer query extension (null if not supported) */
  95590. timerQuery: EXT_disjoint_timer_query;
  95591. /** Defines if timestamp can be used with timer query */
  95592. canUseTimestampForTimerQuery: boolean;
  95593. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  95594. multiview: any;
  95595. /** Function used to let the system compiles shaders in background */
  95596. parallelShaderCompile: {
  95597. COMPLETION_STATUS_KHR: number;
  95598. };
  95599. /** Max number of texture samples for MSAA */
  95600. maxMSAASamples: number;
  95601. }
  95602. /** Interface defining initialization parameters for Engine class */
  95603. export interface EngineOptions extends WebGLContextAttributes {
  95604. /**
  95605. * Defines if the engine should no exceed a specified device ratio
  95606. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  95607. */
  95608. limitDeviceRatio?: number;
  95609. /**
  95610. * Defines if webvr should be enabled automatically
  95611. * @see http://doc.babylonjs.com/how_to/webvr_camera
  95612. */
  95613. autoEnableWebVR?: boolean;
  95614. /**
  95615. * Defines if webgl2 should be turned off even if supported
  95616. * @see http://doc.babylonjs.com/features/webgl2
  95617. */
  95618. disableWebGL2Support?: boolean;
  95619. /**
  95620. * Defines if webaudio should be initialized as well
  95621. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  95622. */
  95623. audioEngine?: boolean;
  95624. /**
  95625. * Defines if animations should run using a deterministic lock step
  95626. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95627. */
  95628. deterministicLockstep?: boolean;
  95629. /** Defines the maximum steps to use with deterministic lock step mode */
  95630. lockstepMaxSteps?: number;
  95631. /**
  95632. * Defines that engine should ignore context lost events
  95633. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  95634. */
  95635. doNotHandleContextLost?: boolean;
  95636. /**
  95637. * Defines that engine should ignore modifying touch action attribute and style
  95638. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  95639. */
  95640. doNotHandleTouchAction?: boolean;
  95641. /**
  95642. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  95643. */
  95644. useHighPrecisionFloats?: boolean;
  95645. }
  95646. /**
  95647. * Defines the interface used by display changed events
  95648. */
  95649. export interface IDisplayChangedEventArgs {
  95650. /** Gets the vrDisplay object (if any) */
  95651. vrDisplay: Nullable<any>;
  95652. /** Gets a boolean indicating if webVR is supported */
  95653. vrSupported: boolean;
  95654. }
  95655. /**
  95656. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  95657. */
  95658. export class Engine {
  95659. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  95660. static ExceptionList: ({
  95661. key: string;
  95662. capture: string;
  95663. captureConstraint: number;
  95664. targets: string[];
  95665. } | {
  95666. key: string;
  95667. capture: null;
  95668. captureConstraint: null;
  95669. targets: string[];
  95670. })[];
  95671. /** Gets the list of created engines */
  95672. static readonly Instances: Engine[];
  95673. /**
  95674. * Gets the latest created engine
  95675. */
  95676. static readonly LastCreatedEngine: Nullable<Engine>;
  95677. /**
  95678. * Gets the latest created scene
  95679. */
  95680. static readonly LastCreatedScene: Nullable<Scene>;
  95681. /**
  95682. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  95683. * @param flag defines which part of the materials must be marked as dirty
  95684. * @param predicate defines a predicate used to filter which materials should be affected
  95685. */
  95686. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  95687. /** @hidden */
  95688. static _TextureLoaders: IInternalTextureLoader[];
  95689. /** Defines that alpha blending is disabled */
  95690. static readonly ALPHA_DISABLE: number;
  95691. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  95692. static readonly ALPHA_ADD: number;
  95693. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  95694. static readonly ALPHA_COMBINE: number;
  95695. /** Defines that alpha blending to DEST - SRC * DEST */
  95696. static readonly ALPHA_SUBTRACT: number;
  95697. /** Defines that alpha blending to SRC * DEST */
  95698. static readonly ALPHA_MULTIPLY: number;
  95699. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  95700. static readonly ALPHA_MAXIMIZED: number;
  95701. /** Defines that alpha blending to SRC + DEST */
  95702. static readonly ALPHA_ONEONE: number;
  95703. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  95704. static readonly ALPHA_PREMULTIPLIED: number;
  95705. /**
  95706. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  95707. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  95708. */
  95709. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  95710. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  95711. static readonly ALPHA_INTERPOLATE: number;
  95712. /**
  95713. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  95714. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  95715. */
  95716. static readonly ALPHA_SCREENMODE: number;
  95717. /** Defines that the ressource is not delayed*/
  95718. static readonly DELAYLOADSTATE_NONE: number;
  95719. /** Defines that the ressource was successfully delay loaded */
  95720. static readonly DELAYLOADSTATE_LOADED: number;
  95721. /** Defines that the ressource is currently delay loading */
  95722. static readonly DELAYLOADSTATE_LOADING: number;
  95723. /** Defines that the ressource is delayed and has not started loading */
  95724. static readonly DELAYLOADSTATE_NOTLOADED: number;
  95725. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  95726. static readonly NEVER: number;
  95727. /** 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 */
  95728. static readonly ALWAYS: number;
  95729. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  95730. static readonly LESS: number;
  95731. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  95732. static readonly EQUAL: number;
  95733. /** 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 */
  95734. static readonly LEQUAL: number;
  95735. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  95736. static readonly GREATER: number;
  95737. /** 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 */
  95738. static readonly GEQUAL: number;
  95739. /** 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 */
  95740. static readonly NOTEQUAL: number;
  95741. /** Passed to stencilOperation to specify that stencil value must be kept */
  95742. static readonly KEEP: number;
  95743. /** Passed to stencilOperation to specify that stencil value must be replaced */
  95744. static readonly REPLACE: number;
  95745. /** Passed to stencilOperation to specify that stencil value must be incremented */
  95746. static readonly INCR: number;
  95747. /** Passed to stencilOperation to specify that stencil value must be decremented */
  95748. static readonly DECR: number;
  95749. /** Passed to stencilOperation to specify that stencil value must be inverted */
  95750. static readonly INVERT: number;
  95751. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  95752. static readonly INCR_WRAP: number;
  95753. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  95754. static readonly DECR_WRAP: number;
  95755. /** Texture is not repeating outside of 0..1 UVs */
  95756. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  95757. /** Texture is repeating outside of 0..1 UVs */
  95758. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  95759. /** Texture is repeating and mirrored */
  95760. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  95761. /** ALPHA */
  95762. static readonly TEXTUREFORMAT_ALPHA: number;
  95763. /** LUMINANCE */
  95764. static readonly TEXTUREFORMAT_LUMINANCE: number;
  95765. /** LUMINANCE_ALPHA */
  95766. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  95767. /** RGB */
  95768. static readonly TEXTUREFORMAT_RGB: number;
  95769. /** RGBA */
  95770. static readonly TEXTUREFORMAT_RGBA: number;
  95771. /** RED */
  95772. static readonly TEXTUREFORMAT_RED: number;
  95773. /** RED (2nd reference) */
  95774. static readonly TEXTUREFORMAT_R: number;
  95775. /** RG */
  95776. static readonly TEXTUREFORMAT_RG: number;
  95777. /** RED_INTEGER */
  95778. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  95779. /** RED_INTEGER (2nd reference) */
  95780. static readonly TEXTUREFORMAT_R_INTEGER: number;
  95781. /** RG_INTEGER */
  95782. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  95783. /** RGB_INTEGER */
  95784. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  95785. /** RGBA_INTEGER */
  95786. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  95787. /** UNSIGNED_BYTE */
  95788. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  95789. /** UNSIGNED_BYTE (2nd reference) */
  95790. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  95791. /** FLOAT */
  95792. static readonly TEXTURETYPE_FLOAT: number;
  95793. /** HALF_FLOAT */
  95794. static readonly TEXTURETYPE_HALF_FLOAT: number;
  95795. /** BYTE */
  95796. static readonly TEXTURETYPE_BYTE: number;
  95797. /** SHORT */
  95798. static readonly TEXTURETYPE_SHORT: number;
  95799. /** UNSIGNED_SHORT */
  95800. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  95801. /** INT */
  95802. static readonly TEXTURETYPE_INT: number;
  95803. /** UNSIGNED_INT */
  95804. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  95805. /** UNSIGNED_SHORT_4_4_4_4 */
  95806. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  95807. /** UNSIGNED_SHORT_5_5_5_1 */
  95808. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  95809. /** UNSIGNED_SHORT_5_6_5 */
  95810. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  95811. /** UNSIGNED_INT_2_10_10_10_REV */
  95812. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  95813. /** UNSIGNED_INT_24_8 */
  95814. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  95815. /** UNSIGNED_INT_10F_11F_11F_REV */
  95816. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  95817. /** UNSIGNED_INT_5_9_9_9_REV */
  95818. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  95819. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  95820. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  95821. /** nearest is mag = nearest and min = nearest and mip = linear */
  95822. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  95823. /** Bilinear is mag = linear and min = linear and mip = nearest */
  95824. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  95825. /** Trilinear is mag = linear and min = linear and mip = linear */
  95826. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  95827. /** nearest is mag = nearest and min = nearest and mip = linear */
  95828. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  95829. /** Bilinear is mag = linear and min = linear and mip = nearest */
  95830. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  95831. /** Trilinear is mag = linear and min = linear and mip = linear */
  95832. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  95833. /** mag = nearest and min = nearest and mip = nearest */
  95834. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  95835. /** mag = nearest and min = linear and mip = nearest */
  95836. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  95837. /** mag = nearest and min = linear and mip = linear */
  95838. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  95839. /** mag = nearest and min = linear and mip = none */
  95840. static readonly TEXTURE_NEAREST_LINEAR: number;
  95841. /** mag = nearest and min = nearest and mip = none */
  95842. static readonly TEXTURE_NEAREST_NEAREST: number;
  95843. /** mag = linear and min = nearest and mip = nearest */
  95844. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  95845. /** mag = linear and min = nearest and mip = linear */
  95846. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  95847. /** mag = linear and min = linear and mip = none */
  95848. static readonly TEXTURE_LINEAR_LINEAR: number;
  95849. /** mag = linear and min = nearest and mip = none */
  95850. static readonly TEXTURE_LINEAR_NEAREST: number;
  95851. /** Explicit coordinates mode */
  95852. static readonly TEXTURE_EXPLICIT_MODE: number;
  95853. /** Spherical coordinates mode */
  95854. static readonly TEXTURE_SPHERICAL_MODE: number;
  95855. /** Planar coordinates mode */
  95856. static readonly TEXTURE_PLANAR_MODE: number;
  95857. /** Cubic coordinates mode */
  95858. static readonly TEXTURE_CUBIC_MODE: number;
  95859. /** Projection coordinates mode */
  95860. static readonly TEXTURE_PROJECTION_MODE: number;
  95861. /** Skybox coordinates mode */
  95862. static readonly TEXTURE_SKYBOX_MODE: number;
  95863. /** Inverse Cubic coordinates mode */
  95864. static readonly TEXTURE_INVCUBIC_MODE: number;
  95865. /** Equirectangular coordinates mode */
  95866. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  95867. /** Equirectangular Fixed coordinates mode */
  95868. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  95869. /** Equirectangular Fixed Mirrored coordinates mode */
  95870. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  95871. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  95872. static readonly SCALEMODE_FLOOR: number;
  95873. /** Defines that texture rescaling will look for the nearest power of 2 size */
  95874. static readonly SCALEMODE_NEAREST: number;
  95875. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  95876. static readonly SCALEMODE_CEILING: number;
  95877. /**
  95878. * Returns the current npm package of the sdk
  95879. */
  95880. static readonly NpmPackage: string;
  95881. /**
  95882. * Returns the current version of the framework
  95883. */
  95884. static readonly Version: string;
  95885. /**
  95886. * Returns a string describing the current engine
  95887. */
  95888. readonly description: string;
  95889. /**
  95890. * Gets or sets the epsilon value used by collision engine
  95891. */
  95892. static CollisionsEpsilon: number;
  95893. /**
  95894. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  95895. */
  95896. static ShadersRepository: string;
  95897. /**
  95898. * Method called to create the default loading screen.
  95899. * This can be overriden in your own app.
  95900. * @param canvas The rendering canvas element
  95901. * @returns The loading screen
  95902. */
  95903. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  95904. /**
  95905. * Method called to create the default rescale post process on each engine.
  95906. */
  95907. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  95908. /** @hidden */
  95909. _shaderProcessor: IShaderProcessor;
  95910. /**
  95911. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  95912. */
  95913. forcePOTTextures: boolean;
  95914. /**
  95915. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  95916. */
  95917. isFullscreen: boolean;
  95918. /**
  95919. * Gets a boolean indicating if the pointer is currently locked
  95920. */
  95921. isPointerLock: boolean;
  95922. /**
  95923. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  95924. */
  95925. cullBackFaces: boolean;
  95926. /**
  95927. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  95928. */
  95929. renderEvenInBackground: boolean;
  95930. /**
  95931. * Gets or sets a boolean indicating that cache can be kept between frames
  95932. */
  95933. preventCacheWipeBetweenFrames: boolean;
  95934. /**
  95935. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  95936. **/
  95937. enableOfflineSupport: boolean;
  95938. /**
  95939. * 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)
  95940. **/
  95941. disableManifestCheck: boolean;
  95942. /**
  95943. * Gets the list of created scenes
  95944. */
  95945. scenes: Scene[];
  95946. /**
  95947. * Event raised when a new scene is created
  95948. */
  95949. onNewSceneAddedObservable: Observable<Scene>;
  95950. /**
  95951. * Gets the list of created postprocesses
  95952. */
  95953. postProcesses: PostProcess[];
  95954. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  95955. validateShaderPrograms: boolean;
  95956. /**
  95957. * Observable event triggered each time the rendering canvas is resized
  95958. */
  95959. onResizeObservable: Observable<Engine>;
  95960. /**
  95961. * Observable event triggered each time the canvas loses focus
  95962. */
  95963. onCanvasBlurObservable: Observable<Engine>;
  95964. /**
  95965. * Observable event triggered each time the canvas gains focus
  95966. */
  95967. onCanvasFocusObservable: Observable<Engine>;
  95968. /**
  95969. * Observable event triggered each time the canvas receives pointerout event
  95970. */
  95971. onCanvasPointerOutObservable: Observable<PointerEvent>;
  95972. /**
  95973. * Observable event triggered before each texture is initialized
  95974. */
  95975. onBeforeTextureInitObservable: Observable<Texture>;
  95976. /**
  95977. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  95978. */
  95979. disableUniformBuffers: boolean;
  95980. /** @hidden */
  95981. _uniformBuffers: UniformBuffer[];
  95982. /**
  95983. * Gets a boolean indicating that the engine supports uniform buffers
  95984. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  95985. */
  95986. readonly supportsUniformBuffers: boolean;
  95987. /**
  95988. * Observable raised when the engine begins a new frame
  95989. */
  95990. onBeginFrameObservable: Observable<Engine>;
  95991. /**
  95992. * If set, will be used to request the next animation frame for the render loop
  95993. */
  95994. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  95995. /**
  95996. * Observable raised when the engine ends the current frame
  95997. */
  95998. onEndFrameObservable: Observable<Engine>;
  95999. /**
  96000. * Observable raised when the engine is about to compile a shader
  96001. */
  96002. onBeforeShaderCompilationObservable: Observable<Engine>;
  96003. /**
  96004. * Observable raised when the engine has jsut compiled a shader
  96005. */
  96006. onAfterShaderCompilationObservable: Observable<Engine>;
  96007. /** @hidden */
  96008. _gl: WebGLRenderingContext;
  96009. private _renderingCanvas;
  96010. private _windowIsBackground;
  96011. protected _webGLVersion: number;
  96012. protected _highPrecisionShadersAllowed: boolean;
  96013. /** @hidden */
  96014. readonly _shouldUseHighPrecisionShader: boolean;
  96015. /**
  96016. * Gets a boolean indicating that only power of 2 textures are supported
  96017. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  96018. */
  96019. readonly needPOTTextures: boolean;
  96020. /** @hidden */
  96021. _badOS: boolean;
  96022. /** @hidden */
  96023. _badDesktopOS: boolean;
  96024. /**
  96025. * Gets the audio engine
  96026. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  96027. * @ignorenaming
  96028. */
  96029. static audioEngine: IAudioEngine;
  96030. /**
  96031. * Default AudioEngine factory responsible of creating the Audio Engine.
  96032. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  96033. */
  96034. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  96035. /**
  96036. * Default offline support factory responsible of creating a tool used to store data locally.
  96037. * By default, this will create a Database object if the workload has been embedded.
  96038. */
  96039. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  96040. private _onFocus;
  96041. private _onBlur;
  96042. private _onCanvasPointerOut;
  96043. private _onCanvasBlur;
  96044. private _onCanvasFocus;
  96045. private _onFullscreenChange;
  96046. private _onPointerLockChange;
  96047. private _hardwareScalingLevel;
  96048. /** @hidden */
  96049. _caps: EngineCapabilities;
  96050. private _pointerLockRequested;
  96051. private _isStencilEnable;
  96052. protected _colorWrite: boolean;
  96053. private _loadingScreen;
  96054. /** @hidden */
  96055. _drawCalls: PerfCounter;
  96056. private _glVersion;
  96057. private _glRenderer;
  96058. private _glVendor;
  96059. private _videoTextureSupported;
  96060. private _renderingQueueLaunched;
  96061. private _activeRenderLoops;
  96062. private _deterministicLockstep;
  96063. private _lockstepMaxSteps;
  96064. /**
  96065. * Observable signaled when a context lost event is raised
  96066. */
  96067. onContextLostObservable: Observable<Engine>;
  96068. /**
  96069. * Observable signaled when a context restored event is raised
  96070. */
  96071. onContextRestoredObservable: Observable<Engine>;
  96072. private _onContextLost;
  96073. private _onContextRestored;
  96074. private _contextWasLost;
  96075. /** @hidden */
  96076. _doNotHandleContextLost: boolean;
  96077. /**
  96078. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  96079. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  96080. */
  96081. doNotHandleContextLost: boolean;
  96082. private _performanceMonitor;
  96083. private _fps;
  96084. private _deltaTime;
  96085. /**
  96086. * Turn this value on if you want to pause FPS computation when in background
  96087. */
  96088. disablePerformanceMonitorInBackground: boolean;
  96089. /**
  96090. * Gets the performance monitor attached to this engine
  96091. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  96092. */
  96093. readonly performanceMonitor: PerformanceMonitor;
  96094. /**
  96095. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  96096. */
  96097. disableVertexArrayObjects: boolean;
  96098. /** @hidden */
  96099. protected _depthCullingState: _DepthCullingState;
  96100. /** @hidden */
  96101. protected _stencilState: _StencilState;
  96102. /** @hidden */
  96103. protected _alphaState: _AlphaState;
  96104. /** @hidden */
  96105. protected _alphaMode: number;
  96106. /** @hidden */
  96107. _internalTexturesCache: InternalTexture[];
  96108. /** @hidden */
  96109. protected _activeChannel: number;
  96110. private _currentTextureChannel;
  96111. /** @hidden */
  96112. protected _boundTexturesCache: {
  96113. [key: string]: Nullable<InternalTexture>;
  96114. };
  96115. /** @hidden */
  96116. protected _currentEffect: Nullable<Effect>;
  96117. /** @hidden */
  96118. protected _currentProgram: Nullable<WebGLProgram>;
  96119. private _compiledEffects;
  96120. private _vertexAttribArraysEnabled;
  96121. /** @hidden */
  96122. protected _cachedViewport: Nullable<IViewportLike>;
  96123. private _cachedVertexArrayObject;
  96124. /** @hidden */
  96125. protected _cachedVertexBuffers: any;
  96126. /** @hidden */
  96127. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  96128. /** @hidden */
  96129. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  96130. /** @hidden */
  96131. _currentRenderTarget: Nullable<InternalTexture>;
  96132. private _uintIndicesCurrentlySet;
  96133. private _currentBoundBuffer;
  96134. /** @hidden */
  96135. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  96136. private _currentBufferPointers;
  96137. private _currentInstanceLocations;
  96138. private _currentInstanceBuffers;
  96139. private _textureUnits;
  96140. /** @hidden */
  96141. _workingCanvas: Nullable<HTMLCanvasElement>;
  96142. /** @hidden */
  96143. _workingContext: Nullable<CanvasRenderingContext2D>;
  96144. private _rescalePostProcess;
  96145. private _dummyFramebuffer;
  96146. private _externalData;
  96147. /** @hidden */
  96148. _bindedRenderFunction: any;
  96149. private _vaoRecordInProgress;
  96150. private _mustWipeVertexAttributes;
  96151. private _emptyTexture;
  96152. private _emptyCubeTexture;
  96153. private _emptyTexture3D;
  96154. /** @hidden */
  96155. _frameHandler: number;
  96156. private _nextFreeTextureSlots;
  96157. private _maxSimultaneousTextures;
  96158. private _activeRequests;
  96159. private _texturesSupported;
  96160. /** @hidden */
  96161. _textureFormatInUse: Nullable<string>;
  96162. /**
  96163. * Gets the list of texture formats supported
  96164. */
  96165. readonly texturesSupported: Array<string>;
  96166. /**
  96167. * Gets the list of texture formats in use
  96168. */
  96169. readonly textureFormatInUse: Nullable<string>;
  96170. /**
  96171. * Gets the current viewport
  96172. */
  96173. readonly currentViewport: Nullable<IViewportLike>;
  96174. /**
  96175. * Gets the default empty texture
  96176. */
  96177. readonly emptyTexture: InternalTexture;
  96178. /**
  96179. * Gets the default empty 3D texture
  96180. */
  96181. readonly emptyTexture3D: InternalTexture;
  96182. /**
  96183. * Gets the default empty cube texture
  96184. */
  96185. readonly emptyCubeTexture: InternalTexture;
  96186. /**
  96187. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  96188. */
  96189. readonly premultipliedAlpha: boolean;
  96190. /**
  96191. * Creates a new engine
  96192. * @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
  96193. * @param antialias defines enable antialiasing (default: false)
  96194. * @param options defines further options to be sent to the getContext() function
  96195. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  96196. */
  96197. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  96198. /**
  96199. * Initializes a webVR display and starts listening to display change events
  96200. * The onVRDisplayChangedObservable will be notified upon these changes
  96201. * @returns The onVRDisplayChangedObservable
  96202. */
  96203. initWebVR(): Observable<IDisplayChangedEventArgs>;
  96204. /** @hidden */
  96205. _prepareVRComponent(): void;
  96206. /** @hidden */
  96207. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  96208. /** @hidden */
  96209. _submitVRFrame(): void;
  96210. /**
  96211. * Call this function to leave webVR mode
  96212. * Will do nothing if webVR is not supported or if there is no webVR device
  96213. * @see http://doc.babylonjs.com/how_to/webvr_camera
  96214. */
  96215. disableVR(): void;
  96216. /**
  96217. * Gets a boolean indicating that the system is in VR mode and is presenting
  96218. * @returns true if VR mode is engaged
  96219. */
  96220. isVRPresenting(): boolean;
  96221. /** @hidden */
  96222. _requestVRFrame(): void;
  96223. private _disableTouchAction;
  96224. private _rebuildInternalTextures;
  96225. private _rebuildEffects;
  96226. /**
  96227. * Gets a boolean indicating if all created effects are ready
  96228. * @returns true if all effects are ready
  96229. */
  96230. areAllEffectsReady(): boolean;
  96231. private _rebuildBuffers;
  96232. private _initGLContext;
  96233. /**
  96234. * Gets version of the current webGL context
  96235. */
  96236. readonly webGLVersion: number;
  96237. /**
  96238. * Gets a string idenfifying the name of the class
  96239. * @returns "Engine" string
  96240. */
  96241. getClassName(): string;
  96242. /**
  96243. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  96244. */
  96245. readonly isStencilEnable: boolean;
  96246. /** @hidden */
  96247. _prepareWorkingCanvas(): void;
  96248. /**
  96249. * Reset the texture cache to empty state
  96250. */
  96251. resetTextureCache(): void;
  96252. /**
  96253. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  96254. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96255. * @returns true if engine is in deterministic lock step mode
  96256. */
  96257. isDeterministicLockStep(): boolean;
  96258. /**
  96259. * Gets the max steps when engine is running in deterministic lock step
  96260. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96261. * @returns the max steps
  96262. */
  96263. getLockstepMaxSteps(): number;
  96264. /**
  96265. * Gets an object containing information about the current webGL context
  96266. * @returns an object containing the vender, the renderer and the version of the current webGL context
  96267. */
  96268. getGlInfo(): {
  96269. vendor: string;
  96270. renderer: string;
  96271. version: string;
  96272. };
  96273. /**
  96274. * Gets current aspect ratio
  96275. * @param viewportOwner defines the camera to use to get the aspect ratio
  96276. * @param useScreen defines if screen size must be used (or the current render target if any)
  96277. * @returns a number defining the aspect ratio
  96278. */
  96279. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  96280. /**
  96281. * Gets current screen aspect ratio
  96282. * @returns a number defining the aspect ratio
  96283. */
  96284. getScreenAspectRatio(): number;
  96285. /**
  96286. * Gets the current render width
  96287. * @param useScreen defines if screen size must be used (or the current render target if any)
  96288. * @returns a number defining the current render width
  96289. */
  96290. getRenderWidth(useScreen?: boolean): number;
  96291. /**
  96292. * Gets the current render height
  96293. * @param useScreen defines if screen size must be used (or the current render target if any)
  96294. * @returns a number defining the current render height
  96295. */
  96296. getRenderHeight(useScreen?: boolean): number;
  96297. /**
  96298. * Gets the HTML canvas attached with the current webGL context
  96299. * @returns a HTML canvas
  96300. */
  96301. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  96302. /**
  96303. * Gets host window
  96304. * @returns the host window object
  96305. */
  96306. getHostWindow(): Window;
  96307. /**
  96308. * Gets host document
  96309. * @returns the host document object
  96310. */
  96311. getHostDocument(): Document;
  96312. /**
  96313. * Gets the client rect of the HTML canvas attached with the current webGL context
  96314. * @returns a client rectanglee
  96315. */
  96316. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  96317. /**
  96318. * Defines the hardware scaling level.
  96319. * By default the hardware scaling level is computed from the window device ratio.
  96320. * 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.
  96321. * @param level defines the level to use
  96322. */
  96323. setHardwareScalingLevel(level: number): void;
  96324. /**
  96325. * Gets the current hardware scaling level.
  96326. * By default the hardware scaling level is computed from the window device ratio.
  96327. * 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.
  96328. * @returns a number indicating the current hardware scaling level
  96329. */
  96330. getHardwareScalingLevel(): number;
  96331. /**
  96332. * Gets the list of loaded textures
  96333. * @returns an array containing all loaded textures
  96334. */
  96335. getLoadedTexturesCache(): InternalTexture[];
  96336. /**
  96337. * Gets the object containing all engine capabilities
  96338. * @returns the EngineCapabilities object
  96339. */
  96340. getCaps(): EngineCapabilities;
  96341. /**
  96342. * Gets the current depth function
  96343. * @returns a number defining the depth function
  96344. */
  96345. getDepthFunction(): Nullable<number>;
  96346. /**
  96347. * Sets the current depth function
  96348. * @param depthFunc defines the function to use
  96349. */
  96350. setDepthFunction(depthFunc: number): void;
  96351. /**
  96352. * Sets the current depth function to GREATER
  96353. */
  96354. setDepthFunctionToGreater(): void;
  96355. /**
  96356. * Sets the current depth function to GEQUAL
  96357. */
  96358. setDepthFunctionToGreaterOrEqual(): void;
  96359. /**
  96360. * Sets the current depth function to LESS
  96361. */
  96362. setDepthFunctionToLess(): void;
  96363. private _cachedStencilBuffer;
  96364. private _cachedStencilFunction;
  96365. private _cachedStencilMask;
  96366. private _cachedStencilOperationPass;
  96367. private _cachedStencilOperationFail;
  96368. private _cachedStencilOperationDepthFail;
  96369. private _cachedStencilReference;
  96370. /**
  96371. * Caches the the state of the stencil buffer
  96372. */
  96373. cacheStencilState(): void;
  96374. /**
  96375. * Restores the state of the stencil buffer
  96376. */
  96377. restoreStencilState(): void;
  96378. /**
  96379. * Sets the current depth function to LEQUAL
  96380. */
  96381. setDepthFunctionToLessOrEqual(): void;
  96382. /**
  96383. * Gets a boolean indicating if stencil buffer is enabled
  96384. * @returns the current stencil buffer state
  96385. */
  96386. getStencilBuffer(): boolean;
  96387. /**
  96388. * Enable or disable the stencil buffer
  96389. * @param enable defines if the stencil buffer must be enabled or disabled
  96390. */
  96391. setStencilBuffer(enable: boolean): void;
  96392. /**
  96393. * Gets the current stencil mask
  96394. * @returns a number defining the new stencil mask to use
  96395. */
  96396. getStencilMask(): number;
  96397. /**
  96398. * Sets the current stencil mask
  96399. * @param mask defines the new stencil mask to use
  96400. */
  96401. setStencilMask(mask: number): void;
  96402. /**
  96403. * Gets the current stencil function
  96404. * @returns a number defining the stencil function to use
  96405. */
  96406. getStencilFunction(): number;
  96407. /**
  96408. * Gets the current stencil reference value
  96409. * @returns a number defining the stencil reference value to use
  96410. */
  96411. getStencilFunctionReference(): number;
  96412. /**
  96413. * Gets the current stencil mask
  96414. * @returns a number defining the stencil mask to use
  96415. */
  96416. getStencilFunctionMask(): number;
  96417. /**
  96418. * Sets the current stencil function
  96419. * @param stencilFunc defines the new stencil function to use
  96420. */
  96421. setStencilFunction(stencilFunc: number): void;
  96422. /**
  96423. * Sets the current stencil reference
  96424. * @param reference defines the new stencil reference to use
  96425. */
  96426. setStencilFunctionReference(reference: number): void;
  96427. /**
  96428. * Sets the current stencil mask
  96429. * @param mask defines the new stencil mask to use
  96430. */
  96431. setStencilFunctionMask(mask: number): void;
  96432. /**
  96433. * Gets the current stencil operation when stencil fails
  96434. * @returns a number defining stencil operation to use when stencil fails
  96435. */
  96436. getStencilOperationFail(): number;
  96437. /**
  96438. * Gets the current stencil operation when depth fails
  96439. * @returns a number defining stencil operation to use when depth fails
  96440. */
  96441. getStencilOperationDepthFail(): number;
  96442. /**
  96443. * Gets the current stencil operation when stencil passes
  96444. * @returns a number defining stencil operation to use when stencil passes
  96445. */
  96446. getStencilOperationPass(): number;
  96447. /**
  96448. * Sets the stencil operation to use when stencil fails
  96449. * @param operation defines the stencil operation to use when stencil fails
  96450. */
  96451. setStencilOperationFail(operation: number): void;
  96452. /**
  96453. * Sets the stencil operation to use when depth fails
  96454. * @param operation defines the stencil operation to use when depth fails
  96455. */
  96456. setStencilOperationDepthFail(operation: number): void;
  96457. /**
  96458. * Sets the stencil operation to use when stencil passes
  96459. * @param operation defines the stencil operation to use when stencil passes
  96460. */
  96461. setStencilOperationPass(operation: number): void;
  96462. /**
  96463. * Sets a boolean indicating if the dithering state is enabled or disabled
  96464. * @param value defines the dithering state
  96465. */
  96466. setDitheringState(value: boolean): void;
  96467. /**
  96468. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  96469. * @param value defines the rasterizer state
  96470. */
  96471. setRasterizerState(value: boolean): void;
  96472. /**
  96473. * stop executing a render loop function and remove it from the execution array
  96474. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  96475. */
  96476. stopRenderLoop(renderFunction?: () => void): void;
  96477. /** @hidden */
  96478. _renderLoop(): void;
  96479. /**
  96480. * Can be used to override the current requestAnimationFrame requester.
  96481. * @hidden
  96482. */
  96483. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  96484. /**
  96485. * Register and execute a render loop. The engine can have more than one render function
  96486. * @param renderFunction defines the function to continuously execute
  96487. */
  96488. runRenderLoop(renderFunction: () => void): void;
  96489. /**
  96490. * Toggle full screen mode
  96491. * @param requestPointerLock defines if a pointer lock should be requested from the user
  96492. */
  96493. switchFullscreen(requestPointerLock: boolean): void;
  96494. /**
  96495. * Enters full screen mode
  96496. * @param requestPointerLock defines if a pointer lock should be requested from the user
  96497. */
  96498. enterFullscreen(requestPointerLock: boolean): void;
  96499. /**
  96500. * Exits full screen mode
  96501. */
  96502. exitFullscreen(): void;
  96503. /**
  96504. * Enters Pointerlock mode
  96505. */
  96506. enterPointerlock(): void;
  96507. /**
  96508. * Exits Pointerlock mode
  96509. */
  96510. exitPointerlock(): void;
  96511. /**
  96512. * Clear the current render buffer or the current render target (if any is set up)
  96513. * @param color defines the color to use
  96514. * @param backBuffer defines if the back buffer must be cleared
  96515. * @param depth defines if the depth buffer must be cleared
  96516. * @param stencil defines if the stencil buffer must be cleared
  96517. */
  96518. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  96519. /**
  96520. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  96521. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  96522. * @param y defines the y-coordinate of the corner of the clear rectangle
  96523. * @param width defines the width of the clear rectangle
  96524. * @param height defines the height of the clear rectangle
  96525. * @param clearColor defines the clear color
  96526. */
  96527. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  96528. /**
  96529. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  96530. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  96531. * @param y defines the y-coordinate of the corner of the clear rectangle
  96532. * @param width defines the width of the clear rectangle
  96533. * @param height defines the height of the clear rectangle
  96534. */
  96535. enableScissor(x: number, y: number, width: number, height: number): void;
  96536. /**
  96537. * Disable previously set scissor test rectangle
  96538. */
  96539. disableScissor(): void;
  96540. private _viewportCached;
  96541. /** @hidden */
  96542. _viewport(x: number, y: number, width: number, height: number): void;
  96543. /**
  96544. * Set the WebGL's viewport
  96545. * @param viewport defines the viewport element to be used
  96546. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  96547. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  96548. */
  96549. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  96550. /**
  96551. * Directly set the WebGL Viewport
  96552. * @param x defines the x coordinate of the viewport (in screen space)
  96553. * @param y defines the y coordinate of the viewport (in screen space)
  96554. * @param width defines the width of the viewport (in screen space)
  96555. * @param height defines the height of the viewport (in screen space)
  96556. * @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
  96557. */
  96558. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  96559. /**
  96560. * Begin a new frame
  96561. */
  96562. beginFrame(): void;
  96563. /**
  96564. * Enf the current frame
  96565. */
  96566. endFrame(): void;
  96567. /**
  96568. * Resize the view according to the canvas' size
  96569. */
  96570. resize(): void;
  96571. /**
  96572. * Force a specific size of the canvas
  96573. * @param width defines the new canvas' width
  96574. * @param height defines the new canvas' height
  96575. */
  96576. setSize(width: number, height: number): void;
  96577. /**
  96578. * Binds the frame buffer to the specified texture.
  96579. * @param texture The texture to render to or null for the default canvas
  96580. * @param faceIndex The face of the texture to render to in case of cube texture
  96581. * @param requiredWidth The width of the target to render to
  96582. * @param requiredHeight The height of the target to render to
  96583. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  96584. * @param depthStencilTexture The depth stencil texture to use to render
  96585. * @param lodLevel defines le lod level to bind to the frame buffer
  96586. */
  96587. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  96588. /** @hidden */
  96589. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  96590. /**
  96591. * Unbind the current render target texture from the webGL context
  96592. * @param texture defines the render target texture to unbind
  96593. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  96594. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  96595. */
  96596. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  96597. /**
  96598. * Force the mipmap generation for the given render target texture
  96599. * @param texture defines the render target texture to use
  96600. */
  96601. generateMipMapsForCubemap(texture: InternalTexture): void;
  96602. /**
  96603. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  96604. */
  96605. flushFramebuffer(): void;
  96606. /**
  96607. * Unbind the current render target and bind the default framebuffer
  96608. */
  96609. restoreDefaultFramebuffer(): void;
  96610. /**
  96611. * Create an uniform buffer
  96612. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  96613. * @param elements defines the content of the uniform buffer
  96614. * @returns the webGL uniform buffer
  96615. */
  96616. createUniformBuffer(elements: FloatArray): DataBuffer;
  96617. /**
  96618. * Create a dynamic uniform buffer
  96619. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  96620. * @param elements defines the content of the uniform buffer
  96621. * @returns the webGL uniform buffer
  96622. */
  96623. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  96624. /**
  96625. * Update an existing uniform buffer
  96626. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  96627. * @param uniformBuffer defines the target uniform buffer
  96628. * @param elements defines the content to update
  96629. * @param offset defines the offset in the uniform buffer where update should start
  96630. * @param count defines the size of the data to update
  96631. */
  96632. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  96633. private _resetVertexBufferBinding;
  96634. /**
  96635. * Creates a vertex buffer
  96636. * @param data the data for the vertex buffer
  96637. * @returns the new WebGL static buffer
  96638. */
  96639. createVertexBuffer(data: DataArray): DataBuffer;
  96640. /**
  96641. * Creates a dynamic vertex buffer
  96642. * @param data the data for the dynamic vertex buffer
  96643. * @returns the new WebGL dynamic buffer
  96644. */
  96645. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  96646. /**
  96647. * Update a dynamic index buffer
  96648. * @param indexBuffer defines the target index buffer
  96649. * @param indices defines the data to update
  96650. * @param offset defines the offset in the target index buffer where update should start
  96651. */
  96652. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  96653. /**
  96654. * Updates a dynamic vertex buffer.
  96655. * @param vertexBuffer the vertex buffer to update
  96656. * @param data the data used to update the vertex buffer
  96657. * @param byteOffset the byte offset of the data
  96658. * @param byteLength the byte length of the data
  96659. */
  96660. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  96661. private _resetIndexBufferBinding;
  96662. /**
  96663. * Creates a new index buffer
  96664. * @param indices defines the content of the index buffer
  96665. * @param updatable defines if the index buffer must be updatable
  96666. * @returns a new webGL buffer
  96667. */
  96668. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  96669. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  96670. /**
  96671. * Bind a webGL buffer to the webGL context
  96672. * @param buffer defines the buffer to bind
  96673. */
  96674. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  96675. /**
  96676. * Bind an uniform buffer to the current webGL context
  96677. * @param buffer defines the buffer to bind
  96678. */
  96679. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  96680. /**
  96681. * Bind a buffer to the current webGL context at a given location
  96682. * @param buffer defines the buffer to bind
  96683. * @param location defines the index where to bind the buffer
  96684. */
  96685. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  96686. /**
  96687. * Bind a specific block at a given index in a specific shader program
  96688. * @param pipelineContext defines the pipeline context to use
  96689. * @param blockName defines the block name
  96690. * @param index defines the index where to bind the block
  96691. */
  96692. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  96693. private bindIndexBuffer;
  96694. private bindBuffer;
  96695. /**
  96696. * update the bound buffer with the given data
  96697. * @param data defines the data to update
  96698. */
  96699. updateArrayBuffer(data: Float32Array): void;
  96700. private _vertexAttribPointer;
  96701. private _bindIndexBufferWithCache;
  96702. private _bindVertexBuffersAttributes;
  96703. /**
  96704. * Records a vertex array object
  96705. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  96706. * @param vertexBuffers defines the list of vertex buffers to store
  96707. * @param indexBuffer defines the index buffer to store
  96708. * @param effect defines the effect to store
  96709. * @returns the new vertex array object
  96710. */
  96711. recordVertexArrayObject(vertexBuffers: {
  96712. [key: string]: VertexBuffer;
  96713. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  96714. /**
  96715. * Bind a specific vertex array object
  96716. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  96717. * @param vertexArrayObject defines the vertex array object to bind
  96718. * @param indexBuffer defines the index buffer to bind
  96719. */
  96720. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  96721. /**
  96722. * Bind webGl buffers directly to the webGL context
  96723. * @param vertexBuffer defines the vertex buffer to bind
  96724. * @param indexBuffer defines the index buffer to bind
  96725. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  96726. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  96727. * @param effect defines the effect associated with the vertex buffer
  96728. */
  96729. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  96730. private _unbindVertexArrayObject;
  96731. /**
  96732. * Bind a list of vertex buffers to the webGL context
  96733. * @param vertexBuffers defines the list of vertex buffers to bind
  96734. * @param indexBuffer defines the index buffer to bind
  96735. * @param effect defines the effect associated with the vertex buffers
  96736. */
  96737. bindBuffers(vertexBuffers: {
  96738. [key: string]: Nullable<VertexBuffer>;
  96739. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  96740. /**
  96741. * Unbind all instance attributes
  96742. */
  96743. unbindInstanceAttributes(): void;
  96744. /**
  96745. * Release and free the memory of a vertex array object
  96746. * @param vao defines the vertex array object to delete
  96747. */
  96748. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  96749. /** @hidden */
  96750. _releaseBuffer(buffer: DataBuffer): boolean;
  96751. protected _deleteBuffer(buffer: DataBuffer): void;
  96752. /**
  96753. * Creates a webGL buffer to use with instanciation
  96754. * @param capacity defines the size of the buffer
  96755. * @returns the webGL buffer
  96756. */
  96757. createInstancesBuffer(capacity: number): DataBuffer;
  96758. /**
  96759. * Delete a webGL buffer used with instanciation
  96760. * @param buffer defines the webGL buffer to delete
  96761. */
  96762. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  96763. /**
  96764. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  96765. * @param instancesBuffer defines the webGL buffer to update and bind
  96766. * @param data defines the data to store in the buffer
  96767. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  96768. */
  96769. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  96770. /**
  96771. * Apply all cached states (depth, culling, stencil and alpha)
  96772. */
  96773. applyStates(): void;
  96774. /**
  96775. * Send a draw order
  96776. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  96777. * @param indexStart defines the starting index
  96778. * @param indexCount defines the number of index to draw
  96779. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96780. */
  96781. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  96782. /**
  96783. * Draw a list of points
  96784. * @param verticesStart defines the index of first vertex to draw
  96785. * @param verticesCount defines the count of vertices to draw
  96786. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96787. */
  96788. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96789. /**
  96790. * Draw a list of unindexed primitives
  96791. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  96792. * @param verticesStart defines the index of first vertex to draw
  96793. * @param verticesCount defines the count of vertices to draw
  96794. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96795. */
  96796. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96797. /**
  96798. * Draw a list of indexed primitives
  96799. * @param fillMode defines the primitive to use
  96800. * @param indexStart defines the starting index
  96801. * @param indexCount defines the number of index to draw
  96802. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96803. */
  96804. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  96805. /**
  96806. * Draw a list of unindexed primitives
  96807. * @param fillMode defines the primitive to use
  96808. * @param verticesStart defines the index of first vertex to draw
  96809. * @param verticesCount defines the count of vertices to draw
  96810. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96811. */
  96812. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96813. private _drawMode;
  96814. /** @hidden */
  96815. _releaseEffect(effect: Effect): void;
  96816. /** @hidden */
  96817. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  96818. /**
  96819. * Create a new effect (used to store vertex/fragment shaders)
  96820. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  96821. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  96822. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  96823. * @param samplers defines an array of string used to represent textures
  96824. * @param defines defines the string containing the defines to use to compile the shaders
  96825. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  96826. * @param onCompiled defines a function to call when the effect creation is successful
  96827. * @param onError defines a function to call when the effect creation has failed
  96828. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  96829. * @returns the new Effect
  96830. */
  96831. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  96832. protected static _concatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  96833. private _compileShader;
  96834. private _compileRawShader;
  96835. /**
  96836. * Directly creates a webGL program
  96837. * @param pipelineContext defines the pipeline context to attach to
  96838. * @param vertexCode defines the vertex shader code to use
  96839. * @param fragmentCode defines the fragment shader code to use
  96840. * @param context defines the webGL context to use (if not set, the current one will be used)
  96841. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  96842. * @returns the new webGL program
  96843. */
  96844. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96845. /**
  96846. * Creates a webGL program
  96847. * @param pipelineContext defines the pipeline context to attach to
  96848. * @param vertexCode defines the vertex shader code to use
  96849. * @param fragmentCode defines the fragment shader code to use
  96850. * @param defines defines the string containing the defines to use to compile the shaders
  96851. * @param context defines the webGL context to use (if not set, the current one will be used)
  96852. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  96853. * @returns the new webGL program
  96854. */
  96855. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96856. /**
  96857. * Creates a new pipeline context
  96858. * @returns the new pipeline
  96859. */
  96860. createPipelineContext(): IPipelineContext;
  96861. private _createShaderProgram;
  96862. private _finalizePipelineContext;
  96863. /** @hidden */
  96864. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  96865. /** @hidden */
  96866. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  96867. /** @hidden */
  96868. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  96869. /**
  96870. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  96871. * @param pipelineContext defines the pipeline context to use
  96872. * @param uniformsNames defines the list of uniform names
  96873. * @returns an array of webGL uniform locations
  96874. */
  96875. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  96876. /**
  96877. * Gets the lsit of active attributes for a given webGL program
  96878. * @param pipelineContext defines the pipeline context to use
  96879. * @param attributesNames defines the list of attribute names to get
  96880. * @returns an array of indices indicating the offset of each attribute
  96881. */
  96882. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  96883. /**
  96884. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  96885. * @param effect defines the effect to activate
  96886. */
  96887. enableEffect(effect: Nullable<Effect>): void;
  96888. /**
  96889. * Set the value of an uniform to an array of int32
  96890. * @param uniform defines the webGL uniform location where to store the value
  96891. * @param array defines the array of int32 to store
  96892. */
  96893. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96894. /**
  96895. * Set the value of an uniform to an array of int32 (stored as vec2)
  96896. * @param uniform defines the webGL uniform location where to store the value
  96897. * @param array defines the array of int32 to store
  96898. */
  96899. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96900. /**
  96901. * Set the value of an uniform to an array of int32 (stored as vec3)
  96902. * @param uniform defines the webGL uniform location where to store the value
  96903. * @param array defines the array of int32 to store
  96904. */
  96905. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96906. /**
  96907. * Set the value of an uniform to an array of int32 (stored as vec4)
  96908. * @param uniform defines the webGL uniform location where to store the value
  96909. * @param array defines the array of int32 to store
  96910. */
  96911. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96912. /**
  96913. * Set the value of an uniform to an array of float32
  96914. * @param uniform defines the webGL uniform location where to store the value
  96915. * @param array defines the array of float32 to store
  96916. */
  96917. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96918. /**
  96919. * Set the value of an uniform to an array of float32 (stored as vec2)
  96920. * @param uniform defines the webGL uniform location where to store the value
  96921. * @param array defines the array of float32 to store
  96922. */
  96923. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96924. /**
  96925. * Set the value of an uniform to an array of float32 (stored as vec3)
  96926. * @param uniform defines the webGL uniform location where to store the value
  96927. * @param array defines the array of float32 to store
  96928. */
  96929. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96930. /**
  96931. * Set the value of an uniform to an array of float32 (stored as vec4)
  96932. * @param uniform defines the webGL uniform location where to store the value
  96933. * @param array defines the array of float32 to store
  96934. */
  96935. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96936. /**
  96937. * Set the value of an uniform to an array of number
  96938. * @param uniform defines the webGL uniform location where to store the value
  96939. * @param array defines the array of number to store
  96940. */
  96941. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96942. /**
  96943. * Set the value of an uniform to an array of number (stored as vec2)
  96944. * @param uniform defines the webGL uniform location where to store the value
  96945. * @param array defines the array of number to store
  96946. */
  96947. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96948. /**
  96949. * Set the value of an uniform to an array of number (stored as vec3)
  96950. * @param uniform defines the webGL uniform location where to store the value
  96951. * @param array defines the array of number to store
  96952. */
  96953. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96954. /**
  96955. * Set the value of an uniform to an array of number (stored as vec4)
  96956. * @param uniform defines the webGL uniform location where to store the value
  96957. * @param array defines the array of number to store
  96958. */
  96959. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96960. /**
  96961. * Set the value of an uniform to an array of float32 (stored as matrices)
  96962. * @param uniform defines the webGL uniform location where to store the value
  96963. * @param matrices defines the array of float32 to store
  96964. */
  96965. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  96966. /**
  96967. * Set the value of an uniform to a matrix (3x3)
  96968. * @param uniform defines the webGL uniform location where to store the value
  96969. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  96970. */
  96971. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  96972. /**
  96973. * Set the value of an uniform to a matrix (2x2)
  96974. * @param uniform defines the webGL uniform location where to store the value
  96975. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  96976. */
  96977. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  96978. /**
  96979. * Set the value of an uniform to a number (int)
  96980. * @param uniform defines the webGL uniform location where to store the value
  96981. * @param value defines the int number to store
  96982. */
  96983. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  96984. /**
  96985. * Set the value of an uniform to a number (float)
  96986. * @param uniform defines the webGL uniform location where to store the value
  96987. * @param value defines the float number to store
  96988. */
  96989. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  96990. /**
  96991. * Set the value of an uniform to a vec2
  96992. * @param uniform defines the webGL uniform location where to store the value
  96993. * @param x defines the 1st component of the value
  96994. * @param y defines the 2nd component of the value
  96995. */
  96996. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  96997. /**
  96998. * Set the value of an uniform to a vec3
  96999. * @param uniform defines the webGL uniform location where to store the value
  97000. * @param x defines the 1st component of the value
  97001. * @param y defines the 2nd component of the value
  97002. * @param z defines the 3rd component of the value
  97003. */
  97004. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  97005. /**
  97006. * Set the value of an uniform to a boolean
  97007. * @param uniform defines the webGL uniform location where to store the value
  97008. * @param bool defines the boolean to store
  97009. */
  97010. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  97011. /**
  97012. * Set the value of an uniform to a vec4
  97013. * @param uniform defines the webGL uniform location where to store the value
  97014. * @param x defines the 1st component of the value
  97015. * @param y defines the 2nd component of the value
  97016. * @param z defines the 3rd component of the value
  97017. * @param w defines the 4th component of the value
  97018. */
  97019. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  97020. /**
  97021. * Sets a Color4 on a uniform variable
  97022. * @param uniform defines the uniform location
  97023. * @param color4 defines the value to be set
  97024. */
  97025. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  97026. /**
  97027. * Set various states to the webGL context
  97028. * @param culling defines backface culling state
  97029. * @param zOffset defines the value to apply to zOffset (0 by default)
  97030. * @param force defines if states must be applied even if cache is up to date
  97031. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  97032. */
  97033. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  97034. /**
  97035. * Set the z offset to apply to current rendering
  97036. * @param value defines the offset to apply
  97037. */
  97038. setZOffset(value: number): void;
  97039. /**
  97040. * Gets the current value of the zOffset
  97041. * @returns the current zOffset state
  97042. */
  97043. getZOffset(): number;
  97044. /**
  97045. * Enable or disable depth buffering
  97046. * @param enable defines the state to set
  97047. */
  97048. setDepthBuffer(enable: boolean): void;
  97049. /**
  97050. * Gets a boolean indicating if depth writing is enabled
  97051. * @returns the current depth writing state
  97052. */
  97053. getDepthWrite(): boolean;
  97054. /**
  97055. * Enable or disable depth writing
  97056. * @param enable defines the state to set
  97057. */
  97058. setDepthWrite(enable: boolean): void;
  97059. /**
  97060. * Enable or disable color writing
  97061. * @param enable defines the state to set
  97062. */
  97063. setColorWrite(enable: boolean): void;
  97064. /**
  97065. * Gets a boolean indicating if color writing is enabled
  97066. * @returns the current color writing state
  97067. */
  97068. getColorWrite(): boolean;
  97069. /**
  97070. * Sets alpha constants used by some alpha blending modes
  97071. * @param r defines the red component
  97072. * @param g defines the green component
  97073. * @param b defines the blue component
  97074. * @param a defines the alpha component
  97075. */
  97076. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  97077. /**
  97078. * Sets the current alpha mode
  97079. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  97080. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  97081. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  97082. */
  97083. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  97084. /**
  97085. * Gets the current alpha mode
  97086. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  97087. * @returns the current alpha mode
  97088. */
  97089. getAlphaMode(): number;
  97090. /**
  97091. * Clears the list of texture accessible through engine.
  97092. * This can help preventing texture load conflict due to name collision.
  97093. */
  97094. clearInternalTexturesCache(): void;
  97095. /**
  97096. * Force the entire cache to be cleared
  97097. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  97098. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  97099. */
  97100. wipeCaches(bruteForce?: boolean): void;
  97101. /**
  97102. * Set the compressed texture format to use, based on the formats you have, and the formats
  97103. * supported by the hardware / browser.
  97104. *
  97105. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  97106. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  97107. * to API arguments needed to compressed textures. This puts the burden on the container
  97108. * generator to house the arcane code for determining these for current & future formats.
  97109. *
  97110. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  97111. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  97112. *
  97113. * Note: The result of this call is not taken into account when a texture is base64.
  97114. *
  97115. * @param formatsAvailable defines the list of those format families you have created
  97116. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  97117. *
  97118. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  97119. * @returns The extension selected.
  97120. */
  97121. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  97122. /** @hidden */
  97123. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  97124. min: number;
  97125. mag: number;
  97126. };
  97127. /** @hidden */
  97128. _createTexture(): WebGLTexture;
  97129. /**
  97130. * Usually called from Texture.ts.
  97131. * Passed information to create a WebGLTexture
  97132. * @param urlArg defines a value which contains one of the following:
  97133. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  97134. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  97135. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  97136. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  97137. * @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)
  97138. * @param scene needed for loading to the correct scene
  97139. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  97140. * @param onLoad optional callback to be called upon successful completion
  97141. * @param onError optional callback to be called upon failure
  97142. * @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
  97143. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  97144. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  97145. * @param forcedExtension defines the extension to use to pick the right loader
  97146. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  97147. * @returns a InternalTexture for assignment back into BABYLON.Texture
  97148. */
  97149. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  97150. /**
  97151. * @hidden
  97152. * Rescales a texture
  97153. * @param source input texutre
  97154. * @param destination destination texture
  97155. * @param scene scene to use to render the resize
  97156. * @param internalFormat format to use when resizing
  97157. * @param onComplete callback to be called when resize has completed
  97158. */
  97159. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  97160. private _unpackFlipYCached;
  97161. /**
  97162. * In case you are sharing the context with other applications, it might
  97163. * be interested to not cache the unpack flip y state to ensure a consistent
  97164. * value would be set.
  97165. */
  97166. enableUnpackFlipYCached: boolean;
  97167. /** @hidden */
  97168. _unpackFlipY(value: boolean): void;
  97169. /** @hidden */
  97170. _getUnpackAlignement(): number;
  97171. /**
  97172. * Creates a dynamic texture
  97173. * @param width defines the width of the texture
  97174. * @param height defines the height of the texture
  97175. * @param generateMipMaps defines if the engine should generate the mip levels
  97176. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  97177. * @returns the dynamic texture inside an InternalTexture
  97178. */
  97179. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  97180. /**
  97181. * Update the sampling mode of a given texture
  97182. * @param samplingMode defines the required sampling mode
  97183. * @param texture defines the texture to update
  97184. */
  97185. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  97186. /**
  97187. * Update the content of a dynamic texture
  97188. * @param texture defines the texture to update
  97189. * @param canvas defines the canvas containing the source
  97190. * @param invertY defines if data must be stored with Y axis inverted
  97191. * @param premulAlpha defines if alpha is stored as premultiplied
  97192. * @param format defines the format of the data
  97193. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  97194. */
  97195. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  97196. /**
  97197. * Update a video texture
  97198. * @param texture defines the texture to update
  97199. * @param video defines the video element to use
  97200. * @param invertY defines if data must be stored with Y axis inverted
  97201. */
  97202. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  97203. /**
  97204. * Updates a depth texture Comparison Mode and Function.
  97205. * If the comparison Function is equal to 0, the mode will be set to none.
  97206. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  97207. * @param texture The texture to set the comparison function for
  97208. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  97209. */
  97210. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  97211. /** @hidden */
  97212. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  97213. width: number;
  97214. height: number;
  97215. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  97216. /**
  97217. * Creates a depth stencil texture.
  97218. * This is only available in WebGL 2 or with the depth texture extension available.
  97219. * @param size The size of face edge in the texture.
  97220. * @param options The options defining the texture.
  97221. * @returns The texture
  97222. */
  97223. createDepthStencilTexture(size: number | {
  97224. width: number;
  97225. height: number;
  97226. }, options: DepthTextureCreationOptions): InternalTexture;
  97227. /**
  97228. * Creates a depth stencil texture.
  97229. * This is only available in WebGL 2 or with the depth texture extension available.
  97230. * @param size The size of face edge in the texture.
  97231. * @param options The options defining the texture.
  97232. * @returns The texture
  97233. */
  97234. private _createDepthStencilTexture;
  97235. /**
  97236. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  97237. * @param renderTarget The render target to set the frame buffer for
  97238. */
  97239. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  97240. /**
  97241. * Creates a new render target texture
  97242. * @param size defines the size of the texture
  97243. * @param options defines the options used to create the texture
  97244. * @returns a new render target texture stored in an InternalTexture
  97245. */
  97246. createRenderTargetTexture(size: number | {
  97247. width: number;
  97248. height: number;
  97249. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  97250. /** @hidden */
  97251. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  97252. /**
  97253. * Updates the sample count of a render target texture
  97254. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  97255. * @param texture defines the texture to update
  97256. * @param samples defines the sample count to set
  97257. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  97258. */
  97259. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  97260. /** @hidden */
  97261. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  97262. /** @hidden */
  97263. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  97264. /** @hidden */
  97265. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  97266. /** @hidden */
  97267. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  97268. /**
  97269. * @hidden
  97270. */
  97271. _setCubeMapTextureParams(loadMipmap: boolean): void;
  97272. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<Scene>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  97273. private _prepareWebGLTexture;
  97274. /** @hidden */
  97275. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  97276. /** @hidden */
  97277. _releaseFramebufferObjects(texture: InternalTexture): void;
  97278. /** @hidden */
  97279. _releaseTexture(texture: InternalTexture): void;
  97280. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  97281. protected _setProgram(program: WebGLProgram): void;
  97282. protected _boundUniforms: {
  97283. [key: number]: WebGLUniformLocation;
  97284. };
  97285. /**
  97286. * Binds an effect to the webGL context
  97287. * @param effect defines the effect to bind
  97288. */
  97289. bindSamplers(effect: Effect): void;
  97290. private _activateCurrentTexture;
  97291. /** @hidden */
  97292. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  97293. /** @hidden */
  97294. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  97295. /**
  97296. * Sets a texture to the webGL context from a postprocess
  97297. * @param channel defines the channel to use
  97298. * @param postProcess defines the source postprocess
  97299. */
  97300. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  97301. /**
  97302. * Binds the output of the passed in post process to the texture channel specified
  97303. * @param channel The channel the texture should be bound to
  97304. * @param postProcess The post process which's output should be bound
  97305. */
  97306. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  97307. /**
  97308. * Unbind all textures from the webGL context
  97309. */
  97310. unbindAllTextures(): void;
  97311. /**
  97312. * Sets a texture to the according uniform.
  97313. * @param channel The texture channel
  97314. * @param uniform The uniform to set
  97315. * @param texture The texture to apply
  97316. */
  97317. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  97318. /**
  97319. * Sets a depth stencil texture from a render target to the according uniform.
  97320. * @param channel The texture channel
  97321. * @param uniform The uniform to set
  97322. * @param texture The render target texture containing the depth stencil texture to apply
  97323. */
  97324. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  97325. private _bindSamplerUniformToChannel;
  97326. private _getTextureWrapMode;
  97327. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  97328. /**
  97329. * Sets an array of texture to the webGL context
  97330. * @param channel defines the channel where the texture array must be set
  97331. * @param uniform defines the associated uniform location
  97332. * @param textures defines the array of textures to bind
  97333. */
  97334. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  97335. /** @hidden */
  97336. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  97337. private _setTextureParameterFloat;
  97338. private _setTextureParameterInteger;
  97339. /**
  97340. * Reads pixels from the current frame buffer. Please note that this function can be slow
  97341. * @param x defines the x coordinate of the rectangle where pixels must be read
  97342. * @param y defines the y coordinate of the rectangle where pixels must be read
  97343. * @param width defines the width of the rectangle where pixels must be read
  97344. * @param height defines the height of the rectangle where pixels must be read
  97345. * @returns a Uint8Array containing RGBA colors
  97346. */
  97347. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  97348. /**
  97349. * Add an externaly attached data from its key.
  97350. * This method call will fail and return false, if such key already exists.
  97351. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  97352. * @param key the unique key that identifies the data
  97353. * @param data the data object to associate to the key for this Engine instance
  97354. * @return true if no such key were already present and the data was added successfully, false otherwise
  97355. */
  97356. addExternalData<T>(key: string, data: T): boolean;
  97357. /**
  97358. * Get an externaly attached data from its key
  97359. * @param key the unique key that identifies the data
  97360. * @return the associated data, if present (can be null), or undefined if not present
  97361. */
  97362. getExternalData<T>(key: string): T;
  97363. /**
  97364. * Get an externaly attached data from its key, create it using a factory if it's not already present
  97365. * @param key the unique key that identifies the data
  97366. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  97367. * @return the associated data, can be null if the factory returned null.
  97368. */
  97369. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  97370. /**
  97371. * Remove an externaly attached data from the Engine instance
  97372. * @param key the unique key that identifies the data
  97373. * @return true if the data was successfully removed, false if it doesn't exist
  97374. */
  97375. removeExternalData(key: string): boolean;
  97376. /**
  97377. * Unbind all vertex attributes from the webGL context
  97378. */
  97379. unbindAllAttributes(): void;
  97380. /**
  97381. * 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
  97382. */
  97383. releaseEffects(): void;
  97384. /**
  97385. * Dispose and release all associated resources
  97386. */
  97387. dispose(): void;
  97388. /**
  97389. * Display the loading screen
  97390. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97391. */
  97392. displayLoadingUI(): void;
  97393. /**
  97394. * Hide the loading screen
  97395. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97396. */
  97397. hideLoadingUI(): void;
  97398. /**
  97399. * Gets the current loading screen object
  97400. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97401. */
  97402. /**
  97403. * Sets the current loading screen object
  97404. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97405. */
  97406. loadingScreen: ILoadingScreen;
  97407. /**
  97408. * Sets the current loading screen text
  97409. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97410. */
  97411. loadingUIText: string;
  97412. /**
  97413. * Sets the current loading screen background color
  97414. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97415. */
  97416. loadingUIBackgroundColor: string;
  97417. /**
  97418. * Attach a new callback raised when context lost event is fired
  97419. * @param callback defines the callback to call
  97420. */
  97421. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  97422. /**
  97423. * Attach a new callback raised when context restored event is fired
  97424. * @param callback defines the callback to call
  97425. */
  97426. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  97427. /**
  97428. * Gets the source code of the vertex shader associated with a specific webGL program
  97429. * @param program defines the program to use
  97430. * @returns a string containing the source code of the vertex shader associated with the program
  97431. */
  97432. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  97433. /**
  97434. * Gets the source code of the fragment shader associated with a specific webGL program
  97435. * @param program defines the program to use
  97436. * @returns a string containing the source code of the fragment shader associated with the program
  97437. */
  97438. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  97439. /**
  97440. * Get the current error code of the webGL context
  97441. * @returns the error code
  97442. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  97443. */
  97444. getError(): number;
  97445. /**
  97446. * Gets the current framerate
  97447. * @returns a number representing the framerate
  97448. */
  97449. getFps(): number;
  97450. /**
  97451. * Gets the time spent between current and previous frame
  97452. * @returns a number representing the delta time in ms
  97453. */
  97454. getDeltaTime(): number;
  97455. private _measureFps;
  97456. /** @hidden */
  97457. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  97458. private _canRenderToFloatFramebuffer;
  97459. private _canRenderToHalfFloatFramebuffer;
  97460. private _canRenderToFramebuffer;
  97461. /** @hidden */
  97462. _getWebGLTextureType(type: number): number;
  97463. /** @hidden */
  97464. _getInternalFormat(format: number): number;
  97465. /** @hidden */
  97466. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  97467. /** @hidden */
  97468. _getRGBAMultiSampleBufferFormat(type: number): number;
  97469. /** @hidden */
  97470. _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;
  97471. /** @hidden */
  97472. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  97473. /**
  97474. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  97475. * @returns true if the engine can be created
  97476. * @ignorenaming
  97477. */
  97478. static isSupported(): boolean;
  97479. /**
  97480. * Find the next highest power of two.
  97481. * @param x Number to start search from.
  97482. * @return Next highest power of two.
  97483. */
  97484. static CeilingPOT(x: number): number;
  97485. /**
  97486. * Find the next lowest power of two.
  97487. * @param x Number to start search from.
  97488. * @return Next lowest power of two.
  97489. */
  97490. static FloorPOT(x: number): number;
  97491. /**
  97492. * Find the nearest power of two.
  97493. * @param x Number to start search from.
  97494. * @return Next nearest power of two.
  97495. */
  97496. static NearestPOT(x: number): number;
  97497. /**
  97498. * Get the closest exponent of two
  97499. * @param value defines the value to approximate
  97500. * @param max defines the maximum value to return
  97501. * @param mode defines how to define the closest value
  97502. * @returns closest exponent of two of the given value
  97503. */
  97504. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  97505. /**
  97506. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  97507. * @param func - the function to be called
  97508. * @param requester - the object that will request the next frame. Falls back to window.
  97509. * @returns frame number
  97510. */
  97511. static QueueNewFrame(func: () => void, requester?: any): number;
  97512. /**
  97513. * Ask the browser to promote the current element to pointerlock mode
  97514. * @param element defines the DOM element to promote
  97515. */
  97516. static _RequestPointerlock(element: HTMLElement): void;
  97517. /**
  97518. * Asks the browser to exit pointerlock mode
  97519. */
  97520. static _ExitPointerlock(): void;
  97521. /**
  97522. * Ask the browser to promote the current element to fullscreen rendering mode
  97523. * @param element defines the DOM element to promote
  97524. */
  97525. static _RequestFullscreen(element: HTMLElement): void;
  97526. /**
  97527. * Asks the browser to exit fullscreen mode
  97528. */
  97529. static _ExitFullscreen(): void;
  97530. }
  97531. }
  97532. declare module BABYLON {
  97533. /**
  97534. * The engine store class is responsible to hold all the instances of Engine and Scene created
  97535. * during the life time of the application.
  97536. */
  97537. export class EngineStore {
  97538. /** Gets the list of created engines */
  97539. static Instances: Engine[];
  97540. /** @hidden */
  97541. static _LastCreatedScene: Nullable<Scene>;
  97542. /**
  97543. * Gets the latest created engine
  97544. */
  97545. static readonly LastCreatedEngine: Nullable<Engine>;
  97546. /**
  97547. * Gets the latest created scene
  97548. */
  97549. static readonly LastCreatedScene: Nullable<Scene>;
  97550. /**
  97551. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  97552. * @ignorenaming
  97553. */
  97554. static UseFallbackTexture: boolean;
  97555. /**
  97556. * Texture content used if a texture cannot loaded
  97557. * @ignorenaming
  97558. */
  97559. static FallbackTexture: string;
  97560. }
  97561. }
  97562. declare module BABYLON {
  97563. /**
  97564. * Helper class that provides a small promise polyfill
  97565. */
  97566. export class PromisePolyfill {
  97567. /**
  97568. * Static function used to check if the polyfill is required
  97569. * If this is the case then the function will inject the polyfill to window.Promise
  97570. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  97571. */
  97572. static Apply(force?: boolean): void;
  97573. }
  97574. }
  97575. declare module BABYLON {
  97576. /**
  97577. * Interface for screenshot methods with describe argument called `size` as object with options
  97578. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  97579. */
  97580. export interface IScreenshotSize {
  97581. /**
  97582. * number in pixels for canvas height
  97583. */
  97584. height?: number;
  97585. /**
  97586. * multiplier allowing render at a higher or lower resolution
  97587. * If value is defined then height and width will be ignored and taken from camera
  97588. */
  97589. precision?: number;
  97590. /**
  97591. * number in pixels for canvas width
  97592. */
  97593. width?: number;
  97594. }
  97595. }
  97596. declare module BABYLON {
  97597. interface IColor4Like {
  97598. r: float;
  97599. g: float;
  97600. b: float;
  97601. a: float;
  97602. }
  97603. /**
  97604. * Class containing a set of static utilities functions
  97605. */
  97606. export class Tools {
  97607. /**
  97608. * Gets or sets the base URL to use to load assets
  97609. */
  97610. static BaseUrl: string;
  97611. /**
  97612. * Enable/Disable Custom HTTP Request Headers globally.
  97613. * default = false
  97614. * @see CustomRequestHeaders
  97615. */
  97616. static UseCustomRequestHeaders: boolean;
  97617. /**
  97618. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  97619. * i.e. when loading files, where the server/service expects an Authorization header
  97620. */
  97621. static CustomRequestHeaders: {
  97622. [key: string]: string;
  97623. };
  97624. /**
  97625. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  97626. */
  97627. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  97628. /**
  97629. * Default behaviour for cors in the application.
  97630. * It can be a string if the expected behavior is identical in the entire app.
  97631. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  97632. */
  97633. static CorsBehavior: string | ((url: string | string[]) => string);
  97634. /**
  97635. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  97636. * @ignorenaming
  97637. */
  97638. static UseFallbackTexture: boolean;
  97639. /**
  97640. * Use this object to register external classes like custom textures or material
  97641. * to allow the laoders to instantiate them
  97642. */
  97643. static RegisteredExternalClasses: {
  97644. [key: string]: Object;
  97645. };
  97646. /**
  97647. * Texture content used if a texture cannot loaded
  97648. * @ignorenaming
  97649. */
  97650. static fallbackTexture: string;
  97651. /**
  97652. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  97653. * @param u defines the coordinate on X axis
  97654. * @param v defines the coordinate on Y axis
  97655. * @param width defines the width of the source data
  97656. * @param height defines the height of the source data
  97657. * @param pixels defines the source byte array
  97658. * @param color defines the output color
  97659. */
  97660. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  97661. /**
  97662. * Interpolates between a and b via alpha
  97663. * @param a The lower value (returned when alpha = 0)
  97664. * @param b The upper value (returned when alpha = 1)
  97665. * @param alpha The interpolation-factor
  97666. * @return The mixed value
  97667. */
  97668. static Mix(a: number, b: number, alpha: number): number;
  97669. /**
  97670. * Tries to instantiate a new object from a given class name
  97671. * @param className defines the class name to instantiate
  97672. * @returns the new object or null if the system was not able to do the instantiation
  97673. */
  97674. static Instantiate(className: string): any;
  97675. /**
  97676. * Provides a slice function that will work even on IE
  97677. * @param data defines the array to slice
  97678. * @param start defines the start of the data (optional)
  97679. * @param end defines the end of the data (optional)
  97680. * @returns the new sliced array
  97681. */
  97682. static Slice<T>(data: T, start?: number, end?: number): T;
  97683. /**
  97684. * Polyfill for setImmediate
  97685. * @param action defines the action to execute after the current execution block
  97686. */
  97687. static SetImmediate(action: () => void): void;
  97688. /**
  97689. * Function indicating if a number is an exponent of 2
  97690. * @param value defines the value to test
  97691. * @returns true if the value is an exponent of 2
  97692. */
  97693. static IsExponentOfTwo(value: number): boolean;
  97694. private static _tmpFloatArray;
  97695. /**
  97696. * Returns the nearest 32-bit single precision float representation of a Number
  97697. * @param value A Number. If the parameter is of a different type, it will get converted
  97698. * to a number or to NaN if it cannot be converted
  97699. * @returns number
  97700. */
  97701. static FloatRound(value: number): number;
  97702. /**
  97703. * Extracts the filename from a path
  97704. * @param path defines the path to use
  97705. * @returns the filename
  97706. */
  97707. static GetFilename(path: string): string;
  97708. /**
  97709. * Extracts the "folder" part of a path (everything before the filename).
  97710. * @param uri The URI to extract the info from
  97711. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  97712. * @returns The "folder" part of the path
  97713. */
  97714. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  97715. /**
  97716. * Extracts text content from a DOM element hierarchy
  97717. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  97718. */
  97719. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  97720. /**
  97721. * Convert an angle in radians to degrees
  97722. * @param angle defines the angle to convert
  97723. * @returns the angle in degrees
  97724. */
  97725. static ToDegrees(angle: number): number;
  97726. /**
  97727. * Convert an angle in degrees to radians
  97728. * @param angle defines the angle to convert
  97729. * @returns the angle in radians
  97730. */
  97731. static ToRadians(angle: number): number;
  97732. /**
  97733. * Encode a buffer to a base64 string
  97734. * @param buffer defines the buffer to encode
  97735. * @returns the encoded string
  97736. */
  97737. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  97738. /**
  97739. * Returns an array if obj is not an array
  97740. * @param obj defines the object to evaluate as an array
  97741. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  97742. * @returns either obj directly if obj is an array or a new array containing obj
  97743. */
  97744. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  97745. /**
  97746. * Gets the pointer prefix to use
  97747. * @returns "pointer" if touch is enabled. Else returns "mouse"
  97748. */
  97749. static GetPointerPrefix(): string;
  97750. /**
  97751. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  97752. * @param url define the url we are trying
  97753. * @param element define the dom element where to configure the cors policy
  97754. */
  97755. static SetCorsBehavior(url: string | string[], element: {
  97756. crossOrigin: string | null;
  97757. }): void;
  97758. /**
  97759. * Removes unwanted characters from an url
  97760. * @param url defines the url to clean
  97761. * @returns the cleaned url
  97762. */
  97763. static CleanUrl(url: string): string;
  97764. /**
  97765. * Gets or sets a function used to pre-process url before using them to load assets
  97766. */
  97767. static PreprocessUrl: (url: string) => string;
  97768. /**
  97769. * Loads an image as an HTMLImageElement.
  97770. * @param input url string, ArrayBuffer, or Blob to load
  97771. * @param onLoad callback called when the image successfully loads
  97772. * @param onError callback called when the image fails to load
  97773. * @param offlineProvider offline provider for caching
  97774. * @returns the HTMLImageElement of the loaded image
  97775. */
  97776. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  97777. /**
  97778. * Loads a file
  97779. * @param url url string, ArrayBuffer, or Blob to load
  97780. * @param onSuccess callback called when the file successfully loads
  97781. * @param onProgress callback called while file is loading (if the server supports this mode)
  97782. * @param offlineProvider defines the offline provider for caching
  97783. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  97784. * @param onError callback called when the file fails to load
  97785. * @returns a file request object
  97786. */
  97787. 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;
  97788. /**
  97789. * Loads a file from a url
  97790. * @param url the file url to load
  97791. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  97792. */
  97793. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  97794. /**
  97795. * Load a script (identified by an url). When the url returns, the
  97796. * content of this file is added into a new script element, attached to the DOM (body element)
  97797. * @param scriptUrl defines the url of the script to laod
  97798. * @param onSuccess defines the callback called when the script is loaded
  97799. * @param onError defines the callback to call if an error occurs
  97800. * @param scriptId defines the id of the script element
  97801. */
  97802. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  97803. /**
  97804. * Load an asynchronous script (identified by an url). When the url returns, the
  97805. * content of this file is added into a new script element, attached to the DOM (body element)
  97806. * @param scriptUrl defines the url of the script to laod
  97807. * @param scriptId defines the id of the script element
  97808. * @returns a promise request object
  97809. */
  97810. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  97811. /**
  97812. * Loads a file from a blob
  97813. * @param fileToLoad defines the blob to use
  97814. * @param callback defines the callback to call when data is loaded
  97815. * @param progressCallback defines the callback to call during loading process
  97816. * @returns a file request object
  97817. */
  97818. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  97819. /**
  97820. * Loads a file
  97821. * @param fileToLoad defines the file to load
  97822. * @param callback defines the callback to call when data is loaded
  97823. * @param progressCallBack defines the callback to call during loading process
  97824. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  97825. * @returns a file request object
  97826. */
  97827. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  97828. /**
  97829. * Creates a data url from a given string content
  97830. * @param content defines the content to convert
  97831. * @returns the new data url link
  97832. */
  97833. static FileAsURL(content: string): string;
  97834. /**
  97835. * Format the given number to a specific decimal format
  97836. * @param value defines the number to format
  97837. * @param decimals defines the number of decimals to use
  97838. * @returns the formatted string
  97839. */
  97840. static Format(value: number, decimals?: number): string;
  97841. /**
  97842. * Tries to copy an object by duplicating every property
  97843. * @param source defines the source object
  97844. * @param destination defines the target object
  97845. * @param doNotCopyList defines a list of properties to avoid
  97846. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  97847. */
  97848. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  97849. /**
  97850. * Gets a boolean indicating if the given object has no own property
  97851. * @param obj defines the object to test
  97852. * @returns true if object has no own property
  97853. */
  97854. static IsEmpty(obj: any): boolean;
  97855. /**
  97856. * Function used to register events at window level
  97857. * @param windowElement defines the Window object to use
  97858. * @param events defines the events to register
  97859. */
  97860. static RegisterTopRootEvents(windowElement: Window, events: {
  97861. name: string;
  97862. handler: Nullable<(e: FocusEvent) => any>;
  97863. }[]): void;
  97864. /**
  97865. * Function used to unregister events from window level
  97866. * @param windowElement defines the Window object to use
  97867. * @param events defines the events to unregister
  97868. */
  97869. static UnregisterTopRootEvents(windowElement: Window, events: {
  97870. name: string;
  97871. handler: Nullable<(e: FocusEvent) => any>;
  97872. }[]): void;
  97873. /**
  97874. * @ignore
  97875. */
  97876. static _ScreenshotCanvas: HTMLCanvasElement;
  97877. /**
  97878. * Dumps the current bound framebuffer
  97879. * @param width defines the rendering width
  97880. * @param height defines the rendering height
  97881. * @param engine defines the hosting engine
  97882. * @param successCallback defines the callback triggered once the data are available
  97883. * @param mimeType defines the mime type of the result
  97884. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  97885. */
  97886. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  97887. /**
  97888. * Converts the canvas data to blob.
  97889. * This acts as a polyfill for browsers not supporting the to blob function.
  97890. * @param canvas Defines the canvas to extract the data from
  97891. * @param successCallback Defines the callback triggered once the data are available
  97892. * @param mimeType Defines the mime type of the result
  97893. */
  97894. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  97895. /**
  97896. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  97897. * @param successCallback defines the callback triggered once the data are available
  97898. * @param mimeType defines the mime type of the result
  97899. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  97900. */
  97901. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  97902. /**
  97903. * Downloads a blob in the browser
  97904. * @param blob defines the blob to download
  97905. * @param fileName defines the name of the downloaded file
  97906. */
  97907. static Download(blob: Blob, fileName: string): void;
  97908. /**
  97909. * Captures a screenshot of the current rendering
  97910. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  97911. * @param engine defines the rendering engine
  97912. * @param camera defines the source camera
  97913. * @param size This parameter can be set to a single number or to an object with the
  97914. * following (optional) properties: precision, width, height. If a single number is passed,
  97915. * it will be used for both width and height. If an object is passed, the screenshot size
  97916. * will be derived from the parameters. The precision property is a multiplier allowing
  97917. * rendering at a higher or lower resolution
  97918. * @param successCallback defines the callback receives a single parameter which contains the
  97919. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  97920. * src parameter of an <img> to display it
  97921. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  97922. * Check your browser for supported MIME types
  97923. */
  97924. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  97925. /**
  97926. * Captures a screenshot of the current rendering
  97927. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  97928. * @param engine defines the rendering engine
  97929. * @param camera defines the source camera
  97930. * @param size This parameter can be set to a single number or to an object with the
  97931. * following (optional) properties: precision, width, height. If a single number is passed,
  97932. * it will be used for both width and height. If an object is passed, the screenshot size
  97933. * will be derived from the parameters. The precision property is a multiplier allowing
  97934. * rendering at a higher or lower resolution
  97935. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  97936. * Check your browser for supported MIME types
  97937. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  97938. * to the src parameter of an <img> to display it
  97939. */
  97940. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  97941. /**
  97942. * Generates an image screenshot from the specified camera.
  97943. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  97944. * @param engine The engine to use for rendering
  97945. * @param camera The camera to use for rendering
  97946. * @param size This parameter can be set to a single number or to an object with the
  97947. * following (optional) properties: precision, width, height. If a single number is passed,
  97948. * it will be used for both width and height. If an object is passed, the screenshot size
  97949. * will be derived from the parameters. The precision property is a multiplier allowing
  97950. * rendering at a higher or lower resolution
  97951. * @param successCallback The callback receives a single parameter which contains the
  97952. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  97953. * src parameter of an <img> to display it
  97954. * @param mimeType The MIME type of the screenshot image (default: image/png).
  97955. * Check your browser for supported MIME types
  97956. * @param samples Texture samples (default: 1)
  97957. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  97958. * @param fileName A name for for the downloaded file.
  97959. */
  97960. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  97961. /**
  97962. * Generates an image screenshot from the specified camera.
  97963. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  97964. * @param engine The engine to use for rendering
  97965. * @param camera The camera to use for rendering
  97966. * @param size This parameter can be set to a single number or to an object with the
  97967. * following (optional) properties: precision, width, height. If a single number is passed,
  97968. * it will be used for both width and height. If an object is passed, the screenshot size
  97969. * will be derived from the parameters. The precision property is a multiplier allowing
  97970. * rendering at a higher or lower resolution
  97971. * @param mimeType The MIME type of the screenshot image (default: image/png).
  97972. * Check your browser for supported MIME types
  97973. * @param samples Texture samples (default: 1)
  97974. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  97975. * @param fileName A name for for the downloaded file.
  97976. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  97977. * to the src parameter of an <img> to display it
  97978. */
  97979. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  97980. /**
  97981. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  97982. * Be aware Math.random() could cause collisions, but:
  97983. * "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"
  97984. * @returns a pseudo random id
  97985. */
  97986. static RandomId(): string;
  97987. /**
  97988. * Test if the given uri is a base64 string
  97989. * @param uri The uri to test
  97990. * @return True if the uri is a base64 string or false otherwise
  97991. */
  97992. static IsBase64(uri: string): boolean;
  97993. /**
  97994. * Decode the given base64 uri.
  97995. * @param uri The uri to decode
  97996. * @return The decoded base64 data.
  97997. */
  97998. static DecodeBase64(uri: string): ArrayBuffer;
  97999. /**
  98000. * Gets the absolute url.
  98001. * @param url the input url
  98002. * @return the absolute url
  98003. */
  98004. static GetAbsoluteUrl(url: string): string;
  98005. /**
  98006. * No log
  98007. */
  98008. static readonly NoneLogLevel: number;
  98009. /**
  98010. * Only message logs
  98011. */
  98012. static readonly MessageLogLevel: number;
  98013. /**
  98014. * Only warning logs
  98015. */
  98016. static readonly WarningLogLevel: number;
  98017. /**
  98018. * Only error logs
  98019. */
  98020. static readonly ErrorLogLevel: number;
  98021. /**
  98022. * All logs
  98023. */
  98024. static readonly AllLogLevel: number;
  98025. /**
  98026. * Gets a value indicating the number of loading errors
  98027. * @ignorenaming
  98028. */
  98029. static readonly errorsCount: number;
  98030. /**
  98031. * Callback called when a new log is added
  98032. */
  98033. static OnNewCacheEntry: (entry: string) => void;
  98034. /**
  98035. * Log a message to the console
  98036. * @param message defines the message to log
  98037. */
  98038. static Log(message: string): void;
  98039. /**
  98040. * Write a warning message to the console
  98041. * @param message defines the message to log
  98042. */
  98043. static Warn(message: string): void;
  98044. /**
  98045. * Write an error message to the console
  98046. * @param message defines the message to log
  98047. */
  98048. static Error(message: string): void;
  98049. /**
  98050. * Gets current log cache (list of logs)
  98051. */
  98052. static readonly LogCache: string;
  98053. /**
  98054. * Clears the log cache
  98055. */
  98056. static ClearLogCache(): void;
  98057. /**
  98058. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  98059. */
  98060. static LogLevels: number;
  98061. /**
  98062. * Checks if the window object exists
  98063. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  98064. */
  98065. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  98066. /**
  98067. * No performance log
  98068. */
  98069. static readonly PerformanceNoneLogLevel: number;
  98070. /**
  98071. * Use user marks to log performance
  98072. */
  98073. static readonly PerformanceUserMarkLogLevel: number;
  98074. /**
  98075. * Log performance to the console
  98076. */
  98077. static readonly PerformanceConsoleLogLevel: number;
  98078. private static _performance;
  98079. /**
  98080. * Sets the current performance log level
  98081. */
  98082. static PerformanceLogLevel: number;
  98083. private static _StartPerformanceCounterDisabled;
  98084. private static _EndPerformanceCounterDisabled;
  98085. private static _StartUserMark;
  98086. private static _EndUserMark;
  98087. private static _StartPerformanceConsole;
  98088. private static _EndPerformanceConsole;
  98089. /**
  98090. * Starts a performance counter
  98091. */
  98092. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  98093. /**
  98094. * Ends a specific performance coutner
  98095. */
  98096. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  98097. /**
  98098. * Gets either window.performance.now() if supported or Date.now() else
  98099. */
  98100. static readonly Now: number;
  98101. /**
  98102. * This method will return the name of the class used to create the instance of the given object.
  98103. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  98104. * @param object the object to get the class name from
  98105. * @param isType defines if the object is actually a type
  98106. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  98107. */
  98108. static GetClassName(object: any, isType?: boolean): string;
  98109. /**
  98110. * Gets the first element of an array satisfying a given predicate
  98111. * @param array defines the array to browse
  98112. * @param predicate defines the predicate to use
  98113. * @returns null if not found or the element
  98114. */
  98115. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  98116. /**
  98117. * This method will return the name of the full name of the class, including its owning module (if any).
  98118. * 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).
  98119. * @param object the object to get the class name from
  98120. * @param isType defines if the object is actually a type
  98121. * @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.
  98122. * @ignorenaming
  98123. */
  98124. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  98125. /**
  98126. * Returns a promise that resolves after the given amount of time.
  98127. * @param delay Number of milliseconds to delay
  98128. * @returns Promise that resolves after the given amount of time
  98129. */
  98130. static DelayAsync(delay: number): Promise<void>;
  98131. }
  98132. /**
  98133. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  98134. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  98135. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  98136. * @param name The name of the class, case should be preserved
  98137. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  98138. */
  98139. export function className(name: string, module?: string): (target: Object) => void;
  98140. /**
  98141. * An implementation of a loop for asynchronous functions.
  98142. */
  98143. export class AsyncLoop {
  98144. /**
  98145. * Defines the number of iterations for the loop
  98146. */
  98147. iterations: number;
  98148. /**
  98149. * Defines the current index of the loop.
  98150. */
  98151. index: number;
  98152. private _done;
  98153. private _fn;
  98154. private _successCallback;
  98155. /**
  98156. * Constructor.
  98157. * @param iterations the number of iterations.
  98158. * @param func the function to run each iteration
  98159. * @param successCallback the callback that will be called upon succesful execution
  98160. * @param offset starting offset.
  98161. */
  98162. constructor(
  98163. /**
  98164. * Defines the number of iterations for the loop
  98165. */
  98166. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  98167. /**
  98168. * Execute the next iteration. Must be called after the last iteration was finished.
  98169. */
  98170. executeNext(): void;
  98171. /**
  98172. * Break the loop and run the success callback.
  98173. */
  98174. breakLoop(): void;
  98175. /**
  98176. * Create and run an async loop.
  98177. * @param iterations the number of iterations.
  98178. * @param fn the function to run each iteration
  98179. * @param successCallback the callback that will be called upon succesful execution
  98180. * @param offset starting offset.
  98181. * @returns the created async loop object
  98182. */
  98183. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  98184. /**
  98185. * A for-loop that will run a given number of iterations synchronous and the rest async.
  98186. * @param iterations total number of iterations
  98187. * @param syncedIterations number of synchronous iterations in each async iteration.
  98188. * @param fn the function to call each iteration.
  98189. * @param callback a success call back that will be called when iterating stops.
  98190. * @param breakFunction a break condition (optional)
  98191. * @param timeout timeout settings for the setTimeout function. default - 0.
  98192. * @returns the created async loop object
  98193. */
  98194. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  98195. }
  98196. }
  98197. declare module BABYLON {
  98198. /** @hidden */
  98199. export interface ICollisionCoordinator {
  98200. createCollider(): Collider;
  98201. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  98202. init(scene: Scene): void;
  98203. }
  98204. /** @hidden */
  98205. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  98206. private _scene;
  98207. private _scaledPosition;
  98208. private _scaledVelocity;
  98209. private _finalPosition;
  98210. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  98211. createCollider(): Collider;
  98212. init(scene: Scene): void;
  98213. private _collideWithWorld;
  98214. }
  98215. }
  98216. declare module BABYLON {
  98217. /**
  98218. * Class used to manage all inputs for the scene.
  98219. */
  98220. export class InputManager {
  98221. /** The distance in pixel that you have to move to prevent some events */
  98222. static DragMovementThreshold: number;
  98223. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  98224. static LongPressDelay: number;
  98225. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  98226. static DoubleClickDelay: number;
  98227. /** If you need to check double click without raising a single click at first click, enable this flag */
  98228. static ExclusiveDoubleClickMode: boolean;
  98229. private _wheelEventName;
  98230. private _onPointerMove;
  98231. private _onPointerDown;
  98232. private _onPointerUp;
  98233. private _initClickEvent;
  98234. private _initActionManager;
  98235. private _delayedSimpleClick;
  98236. private _delayedSimpleClickTimeout;
  98237. private _previousDelayedSimpleClickTimeout;
  98238. private _meshPickProceed;
  98239. private _previousButtonPressed;
  98240. private _currentPickResult;
  98241. private _previousPickResult;
  98242. private _totalPointersPressed;
  98243. private _doubleClickOccured;
  98244. private _pointerOverMesh;
  98245. private _pickedDownMesh;
  98246. private _pickedUpMesh;
  98247. private _pointerX;
  98248. private _pointerY;
  98249. private _unTranslatedPointerX;
  98250. private _unTranslatedPointerY;
  98251. private _startingPointerPosition;
  98252. private _previousStartingPointerPosition;
  98253. private _startingPointerTime;
  98254. private _previousStartingPointerTime;
  98255. private _pointerCaptures;
  98256. private _onKeyDown;
  98257. private _onKeyUp;
  98258. private _onCanvasFocusObserver;
  98259. private _onCanvasBlurObserver;
  98260. private _scene;
  98261. /**
  98262. * Creates a new InputManager
  98263. * @param scene defines the hosting scene
  98264. */
  98265. constructor(scene: Scene);
  98266. /**
  98267. * Gets the mesh that is currently under the pointer
  98268. */
  98269. readonly meshUnderPointer: Nullable<AbstractMesh>;
  98270. /**
  98271. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  98272. */
  98273. readonly unTranslatedPointer: Vector2;
  98274. /**
  98275. * Gets or sets the current on-screen X position of the pointer
  98276. */
  98277. pointerX: number;
  98278. /**
  98279. * Gets or sets the current on-screen Y position of the pointer
  98280. */
  98281. pointerY: number;
  98282. private _updatePointerPosition;
  98283. private _processPointerMove;
  98284. private _setRayOnPointerInfo;
  98285. private _checkPrePointerObservable;
  98286. /**
  98287. * Use this method to simulate a pointer move on a mesh
  98288. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  98289. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  98290. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  98291. */
  98292. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  98293. /**
  98294. * Use this method to simulate a pointer down on a mesh
  98295. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  98296. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  98297. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  98298. */
  98299. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  98300. private _processPointerDown;
  98301. /** @hidden */
  98302. _isPointerSwiping(): boolean;
  98303. /**
  98304. * Use this method to simulate a pointer up on a mesh
  98305. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  98306. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  98307. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  98308. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  98309. */
  98310. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  98311. private _processPointerUp;
  98312. /**
  98313. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  98314. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  98315. * @returns true if the pointer was captured
  98316. */
  98317. isPointerCaptured(pointerId?: number): boolean;
  98318. /**
  98319. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  98320. * @param attachUp defines if you want to attach events to pointerup
  98321. * @param attachDown defines if you want to attach events to pointerdown
  98322. * @param attachMove defines if you want to attach events to pointermove
  98323. */
  98324. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  98325. /**
  98326. * Detaches all event handlers
  98327. */
  98328. detachControl(): void;
  98329. /**
  98330. * Force the value of meshUnderPointer
  98331. * @param mesh defines the mesh to use
  98332. */
  98333. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  98334. /**
  98335. * Gets the mesh under the pointer
  98336. * @returns a Mesh or null if no mesh is under the pointer
  98337. */
  98338. getPointerOverMesh(): Nullable<AbstractMesh>;
  98339. }
  98340. }
  98341. declare module BABYLON {
  98342. /**
  98343. * Helper class used to generate session unique ID
  98344. */
  98345. export class UniqueIdGenerator {
  98346. private static _UniqueIdCounter;
  98347. /**
  98348. * Gets an unique (relatively to the current scene) Id
  98349. */
  98350. static readonly UniqueId: number;
  98351. }
  98352. }
  98353. declare module BABYLON {
  98354. /**
  98355. * This class defines the direct association between an animation and a target
  98356. */
  98357. export class TargetedAnimation {
  98358. /**
  98359. * Animation to perform
  98360. */
  98361. animation: Animation;
  98362. /**
  98363. * Target to animate
  98364. */
  98365. target: any;
  98366. /**
  98367. * Serialize the object
  98368. * @returns the JSON object representing the current entity
  98369. */
  98370. serialize(): any;
  98371. }
  98372. /**
  98373. * Use this class to create coordinated animations on multiple targets
  98374. */
  98375. export class AnimationGroup implements IDisposable {
  98376. /** The name of the animation group */
  98377. name: string;
  98378. private _scene;
  98379. private _targetedAnimations;
  98380. private _animatables;
  98381. private _from;
  98382. private _to;
  98383. private _isStarted;
  98384. private _isPaused;
  98385. private _speedRatio;
  98386. private _loopAnimation;
  98387. /**
  98388. * Gets or sets the unique id of the node
  98389. */
  98390. uniqueId: number;
  98391. /**
  98392. * This observable will notify when one animation have ended
  98393. */
  98394. onAnimationEndObservable: Observable<TargetedAnimation>;
  98395. /**
  98396. * Observer raised when one animation loops
  98397. */
  98398. onAnimationLoopObservable: Observable<TargetedAnimation>;
  98399. /**
  98400. * This observable will notify when all animations have ended.
  98401. */
  98402. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  98403. /**
  98404. * This observable will notify when all animations have paused.
  98405. */
  98406. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  98407. /**
  98408. * This observable will notify when all animations are playing.
  98409. */
  98410. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  98411. /**
  98412. * Gets the first frame
  98413. */
  98414. readonly from: number;
  98415. /**
  98416. * Gets the last frame
  98417. */
  98418. readonly to: number;
  98419. /**
  98420. * Define if the animations are started
  98421. */
  98422. readonly isStarted: boolean;
  98423. /**
  98424. * Gets a value indicating that the current group is playing
  98425. */
  98426. readonly isPlaying: boolean;
  98427. /**
  98428. * Gets or sets the speed ratio to use for all animations
  98429. */
  98430. /**
  98431. * Gets or sets the speed ratio to use for all animations
  98432. */
  98433. speedRatio: number;
  98434. /**
  98435. * Gets or sets if all animations should loop or not
  98436. */
  98437. loopAnimation: boolean;
  98438. /**
  98439. * Gets the targeted animations for this animation group
  98440. */
  98441. readonly targetedAnimations: Array<TargetedAnimation>;
  98442. /**
  98443. * returning the list of animatables controlled by this animation group.
  98444. */
  98445. readonly animatables: Array<Animatable>;
  98446. /**
  98447. * Instantiates a new Animation Group.
  98448. * This helps managing several animations at once.
  98449. * @see http://doc.babylonjs.com/how_to/group
  98450. * @param name Defines the name of the group
  98451. * @param scene Defines the scene the group belongs to
  98452. */
  98453. constructor(
  98454. /** The name of the animation group */
  98455. name: string, scene?: Nullable<Scene>);
  98456. /**
  98457. * Add an animation (with its target) in the group
  98458. * @param animation defines the animation we want to add
  98459. * @param target defines the target of the animation
  98460. * @returns the TargetedAnimation object
  98461. */
  98462. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  98463. /**
  98464. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  98465. * It can add constant keys at begin or end
  98466. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  98467. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  98468. * @returns the animation group
  98469. */
  98470. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  98471. /**
  98472. * Start all animations on given targets
  98473. * @param loop defines if animations must loop
  98474. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  98475. * @param from defines the from key (optional)
  98476. * @param to defines the to key (optional)
  98477. * @returns the current animation group
  98478. */
  98479. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  98480. /**
  98481. * Pause all animations
  98482. * @returns the animation group
  98483. */
  98484. pause(): AnimationGroup;
  98485. /**
  98486. * Play all animations to initial state
  98487. * This function will start() the animations if they were not started or will restart() them if they were paused
  98488. * @param loop defines if animations must loop
  98489. * @returns the animation group
  98490. */
  98491. play(loop?: boolean): AnimationGroup;
  98492. /**
  98493. * Reset all animations to initial state
  98494. * @returns the animation group
  98495. */
  98496. reset(): AnimationGroup;
  98497. /**
  98498. * Restart animations from key 0
  98499. * @returns the animation group
  98500. */
  98501. restart(): AnimationGroup;
  98502. /**
  98503. * Stop all animations
  98504. * @returns the animation group
  98505. */
  98506. stop(): AnimationGroup;
  98507. /**
  98508. * Set animation weight for all animatables
  98509. * @param weight defines the weight to use
  98510. * @return the animationGroup
  98511. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  98512. */
  98513. setWeightForAllAnimatables(weight: number): AnimationGroup;
  98514. /**
  98515. * Synchronize and normalize all animatables with a source animatable
  98516. * @param root defines the root animatable to synchronize with
  98517. * @return the animationGroup
  98518. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  98519. */
  98520. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  98521. /**
  98522. * Goes to a specific frame in this animation group
  98523. * @param frame the frame number to go to
  98524. * @return the animationGroup
  98525. */
  98526. goToFrame(frame: number): AnimationGroup;
  98527. /**
  98528. * Dispose all associated resources
  98529. */
  98530. dispose(): void;
  98531. private _checkAnimationGroupEnded;
  98532. /**
  98533. * Clone the current animation group and returns a copy
  98534. * @param newName defines the name of the new group
  98535. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  98536. * @returns the new aniamtion group
  98537. */
  98538. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  98539. /**
  98540. * Serializes the animationGroup to an object
  98541. * @returns Serialized object
  98542. */
  98543. serialize(): any;
  98544. /**
  98545. * Returns a new AnimationGroup object parsed from the source provided.
  98546. * @param parsedAnimationGroup defines the source
  98547. * @param scene defines the scene that will receive the animationGroup
  98548. * @returns a new AnimationGroup
  98549. */
  98550. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  98551. /**
  98552. * Returns the string "AnimationGroup"
  98553. * @returns "AnimationGroup"
  98554. */
  98555. getClassName(): string;
  98556. /**
  98557. * Creates a detailled string about the object
  98558. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  98559. * @returns a string representing the object
  98560. */
  98561. toString(fullDetails?: boolean): string;
  98562. }
  98563. }
  98564. declare module BABYLON {
  98565. /**
  98566. * Define an interface for all classes that will hold resources
  98567. */
  98568. export interface IDisposable {
  98569. /**
  98570. * Releases all held resources
  98571. */
  98572. dispose(): void;
  98573. }
  98574. /** Interface defining initialization parameters for Scene class */
  98575. export interface SceneOptions {
  98576. /**
  98577. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  98578. * It will improve performance when the number of geometries becomes important.
  98579. */
  98580. useGeometryUniqueIdsMap?: boolean;
  98581. /**
  98582. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  98583. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  98584. */
  98585. useMaterialMeshMap?: boolean;
  98586. /**
  98587. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  98588. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  98589. */
  98590. useClonedMeshhMap?: boolean;
  98591. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  98592. virtual?: boolean;
  98593. }
  98594. /**
  98595. * Represents a scene to be rendered by the engine.
  98596. * @see http://doc.babylonjs.com/features/scene
  98597. */
  98598. export class Scene extends AbstractScene implements IAnimatable {
  98599. /** The fog is deactivated */
  98600. static readonly FOGMODE_NONE: number;
  98601. /** The fog density is following an exponential function */
  98602. static readonly FOGMODE_EXP: number;
  98603. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  98604. static readonly FOGMODE_EXP2: number;
  98605. /** The fog density is following a linear function. */
  98606. static readonly FOGMODE_LINEAR: number;
  98607. /**
  98608. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  98609. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98610. */
  98611. static MinDeltaTime: number;
  98612. /**
  98613. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  98614. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98615. */
  98616. static MaxDeltaTime: number;
  98617. /**
  98618. * Factory used to create the default material.
  98619. * @param name The name of the material to create
  98620. * @param scene The scene to create the material for
  98621. * @returns The default material
  98622. */
  98623. static DefaultMaterialFactory(scene: Scene): Material;
  98624. /**
  98625. * Factory used to create the a collision coordinator.
  98626. * @returns The collision coordinator
  98627. */
  98628. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  98629. /** @hidden */
  98630. _inputManager: InputManager;
  98631. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  98632. cameraToUseForPointers: Nullable<Camera>;
  98633. /** @hidden */
  98634. readonly _isScene: boolean;
  98635. /**
  98636. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  98637. */
  98638. autoClear: boolean;
  98639. /**
  98640. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  98641. */
  98642. autoClearDepthAndStencil: boolean;
  98643. /**
  98644. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  98645. */
  98646. clearColor: Color4;
  98647. /**
  98648. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  98649. */
  98650. ambientColor: Color3;
  98651. /**
  98652. * This is use to store the default BRDF lookup for PBR materials in your scene.
  98653. * It should only be one of the following (if not the default embedded one):
  98654. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  98655. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  98656. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  98657. * The material properties need to be setup according to the type of texture in use.
  98658. */
  98659. environmentBRDFTexture: BaseTexture;
  98660. /** @hidden */
  98661. protected _environmentTexture: Nullable<BaseTexture>;
  98662. /**
  98663. * Texture used in all pbr material as the reflection texture.
  98664. * As in the majority of the scene they are the same (exception for multi room and so on),
  98665. * this is easier to reference from here than from all the materials.
  98666. */
  98667. /**
  98668. * Texture used in all pbr material as the reflection texture.
  98669. * As in the majority of the scene they are the same (exception for multi room and so on),
  98670. * this is easier to set here than in all the materials.
  98671. */
  98672. environmentTexture: Nullable<BaseTexture>;
  98673. /** @hidden */
  98674. protected _environmentIntensity: number;
  98675. /**
  98676. * Intensity of the environment in all pbr material.
  98677. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  98678. * As in the majority of the scene they are the same (exception for multi room and so on),
  98679. * this is easier to reference from here than from all the materials.
  98680. */
  98681. /**
  98682. * Intensity of the environment in all pbr material.
  98683. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  98684. * As in the majority of the scene they are the same (exception for multi room and so on),
  98685. * this is easier to set here than in all the materials.
  98686. */
  98687. environmentIntensity: number;
  98688. /** @hidden */
  98689. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  98690. /**
  98691. * Default image processing configuration used either in the rendering
  98692. * Forward main pass or through the imageProcessingPostProcess if present.
  98693. * As in the majority of the scene they are the same (exception for multi camera),
  98694. * this is easier to reference from here than from all the materials and post process.
  98695. *
  98696. * No setter as we it is a shared configuration, you can set the values instead.
  98697. */
  98698. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  98699. private _forceWireframe;
  98700. /**
  98701. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  98702. */
  98703. forceWireframe: boolean;
  98704. private _forcePointsCloud;
  98705. /**
  98706. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  98707. */
  98708. forcePointsCloud: boolean;
  98709. /**
  98710. * Gets or sets the active clipplane 1
  98711. */
  98712. clipPlane: Nullable<Plane>;
  98713. /**
  98714. * Gets or sets the active clipplane 2
  98715. */
  98716. clipPlane2: Nullable<Plane>;
  98717. /**
  98718. * Gets or sets the active clipplane 3
  98719. */
  98720. clipPlane3: Nullable<Plane>;
  98721. /**
  98722. * Gets or sets the active clipplane 4
  98723. */
  98724. clipPlane4: Nullable<Plane>;
  98725. /**
  98726. * Gets or sets a boolean indicating if animations are enabled
  98727. */
  98728. animationsEnabled: boolean;
  98729. private _animationPropertiesOverride;
  98730. /**
  98731. * Gets or sets the animation properties override
  98732. */
  98733. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  98734. /**
  98735. * Gets or sets a boolean indicating if a constant deltatime has to be used
  98736. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  98737. */
  98738. useConstantAnimationDeltaTime: boolean;
  98739. /**
  98740. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  98741. * Please note that it requires to run a ray cast through the scene on every frame
  98742. */
  98743. constantlyUpdateMeshUnderPointer: boolean;
  98744. /**
  98745. * Defines the HTML cursor to use when hovering over interactive elements
  98746. */
  98747. hoverCursor: string;
  98748. /**
  98749. * Defines the HTML default cursor to use (empty by default)
  98750. */
  98751. defaultCursor: string;
  98752. /**
  98753. * This is used to call preventDefault() on pointer down
  98754. * in order to block unwanted artifacts like system double clicks
  98755. */
  98756. preventDefaultOnPointerDown: boolean;
  98757. /**
  98758. * This is used to call preventDefault() on pointer up
  98759. * in order to block unwanted artifacts like system double clicks
  98760. */
  98761. preventDefaultOnPointerUp: boolean;
  98762. /**
  98763. * Gets or sets user defined metadata
  98764. */
  98765. metadata: any;
  98766. /**
  98767. * For internal use only. Please do not use.
  98768. */
  98769. reservedDataStore: any;
  98770. /**
  98771. * Gets the name of the plugin used to load this scene (null by default)
  98772. */
  98773. loadingPluginName: string;
  98774. /**
  98775. * Use this array to add regular expressions used to disable offline support for specific urls
  98776. */
  98777. disableOfflineSupportExceptionRules: RegExp[];
  98778. /**
  98779. * An event triggered when the scene is disposed.
  98780. */
  98781. onDisposeObservable: Observable<Scene>;
  98782. private _onDisposeObserver;
  98783. /** Sets a function to be executed when this scene is disposed. */
  98784. onDispose: () => void;
  98785. /**
  98786. * An event triggered before rendering the scene (right after animations and physics)
  98787. */
  98788. onBeforeRenderObservable: Observable<Scene>;
  98789. private _onBeforeRenderObserver;
  98790. /** Sets a function to be executed before rendering this scene */
  98791. beforeRender: Nullable<() => void>;
  98792. /**
  98793. * An event triggered after rendering the scene
  98794. */
  98795. onAfterRenderObservable: Observable<Scene>;
  98796. /**
  98797. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  98798. */
  98799. onAfterRenderCameraObservable: Observable<Camera>;
  98800. private _onAfterRenderObserver;
  98801. /** Sets a function to be executed after rendering this scene */
  98802. afterRender: Nullable<() => void>;
  98803. /**
  98804. * An event triggered before animating the scene
  98805. */
  98806. onBeforeAnimationsObservable: Observable<Scene>;
  98807. /**
  98808. * An event triggered after animations processing
  98809. */
  98810. onAfterAnimationsObservable: Observable<Scene>;
  98811. /**
  98812. * An event triggered before draw calls are ready to be sent
  98813. */
  98814. onBeforeDrawPhaseObservable: Observable<Scene>;
  98815. /**
  98816. * An event triggered after draw calls have been sent
  98817. */
  98818. onAfterDrawPhaseObservable: Observable<Scene>;
  98819. /**
  98820. * An event triggered when the scene is ready
  98821. */
  98822. onReadyObservable: Observable<Scene>;
  98823. /**
  98824. * An event triggered before rendering a camera
  98825. */
  98826. onBeforeCameraRenderObservable: Observable<Camera>;
  98827. private _onBeforeCameraRenderObserver;
  98828. /** Sets a function to be executed before rendering a camera*/
  98829. beforeCameraRender: () => void;
  98830. /**
  98831. * An event triggered after rendering a camera
  98832. */
  98833. onAfterCameraRenderObservable: Observable<Camera>;
  98834. private _onAfterCameraRenderObserver;
  98835. /** Sets a function to be executed after rendering a camera*/
  98836. afterCameraRender: () => void;
  98837. /**
  98838. * An event triggered when active meshes evaluation is about to start
  98839. */
  98840. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  98841. /**
  98842. * An event triggered when active meshes evaluation is done
  98843. */
  98844. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  98845. /**
  98846. * An event triggered when particles rendering is about to start
  98847. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  98848. */
  98849. onBeforeParticlesRenderingObservable: Observable<Scene>;
  98850. /**
  98851. * An event triggered when particles rendering is done
  98852. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  98853. */
  98854. onAfterParticlesRenderingObservable: Observable<Scene>;
  98855. /**
  98856. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  98857. */
  98858. onDataLoadedObservable: Observable<Scene>;
  98859. /**
  98860. * An event triggered when a camera is created
  98861. */
  98862. onNewCameraAddedObservable: Observable<Camera>;
  98863. /**
  98864. * An event triggered when a camera is removed
  98865. */
  98866. onCameraRemovedObservable: Observable<Camera>;
  98867. /**
  98868. * An event triggered when a light is created
  98869. */
  98870. onNewLightAddedObservable: Observable<Light>;
  98871. /**
  98872. * An event triggered when a light is removed
  98873. */
  98874. onLightRemovedObservable: Observable<Light>;
  98875. /**
  98876. * An event triggered when a geometry is created
  98877. */
  98878. onNewGeometryAddedObservable: Observable<Geometry>;
  98879. /**
  98880. * An event triggered when a geometry is removed
  98881. */
  98882. onGeometryRemovedObservable: Observable<Geometry>;
  98883. /**
  98884. * An event triggered when a transform node is created
  98885. */
  98886. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  98887. /**
  98888. * An event triggered when a transform node is removed
  98889. */
  98890. onTransformNodeRemovedObservable: Observable<TransformNode>;
  98891. /**
  98892. * An event triggered when a mesh is created
  98893. */
  98894. onNewMeshAddedObservable: Observable<AbstractMesh>;
  98895. /**
  98896. * An event triggered when a mesh is removed
  98897. */
  98898. onMeshRemovedObservable: Observable<AbstractMesh>;
  98899. /**
  98900. * An event triggered when a skeleton is created
  98901. */
  98902. onNewSkeletonAddedObservable: Observable<Skeleton>;
  98903. /**
  98904. * An event triggered when a skeleton is removed
  98905. */
  98906. onSkeletonRemovedObservable: Observable<Skeleton>;
  98907. /**
  98908. * An event triggered when a material is created
  98909. */
  98910. onNewMaterialAddedObservable: Observable<Material>;
  98911. /**
  98912. * An event triggered when a material is removed
  98913. */
  98914. onMaterialRemovedObservable: Observable<Material>;
  98915. /**
  98916. * An event triggered when a texture is created
  98917. */
  98918. onNewTextureAddedObservable: Observable<BaseTexture>;
  98919. /**
  98920. * An event triggered when a texture is removed
  98921. */
  98922. onTextureRemovedObservable: Observable<BaseTexture>;
  98923. /**
  98924. * An event triggered when render targets are about to be rendered
  98925. * Can happen multiple times per frame.
  98926. */
  98927. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  98928. /**
  98929. * An event triggered when render targets were rendered.
  98930. * Can happen multiple times per frame.
  98931. */
  98932. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  98933. /**
  98934. * An event triggered before calculating deterministic simulation step
  98935. */
  98936. onBeforeStepObservable: Observable<Scene>;
  98937. /**
  98938. * An event triggered after calculating deterministic simulation step
  98939. */
  98940. onAfterStepObservable: Observable<Scene>;
  98941. /**
  98942. * An event triggered when the activeCamera property is updated
  98943. */
  98944. onActiveCameraChanged: Observable<Scene>;
  98945. /**
  98946. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  98947. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  98948. * 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)
  98949. */
  98950. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  98951. /**
  98952. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  98953. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  98954. * 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)
  98955. */
  98956. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  98957. /**
  98958. * This Observable will when a mesh has been imported into the scene.
  98959. */
  98960. onMeshImportedObservable: Observable<AbstractMesh>;
  98961. /**
  98962. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  98963. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  98964. */
  98965. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  98966. /** @hidden */
  98967. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  98968. /**
  98969. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  98970. */
  98971. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  98972. /**
  98973. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  98974. */
  98975. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  98976. /**
  98977. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  98978. */
  98979. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  98980. /** Callback called when a pointer move is detected */
  98981. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  98982. /** Callback called when a pointer down is detected */
  98983. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  98984. /** Callback called when a pointer up is detected */
  98985. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  98986. /** Callback called when a pointer pick is detected */
  98987. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  98988. /**
  98989. * 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).
  98990. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  98991. */
  98992. onPrePointerObservable: Observable<PointerInfoPre>;
  98993. /**
  98994. * Observable event triggered each time an input event is received from the rendering canvas
  98995. */
  98996. onPointerObservable: Observable<PointerInfo>;
  98997. /**
  98998. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  98999. */
  99000. readonly unTranslatedPointer: Vector2;
  99001. /**
  99002. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  99003. */
  99004. static DragMovementThreshold: number;
  99005. /**
  99006. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  99007. */
  99008. static LongPressDelay: number;
  99009. /**
  99010. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  99011. */
  99012. static DoubleClickDelay: number;
  99013. /** If you need to check double click without raising a single click at first click, enable this flag */
  99014. static ExclusiveDoubleClickMode: boolean;
  99015. /** @hidden */
  99016. _mirroredCameraPosition: Nullable<Vector3>;
  99017. /**
  99018. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  99019. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  99020. */
  99021. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  99022. /**
  99023. * Observable event triggered each time an keyboard event is received from the hosting window
  99024. */
  99025. onKeyboardObservable: Observable<KeyboardInfo>;
  99026. private _useRightHandedSystem;
  99027. /**
  99028. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  99029. */
  99030. useRightHandedSystem: boolean;
  99031. private _timeAccumulator;
  99032. private _currentStepId;
  99033. private _currentInternalStep;
  99034. /**
  99035. * Sets the step Id used by deterministic lock step
  99036. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99037. * @param newStepId defines the step Id
  99038. */
  99039. setStepId(newStepId: number): void;
  99040. /**
  99041. * Gets the step Id used by deterministic lock step
  99042. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99043. * @returns the step Id
  99044. */
  99045. getStepId(): number;
  99046. /**
  99047. * Gets the internal step used by deterministic lock step
  99048. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99049. * @returns the internal step
  99050. */
  99051. getInternalStep(): number;
  99052. private _fogEnabled;
  99053. /**
  99054. * Gets or sets a boolean indicating if fog is enabled on this scene
  99055. * @see http://doc.babylonjs.com/babylon101/environment#fog
  99056. * (Default is true)
  99057. */
  99058. fogEnabled: boolean;
  99059. private _fogMode;
  99060. /**
  99061. * Gets or sets the fog mode to use
  99062. * @see http://doc.babylonjs.com/babylon101/environment#fog
  99063. * | mode | value |
  99064. * | --- | --- |
  99065. * | FOGMODE_NONE | 0 |
  99066. * | FOGMODE_EXP | 1 |
  99067. * | FOGMODE_EXP2 | 2 |
  99068. * | FOGMODE_LINEAR | 3 |
  99069. */
  99070. fogMode: number;
  99071. /**
  99072. * Gets or sets the fog color to use
  99073. * @see http://doc.babylonjs.com/babylon101/environment#fog
  99074. * (Default is Color3(0.2, 0.2, 0.3))
  99075. */
  99076. fogColor: Color3;
  99077. /**
  99078. * Gets or sets the fog density to use
  99079. * @see http://doc.babylonjs.com/babylon101/environment#fog
  99080. * (Default is 0.1)
  99081. */
  99082. fogDensity: number;
  99083. /**
  99084. * Gets or sets the fog start distance to use
  99085. * @see http://doc.babylonjs.com/babylon101/environment#fog
  99086. * (Default is 0)
  99087. */
  99088. fogStart: number;
  99089. /**
  99090. * Gets or sets the fog end distance to use
  99091. * @see http://doc.babylonjs.com/babylon101/environment#fog
  99092. * (Default is 1000)
  99093. */
  99094. fogEnd: number;
  99095. private _shadowsEnabled;
  99096. /**
  99097. * Gets or sets a boolean indicating if shadows are enabled on this scene
  99098. */
  99099. shadowsEnabled: boolean;
  99100. private _lightsEnabled;
  99101. /**
  99102. * Gets or sets a boolean indicating if lights are enabled on this scene
  99103. */
  99104. lightsEnabled: boolean;
  99105. /** All of the active cameras added to this scene. */
  99106. activeCameras: Camera[];
  99107. /** @hidden */
  99108. _activeCamera: Nullable<Camera>;
  99109. /** Gets or sets the current active camera */
  99110. activeCamera: Nullable<Camera>;
  99111. private _defaultMaterial;
  99112. /** The default material used on meshes when no material is affected */
  99113. /** The default material used on meshes when no material is affected */
  99114. defaultMaterial: Material;
  99115. private _texturesEnabled;
  99116. /**
  99117. * Gets or sets a boolean indicating if textures are enabled on this scene
  99118. */
  99119. texturesEnabled: boolean;
  99120. /**
  99121. * Gets or sets a boolean indicating if particles are enabled on this scene
  99122. */
  99123. particlesEnabled: boolean;
  99124. /**
  99125. * Gets or sets a boolean indicating if sprites are enabled on this scene
  99126. */
  99127. spritesEnabled: boolean;
  99128. private _skeletonsEnabled;
  99129. /**
  99130. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  99131. */
  99132. skeletonsEnabled: boolean;
  99133. /**
  99134. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  99135. */
  99136. lensFlaresEnabled: boolean;
  99137. /**
  99138. * Gets or sets a boolean indicating if collisions are enabled on this scene
  99139. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  99140. */
  99141. collisionsEnabled: boolean;
  99142. private _collisionCoordinator;
  99143. /** @hidden */
  99144. readonly collisionCoordinator: ICollisionCoordinator;
  99145. /**
  99146. * Defines the gravity applied to this scene (used only for collisions)
  99147. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  99148. */
  99149. gravity: Vector3;
  99150. /**
  99151. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  99152. */
  99153. postProcessesEnabled: boolean;
  99154. /**
  99155. * The list of postprocesses added to the scene
  99156. */
  99157. postProcesses: PostProcess[];
  99158. /**
  99159. * Gets the current postprocess manager
  99160. */
  99161. postProcessManager: PostProcessManager;
  99162. /**
  99163. * Gets or sets a boolean indicating if render targets are enabled on this scene
  99164. */
  99165. renderTargetsEnabled: boolean;
  99166. /**
  99167. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  99168. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  99169. */
  99170. dumpNextRenderTargets: boolean;
  99171. /**
  99172. * The list of user defined render targets added to the scene
  99173. */
  99174. customRenderTargets: RenderTargetTexture[];
  99175. /**
  99176. * Defines if texture loading must be delayed
  99177. * If true, textures will only be loaded when they need to be rendered
  99178. */
  99179. useDelayedTextureLoading: boolean;
  99180. /**
  99181. * Gets the list of meshes imported to the scene through SceneLoader
  99182. */
  99183. importedMeshesFiles: String[];
  99184. /**
  99185. * Gets or sets a boolean indicating if probes are enabled on this scene
  99186. */
  99187. probesEnabled: boolean;
  99188. /**
  99189. * Gets or sets the current offline provider to use to store scene data
  99190. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  99191. */
  99192. offlineProvider: IOfflineProvider;
  99193. /**
  99194. * Gets or sets the action manager associated with the scene
  99195. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  99196. */
  99197. actionManager: AbstractActionManager;
  99198. private _meshesForIntersections;
  99199. /**
  99200. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  99201. */
  99202. proceduralTexturesEnabled: boolean;
  99203. private _engine;
  99204. private _totalVertices;
  99205. /** @hidden */
  99206. _activeIndices: PerfCounter;
  99207. /** @hidden */
  99208. _activeParticles: PerfCounter;
  99209. /** @hidden */
  99210. _activeBones: PerfCounter;
  99211. private _animationRatio;
  99212. /** @hidden */
  99213. _animationTimeLast: number;
  99214. /** @hidden */
  99215. _animationTime: number;
  99216. /**
  99217. * Gets or sets a general scale for animation speed
  99218. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  99219. */
  99220. animationTimeScale: number;
  99221. /** @hidden */
  99222. _cachedMaterial: Nullable<Material>;
  99223. /** @hidden */
  99224. _cachedEffect: Nullable<Effect>;
  99225. /** @hidden */
  99226. _cachedVisibility: Nullable<number>;
  99227. private _renderId;
  99228. private _frameId;
  99229. private _executeWhenReadyTimeoutId;
  99230. private _intermediateRendering;
  99231. private _viewUpdateFlag;
  99232. private _projectionUpdateFlag;
  99233. /** @hidden */
  99234. _toBeDisposed: Nullable<IDisposable>[];
  99235. private _activeRequests;
  99236. /** @hidden */
  99237. _pendingData: any[];
  99238. private _isDisposed;
  99239. /**
  99240. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  99241. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  99242. */
  99243. dispatchAllSubMeshesOfActiveMeshes: boolean;
  99244. private _activeMeshes;
  99245. private _processedMaterials;
  99246. private _renderTargets;
  99247. /** @hidden */
  99248. _activeParticleSystems: SmartArray<IParticleSystem>;
  99249. private _activeSkeletons;
  99250. private _softwareSkinnedMeshes;
  99251. private _renderingManager;
  99252. /** @hidden */
  99253. _activeAnimatables: Animatable[];
  99254. private _transformMatrix;
  99255. private _sceneUbo;
  99256. /** @hidden */
  99257. _viewMatrix: Matrix;
  99258. private _projectionMatrix;
  99259. /** @hidden */
  99260. _forcedViewPosition: Nullable<Vector3>;
  99261. /** @hidden */
  99262. _frustumPlanes: Plane[];
  99263. /**
  99264. * Gets the list of frustum planes (built from the active camera)
  99265. */
  99266. readonly frustumPlanes: Plane[];
  99267. /**
  99268. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  99269. * This is useful if there are more lights that the maximum simulteanous authorized
  99270. */
  99271. requireLightSorting: boolean;
  99272. /** @hidden */
  99273. readonly useMaterialMeshMap: boolean;
  99274. /** @hidden */
  99275. readonly useClonedMeshhMap: boolean;
  99276. private _externalData;
  99277. private _uid;
  99278. /**
  99279. * @hidden
  99280. * Backing store of defined scene components.
  99281. */
  99282. _components: ISceneComponent[];
  99283. /**
  99284. * @hidden
  99285. * Backing store of defined scene components.
  99286. */
  99287. _serializableComponents: ISceneSerializableComponent[];
  99288. /**
  99289. * List of components to register on the next registration step.
  99290. */
  99291. private _transientComponents;
  99292. /**
  99293. * Registers the transient components if needed.
  99294. */
  99295. private _registerTransientComponents;
  99296. /**
  99297. * @hidden
  99298. * Add a component to the scene.
  99299. * Note that the ccomponent could be registered on th next frame if this is called after
  99300. * the register component stage.
  99301. * @param component Defines the component to add to the scene
  99302. */
  99303. _addComponent(component: ISceneComponent): void;
  99304. /**
  99305. * @hidden
  99306. * Gets a component from the scene.
  99307. * @param name defines the name of the component to retrieve
  99308. * @returns the component or null if not present
  99309. */
  99310. _getComponent(name: string): Nullable<ISceneComponent>;
  99311. /**
  99312. * @hidden
  99313. * Defines the actions happening before camera updates.
  99314. */
  99315. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  99316. /**
  99317. * @hidden
  99318. * Defines the actions happening before clear the canvas.
  99319. */
  99320. _beforeClearStage: Stage<SimpleStageAction>;
  99321. /**
  99322. * @hidden
  99323. * Defines the actions when collecting render targets for the frame.
  99324. */
  99325. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  99326. /**
  99327. * @hidden
  99328. * Defines the actions happening for one camera in the frame.
  99329. */
  99330. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  99331. /**
  99332. * @hidden
  99333. * Defines the actions happening during the per mesh ready checks.
  99334. */
  99335. _isReadyForMeshStage: Stage<MeshStageAction>;
  99336. /**
  99337. * @hidden
  99338. * Defines the actions happening before evaluate active mesh checks.
  99339. */
  99340. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  99341. /**
  99342. * @hidden
  99343. * Defines the actions happening during the evaluate sub mesh checks.
  99344. */
  99345. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  99346. /**
  99347. * @hidden
  99348. * Defines the actions happening during the active mesh stage.
  99349. */
  99350. _activeMeshStage: Stage<ActiveMeshStageAction>;
  99351. /**
  99352. * @hidden
  99353. * Defines the actions happening during the per camera render target step.
  99354. */
  99355. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  99356. /**
  99357. * @hidden
  99358. * Defines the actions happening just before the active camera is drawing.
  99359. */
  99360. _beforeCameraDrawStage: Stage<CameraStageAction>;
  99361. /**
  99362. * @hidden
  99363. * Defines the actions happening just before a render target is drawing.
  99364. */
  99365. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  99366. /**
  99367. * @hidden
  99368. * Defines the actions happening just before a rendering group is drawing.
  99369. */
  99370. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  99371. /**
  99372. * @hidden
  99373. * Defines the actions happening just before a mesh is drawing.
  99374. */
  99375. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  99376. /**
  99377. * @hidden
  99378. * Defines the actions happening just after a mesh has been drawn.
  99379. */
  99380. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  99381. /**
  99382. * @hidden
  99383. * Defines the actions happening just after a rendering group has been drawn.
  99384. */
  99385. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  99386. /**
  99387. * @hidden
  99388. * Defines the actions happening just after the active camera has been drawn.
  99389. */
  99390. _afterCameraDrawStage: Stage<CameraStageAction>;
  99391. /**
  99392. * @hidden
  99393. * Defines the actions happening just after a render target has been drawn.
  99394. */
  99395. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  99396. /**
  99397. * @hidden
  99398. * Defines the actions happening just after rendering all cameras and computing intersections.
  99399. */
  99400. _afterRenderStage: Stage<SimpleStageAction>;
  99401. /**
  99402. * @hidden
  99403. * Defines the actions happening when a pointer move event happens.
  99404. */
  99405. _pointerMoveStage: Stage<PointerMoveStageAction>;
  99406. /**
  99407. * @hidden
  99408. * Defines the actions happening when a pointer down event happens.
  99409. */
  99410. _pointerDownStage: Stage<PointerUpDownStageAction>;
  99411. /**
  99412. * @hidden
  99413. * Defines the actions happening when a pointer up event happens.
  99414. */
  99415. _pointerUpStage: Stage<PointerUpDownStageAction>;
  99416. /**
  99417. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  99418. */
  99419. private geometriesByUniqueId;
  99420. /**
  99421. * Creates a new Scene
  99422. * @param engine defines the engine to use to render this scene
  99423. * @param options defines the scene options
  99424. */
  99425. constructor(engine: Engine, options?: SceneOptions);
  99426. /**
  99427. * Gets a string idenfifying the name of the class
  99428. * @returns "Scene" string
  99429. */
  99430. getClassName(): string;
  99431. private _defaultMeshCandidates;
  99432. /**
  99433. * @hidden
  99434. */
  99435. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  99436. private _defaultSubMeshCandidates;
  99437. /**
  99438. * @hidden
  99439. */
  99440. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  99441. /**
  99442. * Sets the default candidate providers for the scene.
  99443. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  99444. * and getCollidingSubMeshCandidates to their default function
  99445. */
  99446. setDefaultCandidateProviders(): void;
  99447. /**
  99448. * Gets the mesh that is currently under the pointer
  99449. */
  99450. readonly meshUnderPointer: Nullable<AbstractMesh>;
  99451. /**
  99452. * Gets or sets the current on-screen X position of the pointer
  99453. */
  99454. pointerX: number;
  99455. /**
  99456. * Gets or sets the current on-screen Y position of the pointer
  99457. */
  99458. pointerY: number;
  99459. /**
  99460. * Gets the cached material (ie. the latest rendered one)
  99461. * @returns the cached material
  99462. */
  99463. getCachedMaterial(): Nullable<Material>;
  99464. /**
  99465. * Gets the cached effect (ie. the latest rendered one)
  99466. * @returns the cached effect
  99467. */
  99468. getCachedEffect(): Nullable<Effect>;
  99469. /**
  99470. * Gets the cached visibility state (ie. the latest rendered one)
  99471. * @returns the cached visibility state
  99472. */
  99473. getCachedVisibility(): Nullable<number>;
  99474. /**
  99475. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  99476. * @param material defines the current material
  99477. * @param effect defines the current effect
  99478. * @param visibility defines the current visibility state
  99479. * @returns true if one parameter is not cached
  99480. */
  99481. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  99482. /**
  99483. * Gets the engine associated with the scene
  99484. * @returns an Engine
  99485. */
  99486. getEngine(): Engine;
  99487. /**
  99488. * Gets the total number of vertices rendered per frame
  99489. * @returns the total number of vertices rendered per frame
  99490. */
  99491. getTotalVertices(): number;
  99492. /**
  99493. * Gets the performance counter for total vertices
  99494. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  99495. */
  99496. readonly totalVerticesPerfCounter: PerfCounter;
  99497. /**
  99498. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  99499. * @returns the total number of active indices rendered per frame
  99500. */
  99501. getActiveIndices(): number;
  99502. /**
  99503. * Gets the performance counter for active indices
  99504. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  99505. */
  99506. readonly totalActiveIndicesPerfCounter: PerfCounter;
  99507. /**
  99508. * Gets the total number of active particles rendered per frame
  99509. * @returns the total number of active particles rendered per frame
  99510. */
  99511. getActiveParticles(): number;
  99512. /**
  99513. * Gets the performance counter for active particles
  99514. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  99515. */
  99516. readonly activeParticlesPerfCounter: PerfCounter;
  99517. /**
  99518. * Gets the total number of active bones rendered per frame
  99519. * @returns the total number of active bones rendered per frame
  99520. */
  99521. getActiveBones(): number;
  99522. /**
  99523. * Gets the performance counter for active bones
  99524. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  99525. */
  99526. readonly activeBonesPerfCounter: PerfCounter;
  99527. /**
  99528. * Gets the array of active meshes
  99529. * @returns an array of AbstractMesh
  99530. */
  99531. getActiveMeshes(): SmartArray<AbstractMesh>;
  99532. /**
  99533. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  99534. * @returns a number
  99535. */
  99536. getAnimationRatio(): number;
  99537. /**
  99538. * Gets an unique Id for the current render phase
  99539. * @returns a number
  99540. */
  99541. getRenderId(): number;
  99542. /**
  99543. * Gets an unique Id for the current frame
  99544. * @returns a number
  99545. */
  99546. getFrameId(): number;
  99547. /** Call this function if you want to manually increment the render Id*/
  99548. incrementRenderId(): void;
  99549. private _createUbo;
  99550. /**
  99551. * Use this method to simulate a pointer move on a mesh
  99552. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99553. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99554. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99555. * @returns the current scene
  99556. */
  99557. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  99558. /**
  99559. * Use this method to simulate a pointer down on a mesh
  99560. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99561. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99562. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99563. * @returns the current scene
  99564. */
  99565. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  99566. /**
  99567. * Use this method to simulate a pointer up on a mesh
  99568. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99569. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99570. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99571. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  99572. * @returns the current scene
  99573. */
  99574. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  99575. /**
  99576. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  99577. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  99578. * @returns true if the pointer was captured
  99579. */
  99580. isPointerCaptured(pointerId?: number): boolean;
  99581. /**
  99582. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  99583. * @param attachUp defines if you want to attach events to pointerup
  99584. * @param attachDown defines if you want to attach events to pointerdown
  99585. * @param attachMove defines if you want to attach events to pointermove
  99586. */
  99587. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  99588. /** Detaches all event handlers*/
  99589. detachControl(): void;
  99590. /**
  99591. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  99592. * Delay loaded resources are not taking in account
  99593. * @return true if all required resources are ready
  99594. */
  99595. isReady(): boolean;
  99596. /** Resets all cached information relative to material (including effect and visibility) */
  99597. resetCachedMaterial(): void;
  99598. /**
  99599. * Registers a function to be called before every frame render
  99600. * @param func defines the function to register
  99601. */
  99602. registerBeforeRender(func: () => void): void;
  99603. /**
  99604. * Unregisters a function called before every frame render
  99605. * @param func defines the function to unregister
  99606. */
  99607. unregisterBeforeRender(func: () => void): void;
  99608. /**
  99609. * Registers a function to be called after every frame render
  99610. * @param func defines the function to register
  99611. */
  99612. registerAfterRender(func: () => void): void;
  99613. /**
  99614. * Unregisters a function called after every frame render
  99615. * @param func defines the function to unregister
  99616. */
  99617. unregisterAfterRender(func: () => void): void;
  99618. private _executeOnceBeforeRender;
  99619. /**
  99620. * The provided function will run before render once and will be disposed afterwards.
  99621. * A timeout delay can be provided so that the function will be executed in N ms.
  99622. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  99623. * @param func The function to be executed.
  99624. * @param timeout optional delay in ms
  99625. */
  99626. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  99627. /** @hidden */
  99628. _addPendingData(data: any): void;
  99629. /** @hidden */
  99630. _removePendingData(data: any): void;
  99631. /**
  99632. * Returns the number of items waiting to be loaded
  99633. * @returns the number of items waiting to be loaded
  99634. */
  99635. getWaitingItemsCount(): number;
  99636. /**
  99637. * Returns a boolean indicating if the scene is still loading data
  99638. */
  99639. readonly isLoading: boolean;
  99640. /**
  99641. * Registers a function to be executed when the scene is ready
  99642. * @param {Function} func - the function to be executed
  99643. */
  99644. executeWhenReady(func: () => void): void;
  99645. /**
  99646. * Returns a promise that resolves when the scene is ready
  99647. * @returns A promise that resolves when the scene is ready
  99648. */
  99649. whenReadyAsync(): Promise<void>;
  99650. /** @hidden */
  99651. _checkIsReady(): void;
  99652. /**
  99653. * Gets all animatable attached to the scene
  99654. */
  99655. readonly animatables: Animatable[];
  99656. /**
  99657. * Resets the last animation time frame.
  99658. * Useful to override when animations start running when loading a scene for the first time.
  99659. */
  99660. resetLastAnimationTimeFrame(): void;
  99661. /**
  99662. * Gets the current view matrix
  99663. * @returns a Matrix
  99664. */
  99665. getViewMatrix(): Matrix;
  99666. /**
  99667. * Gets the current projection matrix
  99668. * @returns a Matrix
  99669. */
  99670. getProjectionMatrix(): Matrix;
  99671. /**
  99672. * Gets the current transform matrix
  99673. * @returns a Matrix made of View * Projection
  99674. */
  99675. getTransformMatrix(): Matrix;
  99676. /**
  99677. * Sets the current transform matrix
  99678. * @param viewL defines the View matrix to use
  99679. * @param projectionL defines the Projection matrix to use
  99680. * @param viewR defines the right View matrix to use (if provided)
  99681. * @param projectionR defines the right Projection matrix to use (if provided)
  99682. */
  99683. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  99684. /**
  99685. * Gets the uniform buffer used to store scene data
  99686. * @returns a UniformBuffer
  99687. */
  99688. getSceneUniformBuffer(): UniformBuffer;
  99689. /**
  99690. * Gets an unique (relatively to the current scene) Id
  99691. * @returns an unique number for the scene
  99692. */
  99693. getUniqueId(): number;
  99694. /**
  99695. * Add a mesh to the list of scene's meshes
  99696. * @param newMesh defines the mesh to add
  99697. * @param recursive if all child meshes should also be added to the scene
  99698. */
  99699. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  99700. /**
  99701. * Remove a mesh for the list of scene's meshes
  99702. * @param toRemove defines the mesh to remove
  99703. * @param recursive if all child meshes should also be removed from the scene
  99704. * @returns the index where the mesh was in the mesh list
  99705. */
  99706. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  99707. /**
  99708. * Add a transform node to the list of scene's transform nodes
  99709. * @param newTransformNode defines the transform node to add
  99710. */
  99711. addTransformNode(newTransformNode: TransformNode): void;
  99712. /**
  99713. * Remove a transform node for the list of scene's transform nodes
  99714. * @param toRemove defines the transform node to remove
  99715. * @returns the index where the transform node was in the transform node list
  99716. */
  99717. removeTransformNode(toRemove: TransformNode): number;
  99718. /**
  99719. * Remove a skeleton for the list of scene's skeletons
  99720. * @param toRemove defines the skeleton to remove
  99721. * @returns the index where the skeleton was in the skeleton list
  99722. */
  99723. removeSkeleton(toRemove: Skeleton): number;
  99724. /**
  99725. * Remove a morph target for the list of scene's morph targets
  99726. * @param toRemove defines the morph target to remove
  99727. * @returns the index where the morph target was in the morph target list
  99728. */
  99729. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  99730. /**
  99731. * Remove a light for the list of scene's lights
  99732. * @param toRemove defines the light to remove
  99733. * @returns the index where the light was in the light list
  99734. */
  99735. removeLight(toRemove: Light): number;
  99736. /**
  99737. * Remove a camera for the list of scene's cameras
  99738. * @param toRemove defines the camera to remove
  99739. * @returns the index where the camera was in the camera list
  99740. */
  99741. removeCamera(toRemove: Camera): number;
  99742. /**
  99743. * Remove a particle system for the list of scene's particle systems
  99744. * @param toRemove defines the particle system to remove
  99745. * @returns the index where the particle system was in the particle system list
  99746. */
  99747. removeParticleSystem(toRemove: IParticleSystem): number;
  99748. /**
  99749. * Remove a animation for the list of scene's animations
  99750. * @param toRemove defines the animation to remove
  99751. * @returns the index where the animation was in the animation list
  99752. */
  99753. removeAnimation(toRemove: Animation): number;
  99754. /**
  99755. * Will stop the animation of the given target
  99756. * @param target - the target
  99757. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  99758. * @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)
  99759. */
  99760. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  99761. /**
  99762. * Removes the given animation group from this scene.
  99763. * @param toRemove The animation group to remove
  99764. * @returns The index of the removed animation group
  99765. */
  99766. removeAnimationGroup(toRemove: AnimationGroup): number;
  99767. /**
  99768. * Removes the given multi-material from this scene.
  99769. * @param toRemove The multi-material to remove
  99770. * @returns The index of the removed multi-material
  99771. */
  99772. removeMultiMaterial(toRemove: MultiMaterial): number;
  99773. /**
  99774. * Removes the given material from this scene.
  99775. * @param toRemove The material to remove
  99776. * @returns The index of the removed material
  99777. */
  99778. removeMaterial(toRemove: Material): number;
  99779. /**
  99780. * Removes the given action manager from this scene.
  99781. * @param toRemove The action manager to remove
  99782. * @returns The index of the removed action manager
  99783. */
  99784. removeActionManager(toRemove: AbstractActionManager): number;
  99785. /**
  99786. * Removes the given texture from this scene.
  99787. * @param toRemove The texture to remove
  99788. * @returns The index of the removed texture
  99789. */
  99790. removeTexture(toRemove: BaseTexture): number;
  99791. /**
  99792. * Adds the given light to this scene
  99793. * @param newLight The light to add
  99794. */
  99795. addLight(newLight: Light): void;
  99796. /**
  99797. * Sorts the list list based on light priorities
  99798. */
  99799. sortLightsByPriority(): void;
  99800. /**
  99801. * Adds the given camera to this scene
  99802. * @param newCamera The camera to add
  99803. */
  99804. addCamera(newCamera: Camera): void;
  99805. /**
  99806. * Adds the given skeleton to this scene
  99807. * @param newSkeleton The skeleton to add
  99808. */
  99809. addSkeleton(newSkeleton: Skeleton): void;
  99810. /**
  99811. * Adds the given particle system to this scene
  99812. * @param newParticleSystem The particle system to add
  99813. */
  99814. addParticleSystem(newParticleSystem: IParticleSystem): void;
  99815. /**
  99816. * Adds the given animation to this scene
  99817. * @param newAnimation The animation to add
  99818. */
  99819. addAnimation(newAnimation: Animation): void;
  99820. /**
  99821. * Adds the given animation group to this scene.
  99822. * @param newAnimationGroup The animation group to add
  99823. */
  99824. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  99825. /**
  99826. * Adds the given multi-material to this scene
  99827. * @param newMultiMaterial The multi-material to add
  99828. */
  99829. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  99830. /**
  99831. * Adds the given material to this scene
  99832. * @param newMaterial The material to add
  99833. */
  99834. addMaterial(newMaterial: Material): void;
  99835. /**
  99836. * Adds the given morph target to this scene
  99837. * @param newMorphTargetManager The morph target to add
  99838. */
  99839. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  99840. /**
  99841. * Adds the given geometry to this scene
  99842. * @param newGeometry The geometry to add
  99843. */
  99844. addGeometry(newGeometry: Geometry): void;
  99845. /**
  99846. * Adds the given action manager to this scene
  99847. * @param newActionManager The action manager to add
  99848. */
  99849. addActionManager(newActionManager: AbstractActionManager): void;
  99850. /**
  99851. * Adds the given texture to this scene.
  99852. * @param newTexture The texture to add
  99853. */
  99854. addTexture(newTexture: BaseTexture): void;
  99855. /**
  99856. * Switch active camera
  99857. * @param newCamera defines the new active camera
  99858. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  99859. */
  99860. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  99861. /**
  99862. * sets the active camera of the scene using its ID
  99863. * @param id defines the camera's ID
  99864. * @return the new active camera or null if none found.
  99865. */
  99866. setActiveCameraByID(id: string): Nullable<Camera>;
  99867. /**
  99868. * sets the active camera of the scene using its name
  99869. * @param name defines the camera's name
  99870. * @returns the new active camera or null if none found.
  99871. */
  99872. setActiveCameraByName(name: string): Nullable<Camera>;
  99873. /**
  99874. * get an animation group using its name
  99875. * @param name defines the material's name
  99876. * @return the animation group or null if none found.
  99877. */
  99878. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  99879. /**
  99880. * Get a material using its unique id
  99881. * @param uniqueId defines the material's unique id
  99882. * @return the material or null if none found.
  99883. */
  99884. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  99885. /**
  99886. * get a material using its id
  99887. * @param id defines the material's ID
  99888. * @return the material or null if none found.
  99889. */
  99890. getMaterialByID(id: string): Nullable<Material>;
  99891. /**
  99892. * Gets a the last added material using a given id
  99893. * @param id defines the material's ID
  99894. * @return the last material with the given id or null if none found.
  99895. */
  99896. getLastMaterialByID(id: string): Nullable<Material>;
  99897. /**
  99898. * Gets a material using its name
  99899. * @param name defines the material's name
  99900. * @return the material or null if none found.
  99901. */
  99902. getMaterialByName(name: string): Nullable<Material>;
  99903. /**
  99904. * Get a texture using its unique id
  99905. * @param uniqueId defines the texture's unique id
  99906. * @return the texture or null if none found.
  99907. */
  99908. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  99909. /**
  99910. * Gets a camera using its id
  99911. * @param id defines the id to look for
  99912. * @returns the camera or null if not found
  99913. */
  99914. getCameraByID(id: string): Nullable<Camera>;
  99915. /**
  99916. * Gets a camera using its unique id
  99917. * @param uniqueId defines the unique id to look for
  99918. * @returns the camera or null if not found
  99919. */
  99920. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  99921. /**
  99922. * Gets a camera using its name
  99923. * @param name defines the camera's name
  99924. * @return the camera or null if none found.
  99925. */
  99926. getCameraByName(name: string): Nullable<Camera>;
  99927. /**
  99928. * Gets a bone using its id
  99929. * @param id defines the bone's id
  99930. * @return the bone or null if not found
  99931. */
  99932. getBoneByID(id: string): Nullable<Bone>;
  99933. /**
  99934. * Gets a bone using its id
  99935. * @param name defines the bone's name
  99936. * @return the bone or null if not found
  99937. */
  99938. getBoneByName(name: string): Nullable<Bone>;
  99939. /**
  99940. * Gets a light node using its name
  99941. * @param name defines the the light's name
  99942. * @return the light or null if none found.
  99943. */
  99944. getLightByName(name: string): Nullable<Light>;
  99945. /**
  99946. * Gets a light node using its id
  99947. * @param id defines the light's id
  99948. * @return the light or null if none found.
  99949. */
  99950. getLightByID(id: string): Nullable<Light>;
  99951. /**
  99952. * Gets a light node using its scene-generated unique ID
  99953. * @param uniqueId defines the light's unique id
  99954. * @return the light or null if none found.
  99955. */
  99956. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  99957. /**
  99958. * Gets a particle system by id
  99959. * @param id defines the particle system id
  99960. * @return the corresponding system or null if none found
  99961. */
  99962. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  99963. /**
  99964. * Gets a geometry using its ID
  99965. * @param id defines the geometry's id
  99966. * @return the geometry or null if none found.
  99967. */
  99968. getGeometryByID(id: string): Nullable<Geometry>;
  99969. private _getGeometryByUniqueID;
  99970. /**
  99971. * Add a new geometry to this scene
  99972. * @param geometry defines the geometry to be added to the scene.
  99973. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  99974. * @return a boolean defining if the geometry was added or not
  99975. */
  99976. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  99977. /**
  99978. * Removes an existing geometry
  99979. * @param geometry defines the geometry to be removed from the scene
  99980. * @return a boolean defining if the geometry was removed or not
  99981. */
  99982. removeGeometry(geometry: Geometry): boolean;
  99983. /**
  99984. * Gets the list of geometries attached to the scene
  99985. * @returns an array of Geometry
  99986. */
  99987. getGeometries(): Geometry[];
  99988. /**
  99989. * Gets the first added mesh found of a given ID
  99990. * @param id defines the id to search for
  99991. * @return the mesh found or null if not found at all
  99992. */
  99993. getMeshByID(id: string): Nullable<AbstractMesh>;
  99994. /**
  99995. * Gets a list of meshes using their id
  99996. * @param id defines the id to search for
  99997. * @returns a list of meshes
  99998. */
  99999. getMeshesByID(id: string): Array<AbstractMesh>;
  100000. /**
  100001. * Gets the first added transform node found of a given ID
  100002. * @param id defines the id to search for
  100003. * @return the found transform node or null if not found at all.
  100004. */
  100005. getTransformNodeByID(id: string): Nullable<TransformNode>;
  100006. /**
  100007. * Gets a transform node with its auto-generated unique id
  100008. * @param uniqueId efines the unique id to search for
  100009. * @return the found transform node or null if not found at all.
  100010. */
  100011. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  100012. /**
  100013. * Gets a list of transform nodes using their id
  100014. * @param id defines the id to search for
  100015. * @returns a list of transform nodes
  100016. */
  100017. getTransformNodesByID(id: string): Array<TransformNode>;
  100018. /**
  100019. * Gets a mesh with its auto-generated unique id
  100020. * @param uniqueId defines the unique id to search for
  100021. * @return the found mesh or null if not found at all.
  100022. */
  100023. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  100024. /**
  100025. * Gets a the last added mesh using a given id
  100026. * @param id defines the id to search for
  100027. * @return the found mesh or null if not found at all.
  100028. */
  100029. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  100030. /**
  100031. * Gets a the last added node (Mesh, Camera, Light) using a given id
  100032. * @param id defines the id to search for
  100033. * @return the found node or null if not found at all
  100034. */
  100035. getLastEntryByID(id: string): Nullable<Node>;
  100036. /**
  100037. * Gets a node (Mesh, Camera, Light) using a given id
  100038. * @param id defines the id to search for
  100039. * @return the found node or null if not found at all
  100040. */
  100041. getNodeByID(id: string): Nullable<Node>;
  100042. /**
  100043. * Gets a node (Mesh, Camera, Light) using a given name
  100044. * @param name defines the name to search for
  100045. * @return the found node or null if not found at all.
  100046. */
  100047. getNodeByName(name: string): Nullable<Node>;
  100048. /**
  100049. * Gets a mesh using a given name
  100050. * @param name defines the name to search for
  100051. * @return the found mesh or null if not found at all.
  100052. */
  100053. getMeshByName(name: string): Nullable<AbstractMesh>;
  100054. /**
  100055. * Gets a transform node using a given name
  100056. * @param name defines the name to search for
  100057. * @return the found transform node or null if not found at all.
  100058. */
  100059. getTransformNodeByName(name: string): Nullable<TransformNode>;
  100060. /**
  100061. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  100062. * @param id defines the id to search for
  100063. * @return the found skeleton or null if not found at all.
  100064. */
  100065. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  100066. /**
  100067. * Gets a skeleton using a given auto generated unique id
  100068. * @param uniqueId defines the unique id to search for
  100069. * @return the found skeleton or null if not found at all.
  100070. */
  100071. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  100072. /**
  100073. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  100074. * @param id defines the id to search for
  100075. * @return the found skeleton or null if not found at all.
  100076. */
  100077. getSkeletonById(id: string): Nullable<Skeleton>;
  100078. /**
  100079. * Gets a skeleton using a given name
  100080. * @param name defines the name to search for
  100081. * @return the found skeleton or null if not found at all.
  100082. */
  100083. getSkeletonByName(name: string): Nullable<Skeleton>;
  100084. /**
  100085. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  100086. * @param id defines the id to search for
  100087. * @return the found morph target manager or null if not found at all.
  100088. */
  100089. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  100090. /**
  100091. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  100092. * @param id defines the id to search for
  100093. * @return the found morph target or null if not found at all.
  100094. */
  100095. getMorphTargetById(id: string): Nullable<MorphTarget>;
  100096. /**
  100097. * Gets a boolean indicating if the given mesh is active
  100098. * @param mesh defines the mesh to look for
  100099. * @returns true if the mesh is in the active list
  100100. */
  100101. isActiveMesh(mesh: AbstractMesh): boolean;
  100102. /**
  100103. * Return a unique id as a string which can serve as an identifier for the scene
  100104. */
  100105. readonly uid: string;
  100106. /**
  100107. * Add an externaly attached data from its key.
  100108. * This method call will fail and return false, if such key already exists.
  100109. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  100110. * @param key the unique key that identifies the data
  100111. * @param data the data object to associate to the key for this Engine instance
  100112. * @return true if no such key were already present and the data was added successfully, false otherwise
  100113. */
  100114. addExternalData<T>(key: string, data: T): boolean;
  100115. /**
  100116. * Get an externaly attached data from its key
  100117. * @param key the unique key that identifies the data
  100118. * @return the associated data, if present (can be null), or undefined if not present
  100119. */
  100120. getExternalData<T>(key: string): Nullable<T>;
  100121. /**
  100122. * Get an externaly attached data from its key, create it using a factory if it's not already present
  100123. * @param key the unique key that identifies the data
  100124. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  100125. * @return the associated data, can be null if the factory returned null.
  100126. */
  100127. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  100128. /**
  100129. * Remove an externaly attached data from the Engine instance
  100130. * @param key the unique key that identifies the data
  100131. * @return true if the data was successfully removed, false if it doesn't exist
  100132. */
  100133. removeExternalData(key: string): boolean;
  100134. private _evaluateSubMesh;
  100135. /**
  100136. * Clear the processed materials smart array preventing retention point in material dispose.
  100137. */
  100138. freeProcessedMaterials(): void;
  100139. private _preventFreeActiveMeshesAndRenderingGroups;
  100140. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  100141. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  100142. * when disposing several meshes in a row or a hierarchy of meshes.
  100143. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  100144. */
  100145. blockfreeActiveMeshesAndRenderingGroups: boolean;
  100146. /**
  100147. * Clear the active meshes smart array preventing retention point in mesh dispose.
  100148. */
  100149. freeActiveMeshes(): void;
  100150. /**
  100151. * Clear the info related to rendering groups preventing retention points during dispose.
  100152. */
  100153. freeRenderingGroups(): void;
  100154. /** @hidden */
  100155. _isInIntermediateRendering(): boolean;
  100156. /**
  100157. * Lambda returning the list of potentially active meshes.
  100158. */
  100159. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  100160. /**
  100161. * Lambda returning the list of potentially active sub meshes.
  100162. */
  100163. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  100164. /**
  100165. * Lambda returning the list of potentially intersecting sub meshes.
  100166. */
  100167. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  100168. /**
  100169. * Lambda returning the list of potentially colliding sub meshes.
  100170. */
  100171. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  100172. private _activeMeshesFrozen;
  100173. /**
  100174. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  100175. * @returns the current scene
  100176. */
  100177. freezeActiveMeshes(): Scene;
  100178. /**
  100179. * Use this function to restart evaluating active meshes on every frame
  100180. * @returns the current scene
  100181. */
  100182. unfreezeActiveMeshes(): Scene;
  100183. private _evaluateActiveMeshes;
  100184. private _activeMesh;
  100185. /**
  100186. * Update the transform matrix to update from the current active camera
  100187. * @param force defines a boolean used to force the update even if cache is up to date
  100188. */
  100189. updateTransformMatrix(force?: boolean): void;
  100190. private _bindFrameBuffer;
  100191. /** @hidden */
  100192. _allowPostProcessClearColor: boolean;
  100193. /** @hidden */
  100194. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  100195. private _processSubCameras;
  100196. private _checkIntersections;
  100197. /** @hidden */
  100198. _advancePhysicsEngineStep(step: number): void;
  100199. /**
  100200. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  100201. */
  100202. getDeterministicFrameTime: () => number;
  100203. /** @hidden */
  100204. _animate(): void;
  100205. /** Execute all animations (for a frame) */
  100206. animate(): void;
  100207. /**
  100208. * Render the scene
  100209. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  100210. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  100211. */
  100212. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  100213. /**
  100214. * Freeze all materials
  100215. * A frozen material will not be updatable but should be faster to render
  100216. */
  100217. freezeMaterials(): void;
  100218. /**
  100219. * Unfreeze all materials
  100220. * A frozen material will not be updatable but should be faster to render
  100221. */
  100222. unfreezeMaterials(): void;
  100223. /**
  100224. * Releases all held ressources
  100225. */
  100226. dispose(): void;
  100227. /**
  100228. * Gets if the scene is already disposed
  100229. */
  100230. readonly isDisposed: boolean;
  100231. /**
  100232. * Call this function to reduce memory footprint of the scene.
  100233. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  100234. */
  100235. clearCachedVertexData(): void;
  100236. /**
  100237. * This function will remove the local cached buffer data from texture.
  100238. * It will save memory but will prevent the texture from being rebuilt
  100239. */
  100240. cleanCachedTextureBuffer(): void;
  100241. /**
  100242. * Get the world extend vectors with an optional filter
  100243. *
  100244. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  100245. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  100246. */
  100247. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  100248. min: Vector3;
  100249. max: Vector3;
  100250. };
  100251. /**
  100252. * Creates a ray that can be used to pick in the scene
  100253. * @param x defines the x coordinate of the origin (on-screen)
  100254. * @param y defines the y coordinate of the origin (on-screen)
  100255. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  100256. * @param camera defines the camera to use for the picking
  100257. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  100258. * @returns a Ray
  100259. */
  100260. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  100261. /**
  100262. * Creates a ray that can be used to pick in the scene
  100263. * @param x defines the x coordinate of the origin (on-screen)
  100264. * @param y defines the y coordinate of the origin (on-screen)
  100265. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  100266. * @param result defines the ray where to store the picking ray
  100267. * @param camera defines the camera to use for the picking
  100268. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  100269. * @returns the current scene
  100270. */
  100271. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  100272. /**
  100273. * Creates a ray that can be used to pick in the scene
  100274. * @param x defines the x coordinate of the origin (on-screen)
  100275. * @param y defines the y coordinate of the origin (on-screen)
  100276. * @param camera defines the camera to use for the picking
  100277. * @returns a Ray
  100278. */
  100279. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  100280. /**
  100281. * Creates a ray that can be used to pick in the scene
  100282. * @param x defines the x coordinate of the origin (on-screen)
  100283. * @param y defines the y coordinate of the origin (on-screen)
  100284. * @param result defines the ray where to store the picking ray
  100285. * @param camera defines the camera to use for the picking
  100286. * @returns the current scene
  100287. */
  100288. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  100289. /** Launch a ray to try to pick a mesh in the scene
  100290. * @param x position on screen
  100291. * @param y position on screen
  100292. * @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
  100293. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  100294. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  100295. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  100296. * @returns a PickingInfo
  100297. */
  100298. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  100299. /** Use the given ray to pick a mesh in the scene
  100300. * @param ray The ray to use to pick meshes
  100301. * @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
  100302. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  100303. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  100304. * @returns a PickingInfo
  100305. */
  100306. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  100307. /**
  100308. * Launch a ray to try to pick a mesh in the scene
  100309. * @param x X position on screen
  100310. * @param y Y position on screen
  100311. * @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
  100312. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  100313. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  100314. * @returns an array of PickingInfo
  100315. */
  100316. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  100317. /**
  100318. * Launch a ray to try to pick a mesh in the scene
  100319. * @param ray Ray to use
  100320. * @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
  100321. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  100322. * @returns an array of PickingInfo
  100323. */
  100324. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  100325. /**
  100326. * Force the value of meshUnderPointer
  100327. * @param mesh defines the mesh to use
  100328. */
  100329. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  100330. /**
  100331. * Gets the mesh under the pointer
  100332. * @returns a Mesh or null if no mesh is under the pointer
  100333. */
  100334. getPointerOverMesh(): Nullable<AbstractMesh>;
  100335. /** @hidden */
  100336. _rebuildGeometries(): void;
  100337. /** @hidden */
  100338. _rebuildTextures(): void;
  100339. private _getByTags;
  100340. /**
  100341. * Get a list of meshes by tags
  100342. * @param tagsQuery defines the tags query to use
  100343. * @param forEach defines a predicate used to filter results
  100344. * @returns an array of Mesh
  100345. */
  100346. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  100347. /**
  100348. * Get a list of cameras by tags
  100349. * @param tagsQuery defines the tags query to use
  100350. * @param forEach defines a predicate used to filter results
  100351. * @returns an array of Camera
  100352. */
  100353. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  100354. /**
  100355. * Get a list of lights by tags
  100356. * @param tagsQuery defines the tags query to use
  100357. * @param forEach defines a predicate used to filter results
  100358. * @returns an array of Light
  100359. */
  100360. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  100361. /**
  100362. * Get a list of materials by tags
  100363. * @param tagsQuery defines the tags query to use
  100364. * @param forEach defines a predicate used to filter results
  100365. * @returns an array of Material
  100366. */
  100367. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  100368. /**
  100369. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  100370. * This allowed control for front to back rendering or reversly depending of the special needs.
  100371. *
  100372. * @param renderingGroupId The rendering group id corresponding to its index
  100373. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  100374. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  100375. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  100376. */
  100377. 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;
  100378. /**
  100379. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  100380. *
  100381. * @param renderingGroupId The rendering group id corresponding to its index
  100382. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  100383. * @param depth Automatically clears depth between groups if true and autoClear is true.
  100384. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  100385. */
  100386. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  100387. /**
  100388. * Gets the current auto clear configuration for one rendering group of the rendering
  100389. * manager.
  100390. * @param index the rendering group index to get the information for
  100391. * @returns The auto clear setup for the requested rendering group
  100392. */
  100393. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  100394. private _blockMaterialDirtyMechanism;
  100395. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  100396. blockMaterialDirtyMechanism: boolean;
  100397. /**
  100398. * Will flag all materials as dirty to trigger new shader compilation
  100399. * @param flag defines the flag used to specify which material part must be marked as dirty
  100400. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  100401. */
  100402. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  100403. /** @hidden */
  100404. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  100405. /** @hidden */
  100406. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  100407. }
  100408. }
  100409. declare module BABYLON {
  100410. /**
  100411. * Set of assets to keep when moving a scene into an asset container.
  100412. */
  100413. export class KeepAssets extends AbstractScene {
  100414. }
  100415. /**
  100416. * Container with a set of assets that can be added or removed from a scene.
  100417. */
  100418. export class AssetContainer extends AbstractScene {
  100419. /**
  100420. * The scene the AssetContainer belongs to.
  100421. */
  100422. scene: Scene;
  100423. /**
  100424. * Instantiates an AssetContainer.
  100425. * @param scene The scene the AssetContainer belongs to.
  100426. */
  100427. constructor(scene: Scene);
  100428. /**
  100429. * Adds all the assets from the container to the scene.
  100430. */
  100431. addAllToScene(): void;
  100432. /**
  100433. * Removes all the assets in the container from the scene
  100434. */
  100435. removeAllFromScene(): void;
  100436. /**
  100437. * Disposes all the assets in the container
  100438. */
  100439. dispose(): void;
  100440. private _moveAssets;
  100441. /**
  100442. * Removes all the assets contained in the scene and adds them to the container.
  100443. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  100444. */
  100445. moveAllFromScene(keepAssets?: KeepAssets): void;
  100446. /**
  100447. * 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.
  100448. * @returns the root mesh
  100449. */
  100450. createRootMesh(): Mesh;
  100451. }
  100452. }
  100453. declare module BABYLON {
  100454. /**
  100455. * Defines how the parser contract is defined.
  100456. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  100457. */
  100458. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  100459. /**
  100460. * Defines how the individual parser contract is defined.
  100461. * These parser can parse an individual asset
  100462. */
  100463. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  100464. /**
  100465. * Base class of the scene acting as a container for the different elements composing a scene.
  100466. * This class is dynamically extended by the different components of the scene increasing
  100467. * flexibility and reducing coupling
  100468. */
  100469. export abstract class AbstractScene {
  100470. /**
  100471. * Stores the list of available parsers in the application.
  100472. */
  100473. private static _BabylonFileParsers;
  100474. /**
  100475. * Stores the list of available individual parsers in the application.
  100476. */
  100477. private static _IndividualBabylonFileParsers;
  100478. /**
  100479. * Adds a parser in the list of available ones
  100480. * @param name Defines the name of the parser
  100481. * @param parser Defines the parser to add
  100482. */
  100483. static AddParser(name: string, parser: BabylonFileParser): void;
  100484. /**
  100485. * Gets a general parser from the list of avaialble ones
  100486. * @param name Defines the name of the parser
  100487. * @returns the requested parser or null
  100488. */
  100489. static GetParser(name: string): Nullable<BabylonFileParser>;
  100490. /**
  100491. * Adds n individual parser in the list of available ones
  100492. * @param name Defines the name of the parser
  100493. * @param parser Defines the parser to add
  100494. */
  100495. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  100496. /**
  100497. * Gets an individual parser from the list of avaialble ones
  100498. * @param name Defines the name of the parser
  100499. * @returns the requested parser or null
  100500. */
  100501. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  100502. /**
  100503. * Parser json data and populate both a scene and its associated container object
  100504. * @param jsonData Defines the data to parse
  100505. * @param scene Defines the scene to parse the data for
  100506. * @param container Defines the container attached to the parsing sequence
  100507. * @param rootUrl Defines the root url of the data
  100508. */
  100509. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  100510. /**
  100511. * Gets the list of root nodes (ie. nodes with no parent)
  100512. */
  100513. rootNodes: Node[];
  100514. /** All of the cameras added to this scene
  100515. * @see http://doc.babylonjs.com/babylon101/cameras
  100516. */
  100517. cameras: Camera[];
  100518. /**
  100519. * All of the lights added to this scene
  100520. * @see http://doc.babylonjs.com/babylon101/lights
  100521. */
  100522. lights: Light[];
  100523. /**
  100524. * All of the (abstract) meshes added to this scene
  100525. */
  100526. meshes: AbstractMesh[];
  100527. /**
  100528. * The list of skeletons added to the scene
  100529. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  100530. */
  100531. skeletons: Skeleton[];
  100532. /**
  100533. * All of the particle systems added to this scene
  100534. * @see http://doc.babylonjs.com/babylon101/particles
  100535. */
  100536. particleSystems: IParticleSystem[];
  100537. /**
  100538. * Gets a list of Animations associated with the scene
  100539. */
  100540. animations: Animation[];
  100541. /**
  100542. * All of the animation groups added to this scene
  100543. * @see http://doc.babylonjs.com/how_to/group
  100544. */
  100545. animationGroups: AnimationGroup[];
  100546. /**
  100547. * All of the multi-materials added to this scene
  100548. * @see http://doc.babylonjs.com/how_to/multi_materials
  100549. */
  100550. multiMaterials: MultiMaterial[];
  100551. /**
  100552. * All of the materials added to this scene
  100553. * In the context of a Scene, it is not supposed to be modified manually.
  100554. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  100555. * Note also that the order of the Material wihin the array is not significant and might change.
  100556. * @see http://doc.babylonjs.com/babylon101/materials
  100557. */
  100558. materials: Material[];
  100559. /**
  100560. * The list of morph target managers added to the scene
  100561. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  100562. */
  100563. morphTargetManagers: MorphTargetManager[];
  100564. /**
  100565. * The list of geometries used in the scene.
  100566. */
  100567. geometries: Geometry[];
  100568. /**
  100569. * All of the tranform nodes added to this scene
  100570. * In the context of a Scene, it is not supposed to be modified manually.
  100571. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  100572. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  100573. * @see http://doc.babylonjs.com/how_to/transformnode
  100574. */
  100575. transformNodes: TransformNode[];
  100576. /**
  100577. * ActionManagers available on the scene.
  100578. */
  100579. actionManagers: AbstractActionManager[];
  100580. /**
  100581. * Textures to keep.
  100582. */
  100583. textures: BaseTexture[];
  100584. /**
  100585. * Environment texture for the scene
  100586. */
  100587. environmentTexture: Nullable<BaseTexture>;
  100588. }
  100589. }
  100590. declare module BABYLON {
  100591. /**
  100592. * Interface used to define options for Sound class
  100593. */
  100594. export interface ISoundOptions {
  100595. /**
  100596. * Does the sound autoplay once loaded.
  100597. */
  100598. autoplay?: boolean;
  100599. /**
  100600. * Does the sound loop after it finishes playing once.
  100601. */
  100602. loop?: boolean;
  100603. /**
  100604. * Sound's volume
  100605. */
  100606. volume?: number;
  100607. /**
  100608. * Is it a spatial sound?
  100609. */
  100610. spatialSound?: boolean;
  100611. /**
  100612. * Maximum distance to hear that sound
  100613. */
  100614. maxDistance?: number;
  100615. /**
  100616. * Uses user defined attenuation function
  100617. */
  100618. useCustomAttenuation?: boolean;
  100619. /**
  100620. * Define the roll off factor of spatial sounds.
  100621. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100622. */
  100623. rolloffFactor?: number;
  100624. /**
  100625. * Define the reference distance the sound should be heard perfectly.
  100626. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100627. */
  100628. refDistance?: number;
  100629. /**
  100630. * Define the distance attenuation model the sound will follow.
  100631. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100632. */
  100633. distanceModel?: string;
  100634. /**
  100635. * Defines the playback speed (1 by default)
  100636. */
  100637. playbackRate?: number;
  100638. /**
  100639. * Defines if the sound is from a streaming source
  100640. */
  100641. streaming?: boolean;
  100642. /**
  100643. * Defines an optional length (in seconds) inside the sound file
  100644. */
  100645. length?: number;
  100646. /**
  100647. * Defines an optional offset (in seconds) inside the sound file
  100648. */
  100649. offset?: number;
  100650. /**
  100651. * If true, URLs will not be required to state the audio file codec to use.
  100652. */
  100653. skipCodecCheck?: boolean;
  100654. }
  100655. /**
  100656. * Defines a sound that can be played in the application.
  100657. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  100658. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  100659. */
  100660. export class Sound {
  100661. /**
  100662. * The name of the sound in the scene.
  100663. */
  100664. name: string;
  100665. /**
  100666. * Does the sound autoplay once loaded.
  100667. */
  100668. autoplay: boolean;
  100669. /**
  100670. * Does the sound loop after it finishes playing once.
  100671. */
  100672. loop: boolean;
  100673. /**
  100674. * Does the sound use a custom attenuation curve to simulate the falloff
  100675. * happening when the source gets further away from the camera.
  100676. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  100677. */
  100678. useCustomAttenuation: boolean;
  100679. /**
  100680. * The sound track id this sound belongs to.
  100681. */
  100682. soundTrackId: number;
  100683. /**
  100684. * Is this sound currently played.
  100685. */
  100686. isPlaying: boolean;
  100687. /**
  100688. * Is this sound currently paused.
  100689. */
  100690. isPaused: boolean;
  100691. /**
  100692. * Does this sound enables spatial sound.
  100693. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100694. */
  100695. spatialSound: boolean;
  100696. /**
  100697. * Define the reference distance the sound should be heard perfectly.
  100698. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100699. */
  100700. refDistance: number;
  100701. /**
  100702. * Define the roll off factor of spatial sounds.
  100703. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100704. */
  100705. rolloffFactor: number;
  100706. /**
  100707. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  100708. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100709. */
  100710. maxDistance: number;
  100711. /**
  100712. * Define the distance attenuation model the sound will follow.
  100713. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100714. */
  100715. distanceModel: string;
  100716. /**
  100717. * @hidden
  100718. * Back Compat
  100719. **/
  100720. onended: () => any;
  100721. /**
  100722. * Observable event when the current playing sound finishes.
  100723. */
  100724. onEndedObservable: Observable<Sound>;
  100725. private _panningModel;
  100726. private _playbackRate;
  100727. private _streaming;
  100728. private _startTime;
  100729. private _startOffset;
  100730. private _position;
  100731. /** @hidden */
  100732. _positionInEmitterSpace: boolean;
  100733. private _localDirection;
  100734. private _volume;
  100735. private _isReadyToPlay;
  100736. private _isDirectional;
  100737. private _readyToPlayCallback;
  100738. private _audioBuffer;
  100739. private _soundSource;
  100740. private _streamingSource;
  100741. private _soundPanner;
  100742. private _soundGain;
  100743. private _inputAudioNode;
  100744. private _outputAudioNode;
  100745. private _coneInnerAngle;
  100746. private _coneOuterAngle;
  100747. private _coneOuterGain;
  100748. private _scene;
  100749. private _connectedTransformNode;
  100750. private _customAttenuationFunction;
  100751. private _registerFunc;
  100752. private _isOutputConnected;
  100753. private _htmlAudioElement;
  100754. private _urlType;
  100755. private _length?;
  100756. private _offset?;
  100757. /** @hidden */
  100758. static _SceneComponentInitialization: (scene: Scene) => void;
  100759. /**
  100760. * Create a sound and attach it to a scene
  100761. * @param name Name of your sound
  100762. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  100763. * @param scene defines the scene the sound belongs to
  100764. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  100765. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  100766. */
  100767. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  100768. /**
  100769. * Release the sound and its associated resources
  100770. */
  100771. dispose(): void;
  100772. /**
  100773. * Gets if the sounds is ready to be played or not.
  100774. * @returns true if ready, otherwise false
  100775. */
  100776. isReady(): boolean;
  100777. private _soundLoaded;
  100778. /**
  100779. * Sets the data of the sound from an audiobuffer
  100780. * @param audioBuffer The audioBuffer containing the data
  100781. */
  100782. setAudioBuffer(audioBuffer: AudioBuffer): void;
  100783. /**
  100784. * Updates the current sounds options such as maxdistance, loop...
  100785. * @param options A JSON object containing values named as the object properties
  100786. */
  100787. updateOptions(options: ISoundOptions): void;
  100788. private _createSpatialParameters;
  100789. private _updateSpatialParameters;
  100790. /**
  100791. * Switch the panning model to HRTF:
  100792. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  100793. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100794. */
  100795. switchPanningModelToHRTF(): void;
  100796. /**
  100797. * Switch the panning model to Equal Power:
  100798. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  100799. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100800. */
  100801. switchPanningModelToEqualPower(): void;
  100802. private _switchPanningModel;
  100803. /**
  100804. * Connect this sound to a sound track audio node like gain...
  100805. * @param soundTrackAudioNode the sound track audio node to connect to
  100806. */
  100807. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  100808. /**
  100809. * Transform this sound into a directional source
  100810. * @param coneInnerAngle Size of the inner cone in degree
  100811. * @param coneOuterAngle Size of the outer cone in degree
  100812. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  100813. */
  100814. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  100815. /**
  100816. * Gets or sets the inner angle for the directional cone.
  100817. */
  100818. /**
  100819. * Gets or sets the inner angle for the directional cone.
  100820. */
  100821. directionalConeInnerAngle: number;
  100822. /**
  100823. * Gets or sets the outer angle for the directional cone.
  100824. */
  100825. /**
  100826. * Gets or sets the outer angle for the directional cone.
  100827. */
  100828. directionalConeOuterAngle: number;
  100829. /**
  100830. * Sets the position of the emitter if spatial sound is enabled
  100831. * @param newPosition Defines the new posisiton
  100832. */
  100833. setPosition(newPosition: Vector3): void;
  100834. /**
  100835. * Sets the local direction of the emitter if spatial sound is enabled
  100836. * @param newLocalDirection Defines the new local direction
  100837. */
  100838. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  100839. private _updateDirection;
  100840. /** @hidden */
  100841. updateDistanceFromListener(): void;
  100842. /**
  100843. * Sets a new custom attenuation function for the sound.
  100844. * @param callback Defines the function used for the attenuation
  100845. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  100846. */
  100847. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  100848. /**
  100849. * Play the sound
  100850. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  100851. * @param offset (optional) Start the sound at a specific time in seconds
  100852. * @param length (optional) Sound duration (in seconds)
  100853. */
  100854. play(time?: number, offset?: number, length?: number): void;
  100855. private _onended;
  100856. /**
  100857. * Stop the sound
  100858. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  100859. */
  100860. stop(time?: number): void;
  100861. /**
  100862. * Put the sound in pause
  100863. */
  100864. pause(): void;
  100865. /**
  100866. * Sets a dedicated volume for this sounds
  100867. * @param newVolume Define the new volume of the sound
  100868. * @param time Define time for gradual change to new volume
  100869. */
  100870. setVolume(newVolume: number, time?: number): void;
  100871. /**
  100872. * Set the sound play back rate
  100873. * @param newPlaybackRate Define the playback rate the sound should be played at
  100874. */
  100875. setPlaybackRate(newPlaybackRate: number): void;
  100876. /**
  100877. * Gets the volume of the sound.
  100878. * @returns the volume of the sound
  100879. */
  100880. getVolume(): number;
  100881. /**
  100882. * Attach the sound to a dedicated mesh
  100883. * @param transformNode The transform node to connect the sound with
  100884. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  100885. */
  100886. attachToMesh(transformNode: TransformNode): void;
  100887. /**
  100888. * Detach the sound from the previously attached mesh
  100889. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  100890. */
  100891. detachFromMesh(): void;
  100892. private _onRegisterAfterWorldMatrixUpdate;
  100893. /**
  100894. * Clone the current sound in the scene.
  100895. * @returns the new sound clone
  100896. */
  100897. clone(): Nullable<Sound>;
  100898. /**
  100899. * Gets the current underlying audio buffer containing the data
  100900. * @returns the audio buffer
  100901. */
  100902. getAudioBuffer(): Nullable<AudioBuffer>;
  100903. /**
  100904. * Serializes the Sound in a JSON representation
  100905. * @returns the JSON representation of the sound
  100906. */
  100907. serialize(): any;
  100908. /**
  100909. * Parse a JSON representation of a sound to innstantiate in a given scene
  100910. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  100911. * @param scene Define the scene the new parsed sound should be created in
  100912. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  100913. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  100914. * @returns the newly parsed sound
  100915. */
  100916. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  100917. }
  100918. }
  100919. declare module BABYLON {
  100920. /**
  100921. * This defines an action helpful to play a defined sound on a triggered action.
  100922. */
  100923. export class PlaySoundAction extends Action {
  100924. private _sound;
  100925. /**
  100926. * Instantiate the action
  100927. * @param triggerOptions defines the trigger options
  100928. * @param sound defines the sound to play
  100929. * @param condition defines the trigger related conditions
  100930. */
  100931. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  100932. /** @hidden */
  100933. _prepare(): void;
  100934. /**
  100935. * Execute the action and play the sound.
  100936. */
  100937. execute(): void;
  100938. /**
  100939. * Serializes the actions and its related information.
  100940. * @param parent defines the object to serialize in
  100941. * @returns the serialized object
  100942. */
  100943. serialize(parent: any): any;
  100944. }
  100945. /**
  100946. * This defines an action helpful to stop a defined sound on a triggered action.
  100947. */
  100948. export class StopSoundAction extends Action {
  100949. private _sound;
  100950. /**
  100951. * Instantiate the action
  100952. * @param triggerOptions defines the trigger options
  100953. * @param sound defines the sound to stop
  100954. * @param condition defines the trigger related conditions
  100955. */
  100956. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  100957. /** @hidden */
  100958. _prepare(): void;
  100959. /**
  100960. * Execute the action and stop the sound.
  100961. */
  100962. execute(): void;
  100963. /**
  100964. * Serializes the actions and its related information.
  100965. * @param parent defines the object to serialize in
  100966. * @returns the serialized object
  100967. */
  100968. serialize(parent: any): any;
  100969. }
  100970. }
  100971. declare module BABYLON {
  100972. /**
  100973. * This defines an action responsible to change the value of a property
  100974. * by interpolating between its current value and the newly set one once triggered.
  100975. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  100976. */
  100977. export class InterpolateValueAction extends Action {
  100978. /**
  100979. * Defines the path of the property where the value should be interpolated
  100980. */
  100981. propertyPath: string;
  100982. /**
  100983. * Defines the target value at the end of the interpolation.
  100984. */
  100985. value: any;
  100986. /**
  100987. * Defines the time it will take for the property to interpolate to the value.
  100988. */
  100989. duration: number;
  100990. /**
  100991. * Defines if the other scene animations should be stopped when the action has been triggered
  100992. */
  100993. stopOtherAnimations?: boolean;
  100994. /**
  100995. * Defines a callback raised once the interpolation animation has been done.
  100996. */
  100997. onInterpolationDone?: () => void;
  100998. /**
  100999. * Observable triggered once the interpolation animation has been done.
  101000. */
  101001. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  101002. private _target;
  101003. private _effectiveTarget;
  101004. private _property;
  101005. /**
  101006. * Instantiate the action
  101007. * @param triggerOptions defines the trigger options
  101008. * @param target defines the object containing the value to interpolate
  101009. * @param propertyPath defines the path to the property in the target object
  101010. * @param value defines the target value at the end of the interpolation
  101011. * @param duration deines the time it will take for the property to interpolate to the value.
  101012. * @param condition defines the trigger related conditions
  101013. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  101014. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  101015. */
  101016. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  101017. /** @hidden */
  101018. _prepare(): void;
  101019. /**
  101020. * Execute the action starts the value interpolation.
  101021. */
  101022. execute(): void;
  101023. /**
  101024. * Serializes the actions and its related information.
  101025. * @param parent defines the object to serialize in
  101026. * @returns the serialized object
  101027. */
  101028. serialize(parent: any): any;
  101029. }
  101030. }
  101031. declare module BABYLON {
  101032. /**
  101033. * Options allowed during the creation of a sound track.
  101034. */
  101035. export interface ISoundTrackOptions {
  101036. /**
  101037. * The volume the sound track should take during creation
  101038. */
  101039. volume?: number;
  101040. /**
  101041. * Define if the sound track is the main sound track of the scene
  101042. */
  101043. mainTrack?: boolean;
  101044. }
  101045. /**
  101046. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  101047. * It will be also used in a future release to apply effects on a specific track.
  101048. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  101049. */
  101050. export class SoundTrack {
  101051. /**
  101052. * The unique identifier of the sound track in the scene.
  101053. */
  101054. id: number;
  101055. /**
  101056. * The list of sounds included in the sound track.
  101057. */
  101058. soundCollection: Array<Sound>;
  101059. private _outputAudioNode;
  101060. private _scene;
  101061. private _isMainTrack;
  101062. private _connectedAnalyser;
  101063. private _options;
  101064. private _isInitialized;
  101065. /**
  101066. * Creates a new sound track.
  101067. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  101068. * @param scene Define the scene the sound track belongs to
  101069. * @param options
  101070. */
  101071. constructor(scene: Scene, options?: ISoundTrackOptions);
  101072. private _initializeSoundTrackAudioGraph;
  101073. /**
  101074. * Release the sound track and its associated resources
  101075. */
  101076. dispose(): void;
  101077. /**
  101078. * Adds a sound to this sound track
  101079. * @param sound define the cound to add
  101080. * @ignoreNaming
  101081. */
  101082. AddSound(sound: Sound): void;
  101083. /**
  101084. * Removes a sound to this sound track
  101085. * @param sound define the cound to remove
  101086. * @ignoreNaming
  101087. */
  101088. RemoveSound(sound: Sound): void;
  101089. /**
  101090. * Set a global volume for the full sound track.
  101091. * @param newVolume Define the new volume of the sound track
  101092. */
  101093. setVolume(newVolume: number): void;
  101094. /**
  101095. * Switch the panning model to HRTF:
  101096. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  101097. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101098. */
  101099. switchPanningModelToHRTF(): void;
  101100. /**
  101101. * Switch the panning model to Equal Power:
  101102. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  101103. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101104. */
  101105. switchPanningModelToEqualPower(): void;
  101106. /**
  101107. * Connect the sound track to an audio analyser allowing some amazing
  101108. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  101109. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  101110. * @param analyser The analyser to connect to the engine
  101111. */
  101112. connectToAnalyser(analyser: Analyser): void;
  101113. }
  101114. }
  101115. declare module BABYLON {
  101116. interface AbstractScene {
  101117. /**
  101118. * The list of sounds used in the scene.
  101119. */
  101120. sounds: Nullable<Array<Sound>>;
  101121. }
  101122. interface Scene {
  101123. /**
  101124. * @hidden
  101125. * Backing field
  101126. */
  101127. _mainSoundTrack: SoundTrack;
  101128. /**
  101129. * The main sound track played by the scene.
  101130. * It cotains your primary collection of sounds.
  101131. */
  101132. mainSoundTrack: SoundTrack;
  101133. /**
  101134. * The list of sound tracks added to the scene
  101135. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101136. */
  101137. soundTracks: Nullable<Array<SoundTrack>>;
  101138. /**
  101139. * Gets a sound using a given name
  101140. * @param name defines the name to search for
  101141. * @return the found sound or null if not found at all.
  101142. */
  101143. getSoundByName(name: string): Nullable<Sound>;
  101144. /**
  101145. * Gets or sets if audio support is enabled
  101146. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101147. */
  101148. audioEnabled: boolean;
  101149. /**
  101150. * Gets or sets if audio will be output to headphones
  101151. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101152. */
  101153. headphone: boolean;
  101154. /**
  101155. * Gets or sets custom audio listener position provider
  101156. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101157. */
  101158. audioListenerPositionProvider: Nullable<() => Vector3>;
  101159. }
  101160. /**
  101161. * Defines the sound scene component responsible to manage any sounds
  101162. * in a given scene.
  101163. */
  101164. export class AudioSceneComponent implements ISceneSerializableComponent {
  101165. /**
  101166. * The component name helpfull to identify the component in the list of scene components.
  101167. */
  101168. readonly name: string;
  101169. /**
  101170. * The scene the component belongs to.
  101171. */
  101172. scene: Scene;
  101173. private _audioEnabled;
  101174. /**
  101175. * Gets whether audio is enabled or not.
  101176. * Please use related enable/disable method to switch state.
  101177. */
  101178. readonly audioEnabled: boolean;
  101179. private _headphone;
  101180. /**
  101181. * Gets whether audio is outputing to headphone or not.
  101182. * Please use the according Switch methods to change output.
  101183. */
  101184. readonly headphone: boolean;
  101185. private _audioListenerPositionProvider;
  101186. /**
  101187. * Gets the current audio listener position provider
  101188. */
  101189. /**
  101190. * Sets a custom listener position for all sounds in the scene
  101191. * By default, this is the position of the first active camera
  101192. */
  101193. audioListenerPositionProvider: Nullable<() => Vector3>;
  101194. /**
  101195. * Creates a new instance of the component for the given scene
  101196. * @param scene Defines the scene to register the component in
  101197. */
  101198. constructor(scene: Scene);
  101199. /**
  101200. * Registers the component in a given scene
  101201. */
  101202. register(): void;
  101203. /**
  101204. * Rebuilds the elements related to this component in case of
  101205. * context lost for instance.
  101206. */
  101207. rebuild(): void;
  101208. /**
  101209. * Serializes the component data to the specified json object
  101210. * @param serializationObject The object to serialize to
  101211. */
  101212. serialize(serializationObject: any): void;
  101213. /**
  101214. * Adds all the elements from the container to the scene
  101215. * @param container the container holding the elements
  101216. */
  101217. addFromContainer(container: AbstractScene): void;
  101218. /**
  101219. * Removes all the elements in the container from the scene
  101220. * @param container contains the elements to remove
  101221. * @param dispose if the removed element should be disposed (default: false)
  101222. */
  101223. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  101224. /**
  101225. * Disposes the component and the associated ressources.
  101226. */
  101227. dispose(): void;
  101228. /**
  101229. * Disables audio in the associated scene.
  101230. */
  101231. disableAudio(): void;
  101232. /**
  101233. * Enables audio in the associated scene.
  101234. */
  101235. enableAudio(): void;
  101236. /**
  101237. * Switch audio to headphone output.
  101238. */
  101239. switchAudioModeForHeadphones(): void;
  101240. /**
  101241. * Switch audio to normal speakers.
  101242. */
  101243. switchAudioModeForNormalSpeakers(): void;
  101244. private _afterRender;
  101245. }
  101246. }
  101247. declare module BABYLON {
  101248. /**
  101249. * Wraps one or more Sound objects and selects one with random weight for playback.
  101250. */
  101251. export class WeightedSound {
  101252. /** When true a Sound will be selected and played when the current playing Sound completes. */
  101253. loop: boolean;
  101254. private _coneInnerAngle;
  101255. private _coneOuterAngle;
  101256. private _volume;
  101257. /** A Sound is currently playing. */
  101258. isPlaying: boolean;
  101259. /** A Sound is currently paused. */
  101260. isPaused: boolean;
  101261. private _sounds;
  101262. private _weights;
  101263. private _currentIndex?;
  101264. /**
  101265. * Creates a new WeightedSound from the list of sounds given.
  101266. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  101267. * @param sounds Array of Sounds that will be selected from.
  101268. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  101269. */
  101270. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  101271. /**
  101272. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  101273. */
  101274. /**
  101275. * The size of cone in degress for a directional sound in which there will be no attenuation.
  101276. */
  101277. directionalConeInnerAngle: number;
  101278. /**
  101279. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  101280. * Listener angles between innerAngle and outerAngle will falloff linearly.
  101281. */
  101282. /**
  101283. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  101284. * Listener angles between innerAngle and outerAngle will falloff linearly.
  101285. */
  101286. directionalConeOuterAngle: number;
  101287. /**
  101288. * Playback volume.
  101289. */
  101290. /**
  101291. * Playback volume.
  101292. */
  101293. volume: number;
  101294. private _onended;
  101295. /**
  101296. * Suspend playback
  101297. */
  101298. pause(): void;
  101299. /**
  101300. * Stop playback
  101301. */
  101302. stop(): void;
  101303. /**
  101304. * Start playback.
  101305. * @param startOffset Position the clip head at a specific time in seconds.
  101306. */
  101307. play(startOffset?: number): void;
  101308. }
  101309. }
  101310. declare module BABYLON {
  101311. /**
  101312. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  101313. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  101314. */
  101315. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  101316. /**
  101317. * Gets the name of the behavior.
  101318. */
  101319. readonly name: string;
  101320. /**
  101321. * The easing function used by animations
  101322. */
  101323. static EasingFunction: BackEase;
  101324. /**
  101325. * The easing mode used by animations
  101326. */
  101327. static EasingMode: number;
  101328. /**
  101329. * The duration of the animation, in milliseconds
  101330. */
  101331. transitionDuration: number;
  101332. /**
  101333. * Length of the distance animated by the transition when lower radius is reached
  101334. */
  101335. lowerRadiusTransitionRange: number;
  101336. /**
  101337. * Length of the distance animated by the transition when upper radius is reached
  101338. */
  101339. upperRadiusTransitionRange: number;
  101340. private _autoTransitionRange;
  101341. /**
  101342. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  101343. */
  101344. /**
  101345. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  101346. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  101347. */
  101348. autoTransitionRange: boolean;
  101349. private _attachedCamera;
  101350. private _onAfterCheckInputsObserver;
  101351. private _onMeshTargetChangedObserver;
  101352. /**
  101353. * Initializes the behavior.
  101354. */
  101355. init(): void;
  101356. /**
  101357. * Attaches the behavior to its arc rotate camera.
  101358. * @param camera Defines the camera to attach the behavior to
  101359. */
  101360. attach(camera: ArcRotateCamera): void;
  101361. /**
  101362. * Detaches the behavior from its current arc rotate camera.
  101363. */
  101364. detach(): void;
  101365. private _radiusIsAnimating;
  101366. private _radiusBounceTransition;
  101367. private _animatables;
  101368. private _cachedWheelPrecision;
  101369. /**
  101370. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  101371. * @param radiusLimit The limit to check against.
  101372. * @return Bool to indicate if at limit.
  101373. */
  101374. private _isRadiusAtLimit;
  101375. /**
  101376. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  101377. * @param radiusDelta The delta by which to animate to. Can be negative.
  101378. */
  101379. private _applyBoundRadiusAnimation;
  101380. /**
  101381. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  101382. */
  101383. protected _clearAnimationLocks(): void;
  101384. /**
  101385. * Stops and removes all animations that have been applied to the camera
  101386. */
  101387. stopAllAnimations(): void;
  101388. }
  101389. }
  101390. declare module BABYLON {
  101391. /**
  101392. * 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.
  101393. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  101394. */
  101395. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  101396. /**
  101397. * Gets the name of the behavior.
  101398. */
  101399. readonly name: string;
  101400. private _mode;
  101401. private _radiusScale;
  101402. private _positionScale;
  101403. private _defaultElevation;
  101404. private _elevationReturnTime;
  101405. private _elevationReturnWaitTime;
  101406. private _zoomStopsAnimation;
  101407. private _framingTime;
  101408. /**
  101409. * The easing function used by animations
  101410. */
  101411. static EasingFunction: ExponentialEase;
  101412. /**
  101413. * The easing mode used by animations
  101414. */
  101415. static EasingMode: number;
  101416. /**
  101417. * Sets the current mode used by the behavior
  101418. */
  101419. /**
  101420. * Gets current mode used by the behavior.
  101421. */
  101422. mode: number;
  101423. /**
  101424. * Sets the scale applied to the radius (1 by default)
  101425. */
  101426. /**
  101427. * Gets the scale applied to the radius
  101428. */
  101429. radiusScale: number;
  101430. /**
  101431. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  101432. */
  101433. /**
  101434. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  101435. */
  101436. positionScale: number;
  101437. /**
  101438. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  101439. * behaviour is triggered, in radians.
  101440. */
  101441. /**
  101442. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  101443. * behaviour is triggered, in radians.
  101444. */
  101445. defaultElevation: number;
  101446. /**
  101447. * Sets the time (in milliseconds) taken to return to the default beta position.
  101448. * Negative value indicates camera should not return to default.
  101449. */
  101450. /**
  101451. * Gets the time (in milliseconds) taken to return to the default beta position.
  101452. * Negative value indicates camera should not return to default.
  101453. */
  101454. elevationReturnTime: number;
  101455. /**
  101456. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  101457. */
  101458. /**
  101459. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  101460. */
  101461. elevationReturnWaitTime: number;
  101462. /**
  101463. * Sets the flag that indicates if user zooming should stop animation.
  101464. */
  101465. /**
  101466. * Gets the flag that indicates if user zooming should stop animation.
  101467. */
  101468. zoomStopsAnimation: boolean;
  101469. /**
  101470. * Sets the transition time when framing the mesh, in milliseconds
  101471. */
  101472. /**
  101473. * Gets the transition time when framing the mesh, in milliseconds
  101474. */
  101475. framingTime: number;
  101476. /**
  101477. * Define if the behavior should automatically change the configured
  101478. * camera limits and sensibilities.
  101479. */
  101480. autoCorrectCameraLimitsAndSensibility: boolean;
  101481. private _onPrePointerObservableObserver;
  101482. private _onAfterCheckInputsObserver;
  101483. private _onMeshTargetChangedObserver;
  101484. private _attachedCamera;
  101485. private _isPointerDown;
  101486. private _lastInteractionTime;
  101487. /**
  101488. * Initializes the behavior.
  101489. */
  101490. init(): void;
  101491. /**
  101492. * Attaches the behavior to its arc rotate camera.
  101493. * @param camera Defines the camera to attach the behavior to
  101494. */
  101495. attach(camera: ArcRotateCamera): void;
  101496. /**
  101497. * Detaches the behavior from its current arc rotate camera.
  101498. */
  101499. detach(): void;
  101500. private _animatables;
  101501. private _betaIsAnimating;
  101502. private _betaTransition;
  101503. private _radiusTransition;
  101504. private _vectorTransition;
  101505. /**
  101506. * Targets the given mesh and updates zoom level accordingly.
  101507. * @param mesh The mesh to target.
  101508. * @param radius Optional. If a cached radius position already exists, overrides default.
  101509. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  101510. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  101511. * @param onAnimationEnd Callback triggered at the end of the framing animation
  101512. */
  101513. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  101514. /**
  101515. * Targets the given mesh with its children and updates zoom level accordingly.
  101516. * @param mesh The mesh to target.
  101517. * @param radius Optional. If a cached radius position already exists, overrides default.
  101518. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  101519. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  101520. * @param onAnimationEnd Callback triggered at the end of the framing animation
  101521. */
  101522. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  101523. /**
  101524. * Targets the given meshes with their children and updates zoom level accordingly.
  101525. * @param meshes The mesh to target.
  101526. * @param radius Optional. If a cached radius position already exists, overrides default.
  101527. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  101528. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  101529. * @param onAnimationEnd Callback triggered at the end of the framing animation
  101530. */
  101531. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  101532. /**
  101533. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  101534. * @param minimumWorld Determines the smaller position of the bounding box extend
  101535. * @param maximumWorld Determines the bigger position of the bounding box extend
  101536. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  101537. * @param onAnimationEnd Callback triggered at the end of the framing animation
  101538. */
  101539. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  101540. /**
  101541. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  101542. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  101543. * frustum width.
  101544. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  101545. * to fully enclose the mesh in the viewing frustum.
  101546. */
  101547. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  101548. /**
  101549. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  101550. * is automatically returned to its default position (expected to be above ground plane).
  101551. */
  101552. private _maintainCameraAboveGround;
  101553. /**
  101554. * Returns the frustum slope based on the canvas ratio and camera FOV
  101555. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  101556. */
  101557. private _getFrustumSlope;
  101558. /**
  101559. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  101560. */
  101561. private _clearAnimationLocks;
  101562. /**
  101563. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  101564. */
  101565. private _applyUserInteraction;
  101566. /**
  101567. * Stops and removes all animations that have been applied to the camera
  101568. */
  101569. stopAllAnimations(): void;
  101570. /**
  101571. * Gets a value indicating if the user is moving the camera
  101572. */
  101573. readonly isUserIsMoving: boolean;
  101574. /**
  101575. * The camera can move all the way towards the mesh.
  101576. */
  101577. static IgnoreBoundsSizeMode: number;
  101578. /**
  101579. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  101580. */
  101581. static FitFrustumSidesMode: number;
  101582. }
  101583. }
  101584. declare module BABYLON {
  101585. /**
  101586. * Base class for Camera Pointer Inputs.
  101587. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  101588. * for example usage.
  101589. */
  101590. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  101591. /**
  101592. * Defines the camera the input is attached to.
  101593. */
  101594. abstract camera: Camera;
  101595. /**
  101596. * Whether keyboard modifier keys are pressed at time of last mouse event.
  101597. */
  101598. protected _altKey: boolean;
  101599. protected _ctrlKey: boolean;
  101600. protected _metaKey: boolean;
  101601. protected _shiftKey: boolean;
  101602. /**
  101603. * Which mouse buttons were pressed at time of last mouse event.
  101604. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  101605. */
  101606. protected _buttonsPressed: number;
  101607. /**
  101608. * Defines the buttons associated with the input to handle camera move.
  101609. */
  101610. buttons: number[];
  101611. /**
  101612. * Attach the input controls to a specific dom element to get the input from.
  101613. * @param element Defines the element the controls should be listened from
  101614. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101615. */
  101616. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101617. /**
  101618. * Detach the current controls from the specified dom element.
  101619. * @param element Defines the element to stop listening the inputs from
  101620. */
  101621. detachControl(element: Nullable<HTMLElement>): void;
  101622. /**
  101623. * Gets the class name of the current input.
  101624. * @returns the class name
  101625. */
  101626. getClassName(): string;
  101627. /**
  101628. * Get the friendly name associated with the input class.
  101629. * @returns the input friendly name
  101630. */
  101631. getSimpleName(): string;
  101632. /**
  101633. * Called on pointer POINTERDOUBLETAP event.
  101634. * Override this method to provide functionality on POINTERDOUBLETAP event.
  101635. */
  101636. protected onDoubleTap(type: string): void;
  101637. /**
  101638. * Called on pointer POINTERMOVE event if only a single touch is active.
  101639. * Override this method to provide functionality.
  101640. */
  101641. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  101642. /**
  101643. * Called on pointer POINTERMOVE event if multiple touches are active.
  101644. * Override this method to provide functionality.
  101645. */
  101646. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  101647. /**
  101648. * Called on JS contextmenu event.
  101649. * Override this method to provide functionality.
  101650. */
  101651. protected onContextMenu(evt: PointerEvent): void;
  101652. /**
  101653. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  101654. * press.
  101655. * Override this method to provide functionality.
  101656. */
  101657. protected onButtonDown(evt: PointerEvent): void;
  101658. /**
  101659. * Called each time a new POINTERUP event occurs. Ie, for each button
  101660. * release.
  101661. * Override this method to provide functionality.
  101662. */
  101663. protected onButtonUp(evt: PointerEvent): void;
  101664. /**
  101665. * Called when window becomes inactive.
  101666. * Override this method to provide functionality.
  101667. */
  101668. protected onLostFocus(): void;
  101669. private _pointerInput;
  101670. private _observer;
  101671. private _onLostFocus;
  101672. private pointA;
  101673. private pointB;
  101674. }
  101675. }
  101676. declare module BABYLON {
  101677. /**
  101678. * Manage the pointers inputs to control an arc rotate camera.
  101679. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101680. */
  101681. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  101682. /**
  101683. * Defines the camera the input is attached to.
  101684. */
  101685. camera: ArcRotateCamera;
  101686. /**
  101687. * Gets the class name of the current input.
  101688. * @returns the class name
  101689. */
  101690. getClassName(): string;
  101691. /**
  101692. * Defines the buttons associated with the input to handle camera move.
  101693. */
  101694. buttons: number[];
  101695. /**
  101696. * Defines the pointer angular sensibility along the X axis or how fast is
  101697. * the camera rotating.
  101698. */
  101699. angularSensibilityX: number;
  101700. /**
  101701. * Defines the pointer angular sensibility along the Y axis or how fast is
  101702. * the camera rotating.
  101703. */
  101704. angularSensibilityY: number;
  101705. /**
  101706. * Defines the pointer pinch precision or how fast is the camera zooming.
  101707. */
  101708. pinchPrecision: number;
  101709. /**
  101710. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  101711. * from 0.
  101712. * It defines the percentage of current camera.radius to use as delta when
  101713. * pinch zoom is used.
  101714. */
  101715. pinchDeltaPercentage: number;
  101716. /**
  101717. * Defines the pointer panning sensibility or how fast is the camera moving.
  101718. */
  101719. panningSensibility: number;
  101720. /**
  101721. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  101722. */
  101723. multiTouchPanning: boolean;
  101724. /**
  101725. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  101726. * zoom (pinch) through multitouch.
  101727. */
  101728. multiTouchPanAndZoom: boolean;
  101729. /**
  101730. * Revers pinch action direction.
  101731. */
  101732. pinchInwards: boolean;
  101733. private _isPanClick;
  101734. private _twoFingerActivityCount;
  101735. private _isPinching;
  101736. /**
  101737. * Called on pointer POINTERMOVE event if only a single touch is active.
  101738. */
  101739. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  101740. /**
  101741. * Called on pointer POINTERDOUBLETAP event.
  101742. */
  101743. protected onDoubleTap(type: string): void;
  101744. /**
  101745. * Called on pointer POINTERMOVE event if multiple touches are active.
  101746. */
  101747. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  101748. /**
  101749. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  101750. * press.
  101751. */
  101752. protected onButtonDown(evt: PointerEvent): void;
  101753. /**
  101754. * Called each time a new POINTERUP event occurs. Ie, for each button
  101755. * release.
  101756. */
  101757. protected onButtonUp(evt: PointerEvent): void;
  101758. /**
  101759. * Called when window becomes inactive.
  101760. */
  101761. protected onLostFocus(): void;
  101762. }
  101763. }
  101764. declare module BABYLON {
  101765. /**
  101766. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  101767. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101768. */
  101769. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  101770. /**
  101771. * Defines the camera the input is attached to.
  101772. */
  101773. camera: ArcRotateCamera;
  101774. /**
  101775. * Defines the list of key codes associated with the up action (increase alpha)
  101776. */
  101777. keysUp: number[];
  101778. /**
  101779. * Defines the list of key codes associated with the down action (decrease alpha)
  101780. */
  101781. keysDown: number[];
  101782. /**
  101783. * Defines the list of key codes associated with the left action (increase beta)
  101784. */
  101785. keysLeft: number[];
  101786. /**
  101787. * Defines the list of key codes associated with the right action (decrease beta)
  101788. */
  101789. keysRight: number[];
  101790. /**
  101791. * Defines the list of key codes associated with the reset action.
  101792. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  101793. */
  101794. keysReset: number[];
  101795. /**
  101796. * Defines the panning sensibility of the inputs.
  101797. * (How fast is the camera paning)
  101798. */
  101799. panningSensibility: number;
  101800. /**
  101801. * Defines the zooming sensibility of the inputs.
  101802. * (How fast is the camera zooming)
  101803. */
  101804. zoomingSensibility: number;
  101805. /**
  101806. * Defines wether maintaining the alt key down switch the movement mode from
  101807. * orientation to zoom.
  101808. */
  101809. useAltToZoom: boolean;
  101810. /**
  101811. * Rotation speed of the camera
  101812. */
  101813. angularSpeed: number;
  101814. private _keys;
  101815. private _ctrlPressed;
  101816. private _altPressed;
  101817. private _onCanvasBlurObserver;
  101818. private _onKeyboardObserver;
  101819. private _engine;
  101820. private _scene;
  101821. /**
  101822. * Attach the input controls to a specific dom element to get the input from.
  101823. * @param element Defines the element the controls should be listened from
  101824. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101825. */
  101826. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101827. /**
  101828. * Detach the current controls from the specified dom element.
  101829. * @param element Defines the element to stop listening the inputs from
  101830. */
  101831. detachControl(element: Nullable<HTMLElement>): void;
  101832. /**
  101833. * Update the current camera state depending on the inputs that have been used this frame.
  101834. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  101835. */
  101836. checkInputs(): void;
  101837. /**
  101838. * Gets the class name of the current intput.
  101839. * @returns the class name
  101840. */
  101841. getClassName(): string;
  101842. /**
  101843. * Get the friendly name associated with the input class.
  101844. * @returns the input friendly name
  101845. */
  101846. getSimpleName(): string;
  101847. }
  101848. }
  101849. declare module BABYLON {
  101850. /**
  101851. * Manage the mouse wheel inputs to control an arc rotate camera.
  101852. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101853. */
  101854. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  101855. /**
  101856. * Defines the camera the input is attached to.
  101857. */
  101858. camera: ArcRotateCamera;
  101859. /**
  101860. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  101861. */
  101862. wheelPrecision: number;
  101863. /**
  101864. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  101865. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  101866. */
  101867. wheelDeltaPercentage: number;
  101868. private _wheel;
  101869. private _observer;
  101870. private computeDeltaFromMouseWheelLegacyEvent;
  101871. /**
  101872. * Attach the input controls to a specific dom element to get the input from.
  101873. * @param element Defines the element the controls should be listened from
  101874. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101875. */
  101876. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101877. /**
  101878. * Detach the current controls from the specified dom element.
  101879. * @param element Defines the element to stop listening the inputs from
  101880. */
  101881. detachControl(element: Nullable<HTMLElement>): void;
  101882. /**
  101883. * Gets the class name of the current intput.
  101884. * @returns the class name
  101885. */
  101886. getClassName(): string;
  101887. /**
  101888. * Get the friendly name associated with the input class.
  101889. * @returns the input friendly name
  101890. */
  101891. getSimpleName(): string;
  101892. }
  101893. }
  101894. declare module BABYLON {
  101895. /**
  101896. * Default Inputs manager for the ArcRotateCamera.
  101897. * It groups all the default supported inputs for ease of use.
  101898. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101899. */
  101900. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  101901. /**
  101902. * Instantiates a new ArcRotateCameraInputsManager.
  101903. * @param camera Defines the camera the inputs belong to
  101904. */
  101905. constructor(camera: ArcRotateCamera);
  101906. /**
  101907. * Add mouse wheel input support to the input manager.
  101908. * @returns the current input manager
  101909. */
  101910. addMouseWheel(): ArcRotateCameraInputsManager;
  101911. /**
  101912. * Add pointers input support to the input manager.
  101913. * @returns the current input manager
  101914. */
  101915. addPointers(): ArcRotateCameraInputsManager;
  101916. /**
  101917. * Add keyboard input support to the input manager.
  101918. * @returns the current input manager
  101919. */
  101920. addKeyboard(): ArcRotateCameraInputsManager;
  101921. }
  101922. }
  101923. declare module BABYLON {
  101924. /**
  101925. * This represents an orbital type of camera.
  101926. *
  101927. * 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.
  101928. * 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.
  101929. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  101930. */
  101931. export class ArcRotateCamera extends TargetCamera {
  101932. /**
  101933. * Defines the rotation angle of the camera along the longitudinal axis.
  101934. */
  101935. alpha: number;
  101936. /**
  101937. * Defines the rotation angle of the camera along the latitudinal axis.
  101938. */
  101939. beta: number;
  101940. /**
  101941. * Defines the radius of the camera from it s target point.
  101942. */
  101943. radius: number;
  101944. protected _target: Vector3;
  101945. protected _targetHost: Nullable<AbstractMesh>;
  101946. /**
  101947. * Defines the target point of the camera.
  101948. * The camera looks towards it form the radius distance.
  101949. */
  101950. target: Vector3;
  101951. /**
  101952. * Define the current local position of the camera in the scene
  101953. */
  101954. position: Vector3;
  101955. protected _upVector: Vector3;
  101956. protected _upToYMatrix: Matrix;
  101957. protected _YToUpMatrix: Matrix;
  101958. /**
  101959. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  101960. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  101961. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  101962. */
  101963. upVector: Vector3;
  101964. /**
  101965. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  101966. */
  101967. setMatUp(): void;
  101968. /**
  101969. * Current inertia value on the longitudinal axis.
  101970. * The bigger this number the longer it will take for the camera to stop.
  101971. */
  101972. inertialAlphaOffset: number;
  101973. /**
  101974. * Current inertia value on the latitudinal axis.
  101975. * The bigger this number the longer it will take for the camera to stop.
  101976. */
  101977. inertialBetaOffset: number;
  101978. /**
  101979. * Current inertia value on the radius axis.
  101980. * The bigger this number the longer it will take for the camera to stop.
  101981. */
  101982. inertialRadiusOffset: number;
  101983. /**
  101984. * Minimum allowed angle on the longitudinal axis.
  101985. * This can help limiting how the Camera is able to move in the scene.
  101986. */
  101987. lowerAlphaLimit: Nullable<number>;
  101988. /**
  101989. * Maximum allowed angle on the longitudinal axis.
  101990. * This can help limiting how the Camera is able to move in the scene.
  101991. */
  101992. upperAlphaLimit: Nullable<number>;
  101993. /**
  101994. * Minimum allowed angle on the latitudinal axis.
  101995. * This can help limiting how the Camera is able to move in the scene.
  101996. */
  101997. lowerBetaLimit: number;
  101998. /**
  101999. * Maximum allowed angle on the latitudinal axis.
  102000. * This can help limiting how the Camera is able to move in the scene.
  102001. */
  102002. upperBetaLimit: number;
  102003. /**
  102004. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  102005. * This can help limiting how the Camera is able to move in the scene.
  102006. */
  102007. lowerRadiusLimit: Nullable<number>;
  102008. /**
  102009. * Maximum allowed distance of the camera to the target (The camera can not get further).
  102010. * This can help limiting how the Camera is able to move in the scene.
  102011. */
  102012. upperRadiusLimit: Nullable<number>;
  102013. /**
  102014. * Defines the current inertia value used during panning of the camera along the X axis.
  102015. */
  102016. inertialPanningX: number;
  102017. /**
  102018. * Defines the current inertia value used during panning of the camera along the Y axis.
  102019. */
  102020. inertialPanningY: number;
  102021. /**
  102022. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  102023. * Basically if your fingers moves away from more than this distance you will be considered
  102024. * in pinch mode.
  102025. */
  102026. pinchToPanMaxDistance: number;
  102027. /**
  102028. * Defines the maximum distance the camera can pan.
  102029. * This could help keeping the cammera always in your scene.
  102030. */
  102031. panningDistanceLimit: Nullable<number>;
  102032. /**
  102033. * Defines the target of the camera before paning.
  102034. */
  102035. panningOriginTarget: Vector3;
  102036. /**
  102037. * Defines the value of the inertia used during panning.
  102038. * 0 would mean stop inertia and one would mean no decelleration at all.
  102039. */
  102040. panningInertia: number;
  102041. /**
  102042. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  102043. */
  102044. angularSensibilityX: number;
  102045. /**
  102046. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  102047. */
  102048. angularSensibilityY: number;
  102049. /**
  102050. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  102051. */
  102052. pinchPrecision: number;
  102053. /**
  102054. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  102055. * It will be used instead of pinchDeltaPrecision if different from 0.
  102056. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  102057. */
  102058. pinchDeltaPercentage: number;
  102059. /**
  102060. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  102061. */
  102062. panningSensibility: number;
  102063. /**
  102064. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  102065. */
  102066. keysUp: number[];
  102067. /**
  102068. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  102069. */
  102070. keysDown: number[];
  102071. /**
  102072. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  102073. */
  102074. keysLeft: number[];
  102075. /**
  102076. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  102077. */
  102078. keysRight: number[];
  102079. /**
  102080. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  102081. */
  102082. wheelPrecision: number;
  102083. /**
  102084. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  102085. * It will be used instead of pinchDeltaPrecision if different from 0.
  102086. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  102087. */
  102088. wheelDeltaPercentage: number;
  102089. /**
  102090. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  102091. */
  102092. zoomOnFactor: number;
  102093. /**
  102094. * Defines a screen offset for the camera position.
  102095. */
  102096. targetScreenOffset: Vector2;
  102097. /**
  102098. * Allows the camera to be completely reversed.
  102099. * If false the camera can not arrive upside down.
  102100. */
  102101. allowUpsideDown: boolean;
  102102. /**
  102103. * Define if double tap/click is used to restore the previously saved state of the camera.
  102104. */
  102105. useInputToRestoreState: boolean;
  102106. /** @hidden */
  102107. _viewMatrix: Matrix;
  102108. /** @hidden */
  102109. _useCtrlForPanning: boolean;
  102110. /** @hidden */
  102111. _panningMouseButton: number;
  102112. /**
  102113. * Defines the input associated to the camera.
  102114. */
  102115. inputs: ArcRotateCameraInputsManager;
  102116. /** @hidden */
  102117. _reset: () => void;
  102118. /**
  102119. * Defines the allowed panning axis.
  102120. */
  102121. panningAxis: Vector3;
  102122. protected _localDirection: Vector3;
  102123. protected _transformedDirection: Vector3;
  102124. private _bouncingBehavior;
  102125. /**
  102126. * Gets the bouncing behavior of the camera if it has been enabled.
  102127. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  102128. */
  102129. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  102130. /**
  102131. * Defines if the bouncing behavior of the camera is enabled on the camera.
  102132. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  102133. */
  102134. useBouncingBehavior: boolean;
  102135. private _framingBehavior;
  102136. /**
  102137. * Gets the framing behavior of the camera if it has been enabled.
  102138. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  102139. */
  102140. readonly framingBehavior: Nullable<FramingBehavior>;
  102141. /**
  102142. * Defines if the framing behavior of the camera is enabled on the camera.
  102143. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  102144. */
  102145. useFramingBehavior: boolean;
  102146. private _autoRotationBehavior;
  102147. /**
  102148. * Gets the auto rotation behavior of the camera if it has been enabled.
  102149. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  102150. */
  102151. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  102152. /**
  102153. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  102154. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  102155. */
  102156. useAutoRotationBehavior: boolean;
  102157. /**
  102158. * Observable triggered when the mesh target has been changed on the camera.
  102159. */
  102160. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  102161. /**
  102162. * Event raised when the camera is colliding with a mesh.
  102163. */
  102164. onCollide: (collidedMesh: AbstractMesh) => void;
  102165. /**
  102166. * Defines whether the camera should check collision with the objects oh the scene.
  102167. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  102168. */
  102169. checkCollisions: boolean;
  102170. /**
  102171. * Defines the collision radius of the camera.
  102172. * This simulates a sphere around the camera.
  102173. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  102174. */
  102175. collisionRadius: Vector3;
  102176. protected _collider: Collider;
  102177. protected _previousPosition: Vector3;
  102178. protected _collisionVelocity: Vector3;
  102179. protected _newPosition: Vector3;
  102180. protected _previousAlpha: number;
  102181. protected _previousBeta: number;
  102182. protected _previousRadius: number;
  102183. protected _collisionTriggered: boolean;
  102184. protected _targetBoundingCenter: Nullable<Vector3>;
  102185. private _computationVector;
  102186. /**
  102187. * Instantiates a new ArcRotateCamera in a given scene
  102188. * @param name Defines the name of the camera
  102189. * @param alpha Defines the camera rotation along the logitudinal axis
  102190. * @param beta Defines the camera rotation along the latitudinal axis
  102191. * @param radius Defines the camera distance from its target
  102192. * @param target Defines the camera target
  102193. * @param scene Defines the scene the camera belongs to
  102194. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  102195. */
  102196. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  102197. /** @hidden */
  102198. _initCache(): void;
  102199. /** @hidden */
  102200. _updateCache(ignoreParentClass?: boolean): void;
  102201. protected _getTargetPosition(): Vector3;
  102202. private _storedAlpha;
  102203. private _storedBeta;
  102204. private _storedRadius;
  102205. private _storedTarget;
  102206. private _storedTargetScreenOffset;
  102207. /**
  102208. * Stores the current state of the camera (alpha, beta, radius and target)
  102209. * @returns the camera itself
  102210. */
  102211. storeState(): Camera;
  102212. /**
  102213. * @hidden
  102214. * Restored camera state. You must call storeState() first
  102215. */
  102216. _restoreStateValues(): boolean;
  102217. /** @hidden */
  102218. _isSynchronizedViewMatrix(): boolean;
  102219. /**
  102220. * Attached controls to the current camera.
  102221. * @param element Defines the element the controls should be listened from
  102222. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102223. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  102224. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  102225. */
  102226. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  102227. /**
  102228. * Detach the current controls from the camera.
  102229. * The camera will stop reacting to inputs.
  102230. * @param element Defines the element to stop listening the inputs from
  102231. */
  102232. detachControl(element: HTMLElement): void;
  102233. /** @hidden */
  102234. _checkInputs(): void;
  102235. protected _checkLimits(): void;
  102236. /**
  102237. * Rebuilds angles (alpha, beta) and radius from the give position and target
  102238. */
  102239. rebuildAnglesAndRadius(): void;
  102240. /**
  102241. * Use a position to define the current camera related information like aplha, beta and radius
  102242. * @param position Defines the position to set the camera at
  102243. */
  102244. setPosition(position: Vector3): void;
  102245. /**
  102246. * Defines the target the camera should look at.
  102247. * This will automatically adapt alpha beta and radius to fit within the new target.
  102248. * @param target Defines the new target as a Vector or a mesh
  102249. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  102250. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  102251. */
  102252. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  102253. /** @hidden */
  102254. _getViewMatrix(): Matrix;
  102255. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  102256. /**
  102257. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  102258. * @param meshes Defines the mesh to zoom on
  102259. * @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)
  102260. */
  102261. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  102262. /**
  102263. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  102264. * The target will be changed but the radius
  102265. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  102266. * @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)
  102267. */
  102268. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  102269. min: Vector3;
  102270. max: Vector3;
  102271. distance: number;
  102272. }, doNotUpdateMaxZ?: boolean): void;
  102273. /**
  102274. * @override
  102275. * Override Camera.createRigCamera
  102276. */
  102277. createRigCamera(name: string, cameraIndex: number): Camera;
  102278. /**
  102279. * @hidden
  102280. * @override
  102281. * Override Camera._updateRigCameras
  102282. */
  102283. _updateRigCameras(): void;
  102284. /**
  102285. * Destroy the camera and release the current resources hold by it.
  102286. */
  102287. dispose(): void;
  102288. /**
  102289. * Gets the current object class name.
  102290. * @return the class name
  102291. */
  102292. getClassName(): string;
  102293. }
  102294. }
  102295. declare module BABYLON {
  102296. /**
  102297. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  102298. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  102299. */
  102300. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  102301. /**
  102302. * Gets the name of the behavior.
  102303. */
  102304. readonly name: string;
  102305. private _zoomStopsAnimation;
  102306. private _idleRotationSpeed;
  102307. private _idleRotationWaitTime;
  102308. private _idleRotationSpinupTime;
  102309. /**
  102310. * Sets the flag that indicates if user zooming should stop animation.
  102311. */
  102312. /**
  102313. * Gets the flag that indicates if user zooming should stop animation.
  102314. */
  102315. zoomStopsAnimation: boolean;
  102316. /**
  102317. * Sets the default speed at which the camera rotates around the model.
  102318. */
  102319. /**
  102320. * Gets the default speed at which the camera rotates around the model.
  102321. */
  102322. idleRotationSpeed: number;
  102323. /**
  102324. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  102325. */
  102326. /**
  102327. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  102328. */
  102329. idleRotationWaitTime: number;
  102330. /**
  102331. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  102332. */
  102333. /**
  102334. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  102335. */
  102336. idleRotationSpinupTime: number;
  102337. /**
  102338. * Gets a value indicating if the camera is currently rotating because of this behavior
  102339. */
  102340. readonly rotationInProgress: boolean;
  102341. private _onPrePointerObservableObserver;
  102342. private _onAfterCheckInputsObserver;
  102343. private _attachedCamera;
  102344. private _isPointerDown;
  102345. private _lastFrameTime;
  102346. private _lastInteractionTime;
  102347. private _cameraRotationSpeed;
  102348. /**
  102349. * Initializes the behavior.
  102350. */
  102351. init(): void;
  102352. /**
  102353. * Attaches the behavior to its arc rotate camera.
  102354. * @param camera Defines the camera to attach the behavior to
  102355. */
  102356. attach(camera: ArcRotateCamera): void;
  102357. /**
  102358. * Detaches the behavior from its current arc rotate camera.
  102359. */
  102360. detach(): void;
  102361. /**
  102362. * Returns true if user is scrolling.
  102363. * @return true if user is scrolling.
  102364. */
  102365. private _userIsZooming;
  102366. private _lastFrameRadius;
  102367. private _shouldAnimationStopForInteraction;
  102368. /**
  102369. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  102370. */
  102371. private _applyUserInteraction;
  102372. private _userIsMoving;
  102373. }
  102374. }
  102375. declare module BABYLON {
  102376. /**
  102377. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  102378. */
  102379. export class AttachToBoxBehavior implements Behavior<Mesh> {
  102380. private ui;
  102381. /**
  102382. * The name of the behavior
  102383. */
  102384. name: string;
  102385. /**
  102386. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  102387. */
  102388. distanceAwayFromFace: number;
  102389. /**
  102390. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  102391. */
  102392. distanceAwayFromBottomOfFace: number;
  102393. private _faceVectors;
  102394. private _target;
  102395. private _scene;
  102396. private _onRenderObserver;
  102397. private _tmpMatrix;
  102398. private _tmpVector;
  102399. /**
  102400. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  102401. * @param ui The transform node that should be attched to the mesh
  102402. */
  102403. constructor(ui: TransformNode);
  102404. /**
  102405. * Initializes the behavior
  102406. */
  102407. init(): void;
  102408. private _closestFace;
  102409. private _zeroVector;
  102410. private _lookAtTmpMatrix;
  102411. private _lookAtToRef;
  102412. /**
  102413. * Attaches the AttachToBoxBehavior to the passed in mesh
  102414. * @param target The mesh that the specified node will be attached to
  102415. */
  102416. attach(target: Mesh): void;
  102417. /**
  102418. * Detaches the behavior from the mesh
  102419. */
  102420. detach(): void;
  102421. }
  102422. }
  102423. declare module BABYLON {
  102424. /**
  102425. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  102426. */
  102427. export class FadeInOutBehavior implements Behavior<Mesh> {
  102428. /**
  102429. * Time in milliseconds to delay before fading in (Default: 0)
  102430. */
  102431. delay: number;
  102432. /**
  102433. * Time in milliseconds for the mesh to fade in (Default: 300)
  102434. */
  102435. fadeInTime: number;
  102436. private _millisecondsPerFrame;
  102437. private _hovered;
  102438. private _hoverValue;
  102439. private _ownerNode;
  102440. /**
  102441. * Instatiates the FadeInOutBehavior
  102442. */
  102443. constructor();
  102444. /**
  102445. * The name of the behavior
  102446. */
  102447. readonly name: string;
  102448. /**
  102449. * Initializes the behavior
  102450. */
  102451. init(): void;
  102452. /**
  102453. * Attaches the fade behavior on the passed in mesh
  102454. * @param ownerNode The mesh that will be faded in/out once attached
  102455. */
  102456. attach(ownerNode: Mesh): void;
  102457. /**
  102458. * Detaches the behavior from the mesh
  102459. */
  102460. detach(): void;
  102461. /**
  102462. * Triggers the mesh to begin fading in or out
  102463. * @param value if the object should fade in or out (true to fade in)
  102464. */
  102465. fadeIn(value: boolean): void;
  102466. private _update;
  102467. private _setAllVisibility;
  102468. }
  102469. }
  102470. declare module BABYLON {
  102471. /**
  102472. * Class containing a set of static utilities functions for managing Pivots
  102473. * @hidden
  102474. */
  102475. export class PivotTools {
  102476. private static _PivotCached;
  102477. private static _OldPivotPoint;
  102478. private static _PivotTranslation;
  102479. private static _PivotTmpVector;
  102480. /** @hidden */
  102481. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  102482. /** @hidden */
  102483. static _RestorePivotPoint(mesh: AbstractMesh): void;
  102484. }
  102485. }
  102486. declare module BABYLON {
  102487. /**
  102488. * Class containing static functions to help procedurally build meshes
  102489. */
  102490. export class PlaneBuilder {
  102491. /**
  102492. * Creates a plane mesh
  102493. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  102494. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  102495. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  102496. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  102497. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  102498. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  102499. * @param name defines the name of the mesh
  102500. * @param options defines the options used to create the mesh
  102501. * @param scene defines the hosting scene
  102502. * @returns the plane mesh
  102503. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  102504. */
  102505. static CreatePlane(name: string, options: {
  102506. size?: number;
  102507. width?: number;
  102508. height?: number;
  102509. sideOrientation?: number;
  102510. frontUVs?: Vector4;
  102511. backUVs?: Vector4;
  102512. updatable?: boolean;
  102513. sourcePlane?: Plane;
  102514. }, scene?: Nullable<Scene>): Mesh;
  102515. }
  102516. }
  102517. declare module BABYLON {
  102518. /**
  102519. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  102520. */
  102521. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  102522. private static _AnyMouseID;
  102523. /**
  102524. * Abstract mesh the behavior is set on
  102525. */
  102526. attachedNode: AbstractMesh;
  102527. private _dragPlane;
  102528. private _scene;
  102529. private _pointerObserver;
  102530. private _beforeRenderObserver;
  102531. private static _planeScene;
  102532. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  102533. /**
  102534. * 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)
  102535. */
  102536. maxDragAngle: number;
  102537. /**
  102538. * @hidden
  102539. */
  102540. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  102541. /**
  102542. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  102543. */
  102544. currentDraggingPointerID: number;
  102545. /**
  102546. * The last position where the pointer hit the drag plane in world space
  102547. */
  102548. lastDragPosition: Vector3;
  102549. /**
  102550. * If the behavior is currently in a dragging state
  102551. */
  102552. dragging: boolean;
  102553. /**
  102554. * 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)
  102555. */
  102556. dragDeltaRatio: number;
  102557. /**
  102558. * If the drag plane orientation should be updated during the dragging (Default: true)
  102559. */
  102560. updateDragPlane: boolean;
  102561. private _debugMode;
  102562. private _moving;
  102563. /**
  102564. * Fires each time the attached mesh is dragged with the pointer
  102565. * * delta between last drag position and current drag position in world space
  102566. * * dragDistance along the drag axis
  102567. * * dragPlaneNormal normal of the current drag plane used during the drag
  102568. * * dragPlanePoint in world space where the drag intersects the drag plane
  102569. */
  102570. onDragObservable: Observable<{
  102571. delta: Vector3;
  102572. dragPlanePoint: Vector3;
  102573. dragPlaneNormal: Vector3;
  102574. dragDistance: number;
  102575. pointerId: number;
  102576. }>;
  102577. /**
  102578. * Fires each time a drag begins (eg. mouse down on mesh)
  102579. */
  102580. onDragStartObservable: Observable<{
  102581. dragPlanePoint: Vector3;
  102582. pointerId: number;
  102583. }>;
  102584. /**
  102585. * Fires each time a drag ends (eg. mouse release after drag)
  102586. */
  102587. onDragEndObservable: Observable<{
  102588. dragPlanePoint: Vector3;
  102589. pointerId: number;
  102590. }>;
  102591. /**
  102592. * If the attached mesh should be moved when dragged
  102593. */
  102594. moveAttached: boolean;
  102595. /**
  102596. * If the drag behavior will react to drag events (Default: true)
  102597. */
  102598. enabled: boolean;
  102599. /**
  102600. * If pointer events should start and release the drag (Default: true)
  102601. */
  102602. startAndReleaseDragOnPointerEvents: boolean;
  102603. /**
  102604. * If camera controls should be detached during the drag
  102605. */
  102606. detachCameraControls: boolean;
  102607. /**
  102608. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  102609. */
  102610. useObjectOrienationForDragging: boolean;
  102611. private _options;
  102612. /**
  102613. * Creates a pointer drag behavior that can be attached to a mesh
  102614. * @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)
  102615. */
  102616. constructor(options?: {
  102617. dragAxis?: Vector3;
  102618. dragPlaneNormal?: Vector3;
  102619. });
  102620. /**
  102621. * Predicate to determine if it is valid to move the object to a new position when it is moved
  102622. */
  102623. validateDrag: (targetPosition: Vector3) => boolean;
  102624. /**
  102625. * The name of the behavior
  102626. */
  102627. readonly name: string;
  102628. /**
  102629. * Initializes the behavior
  102630. */
  102631. init(): void;
  102632. private _tmpVector;
  102633. private _alternatePickedPoint;
  102634. private _worldDragAxis;
  102635. private _targetPosition;
  102636. private _attachedElement;
  102637. /**
  102638. * Attaches the drag behavior the passed in mesh
  102639. * @param ownerNode The mesh that will be dragged around once attached
  102640. * @param predicate Predicate to use for pick filtering
  102641. */
  102642. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  102643. /**
  102644. * Force relase the drag action by code.
  102645. */
  102646. releaseDrag(): void;
  102647. private _startDragRay;
  102648. private _lastPointerRay;
  102649. /**
  102650. * Simulates the start of a pointer drag event on the behavior
  102651. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  102652. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  102653. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  102654. */
  102655. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  102656. private _startDrag;
  102657. private _dragDelta;
  102658. private _moveDrag;
  102659. private _pickWithRayOnDragPlane;
  102660. private _pointA;
  102661. private _pointB;
  102662. private _pointC;
  102663. private _lineA;
  102664. private _lineB;
  102665. private _localAxis;
  102666. private _lookAt;
  102667. private _updateDragPlanePosition;
  102668. /**
  102669. * Detaches the behavior from the mesh
  102670. */
  102671. detach(): void;
  102672. }
  102673. }
  102674. declare module BABYLON {
  102675. /**
  102676. * A behavior that when attached to a mesh will allow the mesh to be scaled
  102677. */
  102678. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  102679. private _dragBehaviorA;
  102680. private _dragBehaviorB;
  102681. private _startDistance;
  102682. private _initialScale;
  102683. private _targetScale;
  102684. private _ownerNode;
  102685. private _sceneRenderObserver;
  102686. /**
  102687. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  102688. */
  102689. constructor();
  102690. /**
  102691. * The name of the behavior
  102692. */
  102693. readonly name: string;
  102694. /**
  102695. * Initializes the behavior
  102696. */
  102697. init(): void;
  102698. private _getCurrentDistance;
  102699. /**
  102700. * Attaches the scale behavior the passed in mesh
  102701. * @param ownerNode The mesh that will be scaled around once attached
  102702. */
  102703. attach(ownerNode: Mesh): void;
  102704. /**
  102705. * Detaches the behavior from the mesh
  102706. */
  102707. detach(): void;
  102708. }
  102709. }
  102710. declare module BABYLON {
  102711. /**
  102712. * 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
  102713. */
  102714. export class SixDofDragBehavior implements Behavior<Mesh> {
  102715. private static _virtualScene;
  102716. private _ownerNode;
  102717. private _sceneRenderObserver;
  102718. private _scene;
  102719. private _targetPosition;
  102720. private _virtualOriginMesh;
  102721. private _virtualDragMesh;
  102722. private _pointerObserver;
  102723. private _moving;
  102724. private _startingOrientation;
  102725. /**
  102726. * 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)
  102727. */
  102728. private zDragFactor;
  102729. /**
  102730. * If the object should rotate to face the drag origin
  102731. */
  102732. rotateDraggedObject: boolean;
  102733. /**
  102734. * If the behavior is currently in a dragging state
  102735. */
  102736. dragging: boolean;
  102737. /**
  102738. * 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)
  102739. */
  102740. dragDeltaRatio: number;
  102741. /**
  102742. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  102743. */
  102744. currentDraggingPointerID: number;
  102745. /**
  102746. * If camera controls should be detached during the drag
  102747. */
  102748. detachCameraControls: boolean;
  102749. /**
  102750. * Fires each time a drag starts
  102751. */
  102752. onDragStartObservable: Observable<{}>;
  102753. /**
  102754. * Fires each time a drag ends (eg. mouse release after drag)
  102755. */
  102756. onDragEndObservable: Observable<{}>;
  102757. /**
  102758. * 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
  102759. */
  102760. constructor();
  102761. /**
  102762. * The name of the behavior
  102763. */
  102764. readonly name: string;
  102765. /**
  102766. * Initializes the behavior
  102767. */
  102768. init(): void;
  102769. /**
  102770. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  102771. */
  102772. private readonly _pointerCamera;
  102773. /**
  102774. * Attaches the scale behavior the passed in mesh
  102775. * @param ownerNode The mesh that will be scaled around once attached
  102776. */
  102777. attach(ownerNode: Mesh): void;
  102778. /**
  102779. * Detaches the behavior from the mesh
  102780. */
  102781. detach(): void;
  102782. }
  102783. }
  102784. declare module BABYLON {
  102785. /**
  102786. * Class used to apply inverse kinematics to bones
  102787. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  102788. */
  102789. export class BoneIKController {
  102790. private static _tmpVecs;
  102791. private static _tmpQuat;
  102792. private static _tmpMats;
  102793. /**
  102794. * Gets or sets the target mesh
  102795. */
  102796. targetMesh: AbstractMesh;
  102797. /** Gets or sets the mesh used as pole */
  102798. poleTargetMesh: AbstractMesh;
  102799. /**
  102800. * Gets or sets the bone used as pole
  102801. */
  102802. poleTargetBone: Nullable<Bone>;
  102803. /**
  102804. * Gets or sets the target position
  102805. */
  102806. targetPosition: Vector3;
  102807. /**
  102808. * Gets or sets the pole target position
  102809. */
  102810. poleTargetPosition: Vector3;
  102811. /**
  102812. * Gets or sets the pole target local offset
  102813. */
  102814. poleTargetLocalOffset: Vector3;
  102815. /**
  102816. * Gets or sets the pole angle
  102817. */
  102818. poleAngle: number;
  102819. /**
  102820. * Gets or sets the mesh associated with the controller
  102821. */
  102822. mesh: AbstractMesh;
  102823. /**
  102824. * 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)
  102825. */
  102826. slerpAmount: number;
  102827. private _bone1Quat;
  102828. private _bone1Mat;
  102829. private _bone2Ang;
  102830. private _bone1;
  102831. private _bone2;
  102832. private _bone1Length;
  102833. private _bone2Length;
  102834. private _maxAngle;
  102835. private _maxReach;
  102836. private _rightHandedSystem;
  102837. private _bendAxis;
  102838. private _slerping;
  102839. private _adjustRoll;
  102840. /**
  102841. * Gets or sets maximum allowed angle
  102842. */
  102843. maxAngle: number;
  102844. /**
  102845. * Creates a new BoneIKController
  102846. * @param mesh defines the mesh to control
  102847. * @param bone defines the bone to control
  102848. * @param options defines options to set up the controller
  102849. */
  102850. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  102851. targetMesh?: AbstractMesh;
  102852. poleTargetMesh?: AbstractMesh;
  102853. poleTargetBone?: Bone;
  102854. poleTargetLocalOffset?: Vector3;
  102855. poleAngle?: number;
  102856. bendAxis?: Vector3;
  102857. maxAngle?: number;
  102858. slerpAmount?: number;
  102859. });
  102860. private _setMaxAngle;
  102861. /**
  102862. * Force the controller to update the bones
  102863. */
  102864. update(): void;
  102865. }
  102866. }
  102867. declare module BABYLON {
  102868. /**
  102869. * Class used to make a bone look toward a point in space
  102870. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  102871. */
  102872. export class BoneLookController {
  102873. private static _tmpVecs;
  102874. private static _tmpQuat;
  102875. private static _tmpMats;
  102876. /**
  102877. * The target Vector3 that the bone will look at
  102878. */
  102879. target: Vector3;
  102880. /**
  102881. * The mesh that the bone is attached to
  102882. */
  102883. mesh: AbstractMesh;
  102884. /**
  102885. * The bone that will be looking to the target
  102886. */
  102887. bone: Bone;
  102888. /**
  102889. * The up axis of the coordinate system that is used when the bone is rotated
  102890. */
  102891. upAxis: Vector3;
  102892. /**
  102893. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  102894. */
  102895. upAxisSpace: Space;
  102896. /**
  102897. * Used to make an adjustment to the yaw of the bone
  102898. */
  102899. adjustYaw: number;
  102900. /**
  102901. * Used to make an adjustment to the pitch of the bone
  102902. */
  102903. adjustPitch: number;
  102904. /**
  102905. * Used to make an adjustment to the roll of the bone
  102906. */
  102907. adjustRoll: number;
  102908. /**
  102909. * 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)
  102910. */
  102911. slerpAmount: number;
  102912. private _minYaw;
  102913. private _maxYaw;
  102914. private _minPitch;
  102915. private _maxPitch;
  102916. private _minYawSin;
  102917. private _minYawCos;
  102918. private _maxYawSin;
  102919. private _maxYawCos;
  102920. private _midYawConstraint;
  102921. private _minPitchTan;
  102922. private _maxPitchTan;
  102923. private _boneQuat;
  102924. private _slerping;
  102925. private _transformYawPitch;
  102926. private _transformYawPitchInv;
  102927. private _firstFrameSkipped;
  102928. private _yawRange;
  102929. private _fowardAxis;
  102930. /**
  102931. * Gets or sets the minimum yaw angle that the bone can look to
  102932. */
  102933. minYaw: number;
  102934. /**
  102935. * Gets or sets the maximum yaw angle that the bone can look to
  102936. */
  102937. maxYaw: number;
  102938. /**
  102939. * Gets or sets the minimum pitch angle that the bone can look to
  102940. */
  102941. minPitch: number;
  102942. /**
  102943. * Gets or sets the maximum pitch angle that the bone can look to
  102944. */
  102945. maxPitch: number;
  102946. /**
  102947. * Create a BoneLookController
  102948. * @param mesh the mesh that the bone belongs to
  102949. * @param bone the bone that will be looking to the target
  102950. * @param target the target Vector3 to look at
  102951. * @param options optional settings:
  102952. * * maxYaw: the maximum angle the bone will yaw to
  102953. * * minYaw: the minimum angle the bone will yaw to
  102954. * * maxPitch: the maximum angle the bone will pitch to
  102955. * * minPitch: the minimum angle the bone will yaw to
  102956. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  102957. * * upAxis: the up axis of the coordinate system
  102958. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  102959. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  102960. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  102961. * * adjustYaw: used to make an adjustment to the yaw of the bone
  102962. * * adjustPitch: used to make an adjustment to the pitch of the bone
  102963. * * adjustRoll: used to make an adjustment to the roll of the bone
  102964. **/
  102965. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  102966. maxYaw?: number;
  102967. minYaw?: number;
  102968. maxPitch?: number;
  102969. minPitch?: number;
  102970. slerpAmount?: number;
  102971. upAxis?: Vector3;
  102972. upAxisSpace?: Space;
  102973. yawAxis?: Vector3;
  102974. pitchAxis?: Vector3;
  102975. adjustYaw?: number;
  102976. adjustPitch?: number;
  102977. adjustRoll?: number;
  102978. });
  102979. /**
  102980. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  102981. */
  102982. update(): void;
  102983. private _getAngleDiff;
  102984. private _getAngleBetween;
  102985. private _isAngleBetween;
  102986. }
  102987. }
  102988. declare module BABYLON {
  102989. /**
  102990. * Manage the gamepad inputs to control an arc rotate camera.
  102991. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102992. */
  102993. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  102994. /**
  102995. * Defines the camera the input is attached to.
  102996. */
  102997. camera: ArcRotateCamera;
  102998. /**
  102999. * Defines the gamepad the input is gathering event from.
  103000. */
  103001. gamepad: Nullable<Gamepad>;
  103002. /**
  103003. * Defines the gamepad rotation sensiblity.
  103004. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  103005. */
  103006. gamepadRotationSensibility: number;
  103007. /**
  103008. * Defines the gamepad move sensiblity.
  103009. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  103010. */
  103011. gamepadMoveSensibility: number;
  103012. private _onGamepadConnectedObserver;
  103013. private _onGamepadDisconnectedObserver;
  103014. /**
  103015. * Attach the input controls to a specific dom element to get the input from.
  103016. * @param element Defines the element the controls should be listened from
  103017. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103018. */
  103019. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103020. /**
  103021. * Detach the current controls from the specified dom element.
  103022. * @param element Defines the element to stop listening the inputs from
  103023. */
  103024. detachControl(element: Nullable<HTMLElement>): void;
  103025. /**
  103026. * Update the current camera state depending on the inputs that have been used this frame.
  103027. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103028. */
  103029. checkInputs(): void;
  103030. /**
  103031. * Gets the class name of the current intput.
  103032. * @returns the class name
  103033. */
  103034. getClassName(): string;
  103035. /**
  103036. * Get the friendly name associated with the input class.
  103037. * @returns the input friendly name
  103038. */
  103039. getSimpleName(): string;
  103040. }
  103041. }
  103042. declare module BABYLON {
  103043. interface ArcRotateCameraInputsManager {
  103044. /**
  103045. * Add orientation input support to the input manager.
  103046. * @returns the current input manager
  103047. */
  103048. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  103049. }
  103050. /**
  103051. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  103052. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103053. */
  103054. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  103055. /**
  103056. * Defines the camera the input is attached to.
  103057. */
  103058. camera: ArcRotateCamera;
  103059. /**
  103060. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  103061. */
  103062. alphaCorrection: number;
  103063. /**
  103064. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  103065. */
  103066. gammaCorrection: number;
  103067. private _alpha;
  103068. private _gamma;
  103069. private _dirty;
  103070. private _deviceOrientationHandler;
  103071. /**
  103072. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  103073. */
  103074. constructor();
  103075. /**
  103076. * Attach the input controls to a specific dom element to get the input from.
  103077. * @param element Defines the element the controls should be listened from
  103078. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103079. */
  103080. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103081. /** @hidden */
  103082. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  103083. /**
  103084. * Update the current camera state depending on the inputs that have been used this frame.
  103085. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103086. */
  103087. checkInputs(): void;
  103088. /**
  103089. * Detach the current controls from the specified dom element.
  103090. * @param element Defines the element to stop listening the inputs from
  103091. */
  103092. detachControl(element: Nullable<HTMLElement>): void;
  103093. /**
  103094. * Gets the class name of the current intput.
  103095. * @returns the class name
  103096. */
  103097. getClassName(): string;
  103098. /**
  103099. * Get the friendly name associated with the input class.
  103100. * @returns the input friendly name
  103101. */
  103102. getSimpleName(): string;
  103103. }
  103104. }
  103105. declare module BABYLON {
  103106. /**
  103107. * Listen to mouse events to control the camera.
  103108. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103109. */
  103110. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  103111. /**
  103112. * Defines the camera the input is attached to.
  103113. */
  103114. camera: FlyCamera;
  103115. /**
  103116. * Defines if touch is enabled. (Default is true.)
  103117. */
  103118. touchEnabled: boolean;
  103119. /**
  103120. * Defines the buttons associated with the input to handle camera rotation.
  103121. */
  103122. buttons: number[];
  103123. /**
  103124. * Assign buttons for Yaw control.
  103125. */
  103126. buttonsYaw: number[];
  103127. /**
  103128. * Assign buttons for Pitch control.
  103129. */
  103130. buttonsPitch: number[];
  103131. /**
  103132. * Assign buttons for Roll control.
  103133. */
  103134. buttonsRoll: number[];
  103135. /**
  103136. * Detect if any button is being pressed while mouse is moved.
  103137. * -1 = Mouse locked.
  103138. * 0 = Left button.
  103139. * 1 = Middle Button.
  103140. * 2 = Right Button.
  103141. */
  103142. activeButton: number;
  103143. /**
  103144. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  103145. * Higher values reduce its sensitivity.
  103146. */
  103147. angularSensibility: number;
  103148. private _mousemoveCallback;
  103149. private _observer;
  103150. private _rollObserver;
  103151. private previousPosition;
  103152. private noPreventDefault;
  103153. private element;
  103154. /**
  103155. * Listen to mouse events to control the camera.
  103156. * @param touchEnabled Define if touch is enabled. (Default is true.)
  103157. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103158. */
  103159. constructor(touchEnabled?: boolean);
  103160. /**
  103161. * Attach the mouse control to the HTML DOM element.
  103162. * @param element Defines the element that listens to the input events.
  103163. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  103164. */
  103165. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103166. /**
  103167. * Detach the current controls from the specified dom element.
  103168. * @param element Defines the element to stop listening the inputs from
  103169. */
  103170. detachControl(element: Nullable<HTMLElement>): void;
  103171. /**
  103172. * Gets the class name of the current input.
  103173. * @returns the class name.
  103174. */
  103175. getClassName(): string;
  103176. /**
  103177. * Get the friendly name associated with the input class.
  103178. * @returns the input's friendly name.
  103179. */
  103180. getSimpleName(): string;
  103181. private _pointerInput;
  103182. private _onMouseMove;
  103183. /**
  103184. * Rotate camera by mouse offset.
  103185. */
  103186. private rotateCamera;
  103187. }
  103188. }
  103189. declare module BABYLON {
  103190. /**
  103191. * Default Inputs manager for the FlyCamera.
  103192. * It groups all the default supported inputs for ease of use.
  103193. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103194. */
  103195. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  103196. /**
  103197. * Instantiates a new FlyCameraInputsManager.
  103198. * @param camera Defines the camera the inputs belong to.
  103199. */
  103200. constructor(camera: FlyCamera);
  103201. /**
  103202. * Add keyboard input support to the input manager.
  103203. * @returns the new FlyCameraKeyboardMoveInput().
  103204. */
  103205. addKeyboard(): FlyCameraInputsManager;
  103206. /**
  103207. * Add mouse input support to the input manager.
  103208. * @param touchEnabled Enable touch screen support.
  103209. * @returns the new FlyCameraMouseInput().
  103210. */
  103211. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  103212. }
  103213. }
  103214. declare module BABYLON {
  103215. /**
  103216. * This is a flying camera, designed for 3D movement and rotation in all directions,
  103217. * such as in a 3D Space Shooter or a Flight Simulator.
  103218. */
  103219. export class FlyCamera extends TargetCamera {
  103220. /**
  103221. * Define the collision ellipsoid of the camera.
  103222. * This is helpful for simulating a camera body, like a player's body.
  103223. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  103224. */
  103225. ellipsoid: Vector3;
  103226. /**
  103227. * Define an offset for the position of the ellipsoid around the camera.
  103228. * This can be helpful if the camera is attached away from the player's body center,
  103229. * such as at its head.
  103230. */
  103231. ellipsoidOffset: Vector3;
  103232. /**
  103233. * Enable or disable collisions of the camera with the rest of the scene objects.
  103234. */
  103235. checkCollisions: boolean;
  103236. /**
  103237. * Enable or disable gravity on the camera.
  103238. */
  103239. applyGravity: boolean;
  103240. /**
  103241. * Define the current direction the camera is moving to.
  103242. */
  103243. cameraDirection: Vector3;
  103244. /**
  103245. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  103246. * This overrides and empties cameraRotation.
  103247. */
  103248. rotationQuaternion: Quaternion;
  103249. /**
  103250. * Track Roll to maintain the wanted Rolling when looking around.
  103251. */
  103252. _trackRoll: number;
  103253. /**
  103254. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  103255. */
  103256. rollCorrect: number;
  103257. /**
  103258. * Mimic a banked turn, Rolling the camera when Yawing.
  103259. * It's recommended to use rollCorrect = 10 for faster banking correction.
  103260. */
  103261. bankedTurn: boolean;
  103262. /**
  103263. * Limit in radians for how much Roll banking will add. (Default: 90°)
  103264. */
  103265. bankedTurnLimit: number;
  103266. /**
  103267. * Value of 0 disables the banked Roll.
  103268. * Value of 1 is equal to the Yaw angle in radians.
  103269. */
  103270. bankedTurnMultiplier: number;
  103271. /**
  103272. * The inputs manager loads all the input sources, such as keyboard and mouse.
  103273. */
  103274. inputs: FlyCameraInputsManager;
  103275. /**
  103276. * Gets the input sensibility for mouse input.
  103277. * Higher values reduce sensitivity.
  103278. */
  103279. /**
  103280. * Sets the input sensibility for a mouse input.
  103281. * Higher values reduce sensitivity.
  103282. */
  103283. angularSensibility: number;
  103284. /**
  103285. * Get the keys for camera movement forward.
  103286. */
  103287. /**
  103288. * Set the keys for camera movement forward.
  103289. */
  103290. keysForward: number[];
  103291. /**
  103292. * Get the keys for camera movement backward.
  103293. */
  103294. keysBackward: number[];
  103295. /**
  103296. * Get the keys for camera movement up.
  103297. */
  103298. /**
  103299. * Set the keys for camera movement up.
  103300. */
  103301. keysUp: number[];
  103302. /**
  103303. * Get the keys for camera movement down.
  103304. */
  103305. /**
  103306. * Set the keys for camera movement down.
  103307. */
  103308. keysDown: number[];
  103309. /**
  103310. * Get the keys for camera movement left.
  103311. */
  103312. /**
  103313. * Set the keys for camera movement left.
  103314. */
  103315. keysLeft: number[];
  103316. /**
  103317. * Set the keys for camera movement right.
  103318. */
  103319. /**
  103320. * Set the keys for camera movement right.
  103321. */
  103322. keysRight: number[];
  103323. /**
  103324. * Event raised when the camera collides with a mesh in the scene.
  103325. */
  103326. onCollide: (collidedMesh: AbstractMesh) => void;
  103327. private _collider;
  103328. private _needMoveForGravity;
  103329. private _oldPosition;
  103330. private _diffPosition;
  103331. private _newPosition;
  103332. /** @hidden */
  103333. _localDirection: Vector3;
  103334. /** @hidden */
  103335. _transformedDirection: Vector3;
  103336. /**
  103337. * Instantiates a FlyCamera.
  103338. * This is a flying camera, designed for 3D movement and rotation in all directions,
  103339. * such as in a 3D Space Shooter or a Flight Simulator.
  103340. * @param name Define the name of the camera in the scene.
  103341. * @param position Define the starting position of the camera in the scene.
  103342. * @param scene Define the scene the camera belongs to.
  103343. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  103344. */
  103345. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  103346. /**
  103347. * Attach a control to the HTML DOM element.
  103348. * @param element Defines the element that listens to the input events.
  103349. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  103350. */
  103351. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103352. /**
  103353. * Detach a control from the HTML DOM element.
  103354. * The camera will stop reacting to that input.
  103355. * @param element Defines the element that listens to the input events.
  103356. */
  103357. detachControl(element: HTMLElement): void;
  103358. private _collisionMask;
  103359. /**
  103360. * Get the mask that the camera ignores in collision events.
  103361. */
  103362. /**
  103363. * Set the mask that the camera ignores in collision events.
  103364. */
  103365. collisionMask: number;
  103366. /** @hidden */
  103367. _collideWithWorld(displacement: Vector3): void;
  103368. /** @hidden */
  103369. private _onCollisionPositionChange;
  103370. /** @hidden */
  103371. _checkInputs(): void;
  103372. /** @hidden */
  103373. _decideIfNeedsToMove(): boolean;
  103374. /** @hidden */
  103375. _updatePosition(): void;
  103376. /**
  103377. * Restore the Roll to its target value at the rate specified.
  103378. * @param rate - Higher means slower restoring.
  103379. * @hidden
  103380. */
  103381. restoreRoll(rate: number): void;
  103382. /**
  103383. * Destroy the camera and release the current resources held by it.
  103384. */
  103385. dispose(): void;
  103386. /**
  103387. * Get the current object class name.
  103388. * @returns the class name.
  103389. */
  103390. getClassName(): string;
  103391. }
  103392. }
  103393. declare module BABYLON {
  103394. /**
  103395. * Listen to keyboard events to control the camera.
  103396. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103397. */
  103398. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  103399. /**
  103400. * Defines the camera the input is attached to.
  103401. */
  103402. camera: FlyCamera;
  103403. /**
  103404. * The list of keyboard keys used to control the forward move of the camera.
  103405. */
  103406. keysForward: number[];
  103407. /**
  103408. * The list of keyboard keys used to control the backward move of the camera.
  103409. */
  103410. keysBackward: number[];
  103411. /**
  103412. * The list of keyboard keys used to control the forward move of the camera.
  103413. */
  103414. keysUp: number[];
  103415. /**
  103416. * The list of keyboard keys used to control the backward move of the camera.
  103417. */
  103418. keysDown: number[];
  103419. /**
  103420. * The list of keyboard keys used to control the right strafe move of the camera.
  103421. */
  103422. keysRight: number[];
  103423. /**
  103424. * The list of keyboard keys used to control the left strafe move of the camera.
  103425. */
  103426. keysLeft: number[];
  103427. private _keys;
  103428. private _onCanvasBlurObserver;
  103429. private _onKeyboardObserver;
  103430. private _engine;
  103431. private _scene;
  103432. /**
  103433. * Attach the input controls to a specific dom element to get the input from.
  103434. * @param element Defines the element the controls should be listened from
  103435. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103436. */
  103437. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103438. /**
  103439. * Detach the current controls from the specified dom element.
  103440. * @param element Defines the element to stop listening the inputs from
  103441. */
  103442. detachControl(element: Nullable<HTMLElement>): void;
  103443. /**
  103444. * Gets the class name of the current intput.
  103445. * @returns the class name
  103446. */
  103447. getClassName(): string;
  103448. /** @hidden */
  103449. _onLostFocus(e: FocusEvent): void;
  103450. /**
  103451. * Get the friendly name associated with the input class.
  103452. * @returns the input friendly name
  103453. */
  103454. getSimpleName(): string;
  103455. /**
  103456. * Update the current camera state depending on the inputs that have been used this frame.
  103457. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103458. */
  103459. checkInputs(): void;
  103460. }
  103461. }
  103462. declare module BABYLON {
  103463. /**
  103464. * Manage the mouse wheel inputs to control a follow camera.
  103465. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103466. */
  103467. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  103468. /**
  103469. * Defines the camera the input is attached to.
  103470. */
  103471. camera: FollowCamera;
  103472. /**
  103473. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  103474. */
  103475. axisControlRadius: boolean;
  103476. /**
  103477. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  103478. */
  103479. axisControlHeight: boolean;
  103480. /**
  103481. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  103482. */
  103483. axisControlRotation: boolean;
  103484. /**
  103485. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  103486. * relation to mouseWheel events.
  103487. */
  103488. wheelPrecision: number;
  103489. /**
  103490. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  103491. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  103492. */
  103493. wheelDeltaPercentage: number;
  103494. private _wheel;
  103495. private _observer;
  103496. /**
  103497. * Attach the input controls to a specific dom element to get the input from.
  103498. * @param element Defines the element the controls should be listened from
  103499. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103500. */
  103501. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103502. /**
  103503. * Detach the current controls from the specified dom element.
  103504. * @param element Defines the element to stop listening the inputs from
  103505. */
  103506. detachControl(element: Nullable<HTMLElement>): void;
  103507. /**
  103508. * Gets the class name of the current intput.
  103509. * @returns the class name
  103510. */
  103511. getClassName(): string;
  103512. /**
  103513. * Get the friendly name associated with the input class.
  103514. * @returns the input friendly name
  103515. */
  103516. getSimpleName(): string;
  103517. }
  103518. }
  103519. declare module BABYLON {
  103520. /**
  103521. * Manage the pointers inputs to control an follow camera.
  103522. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103523. */
  103524. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  103525. /**
  103526. * Defines the camera the input is attached to.
  103527. */
  103528. camera: FollowCamera;
  103529. /**
  103530. * Gets the class name of the current input.
  103531. * @returns the class name
  103532. */
  103533. getClassName(): string;
  103534. /**
  103535. * Defines the pointer angular sensibility along the X axis or how fast is
  103536. * the camera rotating.
  103537. * A negative number will reverse the axis direction.
  103538. */
  103539. angularSensibilityX: number;
  103540. /**
  103541. * Defines the pointer angular sensibility along the Y axis or how fast is
  103542. * the camera rotating.
  103543. * A negative number will reverse the axis direction.
  103544. */
  103545. angularSensibilityY: number;
  103546. /**
  103547. * Defines the pointer pinch precision or how fast is the camera zooming.
  103548. * A negative number will reverse the axis direction.
  103549. */
  103550. pinchPrecision: number;
  103551. /**
  103552. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  103553. * from 0.
  103554. * It defines the percentage of current camera.radius to use as delta when
  103555. * pinch zoom is used.
  103556. */
  103557. pinchDeltaPercentage: number;
  103558. /**
  103559. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  103560. */
  103561. axisXControlRadius: boolean;
  103562. /**
  103563. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  103564. */
  103565. axisXControlHeight: boolean;
  103566. /**
  103567. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  103568. */
  103569. axisXControlRotation: boolean;
  103570. /**
  103571. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  103572. */
  103573. axisYControlRadius: boolean;
  103574. /**
  103575. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  103576. */
  103577. axisYControlHeight: boolean;
  103578. /**
  103579. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  103580. */
  103581. axisYControlRotation: boolean;
  103582. /**
  103583. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  103584. */
  103585. axisPinchControlRadius: boolean;
  103586. /**
  103587. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  103588. */
  103589. axisPinchControlHeight: boolean;
  103590. /**
  103591. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  103592. */
  103593. axisPinchControlRotation: boolean;
  103594. /**
  103595. * Log error messages if basic misconfiguration has occurred.
  103596. */
  103597. warningEnable: boolean;
  103598. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  103599. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  103600. private _warningCounter;
  103601. private _warning;
  103602. }
  103603. }
  103604. declare module BABYLON {
  103605. /**
  103606. * Default Inputs manager for the FollowCamera.
  103607. * It groups all the default supported inputs for ease of use.
  103608. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103609. */
  103610. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  103611. /**
  103612. * Instantiates a new FollowCameraInputsManager.
  103613. * @param camera Defines the camera the inputs belong to
  103614. */
  103615. constructor(camera: FollowCamera);
  103616. /**
  103617. * Add keyboard input support to the input manager.
  103618. * @returns the current input manager
  103619. */
  103620. addKeyboard(): FollowCameraInputsManager;
  103621. /**
  103622. * Add mouse wheel input support to the input manager.
  103623. * @returns the current input manager
  103624. */
  103625. addMouseWheel(): FollowCameraInputsManager;
  103626. /**
  103627. * Add pointers input support to the input manager.
  103628. * @returns the current input manager
  103629. */
  103630. addPointers(): FollowCameraInputsManager;
  103631. /**
  103632. * Add orientation input support to the input manager.
  103633. * @returns the current input manager
  103634. */
  103635. addVRDeviceOrientation(): FollowCameraInputsManager;
  103636. }
  103637. }
  103638. declare module BABYLON {
  103639. /**
  103640. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  103641. * an arc rotate version arcFollowCamera are available.
  103642. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  103643. */
  103644. export class FollowCamera extends TargetCamera {
  103645. /**
  103646. * Distance the follow camera should follow an object at
  103647. */
  103648. radius: number;
  103649. /**
  103650. * Minimum allowed distance of the camera to the axis of rotation
  103651. * (The camera can not get closer).
  103652. * This can help limiting how the Camera is able to move in the scene.
  103653. */
  103654. lowerRadiusLimit: Nullable<number>;
  103655. /**
  103656. * Maximum allowed distance of the camera to the axis of rotation
  103657. * (The camera can not get further).
  103658. * This can help limiting how the Camera is able to move in the scene.
  103659. */
  103660. upperRadiusLimit: Nullable<number>;
  103661. /**
  103662. * Define a rotation offset between the camera and the object it follows
  103663. */
  103664. rotationOffset: number;
  103665. /**
  103666. * Minimum allowed angle to camera position relative to target object.
  103667. * This can help limiting how the Camera is able to move in the scene.
  103668. */
  103669. lowerRotationOffsetLimit: Nullable<number>;
  103670. /**
  103671. * Maximum allowed angle to camera position relative to target object.
  103672. * This can help limiting how the Camera is able to move in the scene.
  103673. */
  103674. upperRotationOffsetLimit: Nullable<number>;
  103675. /**
  103676. * Define a height offset between the camera and the object it follows.
  103677. * It can help following an object from the top (like a car chaing a plane)
  103678. */
  103679. heightOffset: number;
  103680. /**
  103681. * Minimum allowed height of camera position relative to target object.
  103682. * This can help limiting how the Camera is able to move in the scene.
  103683. */
  103684. lowerHeightOffsetLimit: Nullable<number>;
  103685. /**
  103686. * Maximum allowed height of camera position relative to target object.
  103687. * This can help limiting how the Camera is able to move in the scene.
  103688. */
  103689. upperHeightOffsetLimit: Nullable<number>;
  103690. /**
  103691. * Define how fast the camera can accelerate to follow it s target.
  103692. */
  103693. cameraAcceleration: number;
  103694. /**
  103695. * Define the speed limit of the camera following an object.
  103696. */
  103697. maxCameraSpeed: number;
  103698. /**
  103699. * Define the target of the camera.
  103700. */
  103701. lockedTarget: Nullable<AbstractMesh>;
  103702. /**
  103703. * Defines the input associated with the camera.
  103704. */
  103705. inputs: FollowCameraInputsManager;
  103706. /**
  103707. * Instantiates the follow camera.
  103708. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  103709. * @param name Define the name of the camera in the scene
  103710. * @param position Define the position of the camera
  103711. * @param scene Define the scene the camera belong to
  103712. * @param lockedTarget Define the target of the camera
  103713. */
  103714. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  103715. private _follow;
  103716. /**
  103717. * Attached controls to the current camera.
  103718. * @param element Defines the element the controls should be listened from
  103719. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103720. */
  103721. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103722. /**
  103723. * Detach the current controls from the camera.
  103724. * The camera will stop reacting to inputs.
  103725. * @param element Defines the element to stop listening the inputs from
  103726. */
  103727. detachControl(element: HTMLElement): void;
  103728. /** @hidden */
  103729. _checkInputs(): void;
  103730. private _checkLimits;
  103731. /**
  103732. * Gets the camera class name.
  103733. * @returns the class name
  103734. */
  103735. getClassName(): string;
  103736. }
  103737. /**
  103738. * Arc Rotate version of the follow camera.
  103739. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  103740. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  103741. */
  103742. export class ArcFollowCamera extends TargetCamera {
  103743. /** The longitudinal angle of the camera */
  103744. alpha: number;
  103745. /** The latitudinal angle of the camera */
  103746. beta: number;
  103747. /** The radius of the camera from its target */
  103748. radius: number;
  103749. /** Define the camera target (the messh it should follow) */
  103750. target: Nullable<AbstractMesh>;
  103751. private _cartesianCoordinates;
  103752. /**
  103753. * Instantiates a new ArcFollowCamera
  103754. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  103755. * @param name Define the name of the camera
  103756. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  103757. * @param beta Define the rotation angle of the camera around the elevation axis
  103758. * @param radius Define the radius of the camera from its target point
  103759. * @param target Define the target of the camera
  103760. * @param scene Define the scene the camera belongs to
  103761. */
  103762. constructor(name: string,
  103763. /** The longitudinal angle of the camera */
  103764. alpha: number,
  103765. /** The latitudinal angle of the camera */
  103766. beta: number,
  103767. /** The radius of the camera from its target */
  103768. radius: number,
  103769. /** Define the camera target (the messh it should follow) */
  103770. target: Nullable<AbstractMesh>, scene: Scene);
  103771. private _follow;
  103772. /** @hidden */
  103773. _checkInputs(): void;
  103774. /**
  103775. * Returns the class name of the object.
  103776. * It is mostly used internally for serialization purposes.
  103777. */
  103778. getClassName(): string;
  103779. }
  103780. }
  103781. declare module BABYLON {
  103782. /**
  103783. * Manage the keyboard inputs to control the movement of a follow camera.
  103784. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103785. */
  103786. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  103787. /**
  103788. * Defines the camera the input is attached to.
  103789. */
  103790. camera: FollowCamera;
  103791. /**
  103792. * Defines the list of key codes associated with the up action (increase heightOffset)
  103793. */
  103794. keysHeightOffsetIncr: number[];
  103795. /**
  103796. * Defines the list of key codes associated with the down action (decrease heightOffset)
  103797. */
  103798. keysHeightOffsetDecr: number[];
  103799. /**
  103800. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  103801. */
  103802. keysHeightOffsetModifierAlt: boolean;
  103803. /**
  103804. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  103805. */
  103806. keysHeightOffsetModifierCtrl: boolean;
  103807. /**
  103808. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  103809. */
  103810. keysHeightOffsetModifierShift: boolean;
  103811. /**
  103812. * Defines the list of key codes associated with the left action (increase rotationOffset)
  103813. */
  103814. keysRotationOffsetIncr: number[];
  103815. /**
  103816. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  103817. */
  103818. keysRotationOffsetDecr: number[];
  103819. /**
  103820. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  103821. */
  103822. keysRotationOffsetModifierAlt: boolean;
  103823. /**
  103824. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  103825. */
  103826. keysRotationOffsetModifierCtrl: boolean;
  103827. /**
  103828. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  103829. */
  103830. keysRotationOffsetModifierShift: boolean;
  103831. /**
  103832. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  103833. */
  103834. keysRadiusIncr: number[];
  103835. /**
  103836. * Defines the list of key codes associated with the zoom-out action (increase radius)
  103837. */
  103838. keysRadiusDecr: number[];
  103839. /**
  103840. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  103841. */
  103842. keysRadiusModifierAlt: boolean;
  103843. /**
  103844. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  103845. */
  103846. keysRadiusModifierCtrl: boolean;
  103847. /**
  103848. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  103849. */
  103850. keysRadiusModifierShift: boolean;
  103851. /**
  103852. * Defines the rate of change of heightOffset.
  103853. */
  103854. heightSensibility: number;
  103855. /**
  103856. * Defines the rate of change of rotationOffset.
  103857. */
  103858. rotationSensibility: number;
  103859. /**
  103860. * Defines the rate of change of radius.
  103861. */
  103862. radiusSensibility: number;
  103863. private _keys;
  103864. private _ctrlPressed;
  103865. private _altPressed;
  103866. private _shiftPressed;
  103867. private _onCanvasBlurObserver;
  103868. private _onKeyboardObserver;
  103869. private _engine;
  103870. private _scene;
  103871. /**
  103872. * Attach the input controls to a specific dom element to get the input from.
  103873. * @param element Defines the element the controls should be listened from
  103874. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103875. */
  103876. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103877. /**
  103878. * Detach the current controls from the specified dom element.
  103879. * @param element Defines the element to stop listening the inputs from
  103880. */
  103881. detachControl(element: Nullable<HTMLElement>): void;
  103882. /**
  103883. * Update the current camera state depending on the inputs that have been used this frame.
  103884. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103885. */
  103886. checkInputs(): void;
  103887. /**
  103888. * Gets the class name of the current input.
  103889. * @returns the class name
  103890. */
  103891. getClassName(): string;
  103892. /**
  103893. * Get the friendly name associated with the input class.
  103894. * @returns the input friendly name
  103895. */
  103896. getSimpleName(): string;
  103897. /**
  103898. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  103899. * allow modification of the heightOffset value.
  103900. */
  103901. private _modifierHeightOffset;
  103902. /**
  103903. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  103904. * allow modification of the rotationOffset value.
  103905. */
  103906. private _modifierRotationOffset;
  103907. /**
  103908. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  103909. * allow modification of the radius value.
  103910. */
  103911. private _modifierRadius;
  103912. }
  103913. }
  103914. declare module BABYLON {
  103915. interface FreeCameraInputsManager {
  103916. /**
  103917. * @hidden
  103918. */
  103919. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  103920. /**
  103921. * Add orientation input support to the input manager.
  103922. * @returns the current input manager
  103923. */
  103924. addDeviceOrientation(): FreeCameraInputsManager;
  103925. }
  103926. /**
  103927. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  103928. * Screen rotation is taken into account.
  103929. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103930. */
  103931. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  103932. private _camera;
  103933. private _screenOrientationAngle;
  103934. private _constantTranform;
  103935. private _screenQuaternion;
  103936. private _alpha;
  103937. private _beta;
  103938. private _gamma;
  103939. /**
  103940. * Can be used to detect if a device orientation sensor is availible on a device
  103941. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  103942. * @returns a promise that will resolve on orientation change
  103943. */
  103944. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  103945. /**
  103946. * @hidden
  103947. */
  103948. _onDeviceOrientationChangedObservable: Observable<void>;
  103949. /**
  103950. * Instantiates a new input
  103951. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103952. */
  103953. constructor();
  103954. /**
  103955. * Define the camera controlled by the input.
  103956. */
  103957. camera: FreeCamera;
  103958. /**
  103959. * Attach the input controls to a specific dom element to get the input from.
  103960. * @param element Defines the element the controls should be listened from
  103961. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103962. */
  103963. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103964. private _orientationChanged;
  103965. private _deviceOrientation;
  103966. /**
  103967. * Detach the current controls from the specified dom element.
  103968. * @param element Defines the element to stop listening the inputs from
  103969. */
  103970. detachControl(element: Nullable<HTMLElement>): void;
  103971. /**
  103972. * Update the current camera state depending on the inputs that have been used this frame.
  103973. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103974. */
  103975. checkInputs(): void;
  103976. /**
  103977. * Gets the class name of the current intput.
  103978. * @returns the class name
  103979. */
  103980. getClassName(): string;
  103981. /**
  103982. * Get the friendly name associated with the input class.
  103983. * @returns the input friendly name
  103984. */
  103985. getSimpleName(): string;
  103986. }
  103987. }
  103988. declare module BABYLON {
  103989. /**
  103990. * Manage the gamepad inputs to control a free camera.
  103991. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103992. */
  103993. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  103994. /**
  103995. * Define the camera the input is attached to.
  103996. */
  103997. camera: FreeCamera;
  103998. /**
  103999. * Define the Gamepad controlling the input
  104000. */
  104001. gamepad: Nullable<Gamepad>;
  104002. /**
  104003. * Defines the gamepad rotation sensiblity.
  104004. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  104005. */
  104006. gamepadAngularSensibility: number;
  104007. /**
  104008. * Defines the gamepad move sensiblity.
  104009. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  104010. */
  104011. gamepadMoveSensibility: number;
  104012. private _onGamepadConnectedObserver;
  104013. private _onGamepadDisconnectedObserver;
  104014. private _cameraTransform;
  104015. private _deltaTransform;
  104016. private _vector3;
  104017. private _vector2;
  104018. /**
  104019. * Attach the input controls to a specific dom element to get the input from.
  104020. * @param element Defines the element the controls should be listened from
  104021. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104022. */
  104023. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104024. /**
  104025. * Detach the current controls from the specified dom element.
  104026. * @param element Defines the element to stop listening the inputs from
  104027. */
  104028. detachControl(element: Nullable<HTMLElement>): void;
  104029. /**
  104030. * Update the current camera state depending on the inputs that have been used this frame.
  104031. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104032. */
  104033. checkInputs(): void;
  104034. /**
  104035. * Gets the class name of the current intput.
  104036. * @returns the class name
  104037. */
  104038. getClassName(): string;
  104039. /**
  104040. * Get the friendly name associated with the input class.
  104041. * @returns the input friendly name
  104042. */
  104043. getSimpleName(): string;
  104044. }
  104045. }
  104046. declare module BABYLON {
  104047. /**
  104048. * Defines the potential axis of a Joystick
  104049. */
  104050. export enum JoystickAxis {
  104051. /** X axis */
  104052. X = 0,
  104053. /** Y axis */
  104054. Y = 1,
  104055. /** Z axis */
  104056. Z = 2
  104057. }
  104058. /**
  104059. * Class used to define virtual joystick (used in touch mode)
  104060. */
  104061. export class VirtualJoystick {
  104062. /**
  104063. * Gets or sets a boolean indicating that left and right values must be inverted
  104064. */
  104065. reverseLeftRight: boolean;
  104066. /**
  104067. * Gets or sets a boolean indicating that up and down values must be inverted
  104068. */
  104069. reverseUpDown: boolean;
  104070. /**
  104071. * Gets the offset value for the position (ie. the change of the position value)
  104072. */
  104073. deltaPosition: Vector3;
  104074. /**
  104075. * Gets a boolean indicating if the virtual joystick was pressed
  104076. */
  104077. pressed: boolean;
  104078. /**
  104079. * Canvas the virtual joystick will render onto, default z-index of this is 5
  104080. */
  104081. static Canvas: Nullable<HTMLCanvasElement>;
  104082. private static _globalJoystickIndex;
  104083. private static vjCanvasContext;
  104084. private static vjCanvasWidth;
  104085. private static vjCanvasHeight;
  104086. private static halfWidth;
  104087. private _action;
  104088. private _axisTargetedByLeftAndRight;
  104089. private _axisTargetedByUpAndDown;
  104090. private _joystickSensibility;
  104091. private _inversedSensibility;
  104092. private _joystickPointerID;
  104093. private _joystickColor;
  104094. private _joystickPointerPos;
  104095. private _joystickPreviousPointerPos;
  104096. private _joystickPointerStartPos;
  104097. private _deltaJoystickVector;
  104098. private _leftJoystick;
  104099. private _touches;
  104100. private _onPointerDownHandlerRef;
  104101. private _onPointerMoveHandlerRef;
  104102. private _onPointerUpHandlerRef;
  104103. private _onResize;
  104104. /**
  104105. * Creates a new virtual joystick
  104106. * @param leftJoystick defines that the joystick is for left hand (false by default)
  104107. */
  104108. constructor(leftJoystick?: boolean);
  104109. /**
  104110. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  104111. * @param newJoystickSensibility defines the new sensibility
  104112. */
  104113. setJoystickSensibility(newJoystickSensibility: number): void;
  104114. private _onPointerDown;
  104115. private _onPointerMove;
  104116. private _onPointerUp;
  104117. /**
  104118. * Change the color of the virtual joystick
  104119. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  104120. */
  104121. setJoystickColor(newColor: string): void;
  104122. /**
  104123. * Defines a callback to call when the joystick is touched
  104124. * @param action defines the callback
  104125. */
  104126. setActionOnTouch(action: () => any): void;
  104127. /**
  104128. * Defines which axis you'd like to control for left & right
  104129. * @param axis defines the axis to use
  104130. */
  104131. setAxisForLeftRight(axis: JoystickAxis): void;
  104132. /**
  104133. * Defines which axis you'd like to control for up & down
  104134. * @param axis defines the axis to use
  104135. */
  104136. setAxisForUpDown(axis: JoystickAxis): void;
  104137. private _drawVirtualJoystick;
  104138. /**
  104139. * Release internal HTML canvas
  104140. */
  104141. releaseCanvas(): void;
  104142. }
  104143. }
  104144. declare module BABYLON {
  104145. interface FreeCameraInputsManager {
  104146. /**
  104147. * Add virtual joystick input support to the input manager.
  104148. * @returns the current input manager
  104149. */
  104150. addVirtualJoystick(): FreeCameraInputsManager;
  104151. }
  104152. /**
  104153. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  104154. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104155. */
  104156. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  104157. /**
  104158. * Defines the camera the input is attached to.
  104159. */
  104160. camera: FreeCamera;
  104161. private _leftjoystick;
  104162. private _rightjoystick;
  104163. /**
  104164. * Gets the left stick of the virtual joystick.
  104165. * @returns The virtual Joystick
  104166. */
  104167. getLeftJoystick(): VirtualJoystick;
  104168. /**
  104169. * Gets the right stick of the virtual joystick.
  104170. * @returns The virtual Joystick
  104171. */
  104172. getRightJoystick(): VirtualJoystick;
  104173. /**
  104174. * Update the current camera state depending on the inputs that have been used this frame.
  104175. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104176. */
  104177. checkInputs(): void;
  104178. /**
  104179. * Attach the input controls to a specific dom element to get the input from.
  104180. * @param element Defines the element the controls should be listened from
  104181. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104182. */
  104183. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104184. /**
  104185. * Detach the current controls from the specified dom element.
  104186. * @param element Defines the element to stop listening the inputs from
  104187. */
  104188. detachControl(element: Nullable<HTMLElement>): void;
  104189. /**
  104190. * Gets the class name of the current intput.
  104191. * @returns the class name
  104192. */
  104193. getClassName(): string;
  104194. /**
  104195. * Get the friendly name associated with the input class.
  104196. * @returns the input friendly name
  104197. */
  104198. getSimpleName(): string;
  104199. }
  104200. }
  104201. declare module BABYLON {
  104202. /**
  104203. * This represents a FPS type of camera controlled by touch.
  104204. * This is like a universal camera minus the Gamepad controls.
  104205. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  104206. */
  104207. export class TouchCamera extends FreeCamera {
  104208. /**
  104209. * Defines the touch sensibility for rotation.
  104210. * The higher the faster.
  104211. */
  104212. touchAngularSensibility: number;
  104213. /**
  104214. * Defines the touch sensibility for move.
  104215. * The higher the faster.
  104216. */
  104217. touchMoveSensibility: number;
  104218. /**
  104219. * Instantiates a new touch camera.
  104220. * This represents a FPS type of camera controlled by touch.
  104221. * This is like a universal camera minus the Gamepad controls.
  104222. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  104223. * @param name Define the name of the camera in the scene
  104224. * @param position Define the start position of the camera in the scene
  104225. * @param scene Define the scene the camera belongs to
  104226. */
  104227. constructor(name: string, position: Vector3, scene: Scene);
  104228. /**
  104229. * Gets the current object class name.
  104230. * @return the class name
  104231. */
  104232. getClassName(): string;
  104233. /** @hidden */
  104234. _setupInputs(): void;
  104235. }
  104236. }
  104237. declare module BABYLON {
  104238. /**
  104239. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  104240. * being tilted forward or back and left or right.
  104241. */
  104242. export class DeviceOrientationCamera extends FreeCamera {
  104243. private _initialQuaternion;
  104244. private _quaternionCache;
  104245. private _tmpDragQuaternion;
  104246. private _disablePointerInputWhenUsingDeviceOrientation;
  104247. /**
  104248. * Creates a new device orientation camera
  104249. * @param name The name of the camera
  104250. * @param position The start position camera
  104251. * @param scene The scene the camera belongs to
  104252. */
  104253. constructor(name: string, position: Vector3, scene: Scene);
  104254. /**
  104255. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  104256. */
  104257. disablePointerInputWhenUsingDeviceOrientation: boolean;
  104258. private _dragFactor;
  104259. /**
  104260. * Enabled turning on the y axis when the orientation sensor is active
  104261. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  104262. */
  104263. enableHorizontalDragging(dragFactor?: number): void;
  104264. /**
  104265. * Gets the current instance class name ("DeviceOrientationCamera").
  104266. * This helps avoiding instanceof at run time.
  104267. * @returns the class name
  104268. */
  104269. getClassName(): string;
  104270. /**
  104271. * @hidden
  104272. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  104273. */
  104274. _checkInputs(): void;
  104275. /**
  104276. * Reset the camera to its default orientation on the specified axis only.
  104277. * @param axis The axis to reset
  104278. */
  104279. resetToCurrentRotation(axis?: Axis): void;
  104280. }
  104281. }
  104282. declare module BABYLON {
  104283. /**
  104284. * Defines supported buttons for XBox360 compatible gamepads
  104285. */
  104286. export enum Xbox360Button {
  104287. /** A */
  104288. A = 0,
  104289. /** B */
  104290. B = 1,
  104291. /** X */
  104292. X = 2,
  104293. /** Y */
  104294. Y = 3,
  104295. /** Start */
  104296. Start = 4,
  104297. /** Back */
  104298. Back = 5,
  104299. /** Left button */
  104300. LB = 6,
  104301. /** Right button */
  104302. RB = 7,
  104303. /** Left stick */
  104304. LeftStick = 8,
  104305. /** Right stick */
  104306. RightStick = 9
  104307. }
  104308. /** Defines values for XBox360 DPad */
  104309. export enum Xbox360Dpad {
  104310. /** Up */
  104311. Up = 0,
  104312. /** Down */
  104313. Down = 1,
  104314. /** Left */
  104315. Left = 2,
  104316. /** Right */
  104317. Right = 3
  104318. }
  104319. /**
  104320. * Defines a XBox360 gamepad
  104321. */
  104322. export class Xbox360Pad extends Gamepad {
  104323. private _leftTrigger;
  104324. private _rightTrigger;
  104325. private _onlefttriggerchanged;
  104326. private _onrighttriggerchanged;
  104327. private _onbuttondown;
  104328. private _onbuttonup;
  104329. private _ondpaddown;
  104330. private _ondpadup;
  104331. /** Observable raised when a button is pressed */
  104332. onButtonDownObservable: Observable<Xbox360Button>;
  104333. /** Observable raised when a button is released */
  104334. onButtonUpObservable: Observable<Xbox360Button>;
  104335. /** Observable raised when a pad is pressed */
  104336. onPadDownObservable: Observable<Xbox360Dpad>;
  104337. /** Observable raised when a pad is released */
  104338. onPadUpObservable: Observable<Xbox360Dpad>;
  104339. private _buttonA;
  104340. private _buttonB;
  104341. private _buttonX;
  104342. private _buttonY;
  104343. private _buttonBack;
  104344. private _buttonStart;
  104345. private _buttonLB;
  104346. private _buttonRB;
  104347. private _buttonLeftStick;
  104348. private _buttonRightStick;
  104349. private _dPadUp;
  104350. private _dPadDown;
  104351. private _dPadLeft;
  104352. private _dPadRight;
  104353. private _isXboxOnePad;
  104354. /**
  104355. * Creates a new XBox360 gamepad object
  104356. * @param id defines the id of this gamepad
  104357. * @param index defines its index
  104358. * @param gamepad defines the internal HTML gamepad object
  104359. * @param xboxOne defines if it is a XBox One gamepad
  104360. */
  104361. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  104362. /**
  104363. * Defines the callback to call when left trigger is pressed
  104364. * @param callback defines the callback to use
  104365. */
  104366. onlefttriggerchanged(callback: (value: number) => void): void;
  104367. /**
  104368. * Defines the callback to call when right trigger is pressed
  104369. * @param callback defines the callback to use
  104370. */
  104371. onrighttriggerchanged(callback: (value: number) => void): void;
  104372. /**
  104373. * Gets the left trigger value
  104374. */
  104375. /**
  104376. * Sets the left trigger value
  104377. */
  104378. leftTrigger: number;
  104379. /**
  104380. * Gets the right trigger value
  104381. */
  104382. /**
  104383. * Sets the right trigger value
  104384. */
  104385. rightTrigger: number;
  104386. /**
  104387. * Defines the callback to call when a button is pressed
  104388. * @param callback defines the callback to use
  104389. */
  104390. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  104391. /**
  104392. * Defines the callback to call when a button is released
  104393. * @param callback defines the callback to use
  104394. */
  104395. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  104396. /**
  104397. * Defines the callback to call when a pad is pressed
  104398. * @param callback defines the callback to use
  104399. */
  104400. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  104401. /**
  104402. * Defines the callback to call when a pad is released
  104403. * @param callback defines the callback to use
  104404. */
  104405. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  104406. private _setButtonValue;
  104407. private _setDPadValue;
  104408. /**
  104409. * Gets the value of the `A` button
  104410. */
  104411. /**
  104412. * Sets the value of the `A` button
  104413. */
  104414. buttonA: number;
  104415. /**
  104416. * Gets the value of the `B` button
  104417. */
  104418. /**
  104419. * Sets the value of the `B` button
  104420. */
  104421. buttonB: number;
  104422. /**
  104423. * Gets the value of the `X` button
  104424. */
  104425. /**
  104426. * Sets the value of the `X` button
  104427. */
  104428. buttonX: number;
  104429. /**
  104430. * Gets the value of the `Y` button
  104431. */
  104432. /**
  104433. * Sets the value of the `Y` button
  104434. */
  104435. buttonY: number;
  104436. /**
  104437. * Gets the value of the `Start` button
  104438. */
  104439. /**
  104440. * Sets the value of the `Start` button
  104441. */
  104442. buttonStart: number;
  104443. /**
  104444. * Gets the value of the `Back` button
  104445. */
  104446. /**
  104447. * Sets the value of the `Back` button
  104448. */
  104449. buttonBack: number;
  104450. /**
  104451. * Gets the value of the `Left` button
  104452. */
  104453. /**
  104454. * Sets the value of the `Left` button
  104455. */
  104456. buttonLB: number;
  104457. /**
  104458. * Gets the value of the `Right` button
  104459. */
  104460. /**
  104461. * Sets the value of the `Right` button
  104462. */
  104463. buttonRB: number;
  104464. /**
  104465. * Gets the value of the Left joystick
  104466. */
  104467. /**
  104468. * Sets the value of the Left joystick
  104469. */
  104470. buttonLeftStick: number;
  104471. /**
  104472. * Gets the value of the Right joystick
  104473. */
  104474. /**
  104475. * Sets the value of the Right joystick
  104476. */
  104477. buttonRightStick: number;
  104478. /**
  104479. * Gets the value of D-pad up
  104480. */
  104481. /**
  104482. * Sets the value of D-pad up
  104483. */
  104484. dPadUp: number;
  104485. /**
  104486. * Gets the value of D-pad down
  104487. */
  104488. /**
  104489. * Sets the value of D-pad down
  104490. */
  104491. dPadDown: number;
  104492. /**
  104493. * Gets the value of D-pad left
  104494. */
  104495. /**
  104496. * Sets the value of D-pad left
  104497. */
  104498. dPadLeft: number;
  104499. /**
  104500. * Gets the value of D-pad right
  104501. */
  104502. /**
  104503. * Sets the value of D-pad right
  104504. */
  104505. dPadRight: number;
  104506. /**
  104507. * Force the gamepad to synchronize with device values
  104508. */
  104509. update(): void;
  104510. /**
  104511. * Disposes the gamepad
  104512. */
  104513. dispose(): void;
  104514. }
  104515. }
  104516. declare module BABYLON {
  104517. /**
  104518. * Defines supported buttons for DualShock compatible gamepads
  104519. */
  104520. export enum DualShockButton {
  104521. /** Cross */
  104522. Cross = 0,
  104523. /** Circle */
  104524. Circle = 1,
  104525. /** Square */
  104526. Square = 2,
  104527. /** Triangle */
  104528. Triangle = 3,
  104529. /** Options */
  104530. Options = 4,
  104531. /** Share */
  104532. Share = 5,
  104533. /** L1 */
  104534. L1 = 6,
  104535. /** R1 */
  104536. R1 = 7,
  104537. /** Left stick */
  104538. LeftStick = 8,
  104539. /** Right stick */
  104540. RightStick = 9
  104541. }
  104542. /** Defines values for DualShock DPad */
  104543. export enum DualShockDpad {
  104544. /** Up */
  104545. Up = 0,
  104546. /** Down */
  104547. Down = 1,
  104548. /** Left */
  104549. Left = 2,
  104550. /** Right */
  104551. Right = 3
  104552. }
  104553. /**
  104554. * Defines a DualShock gamepad
  104555. */
  104556. export class DualShockPad extends Gamepad {
  104557. private _leftTrigger;
  104558. private _rightTrigger;
  104559. private _onlefttriggerchanged;
  104560. private _onrighttriggerchanged;
  104561. private _onbuttondown;
  104562. private _onbuttonup;
  104563. private _ondpaddown;
  104564. private _ondpadup;
  104565. /** Observable raised when a button is pressed */
  104566. onButtonDownObservable: Observable<DualShockButton>;
  104567. /** Observable raised when a button is released */
  104568. onButtonUpObservable: Observable<DualShockButton>;
  104569. /** Observable raised when a pad is pressed */
  104570. onPadDownObservable: Observable<DualShockDpad>;
  104571. /** Observable raised when a pad is released */
  104572. onPadUpObservable: Observable<DualShockDpad>;
  104573. private _buttonCross;
  104574. private _buttonCircle;
  104575. private _buttonSquare;
  104576. private _buttonTriangle;
  104577. private _buttonShare;
  104578. private _buttonOptions;
  104579. private _buttonL1;
  104580. private _buttonR1;
  104581. private _buttonLeftStick;
  104582. private _buttonRightStick;
  104583. private _dPadUp;
  104584. private _dPadDown;
  104585. private _dPadLeft;
  104586. private _dPadRight;
  104587. /**
  104588. * Creates a new DualShock gamepad object
  104589. * @param id defines the id of this gamepad
  104590. * @param index defines its index
  104591. * @param gamepad defines the internal HTML gamepad object
  104592. */
  104593. constructor(id: string, index: number, gamepad: any);
  104594. /**
  104595. * Defines the callback to call when left trigger is pressed
  104596. * @param callback defines the callback to use
  104597. */
  104598. onlefttriggerchanged(callback: (value: number) => void): void;
  104599. /**
  104600. * Defines the callback to call when right trigger is pressed
  104601. * @param callback defines the callback to use
  104602. */
  104603. onrighttriggerchanged(callback: (value: number) => void): void;
  104604. /**
  104605. * Gets the left trigger value
  104606. */
  104607. /**
  104608. * Sets the left trigger value
  104609. */
  104610. leftTrigger: number;
  104611. /**
  104612. * Gets the right trigger value
  104613. */
  104614. /**
  104615. * Sets the right trigger value
  104616. */
  104617. rightTrigger: number;
  104618. /**
  104619. * Defines the callback to call when a button is pressed
  104620. * @param callback defines the callback to use
  104621. */
  104622. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  104623. /**
  104624. * Defines the callback to call when a button is released
  104625. * @param callback defines the callback to use
  104626. */
  104627. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  104628. /**
  104629. * Defines the callback to call when a pad is pressed
  104630. * @param callback defines the callback to use
  104631. */
  104632. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  104633. /**
  104634. * Defines the callback to call when a pad is released
  104635. * @param callback defines the callback to use
  104636. */
  104637. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  104638. private _setButtonValue;
  104639. private _setDPadValue;
  104640. /**
  104641. * Gets the value of the `Cross` button
  104642. */
  104643. /**
  104644. * Sets the value of the `Cross` button
  104645. */
  104646. buttonCross: number;
  104647. /**
  104648. * Gets the value of the `Circle` button
  104649. */
  104650. /**
  104651. * Sets the value of the `Circle` button
  104652. */
  104653. buttonCircle: number;
  104654. /**
  104655. * Gets the value of the `Square` button
  104656. */
  104657. /**
  104658. * Sets the value of the `Square` button
  104659. */
  104660. buttonSquare: number;
  104661. /**
  104662. * Gets the value of the `Triangle` button
  104663. */
  104664. /**
  104665. * Sets the value of the `Triangle` button
  104666. */
  104667. buttonTriangle: number;
  104668. /**
  104669. * Gets the value of the `Options` button
  104670. */
  104671. /**
  104672. * Sets the value of the `Options` button
  104673. */
  104674. buttonOptions: number;
  104675. /**
  104676. * Gets the value of the `Share` button
  104677. */
  104678. /**
  104679. * Sets the value of the `Share` button
  104680. */
  104681. buttonShare: number;
  104682. /**
  104683. * Gets the value of the `L1` button
  104684. */
  104685. /**
  104686. * Sets the value of the `L1` button
  104687. */
  104688. buttonL1: number;
  104689. /**
  104690. * Gets the value of the `R1` button
  104691. */
  104692. /**
  104693. * Sets the value of the `R1` button
  104694. */
  104695. buttonR1: number;
  104696. /**
  104697. * Gets the value of the Left joystick
  104698. */
  104699. /**
  104700. * Sets the value of the Left joystick
  104701. */
  104702. buttonLeftStick: number;
  104703. /**
  104704. * Gets the value of the Right joystick
  104705. */
  104706. /**
  104707. * Sets the value of the Right joystick
  104708. */
  104709. buttonRightStick: number;
  104710. /**
  104711. * Gets the value of D-pad up
  104712. */
  104713. /**
  104714. * Sets the value of D-pad up
  104715. */
  104716. dPadUp: number;
  104717. /**
  104718. * Gets the value of D-pad down
  104719. */
  104720. /**
  104721. * Sets the value of D-pad down
  104722. */
  104723. dPadDown: number;
  104724. /**
  104725. * Gets the value of D-pad left
  104726. */
  104727. /**
  104728. * Sets the value of D-pad left
  104729. */
  104730. dPadLeft: number;
  104731. /**
  104732. * Gets the value of D-pad right
  104733. */
  104734. /**
  104735. * Sets the value of D-pad right
  104736. */
  104737. dPadRight: number;
  104738. /**
  104739. * Force the gamepad to synchronize with device values
  104740. */
  104741. update(): void;
  104742. /**
  104743. * Disposes the gamepad
  104744. */
  104745. dispose(): void;
  104746. }
  104747. }
  104748. declare module BABYLON {
  104749. /**
  104750. * Manager for handling gamepads
  104751. */
  104752. export class GamepadManager {
  104753. private _scene?;
  104754. private _babylonGamepads;
  104755. private _oneGamepadConnected;
  104756. /** @hidden */
  104757. _isMonitoring: boolean;
  104758. private _gamepadEventSupported;
  104759. private _gamepadSupport;
  104760. /**
  104761. * observable to be triggered when the gamepad controller has been connected
  104762. */
  104763. onGamepadConnectedObservable: Observable<Gamepad>;
  104764. /**
  104765. * observable to be triggered when the gamepad controller has been disconnected
  104766. */
  104767. onGamepadDisconnectedObservable: Observable<Gamepad>;
  104768. private _onGamepadConnectedEvent;
  104769. private _onGamepadDisconnectedEvent;
  104770. /**
  104771. * Initializes the gamepad manager
  104772. * @param _scene BabylonJS scene
  104773. */
  104774. constructor(_scene?: Scene | undefined);
  104775. /**
  104776. * The gamepads in the game pad manager
  104777. */
  104778. readonly gamepads: Gamepad[];
  104779. /**
  104780. * Get the gamepad controllers based on type
  104781. * @param type The type of gamepad controller
  104782. * @returns Nullable gamepad
  104783. */
  104784. getGamepadByType(type?: number): Nullable<Gamepad>;
  104785. /**
  104786. * Disposes the gamepad manager
  104787. */
  104788. dispose(): void;
  104789. private _addNewGamepad;
  104790. private _startMonitoringGamepads;
  104791. private _stopMonitoringGamepads;
  104792. /** @hidden */
  104793. _checkGamepadsStatus(): void;
  104794. private _updateGamepadObjects;
  104795. }
  104796. }
  104797. declare module BABYLON {
  104798. interface Scene {
  104799. /** @hidden */
  104800. _gamepadManager: Nullable<GamepadManager>;
  104801. /**
  104802. * Gets the gamepad manager associated with the scene
  104803. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  104804. */
  104805. gamepadManager: GamepadManager;
  104806. }
  104807. /**
  104808. * Interface representing a free camera inputs manager
  104809. */
  104810. interface FreeCameraInputsManager {
  104811. /**
  104812. * Adds gamepad input support to the FreeCameraInputsManager.
  104813. * @returns the FreeCameraInputsManager
  104814. */
  104815. addGamepad(): FreeCameraInputsManager;
  104816. }
  104817. /**
  104818. * Interface representing an arc rotate camera inputs manager
  104819. */
  104820. interface ArcRotateCameraInputsManager {
  104821. /**
  104822. * Adds gamepad input support to the ArcRotateCamera InputManager.
  104823. * @returns the camera inputs manager
  104824. */
  104825. addGamepad(): ArcRotateCameraInputsManager;
  104826. }
  104827. /**
  104828. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  104829. */
  104830. export class GamepadSystemSceneComponent implements ISceneComponent {
  104831. /**
  104832. * The component name helpfull to identify the component in the list of scene components.
  104833. */
  104834. readonly name: string;
  104835. /**
  104836. * The scene the component belongs to.
  104837. */
  104838. scene: Scene;
  104839. /**
  104840. * Creates a new instance of the component for the given scene
  104841. * @param scene Defines the scene to register the component in
  104842. */
  104843. constructor(scene: Scene);
  104844. /**
  104845. * Registers the component in a given scene
  104846. */
  104847. register(): void;
  104848. /**
  104849. * Rebuilds the elements related to this component in case of
  104850. * context lost for instance.
  104851. */
  104852. rebuild(): void;
  104853. /**
  104854. * Disposes the component and the associated ressources
  104855. */
  104856. dispose(): void;
  104857. private _beforeCameraUpdate;
  104858. }
  104859. }
  104860. declare module BABYLON {
  104861. /**
  104862. * 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,
  104863. * which still works and will still be found in many Playgrounds.
  104864. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  104865. */
  104866. export class UniversalCamera extends TouchCamera {
  104867. /**
  104868. * Defines the gamepad rotation sensiblity.
  104869. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  104870. */
  104871. gamepadAngularSensibility: number;
  104872. /**
  104873. * Defines the gamepad move sensiblity.
  104874. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  104875. */
  104876. gamepadMoveSensibility: number;
  104877. /**
  104878. * 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,
  104879. * which still works and will still be found in many Playgrounds.
  104880. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  104881. * @param name Define the name of the camera in the scene
  104882. * @param position Define the start position of the camera in the scene
  104883. * @param scene Define the scene the camera belongs to
  104884. */
  104885. constructor(name: string, position: Vector3, scene: Scene);
  104886. /**
  104887. * Gets the current object class name.
  104888. * @return the class name
  104889. */
  104890. getClassName(): string;
  104891. }
  104892. }
  104893. declare module BABYLON {
  104894. /**
  104895. * This represents a FPS type of camera. This is only here for back compat purpose.
  104896. * Please use the UniversalCamera instead as both are identical.
  104897. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  104898. */
  104899. export class GamepadCamera extends UniversalCamera {
  104900. /**
  104901. * Instantiates a new Gamepad Camera
  104902. * This represents a FPS type of camera. This is only here for back compat purpose.
  104903. * Please use the UniversalCamera instead as both are identical.
  104904. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  104905. * @param name Define the name of the camera in the scene
  104906. * @param position Define the start position of the camera in the scene
  104907. * @param scene Define the scene the camera belongs to
  104908. */
  104909. constructor(name: string, position: Vector3, scene: Scene);
  104910. /**
  104911. * Gets the current object class name.
  104912. * @return the class name
  104913. */
  104914. getClassName(): string;
  104915. }
  104916. }
  104917. declare module BABYLON {
  104918. /** @hidden */
  104919. export var passPixelShader: {
  104920. name: string;
  104921. shader: string;
  104922. };
  104923. }
  104924. declare module BABYLON {
  104925. /** @hidden */
  104926. export var passCubePixelShader: {
  104927. name: string;
  104928. shader: string;
  104929. };
  104930. }
  104931. declare module BABYLON {
  104932. /**
  104933. * PassPostProcess which produces an output the same as it's input
  104934. */
  104935. export class PassPostProcess extends PostProcess {
  104936. /**
  104937. * Creates the PassPostProcess
  104938. * @param name The name of the effect.
  104939. * @param options The required width/height ratio to downsize to before computing the render pass.
  104940. * @param camera The camera to apply the render pass to.
  104941. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  104942. * @param engine The engine which the post process will be applied. (default: current engine)
  104943. * @param reusable If the post process can be reused on the same frame. (default: false)
  104944. * @param textureType The type of texture to be used when performing the post processing.
  104945. * @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)
  104946. */
  104947. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  104948. }
  104949. /**
  104950. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  104951. */
  104952. export class PassCubePostProcess extends PostProcess {
  104953. private _face;
  104954. /**
  104955. * Gets or sets the cube face to display.
  104956. * * 0 is +X
  104957. * * 1 is -X
  104958. * * 2 is +Y
  104959. * * 3 is -Y
  104960. * * 4 is +Z
  104961. * * 5 is -Z
  104962. */
  104963. face: number;
  104964. /**
  104965. * Creates the PassCubePostProcess
  104966. * @param name The name of the effect.
  104967. * @param options The required width/height ratio to downsize to before computing the render pass.
  104968. * @param camera The camera to apply the render pass to.
  104969. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  104970. * @param engine The engine which the post process will be applied. (default: current engine)
  104971. * @param reusable If the post process can be reused on the same frame. (default: false)
  104972. * @param textureType The type of texture to be used when performing the post processing.
  104973. * @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)
  104974. */
  104975. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  104976. }
  104977. }
  104978. declare module BABYLON {
  104979. /** @hidden */
  104980. export var anaglyphPixelShader: {
  104981. name: string;
  104982. shader: string;
  104983. };
  104984. }
  104985. declare module BABYLON {
  104986. /**
  104987. * Postprocess used to generate anaglyphic rendering
  104988. */
  104989. export class AnaglyphPostProcess extends PostProcess {
  104990. private _passedProcess;
  104991. /**
  104992. * Creates a new AnaglyphPostProcess
  104993. * @param name defines postprocess name
  104994. * @param options defines creation options or target ratio scale
  104995. * @param rigCameras defines cameras using this postprocess
  104996. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  104997. * @param engine defines hosting engine
  104998. * @param reusable defines if the postprocess will be reused multiple times per frame
  104999. */
  105000. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  105001. }
  105002. }
  105003. declare module BABYLON {
  105004. /**
  105005. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  105006. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  105007. */
  105008. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  105009. /**
  105010. * Creates a new AnaglyphArcRotateCamera
  105011. * @param name defines camera name
  105012. * @param alpha defines alpha angle (in radians)
  105013. * @param beta defines beta angle (in radians)
  105014. * @param radius defines radius
  105015. * @param target defines camera target
  105016. * @param interaxialDistance defines distance between each color axis
  105017. * @param scene defines the hosting scene
  105018. */
  105019. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  105020. /**
  105021. * Gets camera class name
  105022. * @returns AnaglyphArcRotateCamera
  105023. */
  105024. getClassName(): string;
  105025. }
  105026. }
  105027. declare module BABYLON {
  105028. /**
  105029. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  105030. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  105031. */
  105032. export class AnaglyphFreeCamera extends FreeCamera {
  105033. /**
  105034. * Creates a new AnaglyphFreeCamera
  105035. * @param name defines camera name
  105036. * @param position defines initial position
  105037. * @param interaxialDistance defines distance between each color axis
  105038. * @param scene defines the hosting scene
  105039. */
  105040. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  105041. /**
  105042. * Gets camera class name
  105043. * @returns AnaglyphFreeCamera
  105044. */
  105045. getClassName(): string;
  105046. }
  105047. }
  105048. declare module BABYLON {
  105049. /**
  105050. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  105051. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  105052. */
  105053. export class AnaglyphGamepadCamera extends GamepadCamera {
  105054. /**
  105055. * Creates a new AnaglyphGamepadCamera
  105056. * @param name defines camera name
  105057. * @param position defines initial position
  105058. * @param interaxialDistance defines distance between each color axis
  105059. * @param scene defines the hosting scene
  105060. */
  105061. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  105062. /**
  105063. * Gets camera class name
  105064. * @returns AnaglyphGamepadCamera
  105065. */
  105066. getClassName(): string;
  105067. }
  105068. }
  105069. declare module BABYLON {
  105070. /**
  105071. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  105072. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  105073. */
  105074. export class AnaglyphUniversalCamera extends UniversalCamera {
  105075. /**
  105076. * Creates a new AnaglyphUniversalCamera
  105077. * @param name defines camera name
  105078. * @param position defines initial position
  105079. * @param interaxialDistance defines distance between each color axis
  105080. * @param scene defines the hosting scene
  105081. */
  105082. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  105083. /**
  105084. * Gets camera class name
  105085. * @returns AnaglyphUniversalCamera
  105086. */
  105087. getClassName(): string;
  105088. }
  105089. }
  105090. declare module BABYLON {
  105091. /** @hidden */
  105092. export var stereoscopicInterlacePixelShader: {
  105093. name: string;
  105094. shader: string;
  105095. };
  105096. }
  105097. declare module BABYLON {
  105098. /**
  105099. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  105100. */
  105101. export class StereoscopicInterlacePostProcess extends PostProcess {
  105102. private _stepSize;
  105103. private _passedProcess;
  105104. /**
  105105. * Initializes a StereoscopicInterlacePostProcess
  105106. * @param name The name of the effect.
  105107. * @param rigCameras The rig cameras to be appled to the post process
  105108. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  105109. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  105110. * @param engine The engine which the post process will be applied. (default: current engine)
  105111. * @param reusable If the post process can be reused on the same frame. (default: false)
  105112. */
  105113. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  105114. }
  105115. }
  105116. declare module BABYLON {
  105117. /**
  105118. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  105119. * @see http://doc.babylonjs.com/features/cameras
  105120. */
  105121. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  105122. /**
  105123. * Creates a new StereoscopicArcRotateCamera
  105124. * @param name defines camera name
  105125. * @param alpha defines alpha angle (in radians)
  105126. * @param beta defines beta angle (in radians)
  105127. * @param radius defines radius
  105128. * @param target defines camera target
  105129. * @param interaxialDistance defines distance between each color axis
  105130. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  105131. * @param scene defines the hosting scene
  105132. */
  105133. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  105134. /**
  105135. * Gets camera class name
  105136. * @returns StereoscopicArcRotateCamera
  105137. */
  105138. getClassName(): string;
  105139. }
  105140. }
  105141. declare module BABYLON {
  105142. /**
  105143. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  105144. * @see http://doc.babylonjs.com/features/cameras
  105145. */
  105146. export class StereoscopicFreeCamera extends FreeCamera {
  105147. /**
  105148. * Creates a new StereoscopicFreeCamera
  105149. * @param name defines camera name
  105150. * @param position defines initial position
  105151. * @param interaxialDistance defines distance between each color axis
  105152. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  105153. * @param scene defines the hosting scene
  105154. */
  105155. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  105156. /**
  105157. * Gets camera class name
  105158. * @returns StereoscopicFreeCamera
  105159. */
  105160. getClassName(): string;
  105161. }
  105162. }
  105163. declare module BABYLON {
  105164. /**
  105165. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  105166. * @see http://doc.babylonjs.com/features/cameras
  105167. */
  105168. export class StereoscopicGamepadCamera extends GamepadCamera {
  105169. /**
  105170. * Creates a new StereoscopicGamepadCamera
  105171. * @param name defines camera name
  105172. * @param position defines initial position
  105173. * @param interaxialDistance defines distance between each color axis
  105174. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  105175. * @param scene defines the hosting scene
  105176. */
  105177. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  105178. /**
  105179. * Gets camera class name
  105180. * @returns StereoscopicGamepadCamera
  105181. */
  105182. getClassName(): string;
  105183. }
  105184. }
  105185. declare module BABYLON {
  105186. /**
  105187. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  105188. * @see http://doc.babylonjs.com/features/cameras
  105189. */
  105190. export class StereoscopicUniversalCamera extends UniversalCamera {
  105191. /**
  105192. * Creates a new StereoscopicUniversalCamera
  105193. * @param name defines camera name
  105194. * @param position defines initial position
  105195. * @param interaxialDistance defines distance between each color axis
  105196. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  105197. * @param scene defines the hosting scene
  105198. */
  105199. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  105200. /**
  105201. * Gets camera class name
  105202. * @returns StereoscopicUniversalCamera
  105203. */
  105204. getClassName(): string;
  105205. }
  105206. }
  105207. declare module BABYLON {
  105208. /**
  105209. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  105210. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  105211. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  105212. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  105213. */
  105214. export class VirtualJoysticksCamera extends FreeCamera {
  105215. /**
  105216. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  105217. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  105218. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  105219. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  105220. * @param name Define the name of the camera in the scene
  105221. * @param position Define the start position of the camera in the scene
  105222. * @param scene Define the scene the camera belongs to
  105223. */
  105224. constructor(name: string, position: Vector3, scene: Scene);
  105225. /**
  105226. * Gets the current object class name.
  105227. * @return the class name
  105228. */
  105229. getClassName(): string;
  105230. }
  105231. }
  105232. declare module BABYLON {
  105233. /**
  105234. * This represents all the required metrics to create a VR camera.
  105235. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  105236. */
  105237. export class VRCameraMetrics {
  105238. /**
  105239. * Define the horizontal resolution off the screen.
  105240. */
  105241. hResolution: number;
  105242. /**
  105243. * Define the vertical resolution off the screen.
  105244. */
  105245. vResolution: number;
  105246. /**
  105247. * Define the horizontal screen size.
  105248. */
  105249. hScreenSize: number;
  105250. /**
  105251. * Define the vertical screen size.
  105252. */
  105253. vScreenSize: number;
  105254. /**
  105255. * Define the vertical screen center position.
  105256. */
  105257. vScreenCenter: number;
  105258. /**
  105259. * Define the distance of the eyes to the screen.
  105260. */
  105261. eyeToScreenDistance: number;
  105262. /**
  105263. * Define the distance between both lenses
  105264. */
  105265. lensSeparationDistance: number;
  105266. /**
  105267. * Define the distance between both viewer's eyes.
  105268. */
  105269. interpupillaryDistance: number;
  105270. /**
  105271. * Define the distortion factor of the VR postprocess.
  105272. * Please, touch with care.
  105273. */
  105274. distortionK: number[];
  105275. /**
  105276. * Define the chromatic aberration correction factors for the VR post process.
  105277. */
  105278. chromaAbCorrection: number[];
  105279. /**
  105280. * Define the scale factor of the post process.
  105281. * The smaller the better but the slower.
  105282. */
  105283. postProcessScaleFactor: number;
  105284. /**
  105285. * Define an offset for the lens center.
  105286. */
  105287. lensCenterOffset: number;
  105288. /**
  105289. * Define if the current vr camera should compensate the distortion of the lense or not.
  105290. */
  105291. compensateDistortion: boolean;
  105292. /**
  105293. * Defines if multiview should be enabled when rendering (Default: false)
  105294. */
  105295. multiviewEnabled: boolean;
  105296. /**
  105297. * Gets the rendering aspect ratio based on the provided resolutions.
  105298. */
  105299. readonly aspectRatio: number;
  105300. /**
  105301. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  105302. */
  105303. readonly aspectRatioFov: number;
  105304. /**
  105305. * @hidden
  105306. */
  105307. readonly leftHMatrix: Matrix;
  105308. /**
  105309. * @hidden
  105310. */
  105311. readonly rightHMatrix: Matrix;
  105312. /**
  105313. * @hidden
  105314. */
  105315. readonly leftPreViewMatrix: Matrix;
  105316. /**
  105317. * @hidden
  105318. */
  105319. readonly rightPreViewMatrix: Matrix;
  105320. /**
  105321. * Get the default VRMetrics based on the most generic setup.
  105322. * @returns the default vr metrics
  105323. */
  105324. static GetDefault(): VRCameraMetrics;
  105325. }
  105326. }
  105327. declare module BABYLON {
  105328. /** @hidden */
  105329. export var vrDistortionCorrectionPixelShader: {
  105330. name: string;
  105331. shader: string;
  105332. };
  105333. }
  105334. declare module BABYLON {
  105335. /**
  105336. * VRDistortionCorrectionPostProcess used for mobile VR
  105337. */
  105338. export class VRDistortionCorrectionPostProcess extends PostProcess {
  105339. private _isRightEye;
  105340. private _distortionFactors;
  105341. private _postProcessScaleFactor;
  105342. private _lensCenterOffset;
  105343. private _scaleIn;
  105344. private _scaleFactor;
  105345. private _lensCenter;
  105346. /**
  105347. * Initializes the VRDistortionCorrectionPostProcess
  105348. * @param name The name of the effect.
  105349. * @param camera The camera to apply the render pass to.
  105350. * @param isRightEye If this is for the right eye distortion
  105351. * @param vrMetrics All the required metrics for the VR camera
  105352. */
  105353. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  105354. }
  105355. }
  105356. declare module BABYLON {
  105357. /**
  105358. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  105359. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  105360. */
  105361. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  105362. /**
  105363. * Creates a new VRDeviceOrientationArcRotateCamera
  105364. * @param name defines camera name
  105365. * @param alpha defines the camera rotation along the logitudinal axis
  105366. * @param beta defines the camera rotation along the latitudinal axis
  105367. * @param radius defines the camera distance from its target
  105368. * @param target defines the camera target
  105369. * @param scene defines the scene the camera belongs to
  105370. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  105371. * @param vrCameraMetrics defines the vr metrics associated to the camera
  105372. */
  105373. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  105374. /**
  105375. * Gets camera class name
  105376. * @returns VRDeviceOrientationArcRotateCamera
  105377. */
  105378. getClassName(): string;
  105379. }
  105380. }
  105381. declare module BABYLON {
  105382. /**
  105383. * Camera used to simulate VR rendering (based on FreeCamera)
  105384. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  105385. */
  105386. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  105387. /**
  105388. * Creates a new VRDeviceOrientationFreeCamera
  105389. * @param name defines camera name
  105390. * @param position defines the start position of the camera
  105391. * @param scene defines the scene the camera belongs to
  105392. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  105393. * @param vrCameraMetrics defines the vr metrics associated to the camera
  105394. */
  105395. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  105396. /**
  105397. * Gets camera class name
  105398. * @returns VRDeviceOrientationFreeCamera
  105399. */
  105400. getClassName(): string;
  105401. }
  105402. }
  105403. declare module BABYLON {
  105404. /**
  105405. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  105406. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  105407. */
  105408. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  105409. /**
  105410. * Creates a new VRDeviceOrientationGamepadCamera
  105411. * @param name defines camera name
  105412. * @param position defines the start position of the camera
  105413. * @param scene defines the scene the camera belongs to
  105414. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  105415. * @param vrCameraMetrics defines the vr metrics associated to the camera
  105416. */
  105417. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  105418. /**
  105419. * Gets camera class name
  105420. * @returns VRDeviceOrientationGamepadCamera
  105421. */
  105422. getClassName(): string;
  105423. }
  105424. }
  105425. declare module BABYLON {
  105426. /**
  105427. * Base class of materials working in push mode in babylon JS
  105428. * @hidden
  105429. */
  105430. export class PushMaterial extends Material {
  105431. protected _activeEffect: Effect;
  105432. protected _normalMatrix: Matrix;
  105433. /**
  105434. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  105435. * This means that the material can keep using a previous shader while a new one is being compiled.
  105436. * This is mostly used when shader parallel compilation is supported (true by default)
  105437. */
  105438. allowShaderHotSwapping: boolean;
  105439. constructor(name: string, scene: Scene);
  105440. getEffect(): Effect;
  105441. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  105442. /**
  105443. * Binds the given world matrix to the active effect
  105444. *
  105445. * @param world the matrix to bind
  105446. */
  105447. bindOnlyWorldMatrix(world: Matrix): void;
  105448. /**
  105449. * Binds the given normal matrix to the active effect
  105450. *
  105451. * @param normalMatrix the matrix to bind
  105452. */
  105453. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  105454. bind(world: Matrix, mesh?: Mesh): void;
  105455. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  105456. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  105457. }
  105458. }
  105459. declare module BABYLON {
  105460. /**
  105461. * This groups all the flags used to control the materials channel.
  105462. */
  105463. export class MaterialFlags {
  105464. private static _DiffuseTextureEnabled;
  105465. /**
  105466. * Are diffuse textures enabled in the application.
  105467. */
  105468. static DiffuseTextureEnabled: boolean;
  105469. private static _AmbientTextureEnabled;
  105470. /**
  105471. * Are ambient textures enabled in the application.
  105472. */
  105473. static AmbientTextureEnabled: boolean;
  105474. private static _OpacityTextureEnabled;
  105475. /**
  105476. * Are opacity textures enabled in the application.
  105477. */
  105478. static OpacityTextureEnabled: boolean;
  105479. private static _ReflectionTextureEnabled;
  105480. /**
  105481. * Are reflection textures enabled in the application.
  105482. */
  105483. static ReflectionTextureEnabled: boolean;
  105484. private static _EmissiveTextureEnabled;
  105485. /**
  105486. * Are emissive textures enabled in the application.
  105487. */
  105488. static EmissiveTextureEnabled: boolean;
  105489. private static _SpecularTextureEnabled;
  105490. /**
  105491. * Are specular textures enabled in the application.
  105492. */
  105493. static SpecularTextureEnabled: boolean;
  105494. private static _BumpTextureEnabled;
  105495. /**
  105496. * Are bump textures enabled in the application.
  105497. */
  105498. static BumpTextureEnabled: boolean;
  105499. private static _LightmapTextureEnabled;
  105500. /**
  105501. * Are lightmap textures enabled in the application.
  105502. */
  105503. static LightmapTextureEnabled: boolean;
  105504. private static _RefractionTextureEnabled;
  105505. /**
  105506. * Are refraction textures enabled in the application.
  105507. */
  105508. static RefractionTextureEnabled: boolean;
  105509. private static _ColorGradingTextureEnabled;
  105510. /**
  105511. * Are color grading textures enabled in the application.
  105512. */
  105513. static ColorGradingTextureEnabled: boolean;
  105514. private static _FresnelEnabled;
  105515. /**
  105516. * Are fresnels enabled in the application.
  105517. */
  105518. static FresnelEnabled: boolean;
  105519. private static _ClearCoatTextureEnabled;
  105520. /**
  105521. * Are clear coat textures enabled in the application.
  105522. */
  105523. static ClearCoatTextureEnabled: boolean;
  105524. private static _ClearCoatBumpTextureEnabled;
  105525. /**
  105526. * Are clear coat bump textures enabled in the application.
  105527. */
  105528. static ClearCoatBumpTextureEnabled: boolean;
  105529. private static _ClearCoatTintTextureEnabled;
  105530. /**
  105531. * Are clear coat tint textures enabled in the application.
  105532. */
  105533. static ClearCoatTintTextureEnabled: boolean;
  105534. private static _SheenTextureEnabled;
  105535. /**
  105536. * Are sheen textures enabled in the application.
  105537. */
  105538. static SheenTextureEnabled: boolean;
  105539. private static _AnisotropicTextureEnabled;
  105540. /**
  105541. * Are anisotropic textures enabled in the application.
  105542. */
  105543. static AnisotropicTextureEnabled: boolean;
  105544. private static _ThicknessTextureEnabled;
  105545. /**
  105546. * Are thickness textures enabled in the application.
  105547. */
  105548. static ThicknessTextureEnabled: boolean;
  105549. }
  105550. }
  105551. declare module BABYLON {
  105552. /** @hidden */
  105553. export var defaultFragmentDeclaration: {
  105554. name: string;
  105555. shader: string;
  105556. };
  105557. }
  105558. declare module BABYLON {
  105559. /** @hidden */
  105560. export var defaultUboDeclaration: {
  105561. name: string;
  105562. shader: string;
  105563. };
  105564. }
  105565. declare module BABYLON {
  105566. /** @hidden */
  105567. export var lightFragmentDeclaration: {
  105568. name: string;
  105569. shader: string;
  105570. };
  105571. }
  105572. declare module BABYLON {
  105573. /** @hidden */
  105574. export var lightUboDeclaration: {
  105575. name: string;
  105576. shader: string;
  105577. };
  105578. }
  105579. declare module BABYLON {
  105580. /** @hidden */
  105581. export var lightsFragmentFunctions: {
  105582. name: string;
  105583. shader: string;
  105584. };
  105585. }
  105586. declare module BABYLON {
  105587. /** @hidden */
  105588. export var shadowsFragmentFunctions: {
  105589. name: string;
  105590. shader: string;
  105591. };
  105592. }
  105593. declare module BABYLON {
  105594. /** @hidden */
  105595. export var fresnelFunction: {
  105596. name: string;
  105597. shader: string;
  105598. };
  105599. }
  105600. declare module BABYLON {
  105601. /** @hidden */
  105602. export var reflectionFunction: {
  105603. name: string;
  105604. shader: string;
  105605. };
  105606. }
  105607. declare module BABYLON {
  105608. /** @hidden */
  105609. export var bumpFragmentFunctions: {
  105610. name: string;
  105611. shader: string;
  105612. };
  105613. }
  105614. declare module BABYLON {
  105615. /** @hidden */
  105616. export var logDepthDeclaration: {
  105617. name: string;
  105618. shader: string;
  105619. };
  105620. }
  105621. declare module BABYLON {
  105622. /** @hidden */
  105623. export var bumpFragment: {
  105624. name: string;
  105625. shader: string;
  105626. };
  105627. }
  105628. declare module BABYLON {
  105629. /** @hidden */
  105630. export var depthPrePass: {
  105631. name: string;
  105632. shader: string;
  105633. };
  105634. }
  105635. declare module BABYLON {
  105636. /** @hidden */
  105637. export var lightFragment: {
  105638. name: string;
  105639. shader: string;
  105640. };
  105641. }
  105642. declare module BABYLON {
  105643. /** @hidden */
  105644. export var logDepthFragment: {
  105645. name: string;
  105646. shader: string;
  105647. };
  105648. }
  105649. declare module BABYLON {
  105650. /** @hidden */
  105651. export var defaultPixelShader: {
  105652. name: string;
  105653. shader: string;
  105654. };
  105655. }
  105656. declare module BABYLON {
  105657. /** @hidden */
  105658. export var defaultVertexDeclaration: {
  105659. name: string;
  105660. shader: string;
  105661. };
  105662. }
  105663. declare module BABYLON {
  105664. /** @hidden */
  105665. export var bumpVertexDeclaration: {
  105666. name: string;
  105667. shader: string;
  105668. };
  105669. }
  105670. declare module BABYLON {
  105671. /** @hidden */
  105672. export var bumpVertex: {
  105673. name: string;
  105674. shader: string;
  105675. };
  105676. }
  105677. declare module BABYLON {
  105678. /** @hidden */
  105679. export var fogVertex: {
  105680. name: string;
  105681. shader: string;
  105682. };
  105683. }
  105684. declare module BABYLON {
  105685. /** @hidden */
  105686. export var shadowsVertex: {
  105687. name: string;
  105688. shader: string;
  105689. };
  105690. }
  105691. declare module BABYLON {
  105692. /** @hidden */
  105693. export var pointCloudVertex: {
  105694. name: string;
  105695. shader: string;
  105696. };
  105697. }
  105698. declare module BABYLON {
  105699. /** @hidden */
  105700. export var logDepthVertex: {
  105701. name: string;
  105702. shader: string;
  105703. };
  105704. }
  105705. declare module BABYLON {
  105706. /** @hidden */
  105707. export var defaultVertexShader: {
  105708. name: string;
  105709. shader: string;
  105710. };
  105711. }
  105712. declare module BABYLON {
  105713. /** @hidden */
  105714. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  105715. MAINUV1: boolean;
  105716. MAINUV2: boolean;
  105717. DIFFUSE: boolean;
  105718. DIFFUSEDIRECTUV: number;
  105719. AMBIENT: boolean;
  105720. AMBIENTDIRECTUV: number;
  105721. OPACITY: boolean;
  105722. OPACITYDIRECTUV: number;
  105723. OPACITYRGB: boolean;
  105724. REFLECTION: boolean;
  105725. EMISSIVE: boolean;
  105726. EMISSIVEDIRECTUV: number;
  105727. SPECULAR: boolean;
  105728. SPECULARDIRECTUV: number;
  105729. BUMP: boolean;
  105730. BUMPDIRECTUV: number;
  105731. PARALLAX: boolean;
  105732. PARALLAXOCCLUSION: boolean;
  105733. SPECULAROVERALPHA: boolean;
  105734. CLIPPLANE: boolean;
  105735. CLIPPLANE2: boolean;
  105736. CLIPPLANE3: boolean;
  105737. CLIPPLANE4: boolean;
  105738. ALPHATEST: boolean;
  105739. DEPTHPREPASS: boolean;
  105740. ALPHAFROMDIFFUSE: boolean;
  105741. POINTSIZE: boolean;
  105742. FOG: boolean;
  105743. SPECULARTERM: boolean;
  105744. DIFFUSEFRESNEL: boolean;
  105745. OPACITYFRESNEL: boolean;
  105746. REFLECTIONFRESNEL: boolean;
  105747. REFRACTIONFRESNEL: boolean;
  105748. EMISSIVEFRESNEL: boolean;
  105749. FRESNEL: boolean;
  105750. NORMAL: boolean;
  105751. UV1: boolean;
  105752. UV2: boolean;
  105753. VERTEXCOLOR: boolean;
  105754. VERTEXALPHA: boolean;
  105755. NUM_BONE_INFLUENCERS: number;
  105756. BonesPerMesh: number;
  105757. BONETEXTURE: boolean;
  105758. INSTANCES: boolean;
  105759. GLOSSINESS: boolean;
  105760. ROUGHNESS: boolean;
  105761. EMISSIVEASILLUMINATION: boolean;
  105762. LINKEMISSIVEWITHDIFFUSE: boolean;
  105763. REFLECTIONFRESNELFROMSPECULAR: boolean;
  105764. LIGHTMAP: boolean;
  105765. LIGHTMAPDIRECTUV: number;
  105766. OBJECTSPACE_NORMALMAP: boolean;
  105767. USELIGHTMAPASSHADOWMAP: boolean;
  105768. REFLECTIONMAP_3D: boolean;
  105769. REFLECTIONMAP_SPHERICAL: boolean;
  105770. REFLECTIONMAP_PLANAR: boolean;
  105771. REFLECTIONMAP_CUBIC: boolean;
  105772. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  105773. REFLECTIONMAP_PROJECTION: boolean;
  105774. REFLECTIONMAP_SKYBOX: boolean;
  105775. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  105776. REFLECTIONMAP_EXPLICIT: boolean;
  105777. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  105778. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  105779. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  105780. INVERTCUBICMAP: boolean;
  105781. LOGARITHMICDEPTH: boolean;
  105782. REFRACTION: boolean;
  105783. REFRACTIONMAP_3D: boolean;
  105784. REFLECTIONOVERALPHA: boolean;
  105785. TWOSIDEDLIGHTING: boolean;
  105786. SHADOWFLOAT: boolean;
  105787. MORPHTARGETS: boolean;
  105788. MORPHTARGETS_NORMAL: boolean;
  105789. MORPHTARGETS_TANGENT: boolean;
  105790. MORPHTARGETS_UV: boolean;
  105791. NUM_MORPH_INFLUENCERS: number;
  105792. NONUNIFORMSCALING: boolean;
  105793. PREMULTIPLYALPHA: boolean;
  105794. IMAGEPROCESSING: boolean;
  105795. VIGNETTE: boolean;
  105796. VIGNETTEBLENDMODEMULTIPLY: boolean;
  105797. VIGNETTEBLENDMODEOPAQUE: boolean;
  105798. TONEMAPPING: boolean;
  105799. TONEMAPPING_ACES: boolean;
  105800. CONTRAST: boolean;
  105801. COLORCURVES: boolean;
  105802. COLORGRADING: boolean;
  105803. COLORGRADING3D: boolean;
  105804. SAMPLER3DGREENDEPTH: boolean;
  105805. SAMPLER3DBGRMAP: boolean;
  105806. IMAGEPROCESSINGPOSTPROCESS: boolean;
  105807. MULTIVIEW: boolean;
  105808. /**
  105809. * If the reflection texture on this material is in linear color space
  105810. * @hidden
  105811. */
  105812. IS_REFLECTION_LINEAR: boolean;
  105813. /**
  105814. * If the refraction texture on this material is in linear color space
  105815. * @hidden
  105816. */
  105817. IS_REFRACTION_LINEAR: boolean;
  105818. EXPOSURE: boolean;
  105819. constructor();
  105820. setReflectionMode(modeToEnable: string): void;
  105821. }
  105822. /**
  105823. * This is the default material used in Babylon. It is the best trade off between quality
  105824. * and performances.
  105825. * @see http://doc.babylonjs.com/babylon101/materials
  105826. */
  105827. export class StandardMaterial extends PushMaterial {
  105828. private _diffuseTexture;
  105829. /**
  105830. * The basic texture of the material as viewed under a light.
  105831. */
  105832. diffuseTexture: Nullable<BaseTexture>;
  105833. private _ambientTexture;
  105834. /**
  105835. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  105836. */
  105837. ambientTexture: Nullable<BaseTexture>;
  105838. private _opacityTexture;
  105839. /**
  105840. * Define the transparency of the material from a texture.
  105841. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  105842. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  105843. */
  105844. opacityTexture: Nullable<BaseTexture>;
  105845. private _reflectionTexture;
  105846. /**
  105847. * Define the texture used to display the reflection.
  105848. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  105849. */
  105850. reflectionTexture: Nullable<BaseTexture>;
  105851. private _emissiveTexture;
  105852. /**
  105853. * Define texture of the material as if self lit.
  105854. * This will be mixed in the final result even in the absence of light.
  105855. */
  105856. emissiveTexture: Nullable<BaseTexture>;
  105857. private _specularTexture;
  105858. /**
  105859. * Define how the color and intensity of the highlight given by the light in the material.
  105860. */
  105861. specularTexture: Nullable<BaseTexture>;
  105862. private _bumpTexture;
  105863. /**
  105864. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  105865. * 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.
  105866. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  105867. */
  105868. bumpTexture: Nullable<BaseTexture>;
  105869. private _lightmapTexture;
  105870. /**
  105871. * Complex lighting can be computationally expensive to compute at runtime.
  105872. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  105873. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  105874. */
  105875. lightmapTexture: Nullable<BaseTexture>;
  105876. private _refractionTexture;
  105877. /**
  105878. * Define the texture used to display the refraction.
  105879. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  105880. */
  105881. refractionTexture: Nullable<BaseTexture>;
  105882. /**
  105883. * The color of the material lit by the environmental background lighting.
  105884. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  105885. */
  105886. ambientColor: Color3;
  105887. /**
  105888. * The basic color of the material as viewed under a light.
  105889. */
  105890. diffuseColor: Color3;
  105891. /**
  105892. * Define how the color and intensity of the highlight given by the light in the material.
  105893. */
  105894. specularColor: Color3;
  105895. /**
  105896. * Define the color of the material as if self lit.
  105897. * This will be mixed in the final result even in the absence of light.
  105898. */
  105899. emissiveColor: Color3;
  105900. /**
  105901. * Defines how sharp are the highlights in the material.
  105902. * The bigger the value the sharper giving a more glossy feeling to the result.
  105903. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  105904. */
  105905. specularPower: number;
  105906. private _useAlphaFromDiffuseTexture;
  105907. /**
  105908. * Does the transparency come from the diffuse texture alpha channel.
  105909. */
  105910. useAlphaFromDiffuseTexture: boolean;
  105911. private _useEmissiveAsIllumination;
  105912. /**
  105913. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  105914. */
  105915. useEmissiveAsIllumination: boolean;
  105916. private _linkEmissiveWithDiffuse;
  105917. /**
  105918. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  105919. * the emissive level when the final color is close to one.
  105920. */
  105921. linkEmissiveWithDiffuse: boolean;
  105922. private _useSpecularOverAlpha;
  105923. /**
  105924. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  105925. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  105926. */
  105927. useSpecularOverAlpha: boolean;
  105928. private _useReflectionOverAlpha;
  105929. /**
  105930. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  105931. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  105932. */
  105933. useReflectionOverAlpha: boolean;
  105934. private _disableLighting;
  105935. /**
  105936. * Does lights from the scene impacts this material.
  105937. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  105938. */
  105939. disableLighting: boolean;
  105940. private _useObjectSpaceNormalMap;
  105941. /**
  105942. * Allows using an object space normal map (instead of tangent space).
  105943. */
  105944. useObjectSpaceNormalMap: boolean;
  105945. private _useParallax;
  105946. /**
  105947. * Is parallax enabled or not.
  105948. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  105949. */
  105950. useParallax: boolean;
  105951. private _useParallaxOcclusion;
  105952. /**
  105953. * Is parallax occlusion enabled or not.
  105954. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  105955. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  105956. */
  105957. useParallaxOcclusion: boolean;
  105958. /**
  105959. * 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.
  105960. */
  105961. parallaxScaleBias: number;
  105962. private _roughness;
  105963. /**
  105964. * Helps to define how blurry the reflections should appears in the material.
  105965. */
  105966. roughness: number;
  105967. /**
  105968. * In case of refraction, define the value of the index of refraction.
  105969. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  105970. */
  105971. indexOfRefraction: number;
  105972. /**
  105973. * Invert the refraction texture alongside the y axis.
  105974. * It can be useful with procedural textures or probe for instance.
  105975. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  105976. */
  105977. invertRefractionY: boolean;
  105978. /**
  105979. * Defines the alpha limits in alpha test mode.
  105980. */
  105981. alphaCutOff: number;
  105982. private _useLightmapAsShadowmap;
  105983. /**
  105984. * In case of light mapping, define whether the map contains light or shadow informations.
  105985. */
  105986. useLightmapAsShadowmap: boolean;
  105987. private _diffuseFresnelParameters;
  105988. /**
  105989. * Define the diffuse fresnel parameters of the material.
  105990. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105991. */
  105992. diffuseFresnelParameters: FresnelParameters;
  105993. private _opacityFresnelParameters;
  105994. /**
  105995. * Define the opacity fresnel parameters of the material.
  105996. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105997. */
  105998. opacityFresnelParameters: FresnelParameters;
  105999. private _reflectionFresnelParameters;
  106000. /**
  106001. * Define the reflection fresnel parameters of the material.
  106002. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106003. */
  106004. reflectionFresnelParameters: FresnelParameters;
  106005. private _refractionFresnelParameters;
  106006. /**
  106007. * Define the refraction fresnel parameters of the material.
  106008. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106009. */
  106010. refractionFresnelParameters: FresnelParameters;
  106011. private _emissiveFresnelParameters;
  106012. /**
  106013. * Define the emissive fresnel parameters of the material.
  106014. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106015. */
  106016. emissiveFresnelParameters: FresnelParameters;
  106017. private _useReflectionFresnelFromSpecular;
  106018. /**
  106019. * If true automatically deducts the fresnels values from the material specularity.
  106020. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106021. */
  106022. useReflectionFresnelFromSpecular: boolean;
  106023. private _useGlossinessFromSpecularMapAlpha;
  106024. /**
  106025. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  106026. */
  106027. useGlossinessFromSpecularMapAlpha: boolean;
  106028. private _maxSimultaneousLights;
  106029. /**
  106030. * Defines the maximum number of lights that can be used in the material
  106031. */
  106032. maxSimultaneousLights: number;
  106033. private _invertNormalMapX;
  106034. /**
  106035. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  106036. */
  106037. invertNormalMapX: boolean;
  106038. private _invertNormalMapY;
  106039. /**
  106040. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  106041. */
  106042. invertNormalMapY: boolean;
  106043. private _twoSidedLighting;
  106044. /**
  106045. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  106046. */
  106047. twoSidedLighting: boolean;
  106048. /**
  106049. * Default configuration related to image processing available in the standard Material.
  106050. */
  106051. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  106052. /**
  106053. * Gets the image processing configuration used either in this material.
  106054. */
  106055. /**
  106056. * Sets the Default image processing configuration used either in the this material.
  106057. *
  106058. * If sets to null, the scene one is in use.
  106059. */
  106060. imageProcessingConfiguration: ImageProcessingConfiguration;
  106061. /**
  106062. * Keep track of the image processing observer to allow dispose and replace.
  106063. */
  106064. private _imageProcessingObserver;
  106065. /**
  106066. * Attaches a new image processing configuration to the Standard Material.
  106067. * @param configuration
  106068. */
  106069. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  106070. /**
  106071. * Gets wether the color curves effect is enabled.
  106072. */
  106073. /**
  106074. * Sets wether the color curves effect is enabled.
  106075. */
  106076. cameraColorCurvesEnabled: boolean;
  106077. /**
  106078. * Gets wether the color grading effect is enabled.
  106079. */
  106080. /**
  106081. * Gets wether the color grading effect is enabled.
  106082. */
  106083. cameraColorGradingEnabled: boolean;
  106084. /**
  106085. * Gets wether tonemapping is enabled or not.
  106086. */
  106087. /**
  106088. * Sets wether tonemapping is enabled or not
  106089. */
  106090. cameraToneMappingEnabled: boolean;
  106091. /**
  106092. * The camera exposure used on this material.
  106093. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  106094. * This corresponds to a photographic exposure.
  106095. */
  106096. /**
  106097. * The camera exposure used on this material.
  106098. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  106099. * This corresponds to a photographic exposure.
  106100. */
  106101. cameraExposure: number;
  106102. /**
  106103. * Gets The camera contrast used on this material.
  106104. */
  106105. /**
  106106. * Sets The camera contrast used on this material.
  106107. */
  106108. cameraContrast: number;
  106109. /**
  106110. * Gets the Color Grading 2D Lookup Texture.
  106111. */
  106112. /**
  106113. * Sets the Color Grading 2D Lookup Texture.
  106114. */
  106115. cameraColorGradingTexture: Nullable<BaseTexture>;
  106116. /**
  106117. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  106118. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  106119. * 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;
  106120. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  106121. */
  106122. /**
  106123. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  106124. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  106125. * 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;
  106126. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  106127. */
  106128. cameraColorCurves: Nullable<ColorCurves>;
  106129. /**
  106130. * Custom callback helping to override the default shader used in the material.
  106131. */
  106132. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  106133. protected _renderTargets: SmartArray<RenderTargetTexture>;
  106134. protected _worldViewProjectionMatrix: Matrix;
  106135. protected _globalAmbientColor: Color3;
  106136. protected _useLogarithmicDepth: boolean;
  106137. protected _rebuildInParallel: boolean;
  106138. /**
  106139. * Instantiates a new standard material.
  106140. * This is the default material used in Babylon. It is the best trade off between quality
  106141. * and performances.
  106142. * @see http://doc.babylonjs.com/babylon101/materials
  106143. * @param name Define the name of the material in the scene
  106144. * @param scene Define the scene the material belong to
  106145. */
  106146. constructor(name: string, scene: Scene);
  106147. /**
  106148. * Gets a boolean indicating that current material needs to register RTT
  106149. */
  106150. readonly hasRenderTargetTextures: boolean;
  106151. /**
  106152. * Gets the current class name of the material e.g. "StandardMaterial"
  106153. * Mainly use in serialization.
  106154. * @returns the class name
  106155. */
  106156. getClassName(): string;
  106157. /**
  106158. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  106159. * You can try switching to logarithmic depth.
  106160. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  106161. */
  106162. useLogarithmicDepth: boolean;
  106163. /**
  106164. * Specifies if the material will require alpha blending
  106165. * @returns a boolean specifying if alpha blending is needed
  106166. */
  106167. needAlphaBlending(): boolean;
  106168. /**
  106169. * Specifies if this material should be rendered in alpha test mode
  106170. * @returns a boolean specifying if an alpha test is needed.
  106171. */
  106172. needAlphaTesting(): boolean;
  106173. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  106174. /**
  106175. * Get the texture used for alpha test purpose.
  106176. * @returns the diffuse texture in case of the standard material.
  106177. */
  106178. getAlphaTestTexture(): Nullable<BaseTexture>;
  106179. /**
  106180. * Get if the submesh is ready to be used and all its information available.
  106181. * Child classes can use it to update shaders
  106182. * @param mesh defines the mesh to check
  106183. * @param subMesh defines which submesh to check
  106184. * @param useInstances specifies that instances should be used
  106185. * @returns a boolean indicating that the submesh is ready or not
  106186. */
  106187. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  106188. /**
  106189. * Builds the material UBO layouts.
  106190. * Used internally during the effect preparation.
  106191. */
  106192. buildUniformLayout(): void;
  106193. /**
  106194. * Unbinds the material from the mesh
  106195. */
  106196. unbind(): void;
  106197. /**
  106198. * Binds the submesh to this material by preparing the effect and shader to draw
  106199. * @param world defines the world transformation matrix
  106200. * @param mesh defines the mesh containing the submesh
  106201. * @param subMesh defines the submesh to bind the material to
  106202. */
  106203. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  106204. /**
  106205. * Get the list of animatables in the material.
  106206. * @returns the list of animatables object used in the material
  106207. */
  106208. getAnimatables(): IAnimatable[];
  106209. /**
  106210. * Gets the active textures from the material
  106211. * @returns an array of textures
  106212. */
  106213. getActiveTextures(): BaseTexture[];
  106214. /**
  106215. * Specifies if the material uses a texture
  106216. * @param texture defines the texture to check against the material
  106217. * @returns a boolean specifying if the material uses the texture
  106218. */
  106219. hasTexture(texture: BaseTexture): boolean;
  106220. /**
  106221. * Disposes the material
  106222. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  106223. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  106224. */
  106225. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  106226. /**
  106227. * Makes a duplicate of the material, and gives it a new name
  106228. * @param name defines the new name for the duplicated material
  106229. * @returns the cloned material
  106230. */
  106231. clone(name: string): StandardMaterial;
  106232. /**
  106233. * Serializes this material in a JSON representation
  106234. * @returns the serialized material object
  106235. */
  106236. serialize(): any;
  106237. /**
  106238. * Creates a standard material from parsed material data
  106239. * @param source defines the JSON representation of the material
  106240. * @param scene defines the hosting scene
  106241. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  106242. * @returns a new standard material
  106243. */
  106244. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  106245. /**
  106246. * Are diffuse textures enabled in the application.
  106247. */
  106248. static DiffuseTextureEnabled: boolean;
  106249. /**
  106250. * Are ambient textures enabled in the application.
  106251. */
  106252. static AmbientTextureEnabled: boolean;
  106253. /**
  106254. * Are opacity textures enabled in the application.
  106255. */
  106256. static OpacityTextureEnabled: boolean;
  106257. /**
  106258. * Are reflection textures enabled in the application.
  106259. */
  106260. static ReflectionTextureEnabled: boolean;
  106261. /**
  106262. * Are emissive textures enabled in the application.
  106263. */
  106264. static EmissiveTextureEnabled: boolean;
  106265. /**
  106266. * Are specular textures enabled in the application.
  106267. */
  106268. static SpecularTextureEnabled: boolean;
  106269. /**
  106270. * Are bump textures enabled in the application.
  106271. */
  106272. static BumpTextureEnabled: boolean;
  106273. /**
  106274. * Are lightmap textures enabled in the application.
  106275. */
  106276. static LightmapTextureEnabled: boolean;
  106277. /**
  106278. * Are refraction textures enabled in the application.
  106279. */
  106280. static RefractionTextureEnabled: boolean;
  106281. /**
  106282. * Are color grading textures enabled in the application.
  106283. */
  106284. static ColorGradingTextureEnabled: boolean;
  106285. /**
  106286. * Are fresnels enabled in the application.
  106287. */
  106288. static FresnelEnabled: boolean;
  106289. }
  106290. }
  106291. declare module BABYLON {
  106292. /** @hidden */
  106293. export var imageProcessingPixelShader: {
  106294. name: string;
  106295. shader: string;
  106296. };
  106297. }
  106298. declare module BABYLON {
  106299. /**
  106300. * ImageProcessingPostProcess
  106301. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  106302. */
  106303. export class ImageProcessingPostProcess extends PostProcess {
  106304. /**
  106305. * Default configuration related to image processing available in the PBR Material.
  106306. */
  106307. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  106308. /**
  106309. * Gets the image processing configuration used either in this material.
  106310. */
  106311. /**
  106312. * Sets the Default image processing configuration used either in the this material.
  106313. *
  106314. * If sets to null, the scene one is in use.
  106315. */
  106316. imageProcessingConfiguration: ImageProcessingConfiguration;
  106317. /**
  106318. * Keep track of the image processing observer to allow dispose and replace.
  106319. */
  106320. private _imageProcessingObserver;
  106321. /**
  106322. * Attaches a new image processing configuration to the PBR Material.
  106323. * @param configuration
  106324. */
  106325. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  106326. /**
  106327. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  106328. */
  106329. /**
  106330. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  106331. */
  106332. colorCurves: Nullable<ColorCurves>;
  106333. /**
  106334. * Gets wether the color curves effect is enabled.
  106335. */
  106336. /**
  106337. * Sets wether the color curves effect is enabled.
  106338. */
  106339. colorCurvesEnabled: boolean;
  106340. /**
  106341. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  106342. */
  106343. /**
  106344. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  106345. */
  106346. colorGradingTexture: Nullable<BaseTexture>;
  106347. /**
  106348. * Gets wether the color grading effect is enabled.
  106349. */
  106350. /**
  106351. * Gets wether the color grading effect is enabled.
  106352. */
  106353. colorGradingEnabled: boolean;
  106354. /**
  106355. * Gets exposure used in the effect.
  106356. */
  106357. /**
  106358. * Sets exposure used in the effect.
  106359. */
  106360. exposure: number;
  106361. /**
  106362. * Gets wether tonemapping is enabled or not.
  106363. */
  106364. /**
  106365. * Sets wether tonemapping is enabled or not
  106366. */
  106367. toneMappingEnabled: boolean;
  106368. /**
  106369. * Gets the type of tone mapping effect.
  106370. */
  106371. /**
  106372. * Sets the type of tone mapping effect.
  106373. */
  106374. toneMappingType: number;
  106375. /**
  106376. * Gets contrast used in the effect.
  106377. */
  106378. /**
  106379. * Sets contrast used in the effect.
  106380. */
  106381. contrast: number;
  106382. /**
  106383. * Gets Vignette stretch size.
  106384. */
  106385. /**
  106386. * Sets Vignette stretch size.
  106387. */
  106388. vignetteStretch: number;
  106389. /**
  106390. * Gets Vignette centre X Offset.
  106391. */
  106392. /**
  106393. * Sets Vignette centre X Offset.
  106394. */
  106395. vignetteCentreX: number;
  106396. /**
  106397. * Gets Vignette centre Y Offset.
  106398. */
  106399. /**
  106400. * Sets Vignette centre Y Offset.
  106401. */
  106402. vignetteCentreY: number;
  106403. /**
  106404. * Gets Vignette weight or intensity of the vignette effect.
  106405. */
  106406. /**
  106407. * Sets Vignette weight or intensity of the vignette effect.
  106408. */
  106409. vignetteWeight: number;
  106410. /**
  106411. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  106412. * if vignetteEnabled is set to true.
  106413. */
  106414. /**
  106415. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  106416. * if vignetteEnabled is set to true.
  106417. */
  106418. vignetteColor: Color4;
  106419. /**
  106420. * Gets Camera field of view used by the Vignette effect.
  106421. */
  106422. /**
  106423. * Sets Camera field of view used by the Vignette effect.
  106424. */
  106425. vignetteCameraFov: number;
  106426. /**
  106427. * Gets the vignette blend mode allowing different kind of effect.
  106428. */
  106429. /**
  106430. * Sets the vignette blend mode allowing different kind of effect.
  106431. */
  106432. vignetteBlendMode: number;
  106433. /**
  106434. * Gets wether the vignette effect is enabled.
  106435. */
  106436. /**
  106437. * Sets wether the vignette effect is enabled.
  106438. */
  106439. vignetteEnabled: boolean;
  106440. private _fromLinearSpace;
  106441. /**
  106442. * Gets wether the input of the processing is in Gamma or Linear Space.
  106443. */
  106444. /**
  106445. * Sets wether the input of the processing is in Gamma or Linear Space.
  106446. */
  106447. fromLinearSpace: boolean;
  106448. /**
  106449. * Defines cache preventing GC.
  106450. */
  106451. private _defines;
  106452. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  106453. /**
  106454. * "ImageProcessingPostProcess"
  106455. * @returns "ImageProcessingPostProcess"
  106456. */
  106457. getClassName(): string;
  106458. protected _updateParameters(): void;
  106459. dispose(camera?: Camera): void;
  106460. }
  106461. }
  106462. declare module BABYLON {
  106463. /**
  106464. * Class containing static functions to help procedurally build meshes
  106465. */
  106466. export class GroundBuilder {
  106467. /**
  106468. * Creates a ground mesh
  106469. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  106470. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  106471. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106472. * @param name defines the name of the mesh
  106473. * @param options defines the options used to create the mesh
  106474. * @param scene defines the hosting scene
  106475. * @returns the ground mesh
  106476. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  106477. */
  106478. static CreateGround(name: string, options: {
  106479. width?: number;
  106480. height?: number;
  106481. subdivisions?: number;
  106482. subdivisionsX?: number;
  106483. subdivisionsY?: number;
  106484. updatable?: boolean;
  106485. }, scene: any): Mesh;
  106486. /**
  106487. * Creates a tiled ground mesh
  106488. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  106489. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  106490. * * 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
  106491. * * 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
  106492. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106493. * @param name defines the name of the mesh
  106494. * @param options defines the options used to create the mesh
  106495. * @param scene defines the hosting scene
  106496. * @returns the tiled ground mesh
  106497. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  106498. */
  106499. static CreateTiledGround(name: string, options: {
  106500. xmin: number;
  106501. zmin: number;
  106502. xmax: number;
  106503. zmax: number;
  106504. subdivisions?: {
  106505. w: number;
  106506. h: number;
  106507. };
  106508. precision?: {
  106509. w: number;
  106510. h: number;
  106511. };
  106512. updatable?: boolean;
  106513. }, scene?: Nullable<Scene>): Mesh;
  106514. /**
  106515. * Creates a ground mesh from a height map
  106516. * * The parameter `url` sets the URL of the height map image resource.
  106517. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  106518. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  106519. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  106520. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  106521. * * 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.
  106522. * * 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).
  106523. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  106524. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106525. * @param name defines the name of the mesh
  106526. * @param url defines the url to the height map
  106527. * @param options defines the options used to create the mesh
  106528. * @param scene defines the hosting scene
  106529. * @returns the ground mesh
  106530. * @see https://doc.babylonjs.com/babylon101/height_map
  106531. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  106532. */
  106533. static CreateGroundFromHeightMap(name: string, url: string, options: {
  106534. width?: number;
  106535. height?: number;
  106536. subdivisions?: number;
  106537. minHeight?: number;
  106538. maxHeight?: number;
  106539. colorFilter?: Color3;
  106540. alphaFilter?: number;
  106541. updatable?: boolean;
  106542. onReady?: (mesh: GroundMesh) => void;
  106543. }, scene?: Nullable<Scene>): GroundMesh;
  106544. }
  106545. }
  106546. declare module BABYLON {
  106547. /**
  106548. * Class containing static functions to help procedurally build meshes
  106549. */
  106550. export class TorusBuilder {
  106551. /**
  106552. * Creates a torus mesh
  106553. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  106554. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  106555. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  106556. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106557. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106558. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106559. * @param name defines the name of the mesh
  106560. * @param options defines the options used to create the mesh
  106561. * @param scene defines the hosting scene
  106562. * @returns the torus mesh
  106563. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  106564. */
  106565. static CreateTorus(name: string, options: {
  106566. diameter?: number;
  106567. thickness?: number;
  106568. tessellation?: number;
  106569. updatable?: boolean;
  106570. sideOrientation?: number;
  106571. frontUVs?: Vector4;
  106572. backUVs?: Vector4;
  106573. }, scene: any): Mesh;
  106574. }
  106575. }
  106576. declare module BABYLON {
  106577. /**
  106578. * Class containing static functions to help procedurally build meshes
  106579. */
  106580. export class CylinderBuilder {
  106581. /**
  106582. * Creates a cylinder or a cone mesh
  106583. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  106584. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  106585. * * 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.
  106586. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  106587. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  106588. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  106589. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  106590. * * 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).
  106591. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  106592. * * 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).
  106593. * * 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
  106594. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  106595. * * 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
  106596. * * 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.
  106597. * * If `enclose` is false, a ring surface is one element.
  106598. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  106599. * * 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
  106600. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106601. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106602. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106603. * @param name defines the name of the mesh
  106604. * @param options defines the options used to create the mesh
  106605. * @param scene defines the hosting scene
  106606. * @returns the cylinder mesh
  106607. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  106608. */
  106609. static CreateCylinder(name: string, options: {
  106610. height?: number;
  106611. diameterTop?: number;
  106612. diameterBottom?: number;
  106613. diameter?: number;
  106614. tessellation?: number;
  106615. subdivisions?: number;
  106616. arc?: number;
  106617. faceColors?: Color4[];
  106618. faceUV?: Vector4[];
  106619. updatable?: boolean;
  106620. hasRings?: boolean;
  106621. enclose?: boolean;
  106622. cap?: number;
  106623. sideOrientation?: number;
  106624. frontUVs?: Vector4;
  106625. backUVs?: Vector4;
  106626. }, scene: any): Mesh;
  106627. }
  106628. }
  106629. declare module BABYLON {
  106630. /**
  106631. * Options to modify the vr teleportation behavior.
  106632. */
  106633. export interface VRTeleportationOptions {
  106634. /**
  106635. * The name of the mesh which should be used as the teleportation floor. (default: null)
  106636. */
  106637. floorMeshName?: string;
  106638. /**
  106639. * A list of meshes to be used as the teleportation floor. (default: empty)
  106640. */
  106641. floorMeshes?: Mesh[];
  106642. }
  106643. /**
  106644. * Options to modify the vr experience helper's behavior.
  106645. */
  106646. export interface VRExperienceHelperOptions extends WebVROptions {
  106647. /**
  106648. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  106649. */
  106650. createDeviceOrientationCamera?: boolean;
  106651. /**
  106652. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  106653. */
  106654. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  106655. /**
  106656. * Uses the main button on the controller to toggle the laser casted. (default: true)
  106657. */
  106658. laserToggle?: boolean;
  106659. /**
  106660. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  106661. */
  106662. floorMeshes?: Mesh[];
  106663. /**
  106664. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  106665. */
  106666. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  106667. }
  106668. /**
  106669. * Event containing information after VR has been entered
  106670. */
  106671. export class OnAfterEnteringVRObservableEvent {
  106672. /**
  106673. * If entering vr was successful
  106674. */
  106675. success: boolean;
  106676. }
  106677. /**
  106678. * Helps to quickly add VR support to an existing scene.
  106679. * See http://doc.babylonjs.com/how_to/webvr_helper
  106680. */
  106681. export class VRExperienceHelper {
  106682. /** Options to modify the vr experience helper's behavior. */
  106683. webVROptions: VRExperienceHelperOptions;
  106684. private _scene;
  106685. private _position;
  106686. private _btnVR;
  106687. private _btnVRDisplayed;
  106688. private _webVRsupported;
  106689. private _webVRready;
  106690. private _webVRrequesting;
  106691. private _webVRpresenting;
  106692. private _hasEnteredVR;
  106693. private _fullscreenVRpresenting;
  106694. private _canvas;
  106695. private _webVRCamera;
  106696. private _vrDeviceOrientationCamera;
  106697. private _deviceOrientationCamera;
  106698. private _existingCamera;
  106699. private _onKeyDown;
  106700. private _onVrDisplayPresentChange;
  106701. private _onVRDisplayChanged;
  106702. private _onVRRequestPresentStart;
  106703. private _onVRRequestPresentComplete;
  106704. /**
  106705. * 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)
  106706. */
  106707. enableGazeEvenWhenNoPointerLock: boolean;
  106708. /**
  106709. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  106710. */
  106711. exitVROnDoubleTap: boolean;
  106712. /**
  106713. * Observable raised right before entering VR.
  106714. */
  106715. onEnteringVRObservable: Observable<VRExperienceHelper>;
  106716. /**
  106717. * Observable raised when entering VR has completed.
  106718. */
  106719. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  106720. /**
  106721. * Observable raised when exiting VR.
  106722. */
  106723. onExitingVRObservable: Observable<VRExperienceHelper>;
  106724. /**
  106725. * Observable raised when controller mesh is loaded.
  106726. */
  106727. onControllerMeshLoadedObservable: Observable<WebVRController>;
  106728. /** Return this.onEnteringVRObservable
  106729. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  106730. */
  106731. readonly onEnteringVR: Observable<VRExperienceHelper>;
  106732. /** Return this.onExitingVRObservable
  106733. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  106734. */
  106735. readonly onExitingVR: Observable<VRExperienceHelper>;
  106736. /** Return this.onControllerMeshLoadedObservable
  106737. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  106738. */
  106739. readonly onControllerMeshLoaded: Observable<WebVRController>;
  106740. private _rayLength;
  106741. private _useCustomVRButton;
  106742. private _teleportationRequested;
  106743. private _teleportActive;
  106744. private _floorMeshName;
  106745. private _floorMeshesCollection;
  106746. private _rotationAllowed;
  106747. private _teleportBackwardsVector;
  106748. private _teleportationTarget;
  106749. private _isDefaultTeleportationTarget;
  106750. private _postProcessMove;
  106751. private _teleportationFillColor;
  106752. private _teleportationBorderColor;
  106753. private _rotationAngle;
  106754. private _haloCenter;
  106755. private _cameraGazer;
  106756. private _padSensibilityUp;
  106757. private _padSensibilityDown;
  106758. private _leftController;
  106759. private _rightController;
  106760. /**
  106761. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  106762. */
  106763. onNewMeshSelected: Observable<AbstractMesh>;
  106764. /**
  106765. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  106766. * This observable will provide the mesh and the controller used to select the mesh
  106767. */
  106768. onMeshSelectedWithController: Observable<{
  106769. mesh: AbstractMesh;
  106770. controller: WebVRController;
  106771. }>;
  106772. /**
  106773. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  106774. */
  106775. onNewMeshPicked: Observable<PickingInfo>;
  106776. private _circleEase;
  106777. /**
  106778. * Observable raised before camera teleportation
  106779. */
  106780. onBeforeCameraTeleport: Observable<Vector3>;
  106781. /**
  106782. * Observable raised after camera teleportation
  106783. */
  106784. onAfterCameraTeleport: Observable<Vector3>;
  106785. /**
  106786. * Observable raised when current selected mesh gets unselected
  106787. */
  106788. onSelectedMeshUnselected: Observable<AbstractMesh>;
  106789. private _raySelectionPredicate;
  106790. /**
  106791. * To be optionaly changed by user to define custom ray selection
  106792. */
  106793. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  106794. /**
  106795. * To be optionaly changed by user to define custom selection logic (after ray selection)
  106796. */
  106797. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  106798. /**
  106799. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  106800. */
  106801. teleportationEnabled: boolean;
  106802. private _defaultHeight;
  106803. private _teleportationInitialized;
  106804. private _interactionsEnabled;
  106805. private _interactionsRequested;
  106806. private _displayGaze;
  106807. private _displayLaserPointer;
  106808. /**
  106809. * The mesh used to display where the user is going to teleport.
  106810. */
  106811. /**
  106812. * Sets the mesh to be used to display where the user is going to teleport.
  106813. */
  106814. teleportationTarget: Mesh;
  106815. /**
  106816. * 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
  106817. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  106818. * See http://doc.babylonjs.com/resources/baking_transformations
  106819. */
  106820. gazeTrackerMesh: Mesh;
  106821. /**
  106822. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  106823. */
  106824. updateGazeTrackerScale: boolean;
  106825. /**
  106826. * If the gaze trackers color should be updated when selecting meshes
  106827. */
  106828. updateGazeTrackerColor: boolean;
  106829. /**
  106830. * If the controller laser color should be updated when selecting meshes
  106831. */
  106832. updateControllerLaserColor: boolean;
  106833. /**
  106834. * The gaze tracking mesh corresponding to the left controller
  106835. */
  106836. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  106837. /**
  106838. * The gaze tracking mesh corresponding to the right controller
  106839. */
  106840. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  106841. /**
  106842. * If the ray of the gaze should be displayed.
  106843. */
  106844. /**
  106845. * Sets if the ray of the gaze should be displayed.
  106846. */
  106847. displayGaze: boolean;
  106848. /**
  106849. * If the ray of the LaserPointer should be displayed.
  106850. */
  106851. /**
  106852. * Sets if the ray of the LaserPointer should be displayed.
  106853. */
  106854. displayLaserPointer: boolean;
  106855. /**
  106856. * The deviceOrientationCamera used as the camera when not in VR.
  106857. */
  106858. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  106859. /**
  106860. * Based on the current WebVR support, returns the current VR camera used.
  106861. */
  106862. readonly currentVRCamera: Nullable<Camera>;
  106863. /**
  106864. * The webVRCamera which is used when in VR.
  106865. */
  106866. readonly webVRCamera: WebVRFreeCamera;
  106867. /**
  106868. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  106869. */
  106870. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  106871. /**
  106872. * The html button that is used to trigger entering into VR.
  106873. */
  106874. readonly vrButton: Nullable<HTMLButtonElement>;
  106875. private readonly _teleportationRequestInitiated;
  106876. /**
  106877. * Defines wether or not Pointer lock should be requested when switching to
  106878. * full screen.
  106879. */
  106880. requestPointerLockOnFullScreen: boolean;
  106881. /**
  106882. * Instantiates a VRExperienceHelper.
  106883. * Helps to quickly add VR support to an existing scene.
  106884. * @param scene The scene the VRExperienceHelper belongs to.
  106885. * @param webVROptions Options to modify the vr experience helper's behavior.
  106886. */
  106887. constructor(scene: Scene,
  106888. /** Options to modify the vr experience helper's behavior. */
  106889. webVROptions?: VRExperienceHelperOptions);
  106890. private _onDefaultMeshLoaded;
  106891. private _onResize;
  106892. private _onFullscreenChange;
  106893. /**
  106894. * Gets a value indicating if we are currently in VR mode.
  106895. */
  106896. readonly isInVRMode: boolean;
  106897. private onVrDisplayPresentChange;
  106898. private onVRDisplayChanged;
  106899. private moveButtonToBottomRight;
  106900. private displayVRButton;
  106901. private updateButtonVisibility;
  106902. private _cachedAngularSensibility;
  106903. /**
  106904. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  106905. * Otherwise, will use the fullscreen API.
  106906. */
  106907. enterVR(): void;
  106908. /**
  106909. * Attempt to exit VR, or fullscreen.
  106910. */
  106911. exitVR(): void;
  106912. /**
  106913. * The position of the vr experience helper.
  106914. */
  106915. /**
  106916. * Sets the position of the vr experience helper.
  106917. */
  106918. position: Vector3;
  106919. /**
  106920. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  106921. */
  106922. enableInteractions(): void;
  106923. private readonly _noControllerIsActive;
  106924. private beforeRender;
  106925. private _isTeleportationFloor;
  106926. /**
  106927. * Adds a floor mesh to be used for teleportation.
  106928. * @param floorMesh the mesh to be used for teleportation.
  106929. */
  106930. addFloorMesh(floorMesh: Mesh): void;
  106931. /**
  106932. * Removes a floor mesh from being used for teleportation.
  106933. * @param floorMesh the mesh to be removed.
  106934. */
  106935. removeFloorMesh(floorMesh: Mesh): void;
  106936. /**
  106937. * Enables interactions and teleportation using the VR controllers and gaze.
  106938. * @param vrTeleportationOptions options to modify teleportation behavior.
  106939. */
  106940. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  106941. private _onNewGamepadConnected;
  106942. private _tryEnableInteractionOnController;
  106943. private _onNewGamepadDisconnected;
  106944. private _enableInteractionOnController;
  106945. private _checkTeleportWithRay;
  106946. private _checkRotate;
  106947. private _checkTeleportBackwards;
  106948. private _enableTeleportationOnController;
  106949. private _createTeleportationCircles;
  106950. private _displayTeleportationTarget;
  106951. private _hideTeleportationTarget;
  106952. private _rotateCamera;
  106953. private _moveTeleportationSelectorTo;
  106954. private _workingVector;
  106955. private _workingQuaternion;
  106956. private _workingMatrix;
  106957. /**
  106958. * Teleports the users feet to the desired location
  106959. * @param location The location where the user's feet should be placed
  106960. */
  106961. teleportCamera(location: Vector3): void;
  106962. private _convertNormalToDirectionOfRay;
  106963. private _castRayAndSelectObject;
  106964. private _notifySelectedMeshUnselected;
  106965. /**
  106966. * Sets the color of the laser ray from the vr controllers.
  106967. * @param color new color for the ray.
  106968. */
  106969. changeLaserColor(color: Color3): void;
  106970. /**
  106971. * Sets the color of the ray from the vr headsets gaze.
  106972. * @param color new color for the ray.
  106973. */
  106974. changeGazeColor(color: Color3): void;
  106975. /**
  106976. * Exits VR and disposes of the vr experience helper
  106977. */
  106978. dispose(): void;
  106979. /**
  106980. * Gets the name of the VRExperienceHelper class
  106981. * @returns "VRExperienceHelper"
  106982. */
  106983. getClassName(): string;
  106984. }
  106985. }
  106986. declare module BABYLON {
  106987. /**
  106988. * Manages an XRSession to work with Babylon's engine
  106989. * @see https://doc.babylonjs.com/how_to/webxr
  106990. */
  106991. export class WebXRSessionManager implements IDisposable {
  106992. private scene;
  106993. /**
  106994. * Fires every time a new xrFrame arrives which can be used to update the camera
  106995. */
  106996. onXRFrameObservable: Observable<any>;
  106997. /**
  106998. * Fires when the xr session is ended either by the device or manually done
  106999. */
  107000. onXRSessionEnded: Observable<any>;
  107001. /**
  107002. * Underlying xr session
  107003. */
  107004. session: XRSession;
  107005. /**
  107006. * Type of reference space used when creating the session
  107007. */
  107008. referenceSpace: XRReferenceSpace;
  107009. /** @hidden */
  107010. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  107011. /**
  107012. * Current XR frame
  107013. */
  107014. currentFrame: Nullable<XRFrame>;
  107015. private _xrNavigator;
  107016. private baseLayer;
  107017. /**
  107018. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  107019. * @param scene The scene which the session should be created for
  107020. */
  107021. constructor(scene: Scene);
  107022. /**
  107023. * Initializes the manager
  107024. * After initialization enterXR can be called to start an XR session
  107025. * @returns Promise which resolves after it is initialized
  107026. */
  107027. initializeAsync(): Promise<void>;
  107028. /**
  107029. * Initializes an xr session
  107030. * @param xrSessionMode mode to initialize
  107031. * @returns a promise which will resolve once the session has been initialized
  107032. */
  107033. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  107034. /**
  107035. * Sets the reference space on the xr session
  107036. * @param referenceSpace space to set
  107037. * @returns a promise that will resolve once the reference space has been set
  107038. */
  107039. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  107040. /**
  107041. * Updates the render state of the session
  107042. * @param state state to set
  107043. * @returns a promise that resolves once the render state has been updated
  107044. */
  107045. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  107046. /**
  107047. * Starts rendering to the xr layer
  107048. * @returns a promise that will resolve once rendering has started
  107049. */
  107050. startRenderingToXRAsync(): Promise<void>;
  107051. /**
  107052. * Stops the xrSession and restores the renderloop
  107053. * @returns Promise which resolves after it exits XR
  107054. */
  107055. exitXRAsync(): Promise<unknown>;
  107056. /**
  107057. * Checks if a session would be supported for the creation options specified
  107058. * @param sessionMode session mode to check if supported eg. immersive-vr
  107059. * @returns true if supported
  107060. */
  107061. supportsSessionAsync(sessionMode: XRSessionMode): any;
  107062. /**
  107063. * @hidden
  107064. * Converts the render layer of xrSession to a render target
  107065. * @param session session to create render target for
  107066. * @param scene scene the new render target should be created for
  107067. */
  107068. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  107069. /**
  107070. * Disposes of the session manager
  107071. */
  107072. dispose(): void;
  107073. }
  107074. }
  107075. declare module BABYLON {
  107076. /**
  107077. * WebXR Camera which holds the views for the xrSession
  107078. * @see https://doc.babylonjs.com/how_to/webxr
  107079. */
  107080. export class WebXRCamera extends FreeCamera {
  107081. private static _TmpMatrix;
  107082. /**
  107083. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  107084. * @param name the name of the camera
  107085. * @param scene the scene to add the camera to
  107086. */
  107087. constructor(name: string, scene: Scene);
  107088. private _updateNumberOfRigCameras;
  107089. /** @hidden */
  107090. _updateForDualEyeDebugging(pupilDistance?: number): void;
  107091. /**
  107092. * Updates the cameras position from the current pose information of the XR session
  107093. * @param xrSessionManager the session containing pose information
  107094. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  107095. */
  107096. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  107097. }
  107098. }
  107099. declare module BABYLON {
  107100. /**
  107101. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  107102. */
  107103. export class WebXRManagedOutputCanvas implements IDisposable {
  107104. private helper;
  107105. private _canvas;
  107106. /**
  107107. * xrpresent context of the canvas which can be used to display/mirror xr content
  107108. */
  107109. canvasContext: WebGLRenderingContext;
  107110. /**
  107111. * xr layer for the canvas
  107112. */
  107113. xrLayer: Nullable<XRWebGLLayer>;
  107114. /**
  107115. * Initializes the xr layer for the session
  107116. * @param xrSession xr session
  107117. * @returns a promise that will resolve once the XR Layer has been created
  107118. */
  107119. initializeXRLayerAsync(xrSession: any): any;
  107120. /**
  107121. * Initializes the canvas to be added/removed upon entering/exiting xr
  107122. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  107123. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  107124. */
  107125. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  107126. /**
  107127. * Disposes of the object
  107128. */
  107129. dispose(): void;
  107130. private _setManagedOutputCanvas;
  107131. private _addCanvas;
  107132. private _removeCanvas;
  107133. }
  107134. }
  107135. declare module BABYLON {
  107136. /**
  107137. * States of the webXR experience
  107138. */
  107139. export enum WebXRState {
  107140. /**
  107141. * Transitioning to being in XR mode
  107142. */
  107143. ENTERING_XR = 0,
  107144. /**
  107145. * Transitioning to non XR mode
  107146. */
  107147. EXITING_XR = 1,
  107148. /**
  107149. * In XR mode and presenting
  107150. */
  107151. IN_XR = 2,
  107152. /**
  107153. * Not entered XR mode
  107154. */
  107155. NOT_IN_XR = 3
  107156. }
  107157. /**
  107158. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  107159. * @see https://doc.babylonjs.com/how_to/webxr
  107160. */
  107161. export class WebXRExperienceHelper implements IDisposable {
  107162. private scene;
  107163. /**
  107164. * 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
  107165. */
  107166. container: AbstractMesh;
  107167. /**
  107168. * Camera used to render xr content
  107169. */
  107170. camera: WebXRCamera;
  107171. /**
  107172. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  107173. */
  107174. state: WebXRState;
  107175. private _setState;
  107176. private static _TmpVector;
  107177. /**
  107178. * Fires when the state of the experience helper has changed
  107179. */
  107180. onStateChangedObservable: Observable<WebXRState>;
  107181. /** Session manager used to keep track of xr session */
  107182. sessionManager: WebXRSessionManager;
  107183. private _nonVRCamera;
  107184. private _originalSceneAutoClear;
  107185. private _supported;
  107186. /**
  107187. * Creates the experience helper
  107188. * @param scene the scene to attach the experience helper to
  107189. * @returns a promise for the experience helper
  107190. */
  107191. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  107192. /**
  107193. * Creates a WebXRExperienceHelper
  107194. * @param scene The scene the helper should be created in
  107195. */
  107196. private constructor();
  107197. /**
  107198. * Exits XR mode and returns the scene to its original state
  107199. * @returns promise that resolves after xr mode has exited
  107200. */
  107201. exitXRAsync(): Promise<unknown>;
  107202. /**
  107203. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  107204. * @param sessionCreationOptions options for the XR session
  107205. * @param referenceSpaceType frame of reference of the XR session
  107206. * @param outputCanvas the output canvas that will be used to enter XR mode
  107207. * @returns promise that resolves after xr mode has entered
  107208. */
  107209. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  107210. /**
  107211. * Updates the global position of the camera by moving the camera's container
  107212. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  107213. * @param position The desired global position of the camera
  107214. */
  107215. setPositionOfCameraUsingContainer(position: Vector3): void;
  107216. /**
  107217. * Rotates the xr camera by rotating the camera's container around the camera's position
  107218. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  107219. * @param rotation the desired quaternion rotation to apply to the camera
  107220. */
  107221. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  107222. /**
  107223. * Disposes of the experience helper
  107224. */
  107225. dispose(): void;
  107226. }
  107227. }
  107228. declare module BABYLON {
  107229. /**
  107230. * Button which can be used to enter a different mode of XR
  107231. */
  107232. export class WebXREnterExitUIButton {
  107233. /** button element */
  107234. element: HTMLElement;
  107235. /** XR initialization options for the button */
  107236. sessionMode: XRSessionMode;
  107237. /** Reference space type */
  107238. referenceSpaceType: XRReferenceSpaceType;
  107239. /**
  107240. * Creates a WebXREnterExitUIButton
  107241. * @param element button element
  107242. * @param sessionMode XR initialization session mode
  107243. * @param referenceSpaceType the type of reference space to be used
  107244. */
  107245. constructor(
  107246. /** button element */
  107247. element: HTMLElement,
  107248. /** XR initialization options for the button */
  107249. sessionMode: XRSessionMode,
  107250. /** Reference space type */
  107251. referenceSpaceType: XRReferenceSpaceType);
  107252. /**
  107253. * Overwritable function which can be used to update the button's visuals when the state changes
  107254. * @param activeButton the current active button in the UI
  107255. */
  107256. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  107257. }
  107258. /**
  107259. * Options to create the webXR UI
  107260. */
  107261. export class WebXREnterExitUIOptions {
  107262. /**
  107263. * Context to enter xr with
  107264. */
  107265. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  107266. /**
  107267. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  107268. */
  107269. customButtons?: Array<WebXREnterExitUIButton>;
  107270. }
  107271. /**
  107272. * UI to allow the user to enter/exit XR mode
  107273. */
  107274. export class WebXREnterExitUI implements IDisposable {
  107275. private scene;
  107276. private _overlay;
  107277. private _buttons;
  107278. private _activeButton;
  107279. /**
  107280. * Fired every time the active button is changed.
  107281. *
  107282. * When xr is entered via a button that launches xr that button will be the callback parameter
  107283. *
  107284. * When exiting xr the callback parameter will be null)
  107285. */
  107286. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  107287. /**
  107288. * Creates UI to allow the user to enter/exit XR mode
  107289. * @param scene the scene to add the ui to
  107290. * @param helper the xr experience helper to enter/exit xr with
  107291. * @param options options to configure the UI
  107292. * @returns the created ui
  107293. */
  107294. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  107295. private constructor();
  107296. private _updateButtons;
  107297. /**
  107298. * Disposes of the object
  107299. */
  107300. dispose(): void;
  107301. }
  107302. }
  107303. declare module BABYLON {
  107304. /**
  107305. * Represents an XR input
  107306. */
  107307. export class WebXRController {
  107308. private scene;
  107309. /** The underlying input source for the controller */
  107310. inputSource: XRInputSource;
  107311. private parentContainer;
  107312. /**
  107313. * 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
  107314. */
  107315. grip?: AbstractMesh;
  107316. /**
  107317. * Pointer which can be used to select objects or attach a visible laser to
  107318. */
  107319. pointer: AbstractMesh;
  107320. /**
  107321. * Event that fires when the controller is removed/disposed
  107322. */
  107323. onDisposeObservable: Observable<{}>;
  107324. private _tmpMatrix;
  107325. private _tmpQuaternion;
  107326. private _tmpVector;
  107327. /**
  107328. * Creates the controller
  107329. * @see https://doc.babylonjs.com/how_to/webxr
  107330. * @param scene the scene which the controller should be associated to
  107331. * @param inputSource the underlying input source for the controller
  107332. * @param parentContainer parent that the controller meshes should be children of
  107333. */
  107334. constructor(scene: Scene,
  107335. /** The underlying input source for the controller */
  107336. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  107337. /**
  107338. * Updates the controller pose based on the given XRFrame
  107339. * @param xrFrame xr frame to update the pose with
  107340. * @param referenceSpace reference space to use
  107341. */
  107342. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  107343. /**
  107344. * Gets a world space ray coming from the controller
  107345. * @param result the resulting ray
  107346. */
  107347. getWorldPointerRayToRef(result: Ray): void;
  107348. /**
  107349. * Disposes of the object
  107350. */
  107351. dispose(): void;
  107352. }
  107353. }
  107354. declare module BABYLON {
  107355. /**
  107356. * XR input used to track XR inputs such as controllers/rays
  107357. */
  107358. export class WebXRInput implements IDisposable {
  107359. /**
  107360. * Base experience the input listens to
  107361. */
  107362. baseExperience: WebXRExperienceHelper;
  107363. /**
  107364. * XR controllers being tracked
  107365. */
  107366. controllers: Array<WebXRController>;
  107367. private _frameObserver;
  107368. private _stateObserver;
  107369. /**
  107370. * Event when a controller has been connected/added
  107371. */
  107372. onControllerAddedObservable: Observable<WebXRController>;
  107373. /**
  107374. * Event when a controller has been removed/disconnected
  107375. */
  107376. onControllerRemovedObservable: Observable<WebXRController>;
  107377. /**
  107378. * Initializes the WebXRInput
  107379. * @param baseExperience experience helper which the input should be created for
  107380. */
  107381. constructor(
  107382. /**
  107383. * Base experience the input listens to
  107384. */
  107385. baseExperience: WebXRExperienceHelper);
  107386. private _onInputSourcesChange;
  107387. private _addAndRemoveControllers;
  107388. /**
  107389. * Disposes of the object
  107390. */
  107391. dispose(): void;
  107392. }
  107393. }
  107394. declare module BABYLON {
  107395. /**
  107396. * Enables teleportation
  107397. */
  107398. export class WebXRControllerTeleportation {
  107399. private _teleportationFillColor;
  107400. private _teleportationBorderColor;
  107401. private _tmpRay;
  107402. private _tmpVector;
  107403. /**
  107404. * Creates a WebXRControllerTeleportation
  107405. * @param input input manager to add teleportation to
  107406. * @param floorMeshes floormeshes which can be teleported to
  107407. */
  107408. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  107409. }
  107410. }
  107411. declare module BABYLON {
  107412. /**
  107413. * Handles pointer input automatically for the pointer of XR controllers
  107414. */
  107415. export class WebXRControllerPointerSelection {
  107416. private static _idCounter;
  107417. private _tmpRay;
  107418. /**
  107419. * Creates a WebXRControllerPointerSelection
  107420. * @param input input manager to setup pointer selection
  107421. */
  107422. constructor(input: WebXRInput);
  107423. private _convertNormalToDirectionOfRay;
  107424. private _updatePointerDistance;
  107425. }
  107426. }
  107427. declare module BABYLON {
  107428. /**
  107429. * Class used to represent data loading progression
  107430. */
  107431. export class SceneLoaderProgressEvent {
  107432. /** defines if data length to load can be evaluated */
  107433. readonly lengthComputable: boolean;
  107434. /** defines the loaded data length */
  107435. readonly loaded: number;
  107436. /** defines the data length to load */
  107437. readonly total: number;
  107438. /**
  107439. * Create a new progress event
  107440. * @param lengthComputable defines if data length to load can be evaluated
  107441. * @param loaded defines the loaded data length
  107442. * @param total defines the data length to load
  107443. */
  107444. constructor(
  107445. /** defines if data length to load can be evaluated */
  107446. lengthComputable: boolean,
  107447. /** defines the loaded data length */
  107448. loaded: number,
  107449. /** defines the data length to load */
  107450. total: number);
  107451. /**
  107452. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  107453. * @param event defines the source event
  107454. * @returns a new SceneLoaderProgressEvent
  107455. */
  107456. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  107457. }
  107458. /**
  107459. * Interface used by SceneLoader plugins to define supported file extensions
  107460. */
  107461. export interface ISceneLoaderPluginExtensions {
  107462. /**
  107463. * Defines the list of supported extensions
  107464. */
  107465. [extension: string]: {
  107466. isBinary: boolean;
  107467. };
  107468. }
  107469. /**
  107470. * Interface used by SceneLoader plugin factory
  107471. */
  107472. export interface ISceneLoaderPluginFactory {
  107473. /**
  107474. * Defines the name of the factory
  107475. */
  107476. name: string;
  107477. /**
  107478. * Function called to create a new plugin
  107479. * @return the new plugin
  107480. */
  107481. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  107482. /**
  107483. * Boolean indicating if the plugin can direct load specific data
  107484. */
  107485. canDirectLoad?: (data: string) => boolean;
  107486. }
  107487. /**
  107488. * Interface used to define a SceneLoader plugin
  107489. */
  107490. export interface ISceneLoaderPlugin {
  107491. /**
  107492. * The friendly name of this plugin.
  107493. */
  107494. name: string;
  107495. /**
  107496. * The file extensions supported by this plugin.
  107497. */
  107498. extensions: string | ISceneLoaderPluginExtensions;
  107499. /**
  107500. * Import meshes into a scene.
  107501. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  107502. * @param scene The scene to import into
  107503. * @param data The data to import
  107504. * @param rootUrl The root url for scene and resources
  107505. * @param meshes The meshes array to import into
  107506. * @param particleSystems The particle systems array to import into
  107507. * @param skeletons The skeletons array to import into
  107508. * @param onError The callback when import fails
  107509. * @returns True if successful or false otherwise
  107510. */
  107511. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  107512. /**
  107513. * Load into a scene.
  107514. * @param scene The scene to load into
  107515. * @param data The data to import
  107516. * @param rootUrl The root url for scene and resources
  107517. * @param onError The callback when import fails
  107518. * @returns true if successful or false otherwise
  107519. */
  107520. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  107521. /**
  107522. * The callback that returns true if the data can be directly loaded.
  107523. */
  107524. canDirectLoad?: (data: string) => boolean;
  107525. /**
  107526. * The callback that allows custom handling of the root url based on the response url.
  107527. */
  107528. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  107529. /**
  107530. * Load into an asset container.
  107531. * @param scene The scene to load into
  107532. * @param data The data to import
  107533. * @param rootUrl The root url for scene and resources
  107534. * @param onError The callback when import fails
  107535. * @returns The loaded asset container
  107536. */
  107537. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  107538. }
  107539. /**
  107540. * Interface used to define an async SceneLoader plugin
  107541. */
  107542. export interface ISceneLoaderPluginAsync {
  107543. /**
  107544. * The friendly name of this plugin.
  107545. */
  107546. name: string;
  107547. /**
  107548. * The file extensions supported by this plugin.
  107549. */
  107550. extensions: string | ISceneLoaderPluginExtensions;
  107551. /**
  107552. * Import meshes into a scene.
  107553. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  107554. * @param scene The scene to import into
  107555. * @param data The data to import
  107556. * @param rootUrl The root url for scene and resources
  107557. * @param onProgress The callback when the load progresses
  107558. * @param fileName Defines the name of the file to load
  107559. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  107560. */
  107561. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  107562. meshes: AbstractMesh[];
  107563. particleSystems: IParticleSystem[];
  107564. skeletons: Skeleton[];
  107565. animationGroups: AnimationGroup[];
  107566. }>;
  107567. /**
  107568. * Load into a scene.
  107569. * @param scene The scene to load into
  107570. * @param data The data to import
  107571. * @param rootUrl The root url for scene and resources
  107572. * @param onProgress The callback when the load progresses
  107573. * @param fileName Defines the name of the file to load
  107574. * @returns Nothing
  107575. */
  107576. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  107577. /**
  107578. * The callback that returns true if the data can be directly loaded.
  107579. */
  107580. canDirectLoad?: (data: string) => boolean;
  107581. /**
  107582. * The callback that allows custom handling of the root url based on the response url.
  107583. */
  107584. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  107585. /**
  107586. * Load into an asset container.
  107587. * @param scene The scene to load into
  107588. * @param data The data to import
  107589. * @param rootUrl The root url for scene and resources
  107590. * @param onProgress The callback when the load progresses
  107591. * @param fileName Defines the name of the file to load
  107592. * @returns The loaded asset container
  107593. */
  107594. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  107595. }
  107596. /**
  107597. * Class used to load scene from various file formats using registered plugins
  107598. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  107599. */
  107600. export class SceneLoader {
  107601. /**
  107602. * No logging while loading
  107603. */
  107604. static readonly NO_LOGGING: number;
  107605. /**
  107606. * Minimal logging while loading
  107607. */
  107608. static readonly MINIMAL_LOGGING: number;
  107609. /**
  107610. * Summary logging while loading
  107611. */
  107612. static readonly SUMMARY_LOGGING: number;
  107613. /**
  107614. * Detailled logging while loading
  107615. */
  107616. static readonly DETAILED_LOGGING: number;
  107617. /**
  107618. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  107619. */
  107620. static ForceFullSceneLoadingForIncremental: boolean;
  107621. /**
  107622. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  107623. */
  107624. static ShowLoadingScreen: boolean;
  107625. /**
  107626. * Defines the current logging level (while loading the scene)
  107627. * @ignorenaming
  107628. */
  107629. static loggingLevel: number;
  107630. /**
  107631. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  107632. */
  107633. static CleanBoneMatrixWeights: boolean;
  107634. /**
  107635. * Event raised when a plugin is used to load a scene
  107636. */
  107637. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  107638. private static _registeredPlugins;
  107639. private static _getDefaultPlugin;
  107640. private static _getPluginForExtension;
  107641. private static _getPluginForDirectLoad;
  107642. private static _getPluginForFilename;
  107643. private static _getDirectLoad;
  107644. private static _loadData;
  107645. private static _getFileInfo;
  107646. /**
  107647. * Gets a plugin that can load the given extension
  107648. * @param extension defines the extension to load
  107649. * @returns a plugin or null if none works
  107650. */
  107651. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  107652. /**
  107653. * Gets a boolean indicating that the given extension can be loaded
  107654. * @param extension defines the extension to load
  107655. * @returns true if the extension is supported
  107656. */
  107657. static IsPluginForExtensionAvailable(extension: string): boolean;
  107658. /**
  107659. * Adds a new plugin to the list of registered plugins
  107660. * @param plugin defines the plugin to add
  107661. */
  107662. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  107663. /**
  107664. * Import meshes into a scene
  107665. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  107666. * @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)
  107667. * @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)
  107668. * @param scene the instance of BABYLON.Scene to append to
  107669. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  107670. * @param onProgress a callback with a progress event for each file being loaded
  107671. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  107672. * @param pluginExtension the extension used to determine the plugin
  107673. * @returns The loaded plugin
  107674. */
  107675. 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>;
  107676. /**
  107677. * Import meshes into a scene
  107678. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  107679. * @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)
  107680. * @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)
  107681. * @param scene the instance of BABYLON.Scene to append to
  107682. * @param onProgress a callback with a progress event for each file being loaded
  107683. * @param pluginExtension the extension used to determine the plugin
  107684. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  107685. */
  107686. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  107687. meshes: AbstractMesh[];
  107688. particleSystems: IParticleSystem[];
  107689. skeletons: Skeleton[];
  107690. animationGroups: AnimationGroup[];
  107691. }>;
  107692. /**
  107693. * Load a scene
  107694. * @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)
  107695. * @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)
  107696. * @param engine is the instance of BABYLON.Engine to use to create the scene
  107697. * @param onSuccess a callback with the scene when import succeeds
  107698. * @param onProgress a callback with a progress event for each file being loaded
  107699. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  107700. * @param pluginExtension the extension used to determine the plugin
  107701. * @returns The loaded plugin
  107702. */
  107703. 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>;
  107704. /**
  107705. * Load a scene
  107706. * @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)
  107707. * @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)
  107708. * @param engine is the instance of BABYLON.Engine to use to create the scene
  107709. * @param onProgress a callback with a progress event for each file being loaded
  107710. * @param pluginExtension the extension used to determine the plugin
  107711. * @returns The loaded scene
  107712. */
  107713. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  107714. /**
  107715. * Append a scene
  107716. * @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)
  107717. * @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)
  107718. * @param scene is the instance of BABYLON.Scene to append to
  107719. * @param onSuccess a callback with the scene when import succeeds
  107720. * @param onProgress a callback with a progress event for each file being loaded
  107721. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  107722. * @param pluginExtension the extension used to determine the plugin
  107723. * @returns The loaded plugin
  107724. */
  107725. 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>;
  107726. /**
  107727. * Append a scene
  107728. * @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)
  107729. * @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)
  107730. * @param scene is the instance of BABYLON.Scene to append to
  107731. * @param onProgress a callback with a progress event for each file being loaded
  107732. * @param pluginExtension the extension used to determine the plugin
  107733. * @returns The given scene
  107734. */
  107735. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  107736. /**
  107737. * Load a scene into an asset container
  107738. * @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)
  107739. * @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)
  107740. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  107741. * @param onSuccess a callback with the scene when import succeeds
  107742. * @param onProgress a callback with a progress event for each file being loaded
  107743. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  107744. * @param pluginExtension the extension used to determine the plugin
  107745. * @returns The loaded plugin
  107746. */
  107747. 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>;
  107748. /**
  107749. * Load a scene into an asset container
  107750. * @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)
  107751. * @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)
  107752. * @param scene is the instance of Scene to append to
  107753. * @param onProgress a callback with a progress event for each file being loaded
  107754. * @param pluginExtension the extension used to determine the plugin
  107755. * @returns The loaded asset container
  107756. */
  107757. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  107758. }
  107759. }
  107760. declare module BABYLON {
  107761. /**
  107762. * Generic Controller
  107763. */
  107764. export class GenericController extends WebVRController {
  107765. /**
  107766. * Base Url for the controller model.
  107767. */
  107768. static readonly MODEL_BASE_URL: string;
  107769. /**
  107770. * File name for the controller model.
  107771. */
  107772. static readonly MODEL_FILENAME: string;
  107773. /**
  107774. * Creates a new GenericController from a gamepad
  107775. * @param vrGamepad the gamepad that the controller should be created from
  107776. */
  107777. constructor(vrGamepad: any);
  107778. /**
  107779. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  107780. * @param scene scene in which to add meshes
  107781. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  107782. */
  107783. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  107784. /**
  107785. * Called once for each button that changed state since the last frame
  107786. * @param buttonIdx Which button index changed
  107787. * @param state New state of the button
  107788. * @param changes Which properties on the state changed since last frame
  107789. */
  107790. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  107791. }
  107792. }
  107793. declare module BABYLON {
  107794. /**
  107795. * Defines the WindowsMotionController object that the state of the windows motion controller
  107796. */
  107797. export class WindowsMotionController extends WebVRController {
  107798. /**
  107799. * The base url used to load the left and right controller models
  107800. */
  107801. static MODEL_BASE_URL: string;
  107802. /**
  107803. * The name of the left controller model file
  107804. */
  107805. static MODEL_LEFT_FILENAME: string;
  107806. /**
  107807. * The name of the right controller model file
  107808. */
  107809. static MODEL_RIGHT_FILENAME: string;
  107810. /**
  107811. * The controller name prefix for this controller type
  107812. */
  107813. static readonly GAMEPAD_ID_PREFIX: string;
  107814. /**
  107815. * The controller id pattern for this controller type
  107816. */
  107817. private static readonly GAMEPAD_ID_PATTERN;
  107818. private _loadedMeshInfo;
  107819. private readonly _mapping;
  107820. /**
  107821. * Fired when the trackpad on this controller is clicked
  107822. */
  107823. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  107824. /**
  107825. * Fired when the trackpad on this controller is modified
  107826. */
  107827. onTrackpadValuesChangedObservable: Observable<StickValues>;
  107828. /**
  107829. * The current x and y values of this controller's trackpad
  107830. */
  107831. trackpad: StickValues;
  107832. /**
  107833. * Creates a new WindowsMotionController from a gamepad
  107834. * @param vrGamepad the gamepad that the controller should be created from
  107835. */
  107836. constructor(vrGamepad: any);
  107837. /**
  107838. * Fired when the trigger on this controller is modified
  107839. */
  107840. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107841. /**
  107842. * Fired when the menu button on this controller is modified
  107843. */
  107844. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107845. /**
  107846. * Fired when the grip button on this controller is modified
  107847. */
  107848. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107849. /**
  107850. * Fired when the thumbstick button on this controller is modified
  107851. */
  107852. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107853. /**
  107854. * Fired when the touchpad button on this controller is modified
  107855. */
  107856. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107857. /**
  107858. * Fired when the touchpad values on this controller are modified
  107859. */
  107860. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  107861. private _updateTrackpad;
  107862. /**
  107863. * Called once per frame by the engine.
  107864. */
  107865. update(): void;
  107866. /**
  107867. * Called once for each button that changed state since the last frame
  107868. * @param buttonIdx Which button index changed
  107869. * @param state New state of the button
  107870. * @param changes Which properties on the state changed since last frame
  107871. */
  107872. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  107873. /**
  107874. * Moves the buttons on the controller mesh based on their current state
  107875. * @param buttonName the name of the button to move
  107876. * @param buttonValue the value of the button which determines the buttons new position
  107877. */
  107878. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  107879. /**
  107880. * Moves the axis on the controller mesh based on its current state
  107881. * @param axis the index of the axis
  107882. * @param axisValue the value of the axis which determines the meshes new position
  107883. * @hidden
  107884. */
  107885. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  107886. /**
  107887. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  107888. * @param scene scene in which to add meshes
  107889. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  107890. */
  107891. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  107892. /**
  107893. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  107894. * can be transformed by button presses and axes values, based on this._mapping.
  107895. *
  107896. * @param scene scene in which the meshes exist
  107897. * @param meshes list of meshes that make up the controller model to process
  107898. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  107899. */
  107900. private processModel;
  107901. private createMeshInfo;
  107902. /**
  107903. * Gets the ray of the controller in the direction the controller is pointing
  107904. * @param length the length the resulting ray should be
  107905. * @returns a ray in the direction the controller is pointing
  107906. */
  107907. getForwardRay(length?: number): Ray;
  107908. /**
  107909. * Disposes of the controller
  107910. */
  107911. dispose(): void;
  107912. }
  107913. }
  107914. declare module BABYLON {
  107915. /**
  107916. * Oculus Touch Controller
  107917. */
  107918. export class OculusTouchController extends WebVRController {
  107919. /**
  107920. * Base Url for the controller model.
  107921. */
  107922. static MODEL_BASE_URL: string;
  107923. /**
  107924. * File name for the left controller model.
  107925. */
  107926. static MODEL_LEFT_FILENAME: string;
  107927. /**
  107928. * File name for the right controller model.
  107929. */
  107930. static MODEL_RIGHT_FILENAME: string;
  107931. /**
  107932. * Base Url for the Quest controller model.
  107933. */
  107934. static QUEST_MODEL_BASE_URL: string;
  107935. /**
  107936. * @hidden
  107937. * If the controllers are running on a device that needs the updated Quest controller models
  107938. */
  107939. static _IsQuest: boolean;
  107940. /**
  107941. * Fired when the secondary trigger on this controller is modified
  107942. */
  107943. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  107944. /**
  107945. * Fired when the thumb rest on this controller is modified
  107946. */
  107947. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  107948. /**
  107949. * Creates a new OculusTouchController from a gamepad
  107950. * @param vrGamepad the gamepad that the controller should be created from
  107951. */
  107952. constructor(vrGamepad: any);
  107953. /**
  107954. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  107955. * @param scene scene in which to add meshes
  107956. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  107957. */
  107958. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  107959. /**
  107960. * Fired when the A button on this controller is modified
  107961. */
  107962. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107963. /**
  107964. * Fired when the B button on this controller is modified
  107965. */
  107966. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107967. /**
  107968. * Fired when the X button on this controller is modified
  107969. */
  107970. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107971. /**
  107972. * Fired when the Y button on this controller is modified
  107973. */
  107974. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107975. /**
  107976. * Called once for each button that changed state since the last frame
  107977. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  107978. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  107979. * 2) secondary trigger (same)
  107980. * 3) A (right) X (left), touch, pressed = value
  107981. * 4) B / Y
  107982. * 5) thumb rest
  107983. * @param buttonIdx Which button index changed
  107984. * @param state New state of the button
  107985. * @param changes Which properties on the state changed since last frame
  107986. */
  107987. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  107988. }
  107989. }
  107990. declare module BABYLON {
  107991. /**
  107992. * Vive Controller
  107993. */
  107994. export class ViveController extends WebVRController {
  107995. /**
  107996. * Base Url for the controller model.
  107997. */
  107998. static MODEL_BASE_URL: string;
  107999. /**
  108000. * File name for the controller model.
  108001. */
  108002. static MODEL_FILENAME: string;
  108003. /**
  108004. * Creates a new ViveController from a gamepad
  108005. * @param vrGamepad the gamepad that the controller should be created from
  108006. */
  108007. constructor(vrGamepad: any);
  108008. /**
  108009. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  108010. * @param scene scene in which to add meshes
  108011. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  108012. */
  108013. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  108014. /**
  108015. * Fired when the left button on this controller is modified
  108016. */
  108017. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108018. /**
  108019. * Fired when the right button on this controller is modified
  108020. */
  108021. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108022. /**
  108023. * Fired when the menu button on this controller is modified
  108024. */
  108025. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108026. /**
  108027. * Called once for each button that changed state since the last frame
  108028. * Vive mapping:
  108029. * 0: touchpad
  108030. * 1: trigger
  108031. * 2: left AND right buttons
  108032. * 3: menu button
  108033. * @param buttonIdx Which button index changed
  108034. * @param state New state of the button
  108035. * @param changes Which properties on the state changed since last frame
  108036. */
  108037. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  108038. }
  108039. }
  108040. declare module BABYLON {
  108041. /**
  108042. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  108043. */
  108044. export class WebXRControllerModelLoader {
  108045. /**
  108046. * Creates the WebXRControllerModelLoader
  108047. * @param input xr input that creates the controllers
  108048. */
  108049. constructor(input: WebXRInput);
  108050. }
  108051. }
  108052. declare module BABYLON {
  108053. /**
  108054. * Contains an array of blocks representing the octree
  108055. */
  108056. export interface IOctreeContainer<T> {
  108057. /**
  108058. * Blocks within the octree
  108059. */
  108060. blocks: Array<OctreeBlock<T>>;
  108061. }
  108062. /**
  108063. * Class used to store a cell in an octree
  108064. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  108065. */
  108066. export class OctreeBlock<T> {
  108067. /**
  108068. * Gets the content of the current block
  108069. */
  108070. entries: T[];
  108071. /**
  108072. * Gets the list of block children
  108073. */
  108074. blocks: Array<OctreeBlock<T>>;
  108075. private _depth;
  108076. private _maxDepth;
  108077. private _capacity;
  108078. private _minPoint;
  108079. private _maxPoint;
  108080. private _boundingVectors;
  108081. private _creationFunc;
  108082. /**
  108083. * Creates a new block
  108084. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  108085. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  108086. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  108087. * @param depth defines the current depth of this block in the octree
  108088. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  108089. * @param creationFunc defines a callback to call when an element is added to the block
  108090. */
  108091. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  108092. /**
  108093. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  108094. */
  108095. readonly capacity: number;
  108096. /**
  108097. * Gets the minimum vector (in world space) of the block's bounding box
  108098. */
  108099. readonly minPoint: Vector3;
  108100. /**
  108101. * Gets the maximum vector (in world space) of the block's bounding box
  108102. */
  108103. readonly maxPoint: Vector3;
  108104. /**
  108105. * Add a new element to this block
  108106. * @param entry defines the element to add
  108107. */
  108108. addEntry(entry: T): void;
  108109. /**
  108110. * Remove an element from this block
  108111. * @param entry defines the element to remove
  108112. */
  108113. removeEntry(entry: T): void;
  108114. /**
  108115. * Add an array of elements to this block
  108116. * @param entries defines the array of elements to add
  108117. */
  108118. addEntries(entries: T[]): void;
  108119. /**
  108120. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  108121. * @param frustumPlanes defines the frustum planes to test
  108122. * @param selection defines the array to store current content if selection is positive
  108123. * @param allowDuplicate defines if the selection array can contains duplicated entries
  108124. */
  108125. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  108126. /**
  108127. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  108128. * @param sphereCenter defines the bounding sphere center
  108129. * @param sphereRadius defines the bounding sphere radius
  108130. * @param selection defines the array to store current content if selection is positive
  108131. * @param allowDuplicate defines if the selection array can contains duplicated entries
  108132. */
  108133. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  108134. /**
  108135. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  108136. * @param ray defines the ray to test with
  108137. * @param selection defines the array to store current content if selection is positive
  108138. */
  108139. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  108140. /**
  108141. * Subdivide the content into child blocks (this block will then be empty)
  108142. */
  108143. createInnerBlocks(): void;
  108144. /**
  108145. * @hidden
  108146. */
  108147. 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;
  108148. }
  108149. }
  108150. declare module BABYLON {
  108151. /**
  108152. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  108153. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  108154. */
  108155. export class Octree<T> {
  108156. /** 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.) */
  108157. maxDepth: number;
  108158. /**
  108159. * Blocks within the octree containing objects
  108160. */
  108161. blocks: Array<OctreeBlock<T>>;
  108162. /**
  108163. * Content stored in the octree
  108164. */
  108165. dynamicContent: T[];
  108166. private _maxBlockCapacity;
  108167. private _selectionContent;
  108168. private _creationFunc;
  108169. /**
  108170. * Creates a octree
  108171. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  108172. * @param creationFunc function to be used to instatiate the octree
  108173. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  108174. * @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.)
  108175. */
  108176. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  108177. /** 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.) */
  108178. maxDepth?: number);
  108179. /**
  108180. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  108181. * @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);
  108182. * @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);
  108183. * @param entries meshes to be added to the octree blocks
  108184. */
  108185. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  108186. /**
  108187. * Adds a mesh to the octree
  108188. * @param entry Mesh to add to the octree
  108189. */
  108190. addMesh(entry: T): void;
  108191. /**
  108192. * Remove an element from the octree
  108193. * @param entry defines the element to remove
  108194. */
  108195. removeMesh(entry: T): void;
  108196. /**
  108197. * Selects an array of meshes within the frustum
  108198. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  108199. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  108200. * @returns array of meshes within the frustum
  108201. */
  108202. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  108203. /**
  108204. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  108205. * @param sphereCenter defines the bounding sphere center
  108206. * @param sphereRadius defines the bounding sphere radius
  108207. * @param allowDuplicate defines if the selection array can contains duplicated entries
  108208. * @returns an array of objects that intersect the sphere
  108209. */
  108210. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  108211. /**
  108212. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  108213. * @param ray defines the ray to test with
  108214. * @returns array of intersected objects
  108215. */
  108216. intersectsRay(ray: Ray): SmartArray<T>;
  108217. /**
  108218. * Adds a mesh into the octree block if it intersects the block
  108219. */
  108220. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  108221. /**
  108222. * Adds a submesh into the octree block if it intersects the block
  108223. */
  108224. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  108225. }
  108226. }
  108227. declare module BABYLON {
  108228. interface Scene {
  108229. /**
  108230. * @hidden
  108231. * Backing Filed
  108232. */
  108233. _selectionOctree: Octree<AbstractMesh>;
  108234. /**
  108235. * Gets the octree used to boost mesh selection (picking)
  108236. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  108237. */
  108238. selectionOctree: Octree<AbstractMesh>;
  108239. /**
  108240. * Creates or updates the octree used to boost selection (picking)
  108241. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  108242. * @param maxCapacity defines the maximum capacity per leaf
  108243. * @param maxDepth defines the maximum depth of the octree
  108244. * @returns an octree of AbstractMesh
  108245. */
  108246. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  108247. }
  108248. interface AbstractMesh {
  108249. /**
  108250. * @hidden
  108251. * Backing Field
  108252. */
  108253. _submeshesOctree: Octree<SubMesh>;
  108254. /**
  108255. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  108256. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  108257. * @param maxCapacity defines the maximum size of each block (64 by default)
  108258. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  108259. * @returns the new octree
  108260. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  108261. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  108262. */
  108263. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  108264. }
  108265. /**
  108266. * Defines the octree scene component responsible to manage any octrees
  108267. * in a given scene.
  108268. */
  108269. export class OctreeSceneComponent {
  108270. /**
  108271. * The component name help to identify the component in the list of scene components.
  108272. */
  108273. readonly name: string;
  108274. /**
  108275. * The scene the component belongs to.
  108276. */
  108277. scene: Scene;
  108278. /**
  108279. * Indicates if the meshes have been checked to make sure they are isEnabled()
  108280. */
  108281. readonly checksIsEnabled: boolean;
  108282. /**
  108283. * Creates a new instance of the component for the given scene
  108284. * @param scene Defines the scene to register the component in
  108285. */
  108286. constructor(scene: Scene);
  108287. /**
  108288. * Registers the component in a given scene
  108289. */
  108290. register(): void;
  108291. /**
  108292. * Return the list of active meshes
  108293. * @returns the list of active meshes
  108294. */
  108295. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  108296. /**
  108297. * Return the list of active sub meshes
  108298. * @param mesh The mesh to get the candidates sub meshes from
  108299. * @returns the list of active sub meshes
  108300. */
  108301. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  108302. private _tempRay;
  108303. /**
  108304. * Return the list of sub meshes intersecting with a given local ray
  108305. * @param mesh defines the mesh to find the submesh for
  108306. * @param localRay defines the ray in local space
  108307. * @returns the list of intersecting sub meshes
  108308. */
  108309. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  108310. /**
  108311. * Return the list of sub meshes colliding with a collider
  108312. * @param mesh defines the mesh to find the submesh for
  108313. * @param collider defines the collider to evaluate the collision against
  108314. * @returns the list of colliding sub meshes
  108315. */
  108316. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  108317. /**
  108318. * Rebuilds the elements related to this component in case of
  108319. * context lost for instance.
  108320. */
  108321. rebuild(): void;
  108322. /**
  108323. * Disposes the component and the associated ressources.
  108324. */
  108325. dispose(): void;
  108326. }
  108327. }
  108328. declare module BABYLON {
  108329. /**
  108330. * Renders a layer on top of an existing scene
  108331. */
  108332. export class UtilityLayerRenderer implements IDisposable {
  108333. /** the original scene that will be rendered on top of */
  108334. originalScene: Scene;
  108335. private _pointerCaptures;
  108336. private _lastPointerEvents;
  108337. private static _DefaultUtilityLayer;
  108338. private static _DefaultKeepDepthUtilityLayer;
  108339. private _sharedGizmoLight;
  108340. private _renderCamera;
  108341. /**
  108342. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  108343. * @returns the camera that is used when rendering the utility layer
  108344. */
  108345. getRenderCamera(): Nullable<Camera>;
  108346. /**
  108347. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  108348. * @param cam the camera that should be used when rendering the utility layer
  108349. */
  108350. setRenderCamera(cam: Nullable<Camera>): void;
  108351. /**
  108352. * @hidden
  108353. * Light which used by gizmos to get light shading
  108354. */
  108355. _getSharedGizmoLight(): HemisphericLight;
  108356. /**
  108357. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  108358. */
  108359. pickUtilitySceneFirst: boolean;
  108360. /**
  108361. * 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)
  108362. */
  108363. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  108364. /**
  108365. * 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)
  108366. */
  108367. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  108368. /**
  108369. * The scene that is rendered on top of the original scene
  108370. */
  108371. utilityLayerScene: Scene;
  108372. /**
  108373. * If the utility layer should automatically be rendered on top of existing scene
  108374. */
  108375. shouldRender: boolean;
  108376. /**
  108377. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  108378. */
  108379. onlyCheckPointerDownEvents: boolean;
  108380. /**
  108381. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  108382. */
  108383. processAllEvents: boolean;
  108384. /**
  108385. * Observable raised when the pointer move from the utility layer scene to the main scene
  108386. */
  108387. onPointerOutObservable: Observable<number>;
  108388. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  108389. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  108390. private _afterRenderObserver;
  108391. private _sceneDisposeObserver;
  108392. private _originalPointerObserver;
  108393. /**
  108394. * Instantiates a UtilityLayerRenderer
  108395. * @param originalScene the original scene that will be rendered on top of
  108396. * @param handleEvents boolean indicating if the utility layer should handle events
  108397. */
  108398. constructor(
  108399. /** the original scene that will be rendered on top of */
  108400. originalScene: Scene, handleEvents?: boolean);
  108401. private _notifyObservers;
  108402. /**
  108403. * Renders the utility layers scene on top of the original scene
  108404. */
  108405. render(): void;
  108406. /**
  108407. * Disposes of the renderer
  108408. */
  108409. dispose(): void;
  108410. private _updateCamera;
  108411. }
  108412. }
  108413. declare module BABYLON {
  108414. /**
  108415. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  108416. */
  108417. export class Gizmo implements IDisposable {
  108418. /** The utility layer the gizmo will be added to */
  108419. gizmoLayer: UtilityLayerRenderer;
  108420. /**
  108421. * The root mesh of the gizmo
  108422. */
  108423. _rootMesh: Mesh;
  108424. private _attachedMesh;
  108425. /**
  108426. * Ratio for the scale of the gizmo (Default: 1)
  108427. */
  108428. scaleRatio: number;
  108429. /**
  108430. * If a custom mesh has been set (Default: false)
  108431. */
  108432. protected _customMeshSet: boolean;
  108433. /**
  108434. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  108435. * * When set, interactions will be enabled
  108436. */
  108437. attachedMesh: Nullable<AbstractMesh>;
  108438. /**
  108439. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  108440. * @param mesh The mesh to replace the default mesh of the gizmo
  108441. */
  108442. setCustomMesh(mesh: Mesh): void;
  108443. /**
  108444. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  108445. */
  108446. updateGizmoRotationToMatchAttachedMesh: boolean;
  108447. /**
  108448. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  108449. */
  108450. updateGizmoPositionToMatchAttachedMesh: boolean;
  108451. /**
  108452. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  108453. */
  108454. updateScale: boolean;
  108455. protected _interactionsEnabled: boolean;
  108456. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  108457. private _beforeRenderObserver;
  108458. private _tempVector;
  108459. /**
  108460. * Creates a gizmo
  108461. * @param gizmoLayer The utility layer the gizmo will be added to
  108462. */
  108463. constructor(
  108464. /** The utility layer the gizmo will be added to */
  108465. gizmoLayer?: UtilityLayerRenderer);
  108466. /**
  108467. * Updates the gizmo to match the attached mesh's position/rotation
  108468. */
  108469. protected _update(): void;
  108470. /**
  108471. * Disposes of the gizmo
  108472. */
  108473. dispose(): void;
  108474. }
  108475. }
  108476. declare module BABYLON {
  108477. /**
  108478. * Single plane drag gizmo
  108479. */
  108480. export class PlaneDragGizmo extends Gizmo {
  108481. /**
  108482. * Drag behavior responsible for the gizmos dragging interactions
  108483. */
  108484. dragBehavior: PointerDragBehavior;
  108485. private _pointerObserver;
  108486. /**
  108487. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  108488. */
  108489. snapDistance: number;
  108490. /**
  108491. * Event that fires each time the gizmo snaps to a new location.
  108492. * * snapDistance is the the change in distance
  108493. */
  108494. onSnapObservable: Observable<{
  108495. snapDistance: number;
  108496. }>;
  108497. private _plane;
  108498. private _coloredMaterial;
  108499. private _hoverMaterial;
  108500. private _isEnabled;
  108501. private _parent;
  108502. /** @hidden */
  108503. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  108504. /** @hidden */
  108505. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  108506. /**
  108507. * Creates a PlaneDragGizmo
  108508. * @param gizmoLayer The utility layer the gizmo will be added to
  108509. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  108510. * @param color The color of the gizmo
  108511. */
  108512. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  108513. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  108514. /**
  108515. * If the gizmo is enabled
  108516. */
  108517. isEnabled: boolean;
  108518. /**
  108519. * Disposes of the gizmo
  108520. */
  108521. dispose(): void;
  108522. }
  108523. }
  108524. declare module BABYLON {
  108525. /**
  108526. * Gizmo that enables dragging a mesh along 3 axis
  108527. */
  108528. export class PositionGizmo extends Gizmo {
  108529. /**
  108530. * Internal gizmo used for interactions on the x axis
  108531. */
  108532. xGizmo: AxisDragGizmo;
  108533. /**
  108534. * Internal gizmo used for interactions on the y axis
  108535. */
  108536. yGizmo: AxisDragGizmo;
  108537. /**
  108538. * Internal gizmo used for interactions on the z axis
  108539. */
  108540. zGizmo: AxisDragGizmo;
  108541. /**
  108542. * Internal gizmo used for interactions on the yz plane
  108543. */
  108544. xPlaneGizmo: PlaneDragGizmo;
  108545. /**
  108546. * Internal gizmo used for interactions on the xz plane
  108547. */
  108548. yPlaneGizmo: PlaneDragGizmo;
  108549. /**
  108550. * Internal gizmo used for interactions on the xy plane
  108551. */
  108552. zPlaneGizmo: PlaneDragGizmo;
  108553. /**
  108554. * private variables
  108555. */
  108556. private _meshAttached;
  108557. private _updateGizmoRotationToMatchAttachedMesh;
  108558. private _snapDistance;
  108559. private _scaleRatio;
  108560. /** Fires an event when any of it's sub gizmos are dragged */
  108561. onDragStartObservable: Observable<unknown>;
  108562. /** Fires an event when any of it's sub gizmos are released from dragging */
  108563. onDragEndObservable: Observable<unknown>;
  108564. /**
  108565. * If set to true, planar drag is enabled
  108566. */
  108567. private _planarGizmoEnabled;
  108568. attachedMesh: Nullable<AbstractMesh>;
  108569. /**
  108570. * Creates a PositionGizmo
  108571. * @param gizmoLayer The utility layer the gizmo will be added to
  108572. */
  108573. constructor(gizmoLayer?: UtilityLayerRenderer);
  108574. /**
  108575. * If the planar drag gizmo is enabled
  108576. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  108577. */
  108578. planarGizmoEnabled: boolean;
  108579. updateGizmoRotationToMatchAttachedMesh: boolean;
  108580. /**
  108581. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  108582. */
  108583. snapDistance: number;
  108584. /**
  108585. * Ratio for the scale of the gizmo (Default: 1)
  108586. */
  108587. scaleRatio: number;
  108588. /**
  108589. * Disposes of the gizmo
  108590. */
  108591. dispose(): void;
  108592. /**
  108593. * CustomMeshes are not supported by this gizmo
  108594. * @param mesh The mesh to replace the default mesh of the gizmo
  108595. */
  108596. setCustomMesh(mesh: Mesh): void;
  108597. }
  108598. }
  108599. declare module BABYLON {
  108600. /**
  108601. * Single axis drag gizmo
  108602. */
  108603. export class AxisDragGizmo extends Gizmo {
  108604. /**
  108605. * Drag behavior responsible for the gizmos dragging interactions
  108606. */
  108607. dragBehavior: PointerDragBehavior;
  108608. private _pointerObserver;
  108609. /**
  108610. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  108611. */
  108612. snapDistance: number;
  108613. /**
  108614. * Event that fires each time the gizmo snaps to a new location.
  108615. * * snapDistance is the the change in distance
  108616. */
  108617. onSnapObservable: Observable<{
  108618. snapDistance: number;
  108619. }>;
  108620. private _isEnabled;
  108621. private _parent;
  108622. private _arrow;
  108623. private _coloredMaterial;
  108624. private _hoverMaterial;
  108625. /** @hidden */
  108626. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  108627. /** @hidden */
  108628. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  108629. /**
  108630. * Creates an AxisDragGizmo
  108631. * @param gizmoLayer The utility layer the gizmo will be added to
  108632. * @param dragAxis The axis which the gizmo will be able to drag on
  108633. * @param color The color of the gizmo
  108634. */
  108635. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  108636. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  108637. /**
  108638. * If the gizmo is enabled
  108639. */
  108640. isEnabled: boolean;
  108641. /**
  108642. * Disposes of the gizmo
  108643. */
  108644. dispose(): void;
  108645. }
  108646. }
  108647. declare module BABYLON.Debug {
  108648. /**
  108649. * The Axes viewer will show 3 axes in a specific point in space
  108650. */
  108651. export class AxesViewer {
  108652. private _xAxis;
  108653. private _yAxis;
  108654. private _zAxis;
  108655. private _scaleLinesFactor;
  108656. private _instanced;
  108657. /**
  108658. * Gets the hosting scene
  108659. */
  108660. scene: Scene;
  108661. /**
  108662. * Gets or sets a number used to scale line length
  108663. */
  108664. scaleLines: number;
  108665. /** Gets the node hierarchy used to render x-axis */
  108666. readonly xAxis: TransformNode;
  108667. /** Gets the node hierarchy used to render y-axis */
  108668. readonly yAxis: TransformNode;
  108669. /** Gets the node hierarchy used to render z-axis */
  108670. readonly zAxis: TransformNode;
  108671. /**
  108672. * Creates a new AxesViewer
  108673. * @param scene defines the hosting scene
  108674. * @param scaleLines defines a number used to scale line length (1 by default)
  108675. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  108676. * @param xAxis defines the node hierarchy used to render the x-axis
  108677. * @param yAxis defines the node hierarchy used to render the y-axis
  108678. * @param zAxis defines the node hierarchy used to render the z-axis
  108679. */
  108680. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  108681. /**
  108682. * Force the viewer to update
  108683. * @param position defines the position of the viewer
  108684. * @param xaxis defines the x axis of the viewer
  108685. * @param yaxis defines the y axis of the viewer
  108686. * @param zaxis defines the z axis of the viewer
  108687. */
  108688. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  108689. /**
  108690. * Creates an instance of this axes viewer.
  108691. * @returns a new axes viewer with instanced meshes
  108692. */
  108693. createInstance(): AxesViewer;
  108694. /** Releases resources */
  108695. dispose(): void;
  108696. private static _SetRenderingGroupId;
  108697. }
  108698. }
  108699. declare module BABYLON.Debug {
  108700. /**
  108701. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  108702. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  108703. */
  108704. export class BoneAxesViewer extends AxesViewer {
  108705. /**
  108706. * Gets or sets the target mesh where to display the axes viewer
  108707. */
  108708. mesh: Nullable<Mesh>;
  108709. /**
  108710. * Gets or sets the target bone where to display the axes viewer
  108711. */
  108712. bone: Nullable<Bone>;
  108713. /** Gets current position */
  108714. pos: Vector3;
  108715. /** Gets direction of X axis */
  108716. xaxis: Vector3;
  108717. /** Gets direction of Y axis */
  108718. yaxis: Vector3;
  108719. /** Gets direction of Z axis */
  108720. zaxis: Vector3;
  108721. /**
  108722. * Creates a new BoneAxesViewer
  108723. * @param scene defines the hosting scene
  108724. * @param bone defines the target bone
  108725. * @param mesh defines the target mesh
  108726. * @param scaleLines defines a scaling factor for line length (1 by default)
  108727. */
  108728. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  108729. /**
  108730. * Force the viewer to update
  108731. */
  108732. update(): void;
  108733. /** Releases resources */
  108734. dispose(): void;
  108735. }
  108736. }
  108737. declare module BABYLON {
  108738. /**
  108739. * Interface used to define scene explorer extensibility option
  108740. */
  108741. export interface IExplorerExtensibilityOption {
  108742. /**
  108743. * Define the option label
  108744. */
  108745. label: string;
  108746. /**
  108747. * Defines the action to execute on click
  108748. */
  108749. action: (entity: any) => void;
  108750. }
  108751. /**
  108752. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  108753. */
  108754. export interface IExplorerExtensibilityGroup {
  108755. /**
  108756. * Defines a predicate to test if a given type mut be extended
  108757. */
  108758. predicate: (entity: any) => boolean;
  108759. /**
  108760. * Gets the list of options added to a type
  108761. */
  108762. entries: IExplorerExtensibilityOption[];
  108763. }
  108764. /**
  108765. * Interface used to define the options to use to create the Inspector
  108766. */
  108767. export interface IInspectorOptions {
  108768. /**
  108769. * Display in overlay mode (default: false)
  108770. */
  108771. overlay?: boolean;
  108772. /**
  108773. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  108774. */
  108775. globalRoot?: HTMLElement;
  108776. /**
  108777. * Display the Scene explorer
  108778. */
  108779. showExplorer?: boolean;
  108780. /**
  108781. * Display the property inspector
  108782. */
  108783. showInspector?: boolean;
  108784. /**
  108785. * Display in embed mode (both panes on the right)
  108786. */
  108787. embedMode?: boolean;
  108788. /**
  108789. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  108790. */
  108791. handleResize?: boolean;
  108792. /**
  108793. * Allow the panes to popup (default: true)
  108794. */
  108795. enablePopup?: boolean;
  108796. /**
  108797. * Allow the panes to be closed by users (default: true)
  108798. */
  108799. enableClose?: boolean;
  108800. /**
  108801. * Optional list of extensibility entries
  108802. */
  108803. explorerExtensibility?: IExplorerExtensibilityGroup[];
  108804. /**
  108805. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  108806. */
  108807. inspectorURL?: string;
  108808. }
  108809. interface Scene {
  108810. /**
  108811. * @hidden
  108812. * Backing field
  108813. */
  108814. _debugLayer: DebugLayer;
  108815. /**
  108816. * Gets the debug layer (aka Inspector) associated with the scene
  108817. * @see http://doc.babylonjs.com/features/playground_debuglayer
  108818. */
  108819. debugLayer: DebugLayer;
  108820. }
  108821. /**
  108822. * The debug layer (aka Inspector) is the go to tool in order to better understand
  108823. * what is happening in your scene
  108824. * @see http://doc.babylonjs.com/features/playground_debuglayer
  108825. */
  108826. export class DebugLayer {
  108827. /**
  108828. * Define the url to get the inspector script from.
  108829. * By default it uses the babylonjs CDN.
  108830. * @ignoreNaming
  108831. */
  108832. static InspectorURL: string;
  108833. private _scene;
  108834. private BJSINSPECTOR;
  108835. private _onPropertyChangedObservable?;
  108836. /**
  108837. * Observable triggered when a property is changed through the inspector.
  108838. */
  108839. readonly onPropertyChangedObservable: any;
  108840. /**
  108841. * Instantiates a new debug layer.
  108842. * The debug layer (aka Inspector) is the go to tool in order to better understand
  108843. * what is happening in your scene
  108844. * @see http://doc.babylonjs.com/features/playground_debuglayer
  108845. * @param scene Defines the scene to inspect
  108846. */
  108847. constructor(scene: Scene);
  108848. /** Creates the inspector window. */
  108849. private _createInspector;
  108850. /**
  108851. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  108852. * @param entity defines the entity to select
  108853. * @param lineContainerTitle defines the specific block to highlight
  108854. */
  108855. select(entity: any, lineContainerTitle?: string): void;
  108856. /** Get the inspector from bundle or global */
  108857. private _getGlobalInspector;
  108858. /**
  108859. * Get if the inspector is visible or not.
  108860. * @returns true if visible otherwise, false
  108861. */
  108862. isVisible(): boolean;
  108863. /**
  108864. * Hide the inspector and close its window.
  108865. */
  108866. hide(): void;
  108867. /**
  108868. * Launch the debugLayer.
  108869. * @param config Define the configuration of the inspector
  108870. * @return a promise fulfilled when the debug layer is visible
  108871. */
  108872. show(config?: IInspectorOptions): Promise<DebugLayer>;
  108873. }
  108874. }
  108875. declare module BABYLON {
  108876. /**
  108877. * Class containing static functions to help procedurally build meshes
  108878. */
  108879. export class BoxBuilder {
  108880. /**
  108881. * Creates a box mesh
  108882. * * The parameter `size` sets the size (float) of each box side (default 1)
  108883. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  108884. * * 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)
  108885. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  108886. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108887. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108888. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108889. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  108890. * @param name defines the name of the mesh
  108891. * @param options defines the options used to create the mesh
  108892. * @param scene defines the hosting scene
  108893. * @returns the box mesh
  108894. */
  108895. static CreateBox(name: string, options: {
  108896. size?: number;
  108897. width?: number;
  108898. height?: number;
  108899. depth?: number;
  108900. faceUV?: Vector4[];
  108901. faceColors?: Color4[];
  108902. sideOrientation?: number;
  108903. frontUVs?: Vector4;
  108904. backUVs?: Vector4;
  108905. wrap?: boolean;
  108906. topBaseAt?: number;
  108907. bottomBaseAt?: number;
  108908. updatable?: boolean;
  108909. }, scene?: Nullable<Scene>): Mesh;
  108910. }
  108911. }
  108912. declare module BABYLON {
  108913. /**
  108914. * Class containing static functions to help procedurally build meshes
  108915. */
  108916. export class SphereBuilder {
  108917. /**
  108918. * Creates a sphere mesh
  108919. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  108920. * * 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`)
  108921. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  108922. * * 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
  108923. * * 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)
  108924. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  108925. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  108926. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  108927. * @param name defines the name of the mesh
  108928. * @param options defines the options used to create the mesh
  108929. * @param scene defines the hosting scene
  108930. * @returns the sphere mesh
  108931. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  108932. */
  108933. static CreateSphere(name: string, options: {
  108934. segments?: number;
  108935. diameter?: number;
  108936. diameterX?: number;
  108937. diameterY?: number;
  108938. diameterZ?: number;
  108939. arc?: number;
  108940. slice?: number;
  108941. sideOrientation?: number;
  108942. frontUVs?: Vector4;
  108943. backUVs?: Vector4;
  108944. updatable?: boolean;
  108945. }, scene?: Nullable<Scene>): Mesh;
  108946. }
  108947. }
  108948. declare module BABYLON.Debug {
  108949. /**
  108950. * Used to show the physics impostor around the specific mesh
  108951. */
  108952. export class PhysicsViewer {
  108953. /** @hidden */
  108954. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  108955. /** @hidden */
  108956. protected _meshes: Array<Nullable<AbstractMesh>>;
  108957. /** @hidden */
  108958. protected _scene: Nullable<Scene>;
  108959. /** @hidden */
  108960. protected _numMeshes: number;
  108961. /** @hidden */
  108962. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  108963. private _renderFunction;
  108964. private _utilityLayer;
  108965. private _debugBoxMesh;
  108966. private _debugSphereMesh;
  108967. private _debugCylinderMesh;
  108968. private _debugMaterial;
  108969. private _debugMeshMeshes;
  108970. /**
  108971. * Creates a new PhysicsViewer
  108972. * @param scene defines the hosting scene
  108973. */
  108974. constructor(scene: Scene);
  108975. /** @hidden */
  108976. protected _updateDebugMeshes(): void;
  108977. /**
  108978. * Renders a specified physic impostor
  108979. * @param impostor defines the impostor to render
  108980. * @param targetMesh defines the mesh represented by the impostor
  108981. * @returns the new debug mesh used to render the impostor
  108982. */
  108983. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  108984. /**
  108985. * Hides a specified physic impostor
  108986. * @param impostor defines the impostor to hide
  108987. */
  108988. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  108989. private _getDebugMaterial;
  108990. private _getDebugBoxMesh;
  108991. private _getDebugSphereMesh;
  108992. private _getDebugCylinderMesh;
  108993. private _getDebugMeshMesh;
  108994. private _getDebugMesh;
  108995. /** Releases all resources */
  108996. dispose(): void;
  108997. }
  108998. }
  108999. declare module BABYLON {
  109000. /**
  109001. * Class containing static functions to help procedurally build meshes
  109002. */
  109003. export class LinesBuilder {
  109004. /**
  109005. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  109006. * * 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
  109007. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  109008. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  109009. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  109010. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  109011. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  109012. * * 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
  109013. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  109014. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109015. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  109016. * @param name defines the name of the new line system
  109017. * @param options defines the options used to create the line system
  109018. * @param scene defines the hosting scene
  109019. * @returns a new line system mesh
  109020. */
  109021. static CreateLineSystem(name: string, options: {
  109022. lines: Vector3[][];
  109023. updatable?: boolean;
  109024. instance?: Nullable<LinesMesh>;
  109025. colors?: Nullable<Color4[][]>;
  109026. useVertexAlpha?: boolean;
  109027. }, scene: Nullable<Scene>): LinesMesh;
  109028. /**
  109029. * Creates a line mesh
  109030. * 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
  109031. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  109032. * * The parameter `points` is an array successive Vector3
  109033. * * 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
  109034. * * The optional parameter `colors` is an array of successive Color4, one per line point
  109035. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  109036. * * When updating an instance, remember that only point positions can change, not the number of points
  109037. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109038. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  109039. * @param name defines the name of the new line system
  109040. * @param options defines the options used to create the line system
  109041. * @param scene defines the hosting scene
  109042. * @returns a new line mesh
  109043. */
  109044. static CreateLines(name: string, options: {
  109045. points: Vector3[];
  109046. updatable?: boolean;
  109047. instance?: Nullable<LinesMesh>;
  109048. colors?: Color4[];
  109049. useVertexAlpha?: boolean;
  109050. }, scene?: Nullable<Scene>): LinesMesh;
  109051. /**
  109052. * Creates a dashed line mesh
  109053. * * 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
  109054. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  109055. * * The parameter `points` is an array successive Vector3
  109056. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  109057. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  109058. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  109059. * * 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
  109060. * * When updating an instance, remember that only point positions can change, not the number of points
  109061. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109062. * @param name defines the name of the mesh
  109063. * @param options defines the options used to create the mesh
  109064. * @param scene defines the hosting scene
  109065. * @returns the dashed line mesh
  109066. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  109067. */
  109068. static CreateDashedLines(name: string, options: {
  109069. points: Vector3[];
  109070. dashSize?: number;
  109071. gapSize?: number;
  109072. dashNb?: number;
  109073. updatable?: boolean;
  109074. instance?: LinesMesh;
  109075. }, scene?: Nullable<Scene>): LinesMesh;
  109076. }
  109077. }
  109078. declare module BABYLON {
  109079. /**
  109080. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  109081. * in order to better appreciate the issue one might have.
  109082. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  109083. */
  109084. export class RayHelper {
  109085. /**
  109086. * Defines the ray we are currently tryin to visualize.
  109087. */
  109088. ray: Nullable<Ray>;
  109089. private _renderPoints;
  109090. private _renderLine;
  109091. private _renderFunction;
  109092. private _scene;
  109093. private _updateToMeshFunction;
  109094. private _attachedToMesh;
  109095. private _meshSpaceDirection;
  109096. private _meshSpaceOrigin;
  109097. /**
  109098. * Helper function to create a colored helper in a scene in one line.
  109099. * @param ray Defines the ray we are currently tryin to visualize
  109100. * @param scene Defines the scene the ray is used in
  109101. * @param color Defines the color we want to see the ray in
  109102. * @returns The newly created ray helper.
  109103. */
  109104. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  109105. /**
  109106. * Instantiate a new ray helper.
  109107. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  109108. * in order to better appreciate the issue one might have.
  109109. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  109110. * @param ray Defines the ray we are currently tryin to visualize
  109111. */
  109112. constructor(ray: Ray);
  109113. /**
  109114. * Shows the ray we are willing to debug.
  109115. * @param scene Defines the scene the ray needs to be rendered in
  109116. * @param color Defines the color the ray needs to be rendered in
  109117. */
  109118. show(scene: Scene, color?: Color3): void;
  109119. /**
  109120. * Hides the ray we are debugging.
  109121. */
  109122. hide(): void;
  109123. private _render;
  109124. /**
  109125. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  109126. * @param mesh Defines the mesh we want the helper attached to
  109127. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  109128. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  109129. * @param length Defines the length of the ray
  109130. */
  109131. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  109132. /**
  109133. * Detach the ray helper from the mesh it has previously been attached to.
  109134. */
  109135. detachFromMesh(): void;
  109136. private _updateToMesh;
  109137. /**
  109138. * Dispose the helper and release its associated resources.
  109139. */
  109140. dispose(): void;
  109141. }
  109142. }
  109143. declare module BABYLON.Debug {
  109144. /**
  109145. * Class used to render a debug view of a given skeleton
  109146. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  109147. */
  109148. export class SkeletonViewer {
  109149. /** defines the skeleton to render */
  109150. skeleton: Skeleton;
  109151. /** defines the mesh attached to the skeleton */
  109152. mesh: AbstractMesh;
  109153. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  109154. autoUpdateBonesMatrices: boolean;
  109155. /** defines the rendering group id to use with the viewer */
  109156. renderingGroupId: number;
  109157. /** Gets or sets the color used to render the skeleton */
  109158. color: Color3;
  109159. private _scene;
  109160. private _debugLines;
  109161. private _debugMesh;
  109162. private _isEnabled;
  109163. private _renderFunction;
  109164. private _utilityLayer;
  109165. /**
  109166. * Returns the mesh used to render the bones
  109167. */
  109168. readonly debugMesh: Nullable<LinesMesh>;
  109169. /**
  109170. * Creates a new SkeletonViewer
  109171. * @param skeleton defines the skeleton to render
  109172. * @param mesh defines the mesh attached to the skeleton
  109173. * @param scene defines the hosting scene
  109174. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  109175. * @param renderingGroupId defines the rendering group id to use with the viewer
  109176. */
  109177. constructor(
  109178. /** defines the skeleton to render */
  109179. skeleton: Skeleton,
  109180. /** defines the mesh attached to the skeleton */
  109181. mesh: AbstractMesh, scene: Scene,
  109182. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  109183. autoUpdateBonesMatrices?: boolean,
  109184. /** defines the rendering group id to use with the viewer */
  109185. renderingGroupId?: number);
  109186. /** Gets or sets a boolean indicating if the viewer is enabled */
  109187. isEnabled: boolean;
  109188. private _getBonePosition;
  109189. private _getLinesForBonesWithLength;
  109190. private _getLinesForBonesNoLength;
  109191. /** Update the viewer to sync with current skeleton state */
  109192. update(): void;
  109193. /** Release associated resources */
  109194. dispose(): void;
  109195. }
  109196. }
  109197. declare module BABYLON {
  109198. /**
  109199. * Options to create the null engine
  109200. */
  109201. export class NullEngineOptions {
  109202. /**
  109203. * Render width (Default: 512)
  109204. */
  109205. renderWidth: number;
  109206. /**
  109207. * Render height (Default: 256)
  109208. */
  109209. renderHeight: number;
  109210. /**
  109211. * Texture size (Default: 512)
  109212. */
  109213. textureSize: number;
  109214. /**
  109215. * If delta time between frames should be constant
  109216. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109217. */
  109218. deterministicLockstep: boolean;
  109219. /**
  109220. * Maximum about of steps between frames (Default: 4)
  109221. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109222. */
  109223. lockstepMaxSteps: number;
  109224. }
  109225. /**
  109226. * The null engine class provides support for headless version of babylon.js.
  109227. * This can be used in server side scenario or for testing purposes
  109228. */
  109229. export class NullEngine extends Engine {
  109230. private _options;
  109231. /**
  109232. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109233. */
  109234. isDeterministicLockStep(): boolean;
  109235. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  109236. getLockstepMaxSteps(): number;
  109237. /**
  109238. * Sets hardware scaling, used to save performance if needed
  109239. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109240. */
  109241. getHardwareScalingLevel(): number;
  109242. constructor(options?: NullEngineOptions);
  109243. createVertexBuffer(vertices: FloatArray): DataBuffer;
  109244. createIndexBuffer(indices: IndicesArray): DataBuffer;
  109245. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  109246. getRenderWidth(useScreen?: boolean): number;
  109247. getRenderHeight(useScreen?: boolean): number;
  109248. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  109249. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  109250. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  109251. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  109252. bindSamplers(effect: Effect): void;
  109253. enableEffect(effect: Effect): void;
  109254. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  109255. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  109256. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  109257. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  109258. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  109259. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  109260. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  109261. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  109262. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  109263. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  109264. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  109265. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  109266. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  109267. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  109268. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  109269. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  109270. setFloat(uniform: WebGLUniformLocation, value: number): void;
  109271. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  109272. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  109273. setBool(uniform: WebGLUniformLocation, bool: number): void;
  109274. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  109275. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  109276. bindBuffers(vertexBuffers: {
  109277. [key: string]: VertexBuffer;
  109278. }, indexBuffer: DataBuffer, effect: Effect): void;
  109279. wipeCaches(bruteForce?: boolean): void;
  109280. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  109281. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  109282. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  109283. /** @hidden */
  109284. _createTexture(): WebGLTexture;
  109285. /** @hidden */
  109286. _releaseTexture(texture: InternalTexture): void;
  109287. 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;
  109288. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  109289. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  109290. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  109291. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  109292. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  109293. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  109294. areAllEffectsReady(): boolean;
  109295. /**
  109296. * @hidden
  109297. * Get the current error code of the webGL context
  109298. * @returns the error code
  109299. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  109300. */
  109301. getError(): number;
  109302. /** @hidden */
  109303. _getUnpackAlignement(): number;
  109304. /** @hidden */
  109305. _unpackFlipY(value: boolean): void;
  109306. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  109307. /**
  109308. * Updates a dynamic vertex buffer.
  109309. * @param vertexBuffer the vertex buffer to update
  109310. * @param data the data used to update the vertex buffer
  109311. * @param byteOffset the byte offset of the data (optional)
  109312. * @param byteLength the byte length of the data (optional)
  109313. */
  109314. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  109315. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  109316. /** @hidden */
  109317. _bindTexture(channel: number, texture: InternalTexture): void;
  109318. protected _deleteBuffer(buffer: WebGLBuffer): void;
  109319. releaseEffects(): void;
  109320. displayLoadingUI(): void;
  109321. hideLoadingUI(): void;
  109322. /** @hidden */
  109323. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  109324. /** @hidden */
  109325. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  109326. /** @hidden */
  109327. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  109328. /** @hidden */
  109329. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  109330. }
  109331. }
  109332. declare module BABYLON {
  109333. /** @hidden */
  109334. export class _OcclusionDataStorage {
  109335. /** @hidden */
  109336. occlusionInternalRetryCounter: number;
  109337. /** @hidden */
  109338. isOcclusionQueryInProgress: boolean;
  109339. /** @hidden */
  109340. isOccluded: boolean;
  109341. /** @hidden */
  109342. occlusionRetryCount: number;
  109343. /** @hidden */
  109344. occlusionType: number;
  109345. /** @hidden */
  109346. occlusionQueryAlgorithmType: number;
  109347. }
  109348. interface Engine {
  109349. /**
  109350. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  109351. * @return the new query
  109352. */
  109353. createQuery(): WebGLQuery;
  109354. /**
  109355. * Delete and release a webGL query
  109356. * @param query defines the query to delete
  109357. * @return the current engine
  109358. */
  109359. deleteQuery(query: WebGLQuery): Engine;
  109360. /**
  109361. * Check if a given query has resolved and got its value
  109362. * @param query defines the query to check
  109363. * @returns true if the query got its value
  109364. */
  109365. isQueryResultAvailable(query: WebGLQuery): boolean;
  109366. /**
  109367. * Gets the value of a given query
  109368. * @param query defines the query to check
  109369. * @returns the value of the query
  109370. */
  109371. getQueryResult(query: WebGLQuery): number;
  109372. /**
  109373. * Initiates an occlusion query
  109374. * @param algorithmType defines the algorithm to use
  109375. * @param query defines the query to use
  109376. * @returns the current engine
  109377. * @see http://doc.babylonjs.com/features/occlusionquery
  109378. */
  109379. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  109380. /**
  109381. * Ends an occlusion query
  109382. * @see http://doc.babylonjs.com/features/occlusionquery
  109383. * @param algorithmType defines the algorithm to use
  109384. * @returns the current engine
  109385. */
  109386. endOcclusionQuery(algorithmType: number): Engine;
  109387. /**
  109388. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  109389. * Please note that only one query can be issued at a time
  109390. * @returns a time token used to track the time span
  109391. */
  109392. startTimeQuery(): Nullable<_TimeToken>;
  109393. /**
  109394. * Ends a time query
  109395. * @param token defines the token used to measure the time span
  109396. * @returns the time spent (in ns)
  109397. */
  109398. endTimeQuery(token: _TimeToken): int;
  109399. /** @hidden */
  109400. _currentNonTimestampToken: Nullable<_TimeToken>;
  109401. /** @hidden */
  109402. _createTimeQuery(): WebGLQuery;
  109403. /** @hidden */
  109404. _deleteTimeQuery(query: WebGLQuery): void;
  109405. /** @hidden */
  109406. _getGlAlgorithmType(algorithmType: number): number;
  109407. /** @hidden */
  109408. _getTimeQueryResult(query: WebGLQuery): any;
  109409. /** @hidden */
  109410. _getTimeQueryAvailability(query: WebGLQuery): any;
  109411. }
  109412. interface AbstractMesh {
  109413. /**
  109414. * Backing filed
  109415. * @hidden
  109416. */
  109417. __occlusionDataStorage: _OcclusionDataStorage;
  109418. /**
  109419. * Access property
  109420. * @hidden
  109421. */
  109422. _occlusionDataStorage: _OcclusionDataStorage;
  109423. /**
  109424. * 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.
  109425. * The default value is -1 which means don't break the query and wait till the result
  109426. * @see http://doc.babylonjs.com/features/occlusionquery
  109427. */
  109428. occlusionRetryCount: number;
  109429. /**
  109430. * 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:
  109431. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  109432. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  109433. * * 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.
  109434. * @see http://doc.babylonjs.com/features/occlusionquery
  109435. */
  109436. occlusionType: number;
  109437. /**
  109438. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  109439. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  109440. * * 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.
  109441. * @see http://doc.babylonjs.com/features/occlusionquery
  109442. */
  109443. occlusionQueryAlgorithmType: number;
  109444. /**
  109445. * 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
  109446. * @see http://doc.babylonjs.com/features/occlusionquery
  109447. */
  109448. isOccluded: boolean;
  109449. /**
  109450. * Flag to check the progress status of the query
  109451. * @see http://doc.babylonjs.com/features/occlusionquery
  109452. */
  109453. isOcclusionQueryInProgress: boolean;
  109454. }
  109455. }
  109456. declare module BABYLON {
  109457. /** @hidden */
  109458. export var _forceTransformFeedbackToBundle: boolean;
  109459. interface Engine {
  109460. /**
  109461. * Creates a webGL transform feedback object
  109462. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  109463. * @returns the webGL transform feedback object
  109464. */
  109465. createTransformFeedback(): WebGLTransformFeedback;
  109466. /**
  109467. * Delete a webGL transform feedback object
  109468. * @param value defines the webGL transform feedback object to delete
  109469. */
  109470. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  109471. /**
  109472. * Bind a webGL transform feedback object to the webgl context
  109473. * @param value defines the webGL transform feedback object to bind
  109474. */
  109475. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  109476. /**
  109477. * Begins a transform feedback operation
  109478. * @param usePoints defines if points or triangles must be used
  109479. */
  109480. beginTransformFeedback(usePoints: boolean): void;
  109481. /**
  109482. * Ends a transform feedback operation
  109483. */
  109484. endTransformFeedback(): void;
  109485. /**
  109486. * Specify the varyings to use with transform feedback
  109487. * @param program defines the associated webGL program
  109488. * @param value defines the list of strings representing the varying names
  109489. */
  109490. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  109491. /**
  109492. * Bind a webGL buffer for a transform feedback operation
  109493. * @param value defines the webGL buffer to bind
  109494. */
  109495. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  109496. }
  109497. }
  109498. declare module BABYLON {
  109499. /**
  109500. * Creation options of the multi render target texture.
  109501. */
  109502. export interface IMultiRenderTargetOptions {
  109503. /**
  109504. * Define if the texture needs to create mip maps after render.
  109505. */
  109506. generateMipMaps?: boolean;
  109507. /**
  109508. * Define the types of all the draw buffers we want to create
  109509. */
  109510. types?: number[];
  109511. /**
  109512. * Define the sampling modes of all the draw buffers we want to create
  109513. */
  109514. samplingModes?: number[];
  109515. /**
  109516. * Define if a depth buffer is required
  109517. */
  109518. generateDepthBuffer?: boolean;
  109519. /**
  109520. * Define if a stencil buffer is required
  109521. */
  109522. generateStencilBuffer?: boolean;
  109523. /**
  109524. * Define if a depth texture is required instead of a depth buffer
  109525. */
  109526. generateDepthTexture?: boolean;
  109527. /**
  109528. * Define the number of desired draw buffers
  109529. */
  109530. textureCount?: number;
  109531. /**
  109532. * Define if aspect ratio should be adapted to the texture or stay the scene one
  109533. */
  109534. doNotChangeAspectRatio?: boolean;
  109535. /**
  109536. * Define the default type of the buffers we are creating
  109537. */
  109538. defaultType?: number;
  109539. }
  109540. /**
  109541. * A multi render target, like a render target provides the ability to render to a texture.
  109542. * Unlike the render target, it can render to several draw buffers in one draw.
  109543. * This is specially interesting in deferred rendering or for any effects requiring more than
  109544. * just one color from a single pass.
  109545. */
  109546. export class MultiRenderTarget extends RenderTargetTexture {
  109547. private _internalTextures;
  109548. private _textures;
  109549. private _multiRenderTargetOptions;
  109550. /**
  109551. * Get if draw buffers are currently supported by the used hardware and browser.
  109552. */
  109553. readonly isSupported: boolean;
  109554. /**
  109555. * Get the list of textures generated by the multi render target.
  109556. */
  109557. readonly textures: Texture[];
  109558. /**
  109559. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  109560. */
  109561. readonly depthTexture: Texture;
  109562. /**
  109563. * Set the wrapping mode on U of all the textures we are rendering to.
  109564. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  109565. */
  109566. wrapU: number;
  109567. /**
  109568. * Set the wrapping mode on V of all the textures we are rendering to.
  109569. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  109570. */
  109571. wrapV: number;
  109572. /**
  109573. * Instantiate a new multi render target texture.
  109574. * A multi render target, like a render target provides the ability to render to a texture.
  109575. * Unlike the render target, it can render to several draw buffers in one draw.
  109576. * This is specially interesting in deferred rendering or for any effects requiring more than
  109577. * just one color from a single pass.
  109578. * @param name Define the name of the texture
  109579. * @param size Define the size of the buffers to render to
  109580. * @param count Define the number of target we are rendering into
  109581. * @param scene Define the scene the texture belongs to
  109582. * @param options Define the options used to create the multi render target
  109583. */
  109584. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  109585. /** @hidden */
  109586. _rebuild(): void;
  109587. private _createInternalTextures;
  109588. private _createTextures;
  109589. /**
  109590. * Define the number of samples used if MSAA is enabled.
  109591. */
  109592. samples: number;
  109593. /**
  109594. * Resize all the textures in the multi render target.
  109595. * Be carrefull as it will recreate all the data in the new texture.
  109596. * @param size Define the new size
  109597. */
  109598. resize(size: any): void;
  109599. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  109600. /**
  109601. * Dispose the render targets and their associated resources
  109602. */
  109603. dispose(): void;
  109604. /**
  109605. * Release all the underlying texture used as draw buffers.
  109606. */
  109607. releaseInternalTextures(): void;
  109608. }
  109609. }
  109610. declare module BABYLON {
  109611. interface Engine {
  109612. /**
  109613. * Unbind a list of render target textures from the webGL context
  109614. * This is used only when drawBuffer extension or webGL2 are active
  109615. * @param textures defines the render target textures to unbind
  109616. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  109617. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  109618. */
  109619. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  109620. /**
  109621. * Create a multi render target texture
  109622. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  109623. * @param size defines the size of the texture
  109624. * @param options defines the creation options
  109625. * @returns the cube texture as an InternalTexture
  109626. */
  109627. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  109628. /**
  109629. * Update the sample count for a given multiple render target texture
  109630. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  109631. * @param textures defines the textures to update
  109632. * @param samples defines the sample count to set
  109633. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  109634. */
  109635. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  109636. }
  109637. }
  109638. declare module BABYLON {
  109639. /** @hidden */
  109640. export var rgbdEncodePixelShader: {
  109641. name: string;
  109642. shader: string;
  109643. };
  109644. }
  109645. declare module BABYLON {
  109646. /** @hidden */
  109647. export var rgbdDecodePixelShader: {
  109648. name: string;
  109649. shader: string;
  109650. };
  109651. }
  109652. declare module BABYLON {
  109653. /**
  109654. * Raw texture data and descriptor sufficient for WebGL texture upload
  109655. */
  109656. export interface EnvironmentTextureInfo {
  109657. /**
  109658. * Version of the environment map
  109659. */
  109660. version: number;
  109661. /**
  109662. * Width of image
  109663. */
  109664. width: number;
  109665. /**
  109666. * Irradiance information stored in the file.
  109667. */
  109668. irradiance: any;
  109669. /**
  109670. * Specular information stored in the file.
  109671. */
  109672. specular: any;
  109673. }
  109674. /**
  109675. * Defines One Image in the file. It requires only the position in the file
  109676. * as well as the length.
  109677. */
  109678. interface BufferImageData {
  109679. /**
  109680. * Length of the image data.
  109681. */
  109682. length: number;
  109683. /**
  109684. * Position of the data from the null terminator delimiting the end of the JSON.
  109685. */
  109686. position: number;
  109687. }
  109688. /**
  109689. * Defines the specular data enclosed in the file.
  109690. * This corresponds to the version 1 of the data.
  109691. */
  109692. export interface EnvironmentTextureSpecularInfoV1 {
  109693. /**
  109694. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  109695. */
  109696. specularDataPosition?: number;
  109697. /**
  109698. * This contains all the images data needed to reconstruct the cubemap.
  109699. */
  109700. mipmaps: Array<BufferImageData>;
  109701. /**
  109702. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  109703. */
  109704. lodGenerationScale: number;
  109705. }
  109706. /**
  109707. * Sets of helpers addressing the serialization and deserialization of environment texture
  109708. * stored in a BabylonJS env file.
  109709. * Those files are usually stored as .env files.
  109710. */
  109711. export class EnvironmentTextureTools {
  109712. /**
  109713. * Magic number identifying the env file.
  109714. */
  109715. private static _MagicBytes;
  109716. /**
  109717. * Gets the environment info from an env file.
  109718. * @param data The array buffer containing the .env bytes.
  109719. * @returns the environment file info (the json header) if successfully parsed.
  109720. */
  109721. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  109722. /**
  109723. * Creates an environment texture from a loaded cube texture.
  109724. * @param texture defines the cube texture to convert in env file
  109725. * @return a promise containing the environment data if succesfull.
  109726. */
  109727. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  109728. /**
  109729. * Creates a JSON representation of the spherical data.
  109730. * @param texture defines the texture containing the polynomials
  109731. * @return the JSON representation of the spherical info
  109732. */
  109733. private static _CreateEnvTextureIrradiance;
  109734. /**
  109735. * Creates the ArrayBufferViews used for initializing environment texture image data.
  109736. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  109737. * @param info parameters that determine what views will be created for accessing the underlying buffer
  109738. * @return the views described by info providing access to the underlying buffer
  109739. */
  109740. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  109741. /**
  109742. * Uploads the texture info contained in the env file to the GPU.
  109743. * @param texture defines the internal texture to upload to
  109744. * @param arrayBuffer defines the buffer cotaining the data to load
  109745. * @param info defines the texture info retrieved through the GetEnvInfo method
  109746. * @returns a promise
  109747. */
  109748. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  109749. /**
  109750. * Uploads the levels of image data to the GPU.
  109751. * @param texture defines the internal texture to upload to
  109752. * @param imageData defines the array buffer views of image data [mipmap][face]
  109753. * @returns a promise
  109754. */
  109755. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  109756. /**
  109757. * Uploads spherical polynomials information to the texture.
  109758. * @param texture defines the texture we are trying to upload the information to
  109759. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  109760. */
  109761. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  109762. /** @hidden */
  109763. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  109764. }
  109765. }
  109766. declare module BABYLON {
  109767. /**
  109768. * Contains position and normal vectors for a vertex
  109769. */
  109770. export class PositionNormalVertex {
  109771. /** the position of the vertex (defaut: 0,0,0) */
  109772. position: Vector3;
  109773. /** the normal of the vertex (defaut: 0,1,0) */
  109774. normal: Vector3;
  109775. /**
  109776. * Creates a PositionNormalVertex
  109777. * @param position the position of the vertex (defaut: 0,0,0)
  109778. * @param normal the normal of the vertex (defaut: 0,1,0)
  109779. */
  109780. constructor(
  109781. /** the position of the vertex (defaut: 0,0,0) */
  109782. position?: Vector3,
  109783. /** the normal of the vertex (defaut: 0,1,0) */
  109784. normal?: Vector3);
  109785. /**
  109786. * Clones the PositionNormalVertex
  109787. * @returns the cloned PositionNormalVertex
  109788. */
  109789. clone(): PositionNormalVertex;
  109790. }
  109791. /**
  109792. * Contains position, normal and uv vectors for a vertex
  109793. */
  109794. export class PositionNormalTextureVertex {
  109795. /** the position of the vertex (defaut: 0,0,0) */
  109796. position: Vector3;
  109797. /** the normal of the vertex (defaut: 0,1,0) */
  109798. normal: Vector3;
  109799. /** the uv of the vertex (default: 0,0) */
  109800. uv: Vector2;
  109801. /**
  109802. * Creates a PositionNormalTextureVertex
  109803. * @param position the position of the vertex (defaut: 0,0,0)
  109804. * @param normal the normal of the vertex (defaut: 0,1,0)
  109805. * @param uv the uv of the vertex (default: 0,0)
  109806. */
  109807. constructor(
  109808. /** the position of the vertex (defaut: 0,0,0) */
  109809. position?: Vector3,
  109810. /** the normal of the vertex (defaut: 0,1,0) */
  109811. normal?: Vector3,
  109812. /** the uv of the vertex (default: 0,0) */
  109813. uv?: Vector2);
  109814. /**
  109815. * Clones the PositionNormalTextureVertex
  109816. * @returns the cloned PositionNormalTextureVertex
  109817. */
  109818. clone(): PositionNormalTextureVertex;
  109819. }
  109820. }
  109821. declare module BABYLON {
  109822. /** @hidden */
  109823. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  109824. private _genericAttributeLocation;
  109825. private _varyingLocationCount;
  109826. private _varyingLocationMap;
  109827. private _replacements;
  109828. private _textureCount;
  109829. private _uniforms;
  109830. lineProcessor(line: string): string;
  109831. attributeProcessor(attribute: string): string;
  109832. varyingProcessor(varying: string, isFragment: boolean): string;
  109833. uniformProcessor(uniform: string): string;
  109834. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  109835. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  109836. }
  109837. }
  109838. declare module BABYLON {
  109839. /**
  109840. * Container for accessors for natively-stored mesh data buffers.
  109841. */
  109842. class NativeDataBuffer extends DataBuffer {
  109843. /**
  109844. * Accessor value used to identify/retrieve a natively-stored index buffer.
  109845. */
  109846. nativeIndexBuffer?: any;
  109847. /**
  109848. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  109849. */
  109850. nativeVertexBuffer?: any;
  109851. }
  109852. /** @hidden */
  109853. export class NativeEngine extends Engine {
  109854. private readonly _native;
  109855. getHardwareScalingLevel(): number;
  109856. constructor();
  109857. /**
  109858. * Can be used to override the current requestAnimationFrame requester.
  109859. * @hidden
  109860. */
  109861. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  109862. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  109863. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  109864. createVertexBuffer(data: DataArray): NativeDataBuffer;
  109865. recordVertexArrayObject(vertexBuffers: {
  109866. [key: string]: VertexBuffer;
  109867. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  109868. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  109869. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  109870. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  109871. /**
  109872. * Draw a list of indexed primitives
  109873. * @param fillMode defines the primitive to use
  109874. * @param indexStart defines the starting index
  109875. * @param indexCount defines the number of index to draw
  109876. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  109877. */
  109878. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  109879. /**
  109880. * Draw a list of unindexed primitives
  109881. * @param fillMode defines the primitive to use
  109882. * @param verticesStart defines the index of first vertex to draw
  109883. * @param verticesCount defines the count of vertices to draw
  109884. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  109885. */
  109886. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  109887. createPipelineContext(): IPipelineContext;
  109888. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  109889. /** @hidden */
  109890. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  109891. /** @hidden */
  109892. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  109893. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  109894. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  109895. protected _setProgram(program: WebGLProgram): void;
  109896. _releaseEffect(effect: Effect): void;
  109897. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  109898. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  109899. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  109900. bindSamplers(effect: Effect): void;
  109901. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  109902. getRenderWidth(useScreen?: boolean): number;
  109903. getRenderHeight(useScreen?: boolean): number;
  109904. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  109905. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  109906. /**
  109907. * Set the z offset to apply to current rendering
  109908. * @param value defines the offset to apply
  109909. */
  109910. setZOffset(value: number): void;
  109911. /**
  109912. * Gets the current value of the zOffset
  109913. * @returns the current zOffset state
  109914. */
  109915. getZOffset(): number;
  109916. /**
  109917. * Enable or disable depth buffering
  109918. * @param enable defines the state to set
  109919. */
  109920. setDepthBuffer(enable: boolean): void;
  109921. /**
  109922. * Gets a boolean indicating if depth writing is enabled
  109923. * @returns the current depth writing state
  109924. */
  109925. getDepthWrite(): boolean;
  109926. /**
  109927. * Enable or disable depth writing
  109928. * @param enable defines the state to set
  109929. */
  109930. setDepthWrite(enable: boolean): void;
  109931. /**
  109932. * Enable or disable color writing
  109933. * @param enable defines the state to set
  109934. */
  109935. setColorWrite(enable: boolean): void;
  109936. /**
  109937. * Gets a boolean indicating if color writing is enabled
  109938. * @returns the current color writing state
  109939. */
  109940. getColorWrite(): boolean;
  109941. /**
  109942. * Sets alpha constants used by some alpha blending modes
  109943. * @param r defines the red component
  109944. * @param g defines the green component
  109945. * @param b defines the blue component
  109946. * @param a defines the alpha component
  109947. */
  109948. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  109949. /**
  109950. * Sets the current alpha mode
  109951. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  109952. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  109953. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  109954. */
  109955. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  109956. /**
  109957. * Gets the current alpha mode
  109958. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  109959. * @returns the current alpha mode
  109960. */
  109961. getAlphaMode(): number;
  109962. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  109963. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  109964. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  109965. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  109966. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  109967. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  109968. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  109969. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  109970. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  109971. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  109972. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  109973. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  109974. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  109975. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  109976. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  109977. setFloat(uniform: WebGLUniformLocation, value: number): void;
  109978. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  109979. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  109980. setBool(uniform: WebGLUniformLocation, bool: number): void;
  109981. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  109982. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  109983. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  109984. wipeCaches(bruteForce?: boolean): void;
  109985. _createTexture(): WebGLTexture;
  109986. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  109987. /**
  109988. * Usually called from BABYLON.Texture.ts.
  109989. * Passed information to create a WebGLTexture
  109990. * @param urlArg defines a value which contains one of the following:
  109991. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  109992. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  109993. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  109994. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  109995. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  109996. * @param scene needed for loading to the correct scene
  109997. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  109998. * @param onLoad optional callback to be called upon successful completion
  109999. * @param onError optional callback to be called upon failure
  110000. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  110001. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  110002. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  110003. * @param forcedExtension defines the extension to use to pick the right loader
  110004. * @returns a InternalTexture for assignment back into BABYLON.Texture
  110005. */
  110006. 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;
  110007. /**
  110008. * Creates a cube texture
  110009. * @param rootUrl defines the url where the files to load is located
  110010. * @param scene defines the current scene
  110011. * @param files defines the list of files to load (1 per face)
  110012. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  110013. * @param onLoad defines an optional callback raised when the texture is loaded
  110014. * @param onError defines an optional callback raised if there is an issue to load the texture
  110015. * @param format defines the format of the data
  110016. * @param forcedExtension defines the extension to use to pick the right loader
  110017. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  110018. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  110019. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  110020. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  110021. * @returns the cube texture as an InternalTexture
  110022. */
  110023. 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;
  110024. private _getSamplingFilter;
  110025. private static _GetNativeTextureFormat;
  110026. createRenderTargetTexture(size: number | {
  110027. width: number;
  110028. height: number;
  110029. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  110030. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  110031. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  110032. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  110033. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  110034. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  110035. /**
  110036. * Updates a dynamic vertex buffer.
  110037. * @param vertexBuffer the vertex buffer to update
  110038. * @param data the data used to update the vertex buffer
  110039. * @param byteOffset the byte offset of the data (optional)
  110040. * @param byteLength the byte length of the data (optional)
  110041. */
  110042. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  110043. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  110044. private _updateAnisotropicLevel;
  110045. private _getAddressMode;
  110046. /** @hidden */
  110047. _bindTexture(channel: number, texture: InternalTexture): void;
  110048. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  110049. releaseEffects(): void;
  110050. /** @hidden */
  110051. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  110052. /** @hidden */
  110053. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  110054. /** @hidden */
  110055. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  110056. /** @hidden */
  110057. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  110058. }
  110059. }
  110060. declare module BABYLON {
  110061. /**
  110062. * Gather the list of clipboard event types as constants.
  110063. */
  110064. export class ClipboardEventTypes {
  110065. /**
  110066. * The clipboard event is fired when a copy command is active (pressed).
  110067. */
  110068. static readonly COPY: number;
  110069. /**
  110070. * The clipboard event is fired when a cut command is active (pressed).
  110071. */
  110072. static readonly CUT: number;
  110073. /**
  110074. * The clipboard event is fired when a paste command is active (pressed).
  110075. */
  110076. static readonly PASTE: number;
  110077. }
  110078. /**
  110079. * This class is used to store clipboard related info for the onClipboardObservable event.
  110080. */
  110081. export class ClipboardInfo {
  110082. /**
  110083. * Defines the type of event (BABYLON.ClipboardEventTypes)
  110084. */
  110085. type: number;
  110086. /**
  110087. * Defines the related dom event
  110088. */
  110089. event: ClipboardEvent;
  110090. /**
  110091. *Creates an instance of ClipboardInfo.
  110092. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  110093. * @param event Defines the related dom event
  110094. */
  110095. constructor(
  110096. /**
  110097. * Defines the type of event (BABYLON.ClipboardEventTypes)
  110098. */
  110099. type: number,
  110100. /**
  110101. * Defines the related dom event
  110102. */
  110103. event: ClipboardEvent);
  110104. /**
  110105. * Get the clipboard event's type from the keycode.
  110106. * @param keyCode Defines the keyCode for the current keyboard event.
  110107. * @return {number}
  110108. */
  110109. static GetTypeFromCharacter(keyCode: number): number;
  110110. }
  110111. }
  110112. declare module BABYLON {
  110113. /**
  110114. * Google Daydream controller
  110115. */
  110116. export class DaydreamController extends WebVRController {
  110117. /**
  110118. * Base Url for the controller model.
  110119. */
  110120. static MODEL_BASE_URL: string;
  110121. /**
  110122. * File name for the controller model.
  110123. */
  110124. static MODEL_FILENAME: string;
  110125. /**
  110126. * Gamepad Id prefix used to identify Daydream Controller.
  110127. */
  110128. static readonly GAMEPAD_ID_PREFIX: string;
  110129. /**
  110130. * Creates a new DaydreamController from a gamepad
  110131. * @param vrGamepad the gamepad that the controller should be created from
  110132. */
  110133. constructor(vrGamepad: any);
  110134. /**
  110135. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  110136. * @param scene scene in which to add meshes
  110137. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  110138. */
  110139. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  110140. /**
  110141. * Called once for each button that changed state since the last frame
  110142. * @param buttonIdx Which button index changed
  110143. * @param state New state of the button
  110144. * @param changes Which properties on the state changed since last frame
  110145. */
  110146. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  110147. }
  110148. }
  110149. declare module BABYLON {
  110150. /**
  110151. * Gear VR Controller
  110152. */
  110153. export class GearVRController extends WebVRController {
  110154. /**
  110155. * Base Url for the controller model.
  110156. */
  110157. static MODEL_BASE_URL: string;
  110158. /**
  110159. * File name for the controller model.
  110160. */
  110161. static MODEL_FILENAME: string;
  110162. /**
  110163. * Gamepad Id prefix used to identify this controller.
  110164. */
  110165. static readonly GAMEPAD_ID_PREFIX: string;
  110166. private readonly _buttonIndexToObservableNameMap;
  110167. /**
  110168. * Creates a new GearVRController from a gamepad
  110169. * @param vrGamepad the gamepad that the controller should be created from
  110170. */
  110171. constructor(vrGamepad: any);
  110172. /**
  110173. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  110174. * @param scene scene in which to add meshes
  110175. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  110176. */
  110177. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  110178. /**
  110179. * Called once for each button that changed state since the last frame
  110180. * @param buttonIdx Which button index changed
  110181. * @param state New state of the button
  110182. * @param changes Which properties on the state changed since last frame
  110183. */
  110184. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  110185. }
  110186. }
  110187. declare module BABYLON {
  110188. /**
  110189. * Class containing static functions to help procedurally build meshes
  110190. */
  110191. export class PolyhedronBuilder {
  110192. /**
  110193. * Creates a polyhedron mesh
  110194. * * 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
  110195. * * The parameter `size` (positive float, default 1) sets the polygon size
  110196. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  110197. * * 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`
  110198. * * 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
  110199. * * 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)`)
  110200. * * 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
  110201. * * 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
  110202. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110203. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110204. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110205. * @param name defines the name of the mesh
  110206. * @param options defines the options used to create the mesh
  110207. * @param scene defines the hosting scene
  110208. * @returns the polyhedron mesh
  110209. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  110210. */
  110211. static CreatePolyhedron(name: string, options: {
  110212. type?: number;
  110213. size?: number;
  110214. sizeX?: number;
  110215. sizeY?: number;
  110216. sizeZ?: number;
  110217. custom?: any;
  110218. faceUV?: Vector4[];
  110219. faceColors?: Color4[];
  110220. flat?: boolean;
  110221. updatable?: boolean;
  110222. sideOrientation?: number;
  110223. frontUVs?: Vector4;
  110224. backUVs?: Vector4;
  110225. }, scene?: Nullable<Scene>): Mesh;
  110226. }
  110227. }
  110228. declare module BABYLON {
  110229. /**
  110230. * Gizmo that enables scaling a mesh along 3 axis
  110231. */
  110232. export class ScaleGizmo extends Gizmo {
  110233. /**
  110234. * Internal gizmo used for interactions on the x axis
  110235. */
  110236. xGizmo: AxisScaleGizmo;
  110237. /**
  110238. * Internal gizmo used for interactions on the y axis
  110239. */
  110240. yGizmo: AxisScaleGizmo;
  110241. /**
  110242. * Internal gizmo used for interactions on the z axis
  110243. */
  110244. zGizmo: AxisScaleGizmo;
  110245. /**
  110246. * Internal gizmo used to scale all axis equally
  110247. */
  110248. uniformScaleGizmo: AxisScaleGizmo;
  110249. private _meshAttached;
  110250. private _updateGizmoRotationToMatchAttachedMesh;
  110251. private _snapDistance;
  110252. private _scaleRatio;
  110253. private _uniformScalingMesh;
  110254. private _octahedron;
  110255. /** Fires an event when any of it's sub gizmos are dragged */
  110256. onDragStartObservable: Observable<unknown>;
  110257. /** Fires an event when any of it's sub gizmos are released from dragging */
  110258. onDragEndObservable: Observable<unknown>;
  110259. attachedMesh: Nullable<AbstractMesh>;
  110260. /**
  110261. * Creates a ScaleGizmo
  110262. * @param gizmoLayer The utility layer the gizmo will be added to
  110263. */
  110264. constructor(gizmoLayer?: UtilityLayerRenderer);
  110265. updateGizmoRotationToMatchAttachedMesh: boolean;
  110266. /**
  110267. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  110268. */
  110269. snapDistance: number;
  110270. /**
  110271. * Ratio for the scale of the gizmo (Default: 1)
  110272. */
  110273. scaleRatio: number;
  110274. /**
  110275. * Disposes of the gizmo
  110276. */
  110277. dispose(): void;
  110278. }
  110279. }
  110280. declare module BABYLON {
  110281. /**
  110282. * Single axis scale gizmo
  110283. */
  110284. export class AxisScaleGizmo extends Gizmo {
  110285. /**
  110286. * Drag behavior responsible for the gizmos dragging interactions
  110287. */
  110288. dragBehavior: PointerDragBehavior;
  110289. private _pointerObserver;
  110290. /**
  110291. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  110292. */
  110293. snapDistance: number;
  110294. /**
  110295. * Event that fires each time the gizmo snaps to a new location.
  110296. * * snapDistance is the the change in distance
  110297. */
  110298. onSnapObservable: Observable<{
  110299. snapDistance: number;
  110300. }>;
  110301. /**
  110302. * If the scaling operation should be done on all axis (default: false)
  110303. */
  110304. uniformScaling: boolean;
  110305. private _isEnabled;
  110306. private _parent;
  110307. private _arrow;
  110308. private _coloredMaterial;
  110309. private _hoverMaterial;
  110310. /**
  110311. * Creates an AxisScaleGizmo
  110312. * @param gizmoLayer The utility layer the gizmo will be added to
  110313. * @param dragAxis The axis which the gizmo will be able to scale on
  110314. * @param color The color of the gizmo
  110315. */
  110316. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  110317. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  110318. /**
  110319. * If the gizmo is enabled
  110320. */
  110321. isEnabled: boolean;
  110322. /**
  110323. * Disposes of the gizmo
  110324. */
  110325. dispose(): void;
  110326. /**
  110327. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  110328. * @param mesh The mesh to replace the default mesh of the gizmo
  110329. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  110330. */
  110331. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  110332. }
  110333. }
  110334. declare module BABYLON {
  110335. /**
  110336. * Bounding box gizmo
  110337. */
  110338. export class BoundingBoxGizmo extends Gizmo {
  110339. private _lineBoundingBox;
  110340. private _rotateSpheresParent;
  110341. private _scaleBoxesParent;
  110342. private _boundingDimensions;
  110343. private _renderObserver;
  110344. private _pointerObserver;
  110345. private _scaleDragSpeed;
  110346. private _tmpQuaternion;
  110347. private _tmpVector;
  110348. private _tmpRotationMatrix;
  110349. /**
  110350. * 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)
  110351. */
  110352. ignoreChildren: boolean;
  110353. /**
  110354. * 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)
  110355. */
  110356. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  110357. /**
  110358. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  110359. */
  110360. rotationSphereSize: number;
  110361. /**
  110362. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  110363. */
  110364. scaleBoxSize: number;
  110365. /**
  110366. * 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)
  110367. */
  110368. fixedDragMeshScreenSize: boolean;
  110369. /**
  110370. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  110371. */
  110372. fixedDragMeshScreenSizeDistanceFactor: number;
  110373. /**
  110374. * Fired when a rotation sphere or scale box is dragged
  110375. */
  110376. onDragStartObservable: Observable<{}>;
  110377. /**
  110378. * Fired when a scale box is dragged
  110379. */
  110380. onScaleBoxDragObservable: Observable<{}>;
  110381. /**
  110382. * Fired when a scale box drag is ended
  110383. */
  110384. onScaleBoxDragEndObservable: Observable<{}>;
  110385. /**
  110386. * Fired when a rotation sphere is dragged
  110387. */
  110388. onRotationSphereDragObservable: Observable<{}>;
  110389. /**
  110390. * Fired when a rotation sphere drag is ended
  110391. */
  110392. onRotationSphereDragEndObservable: Observable<{}>;
  110393. /**
  110394. * 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)
  110395. */
  110396. scalePivot: Nullable<Vector3>;
  110397. /**
  110398. * Mesh used as a pivot to rotate the attached mesh
  110399. */
  110400. private _anchorMesh;
  110401. private _existingMeshScale;
  110402. private _dragMesh;
  110403. private pointerDragBehavior;
  110404. private coloredMaterial;
  110405. private hoverColoredMaterial;
  110406. /**
  110407. * Sets the color of the bounding box gizmo
  110408. * @param color the color to set
  110409. */
  110410. setColor(color: Color3): void;
  110411. /**
  110412. * Creates an BoundingBoxGizmo
  110413. * @param gizmoLayer The utility layer the gizmo will be added to
  110414. * @param color The color of the gizmo
  110415. */
  110416. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  110417. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  110418. private _selectNode;
  110419. /**
  110420. * Updates the bounding box information for the Gizmo
  110421. */
  110422. updateBoundingBox(): void;
  110423. private _updateRotationSpheres;
  110424. private _updateScaleBoxes;
  110425. /**
  110426. * Enables rotation on the specified axis and disables rotation on the others
  110427. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  110428. */
  110429. setEnabledRotationAxis(axis: string): void;
  110430. /**
  110431. * Enables/disables scaling
  110432. * @param enable if scaling should be enabled
  110433. */
  110434. setEnabledScaling(enable: boolean): void;
  110435. private _updateDummy;
  110436. /**
  110437. * Enables a pointer drag behavior on the bounding box of the gizmo
  110438. */
  110439. enableDragBehavior(): void;
  110440. /**
  110441. * Disposes of the gizmo
  110442. */
  110443. dispose(): void;
  110444. /**
  110445. * 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)
  110446. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  110447. * @returns the bounding box mesh with the passed in mesh as a child
  110448. */
  110449. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  110450. /**
  110451. * CustomMeshes are not supported by this gizmo
  110452. * @param mesh The mesh to replace the default mesh of the gizmo
  110453. */
  110454. setCustomMesh(mesh: Mesh): void;
  110455. }
  110456. }
  110457. declare module BABYLON {
  110458. /**
  110459. * Single plane rotation gizmo
  110460. */
  110461. export class PlaneRotationGizmo extends Gizmo {
  110462. /**
  110463. * Drag behavior responsible for the gizmos dragging interactions
  110464. */
  110465. dragBehavior: PointerDragBehavior;
  110466. private _pointerObserver;
  110467. /**
  110468. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  110469. */
  110470. snapDistance: number;
  110471. /**
  110472. * Event that fires each time the gizmo snaps to a new location.
  110473. * * snapDistance is the the change in distance
  110474. */
  110475. onSnapObservable: Observable<{
  110476. snapDistance: number;
  110477. }>;
  110478. private _isEnabled;
  110479. private _parent;
  110480. /**
  110481. * Creates a PlaneRotationGizmo
  110482. * @param gizmoLayer The utility layer the gizmo will be added to
  110483. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  110484. * @param color The color of the gizmo
  110485. * @param tessellation Amount of tessellation to be used when creating rotation circles
  110486. * @param useEulerRotation Use and update Euler angle instead of quaternion
  110487. */
  110488. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  110489. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  110490. /**
  110491. * If the gizmo is enabled
  110492. */
  110493. isEnabled: boolean;
  110494. /**
  110495. * Disposes of the gizmo
  110496. */
  110497. dispose(): void;
  110498. }
  110499. }
  110500. declare module BABYLON {
  110501. /**
  110502. * Gizmo that enables rotating a mesh along 3 axis
  110503. */
  110504. export class RotationGizmo extends Gizmo {
  110505. /**
  110506. * Internal gizmo used for interactions on the x axis
  110507. */
  110508. xGizmo: PlaneRotationGizmo;
  110509. /**
  110510. * Internal gizmo used for interactions on the y axis
  110511. */
  110512. yGizmo: PlaneRotationGizmo;
  110513. /**
  110514. * Internal gizmo used for interactions on the z axis
  110515. */
  110516. zGizmo: PlaneRotationGizmo;
  110517. /** Fires an event when any of it's sub gizmos are dragged */
  110518. onDragStartObservable: Observable<unknown>;
  110519. /** Fires an event when any of it's sub gizmos are released from dragging */
  110520. onDragEndObservable: Observable<unknown>;
  110521. private _meshAttached;
  110522. attachedMesh: Nullable<AbstractMesh>;
  110523. /**
  110524. * Creates a RotationGizmo
  110525. * @param gizmoLayer The utility layer the gizmo will be added to
  110526. * @param tessellation Amount of tessellation to be used when creating rotation circles
  110527. * @param useEulerRotation Use and update Euler angle instead of quaternion
  110528. */
  110529. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  110530. updateGizmoRotationToMatchAttachedMesh: boolean;
  110531. /**
  110532. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  110533. */
  110534. snapDistance: number;
  110535. /**
  110536. * Ratio for the scale of the gizmo (Default: 1)
  110537. */
  110538. scaleRatio: number;
  110539. /**
  110540. * Disposes of the gizmo
  110541. */
  110542. dispose(): void;
  110543. /**
  110544. * CustomMeshes are not supported by this gizmo
  110545. * @param mesh The mesh to replace the default mesh of the gizmo
  110546. */
  110547. setCustomMesh(mesh: Mesh): void;
  110548. }
  110549. }
  110550. declare module BABYLON {
  110551. /**
  110552. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  110553. */
  110554. export class GizmoManager implements IDisposable {
  110555. private scene;
  110556. /**
  110557. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  110558. */
  110559. gizmos: {
  110560. positionGizmo: Nullable<PositionGizmo>;
  110561. rotationGizmo: Nullable<RotationGizmo>;
  110562. scaleGizmo: Nullable<ScaleGizmo>;
  110563. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  110564. };
  110565. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  110566. clearGizmoOnEmptyPointerEvent: boolean;
  110567. /** Fires an event when the manager is attached to a mesh */
  110568. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  110569. private _gizmosEnabled;
  110570. private _pointerObserver;
  110571. private _attachedMesh;
  110572. private _boundingBoxColor;
  110573. private _defaultUtilityLayer;
  110574. private _defaultKeepDepthUtilityLayer;
  110575. /**
  110576. * When bounding box gizmo is enabled, this can be used to track drag/end events
  110577. */
  110578. boundingBoxDragBehavior: SixDofDragBehavior;
  110579. /**
  110580. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  110581. */
  110582. attachableMeshes: Nullable<Array<AbstractMesh>>;
  110583. /**
  110584. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  110585. */
  110586. usePointerToAttachGizmos: boolean;
  110587. /**
  110588. * Utility layer that the bounding box gizmo belongs to
  110589. */
  110590. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  110591. /**
  110592. * Utility layer that all gizmos besides bounding box belong to
  110593. */
  110594. readonly utilityLayer: UtilityLayerRenderer;
  110595. /**
  110596. * Instatiates a gizmo manager
  110597. * @param scene the scene to overlay the gizmos on top of
  110598. */
  110599. constructor(scene: Scene);
  110600. /**
  110601. * Attaches a set of gizmos to the specified mesh
  110602. * @param mesh The mesh the gizmo's should be attached to
  110603. */
  110604. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  110605. /**
  110606. * If the position gizmo is enabled
  110607. */
  110608. positionGizmoEnabled: boolean;
  110609. /**
  110610. * If the rotation gizmo is enabled
  110611. */
  110612. rotationGizmoEnabled: boolean;
  110613. /**
  110614. * If the scale gizmo is enabled
  110615. */
  110616. scaleGizmoEnabled: boolean;
  110617. /**
  110618. * If the boundingBox gizmo is enabled
  110619. */
  110620. boundingBoxGizmoEnabled: boolean;
  110621. /**
  110622. * Disposes of the gizmo manager
  110623. */
  110624. dispose(): void;
  110625. }
  110626. }
  110627. declare module BABYLON {
  110628. /**
  110629. * A directional light is defined by a direction (what a surprise!).
  110630. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  110631. * 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.
  110632. * Documentation: https://doc.babylonjs.com/babylon101/lights
  110633. */
  110634. export class DirectionalLight extends ShadowLight {
  110635. private _shadowFrustumSize;
  110636. /**
  110637. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  110638. */
  110639. /**
  110640. * Specifies a fix frustum size for the shadow generation.
  110641. */
  110642. shadowFrustumSize: number;
  110643. private _shadowOrthoScale;
  110644. /**
  110645. * Gets the shadow projection scale against the optimal computed one.
  110646. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  110647. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  110648. */
  110649. /**
  110650. * Sets the shadow projection scale against the optimal computed one.
  110651. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  110652. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  110653. */
  110654. shadowOrthoScale: number;
  110655. /**
  110656. * Automatically compute the projection matrix to best fit (including all the casters)
  110657. * on each frame.
  110658. */
  110659. autoUpdateExtends: boolean;
  110660. private _orthoLeft;
  110661. private _orthoRight;
  110662. private _orthoTop;
  110663. private _orthoBottom;
  110664. /**
  110665. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  110666. * The directional light is emitted from everywhere in the given direction.
  110667. * It can cast shadows.
  110668. * Documentation : https://doc.babylonjs.com/babylon101/lights
  110669. * @param name The friendly name of the light
  110670. * @param direction The direction of the light
  110671. * @param scene The scene the light belongs to
  110672. */
  110673. constructor(name: string, direction: Vector3, scene: Scene);
  110674. /**
  110675. * Returns the string "DirectionalLight".
  110676. * @return The class name
  110677. */
  110678. getClassName(): string;
  110679. /**
  110680. * Returns the integer 1.
  110681. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  110682. */
  110683. getTypeID(): number;
  110684. /**
  110685. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  110686. * Returns the DirectionalLight Shadow projection matrix.
  110687. */
  110688. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  110689. /**
  110690. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  110691. * Returns the DirectionalLight Shadow projection matrix.
  110692. */
  110693. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  110694. /**
  110695. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  110696. * Returns the DirectionalLight Shadow projection matrix.
  110697. */
  110698. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  110699. protected _buildUniformLayout(): void;
  110700. /**
  110701. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  110702. * @param effect The effect to update
  110703. * @param lightIndex The index of the light in the effect to update
  110704. * @returns The directional light
  110705. */
  110706. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  110707. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  110708. /**
  110709. * Gets the minZ used for shadow according to both the scene and the light.
  110710. *
  110711. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  110712. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  110713. * @param activeCamera The camera we are returning the min for
  110714. * @returns the depth min z
  110715. */
  110716. getDepthMinZ(activeCamera: Camera): number;
  110717. /**
  110718. * Gets the maxZ used for shadow according to both the scene and the light.
  110719. *
  110720. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  110721. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  110722. * @param activeCamera The camera we are returning the max for
  110723. * @returns the depth max z
  110724. */
  110725. getDepthMaxZ(activeCamera: Camera): number;
  110726. /**
  110727. * Prepares the list of defines specific to the light type.
  110728. * @param defines the list of defines
  110729. * @param lightIndex defines the index of the light for the effect
  110730. */
  110731. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  110732. }
  110733. }
  110734. declare module BABYLON {
  110735. /**
  110736. * Class containing static functions to help procedurally build meshes
  110737. */
  110738. export class HemisphereBuilder {
  110739. /**
  110740. * Creates a hemisphere mesh
  110741. * @param name defines the name of the mesh
  110742. * @param options defines the options used to create the mesh
  110743. * @param scene defines the hosting scene
  110744. * @returns the hemisphere mesh
  110745. */
  110746. static CreateHemisphere(name: string, options: {
  110747. segments?: number;
  110748. diameter?: number;
  110749. sideOrientation?: number;
  110750. }, scene: any): Mesh;
  110751. }
  110752. }
  110753. declare module BABYLON {
  110754. /**
  110755. * A spot light is defined by a position, a direction, an angle, and an exponent.
  110756. * These values define a cone of light starting from the position, emitting toward the direction.
  110757. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  110758. * and the exponent defines the speed of the decay of the light with distance (reach).
  110759. * Documentation: https://doc.babylonjs.com/babylon101/lights
  110760. */
  110761. export class SpotLight extends ShadowLight {
  110762. private _angle;
  110763. private _innerAngle;
  110764. private _cosHalfAngle;
  110765. private _lightAngleScale;
  110766. private _lightAngleOffset;
  110767. /**
  110768. * Gets the cone angle of the spot light in Radians.
  110769. */
  110770. /**
  110771. * Sets the cone angle of the spot light in Radians.
  110772. */
  110773. angle: number;
  110774. /**
  110775. * Only used in gltf falloff mode, this defines the angle where
  110776. * the directional falloff will start before cutting at angle which could be seen
  110777. * as outer angle.
  110778. */
  110779. /**
  110780. * Only used in gltf falloff mode, this defines the angle where
  110781. * the directional falloff will start before cutting at angle which could be seen
  110782. * as outer angle.
  110783. */
  110784. innerAngle: number;
  110785. private _shadowAngleScale;
  110786. /**
  110787. * Allows scaling the angle of the light for shadow generation only.
  110788. */
  110789. /**
  110790. * Allows scaling the angle of the light for shadow generation only.
  110791. */
  110792. shadowAngleScale: number;
  110793. /**
  110794. * The light decay speed with the distance from the emission spot.
  110795. */
  110796. exponent: number;
  110797. private _projectionTextureMatrix;
  110798. /**
  110799. * Allows reading the projecton texture
  110800. */
  110801. readonly projectionTextureMatrix: Matrix;
  110802. protected _projectionTextureLightNear: number;
  110803. /**
  110804. * Gets the near clip of the Spotlight for texture projection.
  110805. */
  110806. /**
  110807. * Sets the near clip of the Spotlight for texture projection.
  110808. */
  110809. projectionTextureLightNear: number;
  110810. protected _projectionTextureLightFar: number;
  110811. /**
  110812. * Gets the far clip of the Spotlight for texture projection.
  110813. */
  110814. /**
  110815. * Sets the far clip of the Spotlight for texture projection.
  110816. */
  110817. projectionTextureLightFar: number;
  110818. protected _projectionTextureUpDirection: Vector3;
  110819. /**
  110820. * Gets the Up vector of the Spotlight for texture projection.
  110821. */
  110822. /**
  110823. * Sets the Up vector of the Spotlight for texture projection.
  110824. */
  110825. projectionTextureUpDirection: Vector3;
  110826. private _projectionTexture;
  110827. /**
  110828. * Gets the projection texture of the light.
  110829. */
  110830. /**
  110831. * Sets the projection texture of the light.
  110832. */
  110833. projectionTexture: Nullable<BaseTexture>;
  110834. private _projectionTextureViewLightDirty;
  110835. private _projectionTextureProjectionLightDirty;
  110836. private _projectionTextureDirty;
  110837. private _projectionTextureViewTargetVector;
  110838. private _projectionTextureViewLightMatrix;
  110839. private _projectionTextureProjectionLightMatrix;
  110840. private _projectionTextureScalingMatrix;
  110841. /**
  110842. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  110843. * It can cast shadows.
  110844. * Documentation : https://doc.babylonjs.com/babylon101/lights
  110845. * @param name The light friendly name
  110846. * @param position The position of the spot light in the scene
  110847. * @param direction The direction of the light in the scene
  110848. * @param angle The cone angle of the light in Radians
  110849. * @param exponent The light decay speed with the distance from the emission spot
  110850. * @param scene The scene the lights belongs to
  110851. */
  110852. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  110853. /**
  110854. * Returns the string "SpotLight".
  110855. * @returns the class name
  110856. */
  110857. getClassName(): string;
  110858. /**
  110859. * Returns the integer 2.
  110860. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  110861. */
  110862. getTypeID(): number;
  110863. /**
  110864. * Overrides the direction setter to recompute the projection texture view light Matrix.
  110865. */
  110866. protected _setDirection(value: Vector3): void;
  110867. /**
  110868. * Overrides the position setter to recompute the projection texture view light Matrix.
  110869. */
  110870. protected _setPosition(value: Vector3): void;
  110871. /**
  110872. * 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.
  110873. * Returns the SpotLight.
  110874. */
  110875. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  110876. protected _computeProjectionTextureViewLightMatrix(): void;
  110877. protected _computeProjectionTextureProjectionLightMatrix(): void;
  110878. /**
  110879. * Main function for light texture projection matrix computing.
  110880. */
  110881. protected _computeProjectionTextureMatrix(): void;
  110882. protected _buildUniformLayout(): void;
  110883. private _computeAngleValues;
  110884. /**
  110885. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  110886. * @param effect The effect to update
  110887. * @param lightIndex The index of the light in the effect to update
  110888. * @returns The spot light
  110889. */
  110890. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  110891. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  110892. /**
  110893. * Disposes the light and the associated resources.
  110894. */
  110895. dispose(): void;
  110896. /**
  110897. * Prepares the list of defines specific to the light type.
  110898. * @param defines the list of defines
  110899. * @param lightIndex defines the index of the light for the effect
  110900. */
  110901. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  110902. }
  110903. }
  110904. declare module BABYLON {
  110905. /**
  110906. * Gizmo that enables viewing a light
  110907. */
  110908. export class LightGizmo extends Gizmo {
  110909. private _lightMesh;
  110910. private _material;
  110911. private cachedPosition;
  110912. private cachedForward;
  110913. /**
  110914. * Creates a LightGizmo
  110915. * @param gizmoLayer The utility layer the gizmo will be added to
  110916. */
  110917. constructor(gizmoLayer?: UtilityLayerRenderer);
  110918. private _light;
  110919. /**
  110920. * The light that the gizmo is attached to
  110921. */
  110922. light: Nullable<Light>;
  110923. /**
  110924. * Gets the material used to render the light gizmo
  110925. */
  110926. readonly material: StandardMaterial;
  110927. /**
  110928. * @hidden
  110929. * Updates the gizmo to match the attached mesh's position/rotation
  110930. */
  110931. protected _update(): void;
  110932. private static _Scale;
  110933. /**
  110934. * Creates the lines for a light mesh
  110935. */
  110936. private static _createLightLines;
  110937. /**
  110938. * Disposes of the light gizmo
  110939. */
  110940. dispose(): void;
  110941. private static _CreateHemisphericLightMesh;
  110942. private static _CreatePointLightMesh;
  110943. private static _CreateSpotLightMesh;
  110944. private static _CreateDirectionalLightMesh;
  110945. }
  110946. }
  110947. declare module BABYLON {
  110948. /** @hidden */
  110949. export var backgroundFragmentDeclaration: {
  110950. name: string;
  110951. shader: string;
  110952. };
  110953. }
  110954. declare module BABYLON {
  110955. /** @hidden */
  110956. export var backgroundUboDeclaration: {
  110957. name: string;
  110958. shader: string;
  110959. };
  110960. }
  110961. declare module BABYLON {
  110962. /** @hidden */
  110963. export var backgroundPixelShader: {
  110964. name: string;
  110965. shader: string;
  110966. };
  110967. }
  110968. declare module BABYLON {
  110969. /** @hidden */
  110970. export var backgroundVertexDeclaration: {
  110971. name: string;
  110972. shader: string;
  110973. };
  110974. }
  110975. declare module BABYLON {
  110976. /** @hidden */
  110977. export var backgroundVertexShader: {
  110978. name: string;
  110979. shader: string;
  110980. };
  110981. }
  110982. declare module BABYLON {
  110983. /**
  110984. * Background material used to create an efficient environement around your scene.
  110985. */
  110986. export class BackgroundMaterial extends PushMaterial {
  110987. /**
  110988. * Standard reflectance value at parallel view angle.
  110989. */
  110990. static StandardReflectance0: number;
  110991. /**
  110992. * Standard reflectance value at grazing angle.
  110993. */
  110994. static StandardReflectance90: number;
  110995. protected _primaryColor: Color3;
  110996. /**
  110997. * Key light Color (multiply against the environement texture)
  110998. */
  110999. primaryColor: Color3;
  111000. protected __perceptualColor: Nullable<Color3>;
  111001. /**
  111002. * Experimental Internal Use Only.
  111003. *
  111004. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  111005. * This acts as a helper to set the primary color to a more "human friendly" value.
  111006. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  111007. * output color as close as possible from the chosen value.
  111008. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  111009. * part of lighting setup.)
  111010. */
  111011. _perceptualColor: Nullable<Color3>;
  111012. protected _primaryColorShadowLevel: float;
  111013. /**
  111014. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  111015. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  111016. */
  111017. primaryColorShadowLevel: float;
  111018. protected _primaryColorHighlightLevel: float;
  111019. /**
  111020. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  111021. * The primary color is used at the level chosen to define what the white area would look.
  111022. */
  111023. primaryColorHighlightLevel: float;
  111024. protected _reflectionTexture: Nullable<BaseTexture>;
  111025. /**
  111026. * Reflection Texture used in the material.
  111027. * Should be author in a specific way for the best result (refer to the documentation).
  111028. */
  111029. reflectionTexture: Nullable<BaseTexture>;
  111030. protected _reflectionBlur: float;
  111031. /**
  111032. * Reflection Texture level of blur.
  111033. *
  111034. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  111035. * texture twice.
  111036. */
  111037. reflectionBlur: float;
  111038. protected _diffuseTexture: Nullable<BaseTexture>;
  111039. /**
  111040. * Diffuse Texture used in the material.
  111041. * Should be author in a specific way for the best result (refer to the documentation).
  111042. */
  111043. diffuseTexture: Nullable<BaseTexture>;
  111044. protected _shadowLights: Nullable<IShadowLight[]>;
  111045. /**
  111046. * Specify the list of lights casting shadow on the material.
  111047. * All scene shadow lights will be included if null.
  111048. */
  111049. shadowLights: Nullable<IShadowLight[]>;
  111050. protected _shadowLevel: float;
  111051. /**
  111052. * Helps adjusting the shadow to a softer level if required.
  111053. * 0 means black shadows and 1 means no shadows.
  111054. */
  111055. shadowLevel: float;
  111056. protected _sceneCenter: Vector3;
  111057. /**
  111058. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  111059. * It is usually zero but might be interesting to modify according to your setup.
  111060. */
  111061. sceneCenter: Vector3;
  111062. protected _opacityFresnel: boolean;
  111063. /**
  111064. * This helps specifying that the material is falling off to the sky box at grazing angle.
  111065. * This helps ensuring a nice transition when the camera goes under the ground.
  111066. */
  111067. opacityFresnel: boolean;
  111068. protected _reflectionFresnel: boolean;
  111069. /**
  111070. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  111071. * This helps adding a mirror texture on the ground.
  111072. */
  111073. reflectionFresnel: boolean;
  111074. protected _reflectionFalloffDistance: number;
  111075. /**
  111076. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  111077. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  111078. */
  111079. reflectionFalloffDistance: number;
  111080. protected _reflectionAmount: number;
  111081. /**
  111082. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  111083. */
  111084. reflectionAmount: number;
  111085. protected _reflectionReflectance0: number;
  111086. /**
  111087. * This specifies the weight of the reflection at grazing angle.
  111088. */
  111089. reflectionReflectance0: number;
  111090. protected _reflectionReflectance90: number;
  111091. /**
  111092. * This specifies the weight of the reflection at a perpendicular point of view.
  111093. */
  111094. reflectionReflectance90: number;
  111095. /**
  111096. * Sets the reflection reflectance fresnel values according to the default standard
  111097. * empirically know to work well :-)
  111098. */
  111099. reflectionStandardFresnelWeight: number;
  111100. protected _useRGBColor: boolean;
  111101. /**
  111102. * Helps to directly use the maps channels instead of their level.
  111103. */
  111104. useRGBColor: boolean;
  111105. protected _enableNoise: boolean;
  111106. /**
  111107. * This helps reducing the banding effect that could occur on the background.
  111108. */
  111109. enableNoise: boolean;
  111110. /**
  111111. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  111112. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  111113. * Recommended to be keep at 1.0 except for special cases.
  111114. */
  111115. fovMultiplier: number;
  111116. private _fovMultiplier;
  111117. /**
  111118. * Enable the FOV adjustment feature controlled by fovMultiplier.
  111119. */
  111120. useEquirectangularFOV: boolean;
  111121. private _maxSimultaneousLights;
  111122. /**
  111123. * Number of Simultaneous lights allowed on the material.
  111124. */
  111125. maxSimultaneousLights: int;
  111126. /**
  111127. * Default configuration related to image processing available in the Background Material.
  111128. */
  111129. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  111130. /**
  111131. * Keep track of the image processing observer to allow dispose and replace.
  111132. */
  111133. private _imageProcessingObserver;
  111134. /**
  111135. * Attaches a new image processing configuration to the PBR Material.
  111136. * @param configuration (if null the scene configuration will be use)
  111137. */
  111138. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  111139. /**
  111140. * Gets the image processing configuration used either in this material.
  111141. */
  111142. /**
  111143. * Sets the Default image processing configuration used either in the this material.
  111144. *
  111145. * If sets to null, the scene one is in use.
  111146. */
  111147. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  111148. /**
  111149. * Gets wether the color curves effect is enabled.
  111150. */
  111151. /**
  111152. * Sets wether the color curves effect is enabled.
  111153. */
  111154. cameraColorCurvesEnabled: boolean;
  111155. /**
  111156. * Gets wether the color grading effect is enabled.
  111157. */
  111158. /**
  111159. * Gets wether the color grading effect is enabled.
  111160. */
  111161. cameraColorGradingEnabled: boolean;
  111162. /**
  111163. * Gets wether tonemapping is enabled or not.
  111164. */
  111165. /**
  111166. * Sets wether tonemapping is enabled or not
  111167. */
  111168. cameraToneMappingEnabled: boolean;
  111169. /**
  111170. * The camera exposure used on this material.
  111171. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  111172. * This corresponds to a photographic exposure.
  111173. */
  111174. /**
  111175. * The camera exposure used on this material.
  111176. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  111177. * This corresponds to a photographic exposure.
  111178. */
  111179. cameraExposure: float;
  111180. /**
  111181. * Gets The camera contrast used on this material.
  111182. */
  111183. /**
  111184. * Sets The camera contrast used on this material.
  111185. */
  111186. cameraContrast: float;
  111187. /**
  111188. * Gets the Color Grading 2D Lookup Texture.
  111189. */
  111190. /**
  111191. * Sets the Color Grading 2D Lookup Texture.
  111192. */
  111193. cameraColorGradingTexture: Nullable<BaseTexture>;
  111194. /**
  111195. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  111196. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  111197. * 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;
  111198. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  111199. */
  111200. /**
  111201. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  111202. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  111203. * 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;
  111204. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  111205. */
  111206. cameraColorCurves: Nullable<ColorCurves>;
  111207. /**
  111208. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  111209. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  111210. */
  111211. switchToBGR: boolean;
  111212. private _renderTargets;
  111213. private _reflectionControls;
  111214. private _white;
  111215. private _primaryShadowColor;
  111216. private _primaryHighlightColor;
  111217. /**
  111218. * Instantiates a Background Material in the given scene
  111219. * @param name The friendly name of the material
  111220. * @param scene The scene to add the material to
  111221. */
  111222. constructor(name: string, scene: Scene);
  111223. /**
  111224. * Gets a boolean indicating that current material needs to register RTT
  111225. */
  111226. readonly hasRenderTargetTextures: boolean;
  111227. /**
  111228. * The entire material has been created in order to prevent overdraw.
  111229. * @returns false
  111230. */
  111231. needAlphaTesting(): boolean;
  111232. /**
  111233. * The entire material has been created in order to prevent overdraw.
  111234. * @returns true if blending is enable
  111235. */
  111236. needAlphaBlending(): boolean;
  111237. /**
  111238. * Checks wether the material is ready to be rendered for a given mesh.
  111239. * @param mesh The mesh to render
  111240. * @param subMesh The submesh to check against
  111241. * @param useInstances Specify wether or not the material is used with instances
  111242. * @returns true if all the dependencies are ready (Textures, Effects...)
  111243. */
  111244. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  111245. /**
  111246. * Compute the primary color according to the chosen perceptual color.
  111247. */
  111248. private _computePrimaryColorFromPerceptualColor;
  111249. /**
  111250. * Compute the highlights and shadow colors according to their chosen levels.
  111251. */
  111252. private _computePrimaryColors;
  111253. /**
  111254. * Build the uniform buffer used in the material.
  111255. */
  111256. buildUniformLayout(): void;
  111257. /**
  111258. * Unbind the material.
  111259. */
  111260. unbind(): void;
  111261. /**
  111262. * Bind only the world matrix to the material.
  111263. * @param world The world matrix to bind.
  111264. */
  111265. bindOnlyWorldMatrix(world: Matrix): void;
  111266. /**
  111267. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  111268. * @param world The world matrix to bind.
  111269. * @param subMesh The submesh to bind for.
  111270. */
  111271. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  111272. /**
  111273. * Checks to see if a texture is used in the material.
  111274. * @param texture - Base texture to use.
  111275. * @returns - Boolean specifying if a texture is used in the material.
  111276. */
  111277. hasTexture(texture: BaseTexture): boolean;
  111278. /**
  111279. * Dispose the material.
  111280. * @param forceDisposeEffect Force disposal of the associated effect.
  111281. * @param forceDisposeTextures Force disposal of the associated textures.
  111282. */
  111283. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  111284. /**
  111285. * Clones the material.
  111286. * @param name The cloned name.
  111287. * @returns The cloned material.
  111288. */
  111289. clone(name: string): BackgroundMaterial;
  111290. /**
  111291. * Serializes the current material to its JSON representation.
  111292. * @returns The JSON representation.
  111293. */
  111294. serialize(): any;
  111295. /**
  111296. * Gets the class name of the material
  111297. * @returns "BackgroundMaterial"
  111298. */
  111299. getClassName(): string;
  111300. /**
  111301. * Parse a JSON input to create back a background material.
  111302. * @param source The JSON data to parse
  111303. * @param scene The scene to create the parsed material in
  111304. * @param rootUrl The root url of the assets the material depends upon
  111305. * @returns the instantiated BackgroundMaterial.
  111306. */
  111307. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  111308. }
  111309. }
  111310. declare module BABYLON {
  111311. /**
  111312. * Represents the different options available during the creation of
  111313. * a Environment helper.
  111314. *
  111315. * This can control the default ground, skybox and image processing setup of your scene.
  111316. */
  111317. export interface IEnvironmentHelperOptions {
  111318. /**
  111319. * Specifies wether or not to create a ground.
  111320. * True by default.
  111321. */
  111322. createGround: boolean;
  111323. /**
  111324. * Specifies the ground size.
  111325. * 15 by default.
  111326. */
  111327. groundSize: number;
  111328. /**
  111329. * The texture used on the ground for the main color.
  111330. * Comes from the BabylonJS CDN by default.
  111331. *
  111332. * Remarks: Can be either a texture or a url.
  111333. */
  111334. groundTexture: string | BaseTexture;
  111335. /**
  111336. * The color mixed in the ground texture by default.
  111337. * BabylonJS clearColor by default.
  111338. */
  111339. groundColor: Color3;
  111340. /**
  111341. * Specifies the ground opacity.
  111342. * 1 by default.
  111343. */
  111344. groundOpacity: number;
  111345. /**
  111346. * Enables the ground to receive shadows.
  111347. * True by default.
  111348. */
  111349. enableGroundShadow: boolean;
  111350. /**
  111351. * Helps preventing the shadow to be fully black on the ground.
  111352. * 0.5 by default.
  111353. */
  111354. groundShadowLevel: number;
  111355. /**
  111356. * Creates a mirror texture attach to the ground.
  111357. * false by default.
  111358. */
  111359. enableGroundMirror: boolean;
  111360. /**
  111361. * Specifies the ground mirror size ratio.
  111362. * 0.3 by default as the default kernel is 64.
  111363. */
  111364. groundMirrorSizeRatio: number;
  111365. /**
  111366. * Specifies the ground mirror blur kernel size.
  111367. * 64 by default.
  111368. */
  111369. groundMirrorBlurKernel: number;
  111370. /**
  111371. * Specifies the ground mirror visibility amount.
  111372. * 1 by default
  111373. */
  111374. groundMirrorAmount: number;
  111375. /**
  111376. * Specifies the ground mirror reflectance weight.
  111377. * This uses the standard weight of the background material to setup the fresnel effect
  111378. * of the mirror.
  111379. * 1 by default.
  111380. */
  111381. groundMirrorFresnelWeight: number;
  111382. /**
  111383. * Specifies the ground mirror Falloff distance.
  111384. * This can helps reducing the size of the reflection.
  111385. * 0 by Default.
  111386. */
  111387. groundMirrorFallOffDistance: number;
  111388. /**
  111389. * Specifies the ground mirror texture type.
  111390. * Unsigned Int by Default.
  111391. */
  111392. groundMirrorTextureType: number;
  111393. /**
  111394. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  111395. * the shown objects.
  111396. */
  111397. groundYBias: number;
  111398. /**
  111399. * Specifies wether or not to create a skybox.
  111400. * True by default.
  111401. */
  111402. createSkybox: boolean;
  111403. /**
  111404. * Specifies the skybox size.
  111405. * 20 by default.
  111406. */
  111407. skyboxSize: number;
  111408. /**
  111409. * The texture used on the skybox for the main color.
  111410. * Comes from the BabylonJS CDN by default.
  111411. *
  111412. * Remarks: Can be either a texture or a url.
  111413. */
  111414. skyboxTexture: string | BaseTexture;
  111415. /**
  111416. * The color mixed in the skybox texture by default.
  111417. * BabylonJS clearColor by default.
  111418. */
  111419. skyboxColor: Color3;
  111420. /**
  111421. * The background rotation around the Y axis of the scene.
  111422. * This helps aligning the key lights of your scene with the background.
  111423. * 0 by default.
  111424. */
  111425. backgroundYRotation: number;
  111426. /**
  111427. * Compute automatically the size of the elements to best fit with the scene.
  111428. */
  111429. sizeAuto: boolean;
  111430. /**
  111431. * Default position of the rootMesh if autoSize is not true.
  111432. */
  111433. rootPosition: Vector3;
  111434. /**
  111435. * Sets up the image processing in the scene.
  111436. * true by default.
  111437. */
  111438. setupImageProcessing: boolean;
  111439. /**
  111440. * The texture used as your environment texture in the scene.
  111441. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  111442. *
  111443. * Remarks: Can be either a texture or a url.
  111444. */
  111445. environmentTexture: string | BaseTexture;
  111446. /**
  111447. * The value of the exposure to apply to the scene.
  111448. * 0.6 by default if setupImageProcessing is true.
  111449. */
  111450. cameraExposure: number;
  111451. /**
  111452. * The value of the contrast to apply to the scene.
  111453. * 1.6 by default if setupImageProcessing is true.
  111454. */
  111455. cameraContrast: number;
  111456. /**
  111457. * Specifies wether or not tonemapping should be enabled in the scene.
  111458. * true by default if setupImageProcessing is true.
  111459. */
  111460. toneMappingEnabled: boolean;
  111461. }
  111462. /**
  111463. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  111464. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  111465. * It also helps with the default setup of your imageProcessing configuration.
  111466. */
  111467. export class EnvironmentHelper {
  111468. /**
  111469. * Default ground texture URL.
  111470. */
  111471. private static _groundTextureCDNUrl;
  111472. /**
  111473. * Default skybox texture URL.
  111474. */
  111475. private static _skyboxTextureCDNUrl;
  111476. /**
  111477. * Default environment texture URL.
  111478. */
  111479. private static _environmentTextureCDNUrl;
  111480. /**
  111481. * Creates the default options for the helper.
  111482. */
  111483. private static _getDefaultOptions;
  111484. private _rootMesh;
  111485. /**
  111486. * Gets the root mesh created by the helper.
  111487. */
  111488. readonly rootMesh: Mesh;
  111489. private _skybox;
  111490. /**
  111491. * Gets the skybox created by the helper.
  111492. */
  111493. readonly skybox: Nullable<Mesh>;
  111494. private _skyboxTexture;
  111495. /**
  111496. * Gets the skybox texture created by the helper.
  111497. */
  111498. readonly skyboxTexture: Nullable<BaseTexture>;
  111499. private _skyboxMaterial;
  111500. /**
  111501. * Gets the skybox material created by the helper.
  111502. */
  111503. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  111504. private _ground;
  111505. /**
  111506. * Gets the ground mesh created by the helper.
  111507. */
  111508. readonly ground: Nullable<Mesh>;
  111509. private _groundTexture;
  111510. /**
  111511. * Gets the ground texture created by the helper.
  111512. */
  111513. readonly groundTexture: Nullable<BaseTexture>;
  111514. private _groundMirror;
  111515. /**
  111516. * Gets the ground mirror created by the helper.
  111517. */
  111518. readonly groundMirror: Nullable<MirrorTexture>;
  111519. /**
  111520. * Gets the ground mirror render list to helps pushing the meshes
  111521. * you wish in the ground reflection.
  111522. */
  111523. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  111524. private _groundMaterial;
  111525. /**
  111526. * Gets the ground material created by the helper.
  111527. */
  111528. readonly groundMaterial: Nullable<BackgroundMaterial>;
  111529. /**
  111530. * Stores the creation options.
  111531. */
  111532. private readonly _scene;
  111533. private _options;
  111534. /**
  111535. * This observable will be notified with any error during the creation of the environment,
  111536. * mainly texture creation errors.
  111537. */
  111538. onErrorObservable: Observable<{
  111539. message?: string;
  111540. exception?: any;
  111541. }>;
  111542. /**
  111543. * constructor
  111544. * @param options Defines the options we want to customize the helper
  111545. * @param scene The scene to add the material to
  111546. */
  111547. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  111548. /**
  111549. * Updates the background according to the new options
  111550. * @param options
  111551. */
  111552. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  111553. /**
  111554. * Sets the primary color of all the available elements.
  111555. * @param color the main color to affect to the ground and the background
  111556. */
  111557. setMainColor(color: Color3): void;
  111558. /**
  111559. * Setup the image processing according to the specified options.
  111560. */
  111561. private _setupImageProcessing;
  111562. /**
  111563. * Setup the environment texture according to the specified options.
  111564. */
  111565. private _setupEnvironmentTexture;
  111566. /**
  111567. * Setup the background according to the specified options.
  111568. */
  111569. private _setupBackground;
  111570. /**
  111571. * Get the scene sizes according to the setup.
  111572. */
  111573. private _getSceneSize;
  111574. /**
  111575. * Setup the ground according to the specified options.
  111576. */
  111577. private _setupGround;
  111578. /**
  111579. * Setup the ground material according to the specified options.
  111580. */
  111581. private _setupGroundMaterial;
  111582. /**
  111583. * Setup the ground diffuse texture according to the specified options.
  111584. */
  111585. private _setupGroundDiffuseTexture;
  111586. /**
  111587. * Setup the ground mirror texture according to the specified options.
  111588. */
  111589. private _setupGroundMirrorTexture;
  111590. /**
  111591. * Setup the ground to receive the mirror texture.
  111592. */
  111593. private _setupMirrorInGroundMaterial;
  111594. /**
  111595. * Setup the skybox according to the specified options.
  111596. */
  111597. private _setupSkybox;
  111598. /**
  111599. * Setup the skybox material according to the specified options.
  111600. */
  111601. private _setupSkyboxMaterial;
  111602. /**
  111603. * Setup the skybox reflection texture according to the specified options.
  111604. */
  111605. private _setupSkyboxReflectionTexture;
  111606. private _errorHandler;
  111607. /**
  111608. * Dispose all the elements created by the Helper.
  111609. */
  111610. dispose(): void;
  111611. }
  111612. }
  111613. declare module BABYLON {
  111614. /**
  111615. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  111616. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  111617. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  111618. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  111619. */
  111620. export class PhotoDome extends TransformNode {
  111621. /**
  111622. * Define the image as a Monoscopic panoramic 360 image.
  111623. */
  111624. static readonly MODE_MONOSCOPIC: number;
  111625. /**
  111626. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  111627. */
  111628. static readonly MODE_TOPBOTTOM: number;
  111629. /**
  111630. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  111631. */
  111632. static readonly MODE_SIDEBYSIDE: number;
  111633. private _useDirectMapping;
  111634. /**
  111635. * The texture being displayed on the sphere
  111636. */
  111637. protected _photoTexture: Texture;
  111638. /**
  111639. * Gets or sets the texture being displayed on the sphere
  111640. */
  111641. photoTexture: Texture;
  111642. /**
  111643. * Observable raised when an error occured while loading the 360 image
  111644. */
  111645. onLoadErrorObservable: Observable<string>;
  111646. /**
  111647. * The skybox material
  111648. */
  111649. protected _material: BackgroundMaterial;
  111650. /**
  111651. * The surface used for the skybox
  111652. */
  111653. protected _mesh: Mesh;
  111654. /**
  111655. * Gets the mesh used for the skybox.
  111656. */
  111657. readonly mesh: Mesh;
  111658. /**
  111659. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  111660. * Also see the options.resolution property.
  111661. */
  111662. fovMultiplier: number;
  111663. private _imageMode;
  111664. /**
  111665. * Gets or set the current video mode for the video. It can be:
  111666. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  111667. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  111668. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  111669. */
  111670. imageMode: number;
  111671. /**
  111672. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  111673. * @param name Element's name, child elements will append suffixes for their own names.
  111674. * @param urlsOfPhoto defines the url of the photo to display
  111675. * @param options defines an object containing optional or exposed sub element properties
  111676. * @param onError defines a callback called when an error occured while loading the texture
  111677. */
  111678. constructor(name: string, urlOfPhoto: string, options: {
  111679. resolution?: number;
  111680. size?: number;
  111681. useDirectMapping?: boolean;
  111682. faceForward?: boolean;
  111683. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  111684. private _onBeforeCameraRenderObserver;
  111685. private _changeImageMode;
  111686. /**
  111687. * Releases resources associated with this node.
  111688. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  111689. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  111690. */
  111691. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  111692. }
  111693. }
  111694. declare module BABYLON {
  111695. /**
  111696. * Class used to host RGBD texture specific utilities
  111697. */
  111698. export class RGBDTextureTools {
  111699. /**
  111700. * Expand the RGBD Texture from RGBD to Half Float if possible.
  111701. * @param texture the texture to expand.
  111702. */
  111703. static ExpandRGBDTexture(texture: Texture): void;
  111704. }
  111705. }
  111706. declare module BABYLON {
  111707. /**
  111708. * Class used to host texture specific utilities
  111709. */
  111710. export class BRDFTextureTools {
  111711. /**
  111712. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  111713. * @param scene defines the hosting scene
  111714. * @returns the environment BRDF texture
  111715. */
  111716. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  111717. private static _environmentBRDFBase64Texture;
  111718. }
  111719. }
  111720. declare module BABYLON {
  111721. /**
  111722. * @hidden
  111723. */
  111724. export interface IMaterialClearCoatDefines {
  111725. CLEARCOAT: boolean;
  111726. CLEARCOAT_DEFAULTIOR: boolean;
  111727. CLEARCOAT_TEXTURE: boolean;
  111728. CLEARCOAT_TEXTUREDIRECTUV: number;
  111729. CLEARCOAT_BUMP: boolean;
  111730. CLEARCOAT_BUMPDIRECTUV: number;
  111731. CLEARCOAT_TINT: boolean;
  111732. CLEARCOAT_TINT_TEXTURE: boolean;
  111733. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  111734. /** @hidden */
  111735. _areTexturesDirty: boolean;
  111736. }
  111737. /**
  111738. * Define the code related to the clear coat parameters of the pbr material.
  111739. */
  111740. export class PBRClearCoatConfiguration {
  111741. /**
  111742. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  111743. * The default fits with a polyurethane material.
  111744. */
  111745. private static readonly _DefaultIndexOfRefraction;
  111746. private _isEnabled;
  111747. /**
  111748. * Defines if the clear coat is enabled in the material.
  111749. */
  111750. isEnabled: boolean;
  111751. /**
  111752. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  111753. */
  111754. intensity: number;
  111755. /**
  111756. * Defines the clear coat layer roughness.
  111757. */
  111758. roughness: number;
  111759. private _indexOfRefraction;
  111760. /**
  111761. * Defines the index of refraction of the clear coat.
  111762. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  111763. * The default fits with a polyurethane material.
  111764. * Changing the default value is more performance intensive.
  111765. */
  111766. indexOfRefraction: number;
  111767. private _texture;
  111768. /**
  111769. * Stores the clear coat values in a texture.
  111770. */
  111771. texture: Nullable<BaseTexture>;
  111772. private _bumpTexture;
  111773. /**
  111774. * Define the clear coat specific bump texture.
  111775. */
  111776. bumpTexture: Nullable<BaseTexture>;
  111777. private _isTintEnabled;
  111778. /**
  111779. * Defines if the clear coat tint is enabled in the material.
  111780. */
  111781. isTintEnabled: boolean;
  111782. /**
  111783. * Defines the clear coat tint of the material.
  111784. * This is only use if tint is enabled
  111785. */
  111786. tintColor: Color3;
  111787. /**
  111788. * Defines the distance at which the tint color should be found in the
  111789. * clear coat media.
  111790. * This is only use if tint is enabled
  111791. */
  111792. tintColorAtDistance: number;
  111793. /**
  111794. * Defines the clear coat layer thickness.
  111795. * This is only use if tint is enabled
  111796. */
  111797. tintThickness: number;
  111798. private _tintTexture;
  111799. /**
  111800. * Stores the clear tint values in a texture.
  111801. * rgb is tint
  111802. * a is a thickness factor
  111803. */
  111804. tintTexture: Nullable<BaseTexture>;
  111805. /** @hidden */
  111806. private _internalMarkAllSubMeshesAsTexturesDirty;
  111807. /** @hidden */
  111808. _markAllSubMeshesAsTexturesDirty(): void;
  111809. /**
  111810. * Instantiate a new istance of clear coat configuration.
  111811. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  111812. */
  111813. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  111814. /**
  111815. * Gets wehter the submesh is ready to be used or not.
  111816. * @param defines the list of "defines" to update.
  111817. * @param scene defines the scene the material belongs to.
  111818. * @param engine defines the engine the material belongs to.
  111819. * @param disableBumpMap defines wether the material disables bump or not.
  111820. * @returns - boolean indicating that the submesh is ready or not.
  111821. */
  111822. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  111823. /**
  111824. * Checks to see if a texture is used in the material.
  111825. * @param defines the list of "defines" to update.
  111826. * @param scene defines the scene to the material belongs to.
  111827. */
  111828. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  111829. /**
  111830. * Binds the material data.
  111831. * @param uniformBuffer defines the Uniform buffer to fill in.
  111832. * @param scene defines the scene the material belongs to.
  111833. * @param engine defines the engine the material belongs to.
  111834. * @param disableBumpMap defines wether the material disables bump or not.
  111835. * @param isFrozen defines wether the material is frozen or not.
  111836. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  111837. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  111838. */
  111839. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  111840. /**
  111841. * Checks to see if a texture is used in the material.
  111842. * @param texture - Base texture to use.
  111843. * @returns - Boolean specifying if a texture is used in the material.
  111844. */
  111845. hasTexture(texture: BaseTexture): boolean;
  111846. /**
  111847. * Returns an array of the actively used textures.
  111848. * @param activeTextures Array of BaseTextures
  111849. */
  111850. getActiveTextures(activeTextures: BaseTexture[]): void;
  111851. /**
  111852. * Returns the animatable textures.
  111853. * @param animatables Array of animatable textures.
  111854. */
  111855. getAnimatables(animatables: IAnimatable[]): void;
  111856. /**
  111857. * Disposes the resources of the material.
  111858. * @param forceDisposeTextures - Forces the disposal of all textures.
  111859. */
  111860. dispose(forceDisposeTextures?: boolean): void;
  111861. /**
  111862. * Get the current class name of the texture useful for serialization or dynamic coding.
  111863. * @returns "PBRClearCoatConfiguration"
  111864. */
  111865. getClassName(): string;
  111866. /**
  111867. * Add fallbacks to the effect fallbacks list.
  111868. * @param defines defines the Base texture to use.
  111869. * @param fallbacks defines the current fallback list.
  111870. * @param currentRank defines the current fallback rank.
  111871. * @returns the new fallback rank.
  111872. */
  111873. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  111874. /**
  111875. * Add the required uniforms to the current list.
  111876. * @param uniforms defines the current uniform list.
  111877. */
  111878. static AddUniforms(uniforms: string[]): void;
  111879. /**
  111880. * Add the required samplers to the current list.
  111881. * @param samplers defines the current sampler list.
  111882. */
  111883. static AddSamplers(samplers: string[]): void;
  111884. /**
  111885. * Add the required uniforms to the current buffer.
  111886. * @param uniformBuffer defines the current uniform buffer.
  111887. */
  111888. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  111889. /**
  111890. * Makes a duplicate of the current configuration into another one.
  111891. * @param clearCoatConfiguration define the config where to copy the info
  111892. */
  111893. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  111894. /**
  111895. * Serializes this clear coat configuration.
  111896. * @returns - An object with the serialized config.
  111897. */
  111898. serialize(): any;
  111899. /**
  111900. * Parses a anisotropy Configuration from a serialized object.
  111901. * @param source - Serialized object.
  111902. * @param scene Defines the scene we are parsing for
  111903. * @param rootUrl Defines the rootUrl to load from
  111904. */
  111905. parse(source: any, scene: Scene, rootUrl: string): void;
  111906. }
  111907. }
  111908. declare module BABYLON {
  111909. /**
  111910. * @hidden
  111911. */
  111912. export interface IMaterialAnisotropicDefines {
  111913. ANISOTROPIC: boolean;
  111914. ANISOTROPIC_TEXTURE: boolean;
  111915. ANISOTROPIC_TEXTUREDIRECTUV: number;
  111916. MAINUV1: boolean;
  111917. _areTexturesDirty: boolean;
  111918. _needUVs: boolean;
  111919. }
  111920. /**
  111921. * Define the code related to the anisotropic parameters of the pbr material.
  111922. */
  111923. export class PBRAnisotropicConfiguration {
  111924. private _isEnabled;
  111925. /**
  111926. * Defines if the anisotropy is enabled in the material.
  111927. */
  111928. isEnabled: boolean;
  111929. /**
  111930. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  111931. */
  111932. intensity: number;
  111933. /**
  111934. * Defines if the effect is along the tangents, bitangents or in between.
  111935. * By default, the effect is "strectching" the highlights along the tangents.
  111936. */
  111937. direction: Vector2;
  111938. private _texture;
  111939. /**
  111940. * Stores the anisotropy values in a texture.
  111941. * rg is direction (like normal from -1 to 1)
  111942. * b is a intensity
  111943. */
  111944. texture: Nullable<BaseTexture>;
  111945. /** @hidden */
  111946. private _internalMarkAllSubMeshesAsTexturesDirty;
  111947. /** @hidden */
  111948. _markAllSubMeshesAsTexturesDirty(): void;
  111949. /**
  111950. * Instantiate a new istance of anisotropy configuration.
  111951. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  111952. */
  111953. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  111954. /**
  111955. * Specifies that the submesh is ready to be used.
  111956. * @param defines the list of "defines" to update.
  111957. * @param scene defines the scene the material belongs to.
  111958. * @returns - boolean indicating that the submesh is ready or not.
  111959. */
  111960. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  111961. /**
  111962. * Checks to see if a texture is used in the material.
  111963. * @param defines the list of "defines" to update.
  111964. * @param mesh the mesh we are preparing the defines for.
  111965. * @param scene defines the scene the material belongs to.
  111966. */
  111967. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  111968. /**
  111969. * Binds the material data.
  111970. * @param uniformBuffer defines the Uniform buffer to fill in.
  111971. * @param scene defines the scene the material belongs to.
  111972. * @param isFrozen defines wether the material is frozen or not.
  111973. */
  111974. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  111975. /**
  111976. * Checks to see if a texture is used in the material.
  111977. * @param texture - Base texture to use.
  111978. * @returns - Boolean specifying if a texture is used in the material.
  111979. */
  111980. hasTexture(texture: BaseTexture): boolean;
  111981. /**
  111982. * Returns an array of the actively used textures.
  111983. * @param activeTextures Array of BaseTextures
  111984. */
  111985. getActiveTextures(activeTextures: BaseTexture[]): void;
  111986. /**
  111987. * Returns the animatable textures.
  111988. * @param animatables Array of animatable textures.
  111989. */
  111990. getAnimatables(animatables: IAnimatable[]): void;
  111991. /**
  111992. * Disposes the resources of the material.
  111993. * @param forceDisposeTextures - Forces the disposal of all textures.
  111994. */
  111995. dispose(forceDisposeTextures?: boolean): void;
  111996. /**
  111997. * Get the current class name of the texture useful for serialization or dynamic coding.
  111998. * @returns "PBRAnisotropicConfiguration"
  111999. */
  112000. getClassName(): string;
  112001. /**
  112002. * Add fallbacks to the effect fallbacks list.
  112003. * @param defines defines the Base texture to use.
  112004. * @param fallbacks defines the current fallback list.
  112005. * @param currentRank defines the current fallback rank.
  112006. * @returns the new fallback rank.
  112007. */
  112008. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  112009. /**
  112010. * Add the required uniforms to the current list.
  112011. * @param uniforms defines the current uniform list.
  112012. */
  112013. static AddUniforms(uniforms: string[]): void;
  112014. /**
  112015. * Add the required uniforms to the current buffer.
  112016. * @param uniformBuffer defines the current uniform buffer.
  112017. */
  112018. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  112019. /**
  112020. * Add the required samplers to the current list.
  112021. * @param samplers defines the current sampler list.
  112022. */
  112023. static AddSamplers(samplers: string[]): void;
  112024. /**
  112025. * Makes a duplicate of the current configuration into another one.
  112026. * @param anisotropicConfiguration define the config where to copy the info
  112027. */
  112028. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  112029. /**
  112030. * Serializes this anisotropy configuration.
  112031. * @returns - An object with the serialized config.
  112032. */
  112033. serialize(): any;
  112034. /**
  112035. * Parses a anisotropy Configuration from a serialized object.
  112036. * @param source - Serialized object.
  112037. * @param scene Defines the scene we are parsing for
  112038. * @param rootUrl Defines the rootUrl to load from
  112039. */
  112040. parse(source: any, scene: Scene, rootUrl: string): void;
  112041. }
  112042. }
  112043. declare module BABYLON {
  112044. /**
  112045. * @hidden
  112046. */
  112047. export interface IMaterialBRDFDefines {
  112048. BRDF_V_HEIGHT_CORRELATED: boolean;
  112049. MS_BRDF_ENERGY_CONSERVATION: boolean;
  112050. SPHERICAL_HARMONICS: boolean;
  112051. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  112052. /** @hidden */
  112053. _areMiscDirty: boolean;
  112054. }
  112055. /**
  112056. * Define the code related to the BRDF parameters of the pbr material.
  112057. */
  112058. export class PBRBRDFConfiguration {
  112059. /**
  112060. * Default value used for the energy conservation.
  112061. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  112062. */
  112063. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  112064. /**
  112065. * Default value used for the Smith Visibility Height Correlated mode.
  112066. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  112067. */
  112068. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  112069. /**
  112070. * Default value used for the IBL diffuse part.
  112071. * This can help switching back to the polynomials mode globally which is a tiny bit
  112072. * less GPU intensive at the drawback of a lower quality.
  112073. */
  112074. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  112075. /**
  112076. * Default value used for activating energy conservation for the specular workflow.
  112077. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  112078. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  112079. */
  112080. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  112081. private _useEnergyConservation;
  112082. /**
  112083. * Defines if the material uses energy conservation.
  112084. */
  112085. useEnergyConservation: boolean;
  112086. private _useSmithVisibilityHeightCorrelated;
  112087. /**
  112088. * LEGACY Mode set to false
  112089. * Defines if the material uses height smith correlated visibility term.
  112090. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  112091. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  112092. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  112093. * Not relying on height correlated will also disable energy conservation.
  112094. */
  112095. useSmithVisibilityHeightCorrelated: boolean;
  112096. private _useSphericalHarmonics;
  112097. /**
  112098. * LEGACY Mode set to false
  112099. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  112100. * diffuse part of the IBL.
  112101. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  112102. * to the ground truth.
  112103. */
  112104. useSphericalHarmonics: boolean;
  112105. private _useSpecularGlossinessInputEnergyConservation;
  112106. /**
  112107. * Defines if the material uses energy conservation, when the specular workflow is active.
  112108. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  112109. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  112110. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  112111. */
  112112. useSpecularGlossinessInputEnergyConservation: boolean;
  112113. /** @hidden */
  112114. private _internalMarkAllSubMeshesAsMiscDirty;
  112115. /** @hidden */
  112116. _markAllSubMeshesAsMiscDirty(): void;
  112117. /**
  112118. * Instantiate a new istance of clear coat configuration.
  112119. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  112120. */
  112121. constructor(markAllSubMeshesAsMiscDirty: () => void);
  112122. /**
  112123. * Checks to see if a texture is used in the material.
  112124. * @param defines the list of "defines" to update.
  112125. */
  112126. prepareDefines(defines: IMaterialBRDFDefines): void;
  112127. /**
  112128. * Get the current class name of the texture useful for serialization or dynamic coding.
  112129. * @returns "PBRClearCoatConfiguration"
  112130. */
  112131. getClassName(): string;
  112132. /**
  112133. * Makes a duplicate of the current configuration into another one.
  112134. * @param brdfConfiguration define the config where to copy the info
  112135. */
  112136. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  112137. /**
  112138. * Serializes this BRDF configuration.
  112139. * @returns - An object with the serialized config.
  112140. */
  112141. serialize(): any;
  112142. /**
  112143. * Parses a anisotropy Configuration from a serialized object.
  112144. * @param source - Serialized object.
  112145. * @param scene Defines the scene we are parsing for
  112146. * @param rootUrl Defines the rootUrl to load from
  112147. */
  112148. parse(source: any, scene: Scene, rootUrl: string): void;
  112149. }
  112150. }
  112151. declare module BABYLON {
  112152. /**
  112153. * @hidden
  112154. */
  112155. export interface IMaterialSheenDefines {
  112156. SHEEN: boolean;
  112157. SHEEN_TEXTURE: boolean;
  112158. SHEEN_TEXTUREDIRECTUV: number;
  112159. SHEEN_LINKWITHALBEDO: boolean;
  112160. /** @hidden */
  112161. _areTexturesDirty: boolean;
  112162. }
  112163. /**
  112164. * Define the code related to the Sheen parameters of the pbr material.
  112165. */
  112166. export class PBRSheenConfiguration {
  112167. private _isEnabled;
  112168. /**
  112169. * Defines if the material uses sheen.
  112170. */
  112171. isEnabled: boolean;
  112172. private _linkSheenWithAlbedo;
  112173. /**
  112174. * Defines if the sheen is linked to the sheen color.
  112175. */
  112176. linkSheenWithAlbedo: boolean;
  112177. /**
  112178. * Defines the sheen intensity.
  112179. */
  112180. intensity: number;
  112181. /**
  112182. * Defines the sheen color.
  112183. */
  112184. color: Color3;
  112185. private _texture;
  112186. /**
  112187. * Stores the sheen tint values in a texture.
  112188. * rgb is tint
  112189. * a is a intensity
  112190. */
  112191. texture: Nullable<BaseTexture>;
  112192. /** @hidden */
  112193. private _internalMarkAllSubMeshesAsTexturesDirty;
  112194. /** @hidden */
  112195. _markAllSubMeshesAsTexturesDirty(): void;
  112196. /**
  112197. * Instantiate a new istance of clear coat configuration.
  112198. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  112199. */
  112200. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  112201. /**
  112202. * Specifies that the submesh is ready to be used.
  112203. * @param defines the list of "defines" to update.
  112204. * @param scene defines the scene the material belongs to.
  112205. * @returns - boolean indicating that the submesh is ready or not.
  112206. */
  112207. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  112208. /**
  112209. * Checks to see if a texture is used in the material.
  112210. * @param defines the list of "defines" to update.
  112211. * @param scene defines the scene the material belongs to.
  112212. */
  112213. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  112214. /**
  112215. * Binds the material data.
  112216. * @param uniformBuffer defines the Uniform buffer to fill in.
  112217. * @param scene defines the scene the material belongs to.
  112218. * @param isFrozen defines wether the material is frozen or not.
  112219. */
  112220. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  112221. /**
  112222. * Checks to see if a texture is used in the material.
  112223. * @param texture - Base texture to use.
  112224. * @returns - Boolean specifying if a texture is used in the material.
  112225. */
  112226. hasTexture(texture: BaseTexture): boolean;
  112227. /**
  112228. * Returns an array of the actively used textures.
  112229. * @param activeTextures Array of BaseTextures
  112230. */
  112231. getActiveTextures(activeTextures: BaseTexture[]): void;
  112232. /**
  112233. * Returns the animatable textures.
  112234. * @param animatables Array of animatable textures.
  112235. */
  112236. getAnimatables(animatables: IAnimatable[]): void;
  112237. /**
  112238. * Disposes the resources of the material.
  112239. * @param forceDisposeTextures - Forces the disposal of all textures.
  112240. */
  112241. dispose(forceDisposeTextures?: boolean): void;
  112242. /**
  112243. * Get the current class name of the texture useful for serialization or dynamic coding.
  112244. * @returns "PBRSheenConfiguration"
  112245. */
  112246. getClassName(): string;
  112247. /**
  112248. * Add fallbacks to the effect fallbacks list.
  112249. * @param defines defines the Base texture to use.
  112250. * @param fallbacks defines the current fallback list.
  112251. * @param currentRank defines the current fallback rank.
  112252. * @returns the new fallback rank.
  112253. */
  112254. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  112255. /**
  112256. * Add the required uniforms to the current list.
  112257. * @param uniforms defines the current uniform list.
  112258. */
  112259. static AddUniforms(uniforms: string[]): void;
  112260. /**
  112261. * Add the required uniforms to the current buffer.
  112262. * @param uniformBuffer defines the current uniform buffer.
  112263. */
  112264. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  112265. /**
  112266. * Add the required samplers to the current list.
  112267. * @param samplers defines the current sampler list.
  112268. */
  112269. static AddSamplers(samplers: string[]): void;
  112270. /**
  112271. * Makes a duplicate of the current configuration into another one.
  112272. * @param sheenConfiguration define the config where to copy the info
  112273. */
  112274. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  112275. /**
  112276. * Serializes this BRDF configuration.
  112277. * @returns - An object with the serialized config.
  112278. */
  112279. serialize(): any;
  112280. /**
  112281. * Parses a anisotropy Configuration from a serialized object.
  112282. * @param source - Serialized object.
  112283. * @param scene Defines the scene we are parsing for
  112284. * @param rootUrl Defines the rootUrl to load from
  112285. */
  112286. parse(source: any, scene: Scene, rootUrl: string): void;
  112287. }
  112288. }
  112289. declare module BABYLON {
  112290. /**
  112291. * @hidden
  112292. */
  112293. export interface IMaterialSubSurfaceDefines {
  112294. SUBSURFACE: boolean;
  112295. SS_REFRACTION: boolean;
  112296. SS_TRANSLUCENCY: boolean;
  112297. SS_SCATERRING: boolean;
  112298. SS_THICKNESSANDMASK_TEXTURE: boolean;
  112299. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  112300. SS_REFRACTIONMAP_3D: boolean;
  112301. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  112302. SS_LODINREFRACTIONALPHA: boolean;
  112303. SS_GAMMAREFRACTION: boolean;
  112304. SS_RGBDREFRACTION: boolean;
  112305. SS_LINEARSPECULARREFRACTION: boolean;
  112306. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  112307. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  112308. /** @hidden */
  112309. _areTexturesDirty: boolean;
  112310. }
  112311. /**
  112312. * Define the code related to the sub surface parameters of the pbr material.
  112313. */
  112314. export class PBRSubSurfaceConfiguration {
  112315. private _isRefractionEnabled;
  112316. /**
  112317. * Defines if the refraction is enabled in the material.
  112318. */
  112319. isRefractionEnabled: boolean;
  112320. private _isTranslucencyEnabled;
  112321. /**
  112322. * Defines if the translucency is enabled in the material.
  112323. */
  112324. isTranslucencyEnabled: boolean;
  112325. private _isScatteringEnabled;
  112326. /**
  112327. * Defines the refraction intensity of the material.
  112328. * The refraction when enabled replaces the Diffuse part of the material.
  112329. * The intensity helps transitionning between diffuse and refraction.
  112330. */
  112331. refractionIntensity: number;
  112332. /**
  112333. * Defines the translucency intensity of the material.
  112334. * When translucency has been enabled, this defines how much of the "translucency"
  112335. * is addded to the diffuse part of the material.
  112336. */
  112337. translucencyIntensity: number;
  112338. /**
  112339. * Defines the scattering intensity of the material.
  112340. * When scattering has been enabled, this defines how much of the "scattered light"
  112341. * is addded to the diffuse part of the material.
  112342. */
  112343. scatteringIntensity: number;
  112344. private _thicknessTexture;
  112345. /**
  112346. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  112347. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  112348. * 0 would mean minimumThickness
  112349. * 1 would mean maximumThickness
  112350. * The other channels might be use as a mask to vary the different effects intensity.
  112351. */
  112352. thicknessTexture: Nullable<BaseTexture>;
  112353. private _refractionTexture;
  112354. /**
  112355. * Defines the texture to use for refraction.
  112356. */
  112357. refractionTexture: Nullable<BaseTexture>;
  112358. private _indexOfRefraction;
  112359. /**
  112360. * Defines the index of refraction used in the material.
  112361. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  112362. */
  112363. indexOfRefraction: number;
  112364. private _invertRefractionY;
  112365. /**
  112366. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  112367. */
  112368. invertRefractionY: boolean;
  112369. private _linkRefractionWithTransparency;
  112370. /**
  112371. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  112372. * Materials half opaque for instance using refraction could benefit from this control.
  112373. */
  112374. linkRefractionWithTransparency: boolean;
  112375. /**
  112376. * Defines the minimum thickness stored in the thickness map.
  112377. * If no thickness map is defined, this value will be used to simulate thickness.
  112378. */
  112379. minimumThickness: number;
  112380. /**
  112381. * Defines the maximum thickness stored in the thickness map.
  112382. */
  112383. maximumThickness: number;
  112384. /**
  112385. * Defines the volume tint of the material.
  112386. * This is used for both translucency and scattering.
  112387. */
  112388. tintColor: Color3;
  112389. /**
  112390. * Defines the distance at which the tint color should be found in the media.
  112391. * This is used for refraction only.
  112392. */
  112393. tintColorAtDistance: number;
  112394. /**
  112395. * Defines how far each channel transmit through the media.
  112396. * It is defined as a color to simplify it selection.
  112397. */
  112398. diffusionDistance: Color3;
  112399. private _useMaskFromThicknessTexture;
  112400. /**
  112401. * Stores the intensity of the different subsurface effects in the thickness texture.
  112402. * * the green channel is the translucency intensity.
  112403. * * the blue channel is the scattering intensity.
  112404. * * the alpha channel is the refraction intensity.
  112405. */
  112406. useMaskFromThicknessTexture: boolean;
  112407. /** @hidden */
  112408. private _internalMarkAllSubMeshesAsTexturesDirty;
  112409. /** @hidden */
  112410. _markAllSubMeshesAsTexturesDirty(): void;
  112411. /**
  112412. * Instantiate a new istance of sub surface configuration.
  112413. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  112414. */
  112415. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  112416. /**
  112417. * Gets wehter the submesh is ready to be used or not.
  112418. * @param defines the list of "defines" to update.
  112419. * @param scene defines the scene the material belongs to.
  112420. * @returns - boolean indicating that the submesh is ready or not.
  112421. */
  112422. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  112423. /**
  112424. * Checks to see if a texture is used in the material.
  112425. * @param defines the list of "defines" to update.
  112426. * @param scene defines the scene to the material belongs to.
  112427. */
  112428. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  112429. /**
  112430. * Binds the material data.
  112431. * @param uniformBuffer defines the Uniform buffer to fill in.
  112432. * @param scene defines the scene the material belongs to.
  112433. * @param engine defines the engine the material belongs to.
  112434. * @param isFrozen defines wether the material is frozen or not.
  112435. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  112436. */
  112437. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  112438. /**
  112439. * Unbinds the material from the mesh.
  112440. * @param activeEffect defines the effect that should be unbound from.
  112441. * @returns true if unbound, otherwise false
  112442. */
  112443. unbind(activeEffect: Effect): boolean;
  112444. /**
  112445. * Returns the texture used for refraction or null if none is used.
  112446. * @param scene defines the scene the material belongs to.
  112447. * @returns - Refraction texture if present. If no refraction texture and refraction
  112448. * is linked with transparency, returns environment texture. Otherwise, returns null.
  112449. */
  112450. private _getRefractionTexture;
  112451. /**
  112452. * Returns true if alpha blending should be disabled.
  112453. */
  112454. readonly disableAlphaBlending: boolean;
  112455. /**
  112456. * Fills the list of render target textures.
  112457. * @param renderTargets the list of render targets to update
  112458. */
  112459. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  112460. /**
  112461. * Checks to see if a texture is used in the material.
  112462. * @param texture - Base texture to use.
  112463. * @returns - Boolean specifying if a texture is used in the material.
  112464. */
  112465. hasTexture(texture: BaseTexture): boolean;
  112466. /**
  112467. * Gets a boolean indicating that current material needs to register RTT
  112468. * @returns true if this uses a render target otherwise false.
  112469. */
  112470. hasRenderTargetTextures(): boolean;
  112471. /**
  112472. * Returns an array of the actively used textures.
  112473. * @param activeTextures Array of BaseTextures
  112474. */
  112475. getActiveTextures(activeTextures: BaseTexture[]): void;
  112476. /**
  112477. * Returns the animatable textures.
  112478. * @param animatables Array of animatable textures.
  112479. */
  112480. getAnimatables(animatables: IAnimatable[]): void;
  112481. /**
  112482. * Disposes the resources of the material.
  112483. * @param forceDisposeTextures - Forces the disposal of all textures.
  112484. */
  112485. dispose(forceDisposeTextures?: boolean): void;
  112486. /**
  112487. * Get the current class name of the texture useful for serialization or dynamic coding.
  112488. * @returns "PBRSubSurfaceConfiguration"
  112489. */
  112490. getClassName(): string;
  112491. /**
  112492. * Add fallbacks to the effect fallbacks list.
  112493. * @param defines defines the Base texture to use.
  112494. * @param fallbacks defines the current fallback list.
  112495. * @param currentRank defines the current fallback rank.
  112496. * @returns the new fallback rank.
  112497. */
  112498. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  112499. /**
  112500. * Add the required uniforms to the current list.
  112501. * @param uniforms defines the current uniform list.
  112502. */
  112503. static AddUniforms(uniforms: string[]): void;
  112504. /**
  112505. * Add the required samplers to the current list.
  112506. * @param samplers defines the current sampler list.
  112507. */
  112508. static AddSamplers(samplers: string[]): void;
  112509. /**
  112510. * Add the required uniforms to the current buffer.
  112511. * @param uniformBuffer defines the current uniform buffer.
  112512. */
  112513. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  112514. /**
  112515. * Makes a duplicate of the current configuration into another one.
  112516. * @param configuration define the config where to copy the info
  112517. */
  112518. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  112519. /**
  112520. * Serializes this Sub Surface configuration.
  112521. * @returns - An object with the serialized config.
  112522. */
  112523. serialize(): any;
  112524. /**
  112525. * Parses a anisotropy Configuration from a serialized object.
  112526. * @param source - Serialized object.
  112527. * @param scene Defines the scene we are parsing for
  112528. * @param rootUrl Defines the rootUrl to load from
  112529. */
  112530. parse(source: any, scene: Scene, rootUrl: string): void;
  112531. }
  112532. }
  112533. declare module BABYLON {
  112534. /** @hidden */
  112535. export var pbrFragmentDeclaration: {
  112536. name: string;
  112537. shader: string;
  112538. };
  112539. }
  112540. declare module BABYLON {
  112541. /** @hidden */
  112542. export var pbrUboDeclaration: {
  112543. name: string;
  112544. shader: string;
  112545. };
  112546. }
  112547. declare module BABYLON {
  112548. /** @hidden */
  112549. export var pbrFragmentExtraDeclaration: {
  112550. name: string;
  112551. shader: string;
  112552. };
  112553. }
  112554. declare module BABYLON {
  112555. /** @hidden */
  112556. export var pbrFragmentSamplersDeclaration: {
  112557. name: string;
  112558. shader: string;
  112559. };
  112560. }
  112561. declare module BABYLON {
  112562. /** @hidden */
  112563. export var pbrHelperFunctions: {
  112564. name: string;
  112565. shader: string;
  112566. };
  112567. }
  112568. declare module BABYLON {
  112569. /** @hidden */
  112570. export var harmonicsFunctions: {
  112571. name: string;
  112572. shader: string;
  112573. };
  112574. }
  112575. declare module BABYLON {
  112576. /** @hidden */
  112577. export var pbrDirectLightingSetupFunctions: {
  112578. name: string;
  112579. shader: string;
  112580. };
  112581. }
  112582. declare module BABYLON {
  112583. /** @hidden */
  112584. export var pbrDirectLightingFalloffFunctions: {
  112585. name: string;
  112586. shader: string;
  112587. };
  112588. }
  112589. declare module BABYLON {
  112590. /** @hidden */
  112591. export var pbrBRDFFunctions: {
  112592. name: string;
  112593. shader: string;
  112594. };
  112595. }
  112596. declare module BABYLON {
  112597. /** @hidden */
  112598. export var pbrDirectLightingFunctions: {
  112599. name: string;
  112600. shader: string;
  112601. };
  112602. }
  112603. declare module BABYLON {
  112604. /** @hidden */
  112605. export var pbrIBLFunctions: {
  112606. name: string;
  112607. shader: string;
  112608. };
  112609. }
  112610. declare module BABYLON {
  112611. /** @hidden */
  112612. export var pbrDebug: {
  112613. name: string;
  112614. shader: string;
  112615. };
  112616. }
  112617. declare module BABYLON {
  112618. /** @hidden */
  112619. export var pbrPixelShader: {
  112620. name: string;
  112621. shader: string;
  112622. };
  112623. }
  112624. declare module BABYLON {
  112625. /** @hidden */
  112626. export var pbrVertexDeclaration: {
  112627. name: string;
  112628. shader: string;
  112629. };
  112630. }
  112631. declare module BABYLON {
  112632. /** @hidden */
  112633. export var pbrVertexShader: {
  112634. name: string;
  112635. shader: string;
  112636. };
  112637. }
  112638. declare module BABYLON {
  112639. /**
  112640. * Manages the defines for the PBR Material.
  112641. * @hidden
  112642. */
  112643. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  112644. PBR: boolean;
  112645. MAINUV1: boolean;
  112646. MAINUV2: boolean;
  112647. UV1: boolean;
  112648. UV2: boolean;
  112649. ALBEDO: boolean;
  112650. ALBEDODIRECTUV: number;
  112651. VERTEXCOLOR: boolean;
  112652. AMBIENT: boolean;
  112653. AMBIENTDIRECTUV: number;
  112654. AMBIENTINGRAYSCALE: boolean;
  112655. OPACITY: boolean;
  112656. VERTEXALPHA: boolean;
  112657. OPACITYDIRECTUV: number;
  112658. OPACITYRGB: boolean;
  112659. ALPHATEST: boolean;
  112660. DEPTHPREPASS: boolean;
  112661. ALPHABLEND: boolean;
  112662. ALPHAFROMALBEDO: boolean;
  112663. ALPHATESTVALUE: string;
  112664. SPECULAROVERALPHA: boolean;
  112665. RADIANCEOVERALPHA: boolean;
  112666. ALPHAFRESNEL: boolean;
  112667. LINEARALPHAFRESNEL: boolean;
  112668. PREMULTIPLYALPHA: boolean;
  112669. EMISSIVE: boolean;
  112670. EMISSIVEDIRECTUV: number;
  112671. REFLECTIVITY: boolean;
  112672. REFLECTIVITYDIRECTUV: number;
  112673. SPECULARTERM: boolean;
  112674. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  112675. MICROSURFACEAUTOMATIC: boolean;
  112676. LODBASEDMICROSFURACE: boolean;
  112677. MICROSURFACEMAP: boolean;
  112678. MICROSURFACEMAPDIRECTUV: number;
  112679. METALLICWORKFLOW: boolean;
  112680. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  112681. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  112682. METALLNESSSTOREINMETALMAPBLUE: boolean;
  112683. AOSTOREINMETALMAPRED: boolean;
  112684. ENVIRONMENTBRDF: boolean;
  112685. ENVIRONMENTBRDF_RGBD: boolean;
  112686. NORMAL: boolean;
  112687. TANGENT: boolean;
  112688. BUMP: boolean;
  112689. BUMPDIRECTUV: number;
  112690. OBJECTSPACE_NORMALMAP: boolean;
  112691. PARALLAX: boolean;
  112692. PARALLAXOCCLUSION: boolean;
  112693. NORMALXYSCALE: boolean;
  112694. LIGHTMAP: boolean;
  112695. LIGHTMAPDIRECTUV: number;
  112696. USELIGHTMAPASSHADOWMAP: boolean;
  112697. GAMMALIGHTMAP: boolean;
  112698. RGBDLIGHTMAP: boolean;
  112699. REFLECTION: boolean;
  112700. REFLECTIONMAP_3D: boolean;
  112701. REFLECTIONMAP_SPHERICAL: boolean;
  112702. REFLECTIONMAP_PLANAR: boolean;
  112703. REFLECTIONMAP_CUBIC: boolean;
  112704. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  112705. REFLECTIONMAP_PROJECTION: boolean;
  112706. REFLECTIONMAP_SKYBOX: boolean;
  112707. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  112708. REFLECTIONMAP_EXPLICIT: boolean;
  112709. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  112710. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  112711. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  112712. INVERTCUBICMAP: boolean;
  112713. USESPHERICALFROMREFLECTIONMAP: boolean;
  112714. USEIRRADIANCEMAP: boolean;
  112715. SPHERICAL_HARMONICS: boolean;
  112716. USESPHERICALINVERTEX: boolean;
  112717. REFLECTIONMAP_OPPOSITEZ: boolean;
  112718. LODINREFLECTIONALPHA: boolean;
  112719. GAMMAREFLECTION: boolean;
  112720. RGBDREFLECTION: boolean;
  112721. LINEARSPECULARREFLECTION: boolean;
  112722. RADIANCEOCCLUSION: boolean;
  112723. HORIZONOCCLUSION: boolean;
  112724. INSTANCES: boolean;
  112725. NUM_BONE_INFLUENCERS: number;
  112726. BonesPerMesh: number;
  112727. BONETEXTURE: boolean;
  112728. NONUNIFORMSCALING: boolean;
  112729. MORPHTARGETS: boolean;
  112730. MORPHTARGETS_NORMAL: boolean;
  112731. MORPHTARGETS_TANGENT: boolean;
  112732. MORPHTARGETS_UV: boolean;
  112733. NUM_MORPH_INFLUENCERS: number;
  112734. IMAGEPROCESSING: boolean;
  112735. VIGNETTE: boolean;
  112736. VIGNETTEBLENDMODEMULTIPLY: boolean;
  112737. VIGNETTEBLENDMODEOPAQUE: boolean;
  112738. TONEMAPPING: boolean;
  112739. TONEMAPPING_ACES: boolean;
  112740. CONTRAST: boolean;
  112741. COLORCURVES: boolean;
  112742. COLORGRADING: boolean;
  112743. COLORGRADING3D: boolean;
  112744. SAMPLER3DGREENDEPTH: boolean;
  112745. SAMPLER3DBGRMAP: boolean;
  112746. IMAGEPROCESSINGPOSTPROCESS: boolean;
  112747. EXPOSURE: boolean;
  112748. MULTIVIEW: boolean;
  112749. USEPHYSICALLIGHTFALLOFF: boolean;
  112750. USEGLTFLIGHTFALLOFF: boolean;
  112751. TWOSIDEDLIGHTING: boolean;
  112752. SHADOWFLOAT: boolean;
  112753. CLIPPLANE: boolean;
  112754. CLIPPLANE2: boolean;
  112755. CLIPPLANE3: boolean;
  112756. CLIPPLANE4: boolean;
  112757. POINTSIZE: boolean;
  112758. FOG: boolean;
  112759. LOGARITHMICDEPTH: boolean;
  112760. FORCENORMALFORWARD: boolean;
  112761. SPECULARAA: boolean;
  112762. CLEARCOAT: boolean;
  112763. CLEARCOAT_DEFAULTIOR: boolean;
  112764. CLEARCOAT_TEXTURE: boolean;
  112765. CLEARCOAT_TEXTUREDIRECTUV: number;
  112766. CLEARCOAT_BUMP: boolean;
  112767. CLEARCOAT_BUMPDIRECTUV: number;
  112768. CLEARCOAT_TINT: boolean;
  112769. CLEARCOAT_TINT_TEXTURE: boolean;
  112770. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  112771. ANISOTROPIC: boolean;
  112772. ANISOTROPIC_TEXTURE: boolean;
  112773. ANISOTROPIC_TEXTUREDIRECTUV: number;
  112774. BRDF_V_HEIGHT_CORRELATED: boolean;
  112775. MS_BRDF_ENERGY_CONSERVATION: boolean;
  112776. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  112777. SHEEN: boolean;
  112778. SHEEN_TEXTURE: boolean;
  112779. SHEEN_TEXTUREDIRECTUV: number;
  112780. SHEEN_LINKWITHALBEDO: boolean;
  112781. SUBSURFACE: boolean;
  112782. SS_REFRACTION: boolean;
  112783. SS_TRANSLUCENCY: boolean;
  112784. SS_SCATERRING: boolean;
  112785. SS_THICKNESSANDMASK_TEXTURE: boolean;
  112786. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  112787. SS_REFRACTIONMAP_3D: boolean;
  112788. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  112789. SS_LODINREFRACTIONALPHA: boolean;
  112790. SS_GAMMAREFRACTION: boolean;
  112791. SS_RGBDREFRACTION: boolean;
  112792. SS_LINEARSPECULARREFRACTION: boolean;
  112793. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  112794. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  112795. UNLIT: boolean;
  112796. DEBUGMODE: number;
  112797. /**
  112798. * Initializes the PBR Material defines.
  112799. */
  112800. constructor();
  112801. /**
  112802. * Resets the PBR Material defines.
  112803. */
  112804. reset(): void;
  112805. }
  112806. /**
  112807. * The Physically based material base class of BJS.
  112808. *
  112809. * This offers the main features of a standard PBR material.
  112810. * For more information, please refer to the documentation :
  112811. * https://doc.babylonjs.com/how_to/physically_based_rendering
  112812. */
  112813. export abstract class PBRBaseMaterial extends PushMaterial {
  112814. /**
  112815. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  112816. */
  112817. static readonly PBRMATERIAL_OPAQUE: number;
  112818. /**
  112819. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  112820. */
  112821. static readonly PBRMATERIAL_ALPHATEST: number;
  112822. /**
  112823. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  112824. */
  112825. static readonly PBRMATERIAL_ALPHABLEND: number;
  112826. /**
  112827. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  112828. * They are also discarded below the alpha cutoff threshold to improve performances.
  112829. */
  112830. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  112831. /**
  112832. * Defines the default value of how much AO map is occluding the analytical lights
  112833. * (point spot...).
  112834. */
  112835. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  112836. /**
  112837. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  112838. */
  112839. static readonly LIGHTFALLOFF_PHYSICAL: number;
  112840. /**
  112841. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  112842. * to enhance interoperability with other engines.
  112843. */
  112844. static readonly LIGHTFALLOFF_GLTF: number;
  112845. /**
  112846. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  112847. * to enhance interoperability with other materials.
  112848. */
  112849. static readonly LIGHTFALLOFF_STANDARD: number;
  112850. /**
  112851. * Intensity of the direct lights e.g. the four lights available in your scene.
  112852. * This impacts both the direct diffuse and specular highlights.
  112853. */
  112854. protected _directIntensity: number;
  112855. /**
  112856. * Intensity of the emissive part of the material.
  112857. * This helps controlling the emissive effect without modifying the emissive color.
  112858. */
  112859. protected _emissiveIntensity: number;
  112860. /**
  112861. * Intensity of the environment e.g. how much the environment will light the object
  112862. * either through harmonics for rough material or through the refelction for shiny ones.
  112863. */
  112864. protected _environmentIntensity: number;
  112865. /**
  112866. * This is a special control allowing the reduction of the specular highlights coming from the
  112867. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  112868. */
  112869. protected _specularIntensity: number;
  112870. /**
  112871. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  112872. */
  112873. private _lightingInfos;
  112874. /**
  112875. * Debug Control allowing disabling the bump map on this material.
  112876. */
  112877. protected _disableBumpMap: boolean;
  112878. /**
  112879. * AKA Diffuse Texture in standard nomenclature.
  112880. */
  112881. protected _albedoTexture: Nullable<BaseTexture>;
  112882. /**
  112883. * AKA Occlusion Texture in other nomenclature.
  112884. */
  112885. protected _ambientTexture: Nullable<BaseTexture>;
  112886. /**
  112887. * AKA Occlusion Texture Intensity in other nomenclature.
  112888. */
  112889. protected _ambientTextureStrength: number;
  112890. /**
  112891. * Defines how much the AO map is occluding the analytical lights (point spot...).
  112892. * 1 means it completely occludes it
  112893. * 0 mean it has no impact
  112894. */
  112895. protected _ambientTextureImpactOnAnalyticalLights: number;
  112896. /**
  112897. * Stores the alpha values in a texture.
  112898. */
  112899. protected _opacityTexture: Nullable<BaseTexture>;
  112900. /**
  112901. * Stores the reflection values in a texture.
  112902. */
  112903. protected _reflectionTexture: Nullable<BaseTexture>;
  112904. /**
  112905. * Stores the emissive values in a texture.
  112906. */
  112907. protected _emissiveTexture: Nullable<BaseTexture>;
  112908. /**
  112909. * AKA Specular texture in other nomenclature.
  112910. */
  112911. protected _reflectivityTexture: Nullable<BaseTexture>;
  112912. /**
  112913. * Used to switch from specular/glossiness to metallic/roughness workflow.
  112914. */
  112915. protected _metallicTexture: Nullable<BaseTexture>;
  112916. /**
  112917. * Specifies the metallic scalar of the metallic/roughness workflow.
  112918. * Can also be used to scale the metalness values of the metallic texture.
  112919. */
  112920. protected _metallic: Nullable<number>;
  112921. /**
  112922. * Specifies the roughness scalar of the metallic/roughness workflow.
  112923. * Can also be used to scale the roughness values of the metallic texture.
  112924. */
  112925. protected _roughness: Nullable<number>;
  112926. /**
  112927. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  112928. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  112929. */
  112930. protected _microSurfaceTexture: Nullable<BaseTexture>;
  112931. /**
  112932. * Stores surface normal data used to displace a mesh in a texture.
  112933. */
  112934. protected _bumpTexture: Nullable<BaseTexture>;
  112935. /**
  112936. * Stores the pre-calculated light information of a mesh in a texture.
  112937. */
  112938. protected _lightmapTexture: Nullable<BaseTexture>;
  112939. /**
  112940. * The color of a material in ambient lighting.
  112941. */
  112942. protected _ambientColor: Color3;
  112943. /**
  112944. * AKA Diffuse Color in other nomenclature.
  112945. */
  112946. protected _albedoColor: Color3;
  112947. /**
  112948. * AKA Specular Color in other nomenclature.
  112949. */
  112950. protected _reflectivityColor: Color3;
  112951. /**
  112952. * The color applied when light is reflected from a material.
  112953. */
  112954. protected _reflectionColor: Color3;
  112955. /**
  112956. * The color applied when light is emitted from a material.
  112957. */
  112958. protected _emissiveColor: Color3;
  112959. /**
  112960. * AKA Glossiness in other nomenclature.
  112961. */
  112962. protected _microSurface: number;
  112963. /**
  112964. * Specifies that the material will use the light map as a show map.
  112965. */
  112966. protected _useLightmapAsShadowmap: boolean;
  112967. /**
  112968. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  112969. * makes the reflect vector face the model (under horizon).
  112970. */
  112971. protected _useHorizonOcclusion: boolean;
  112972. /**
  112973. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  112974. * too much the area relying on ambient texture to define their ambient occlusion.
  112975. */
  112976. protected _useRadianceOcclusion: boolean;
  112977. /**
  112978. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  112979. */
  112980. protected _useAlphaFromAlbedoTexture: boolean;
  112981. /**
  112982. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  112983. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  112984. */
  112985. protected _useSpecularOverAlpha: boolean;
  112986. /**
  112987. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  112988. */
  112989. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  112990. /**
  112991. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  112992. */
  112993. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  112994. /**
  112995. * Specifies if the metallic texture contains the roughness information in its green channel.
  112996. */
  112997. protected _useRoughnessFromMetallicTextureGreen: boolean;
  112998. /**
  112999. * Specifies if the metallic texture contains the metallness information in its blue channel.
  113000. */
  113001. protected _useMetallnessFromMetallicTextureBlue: boolean;
  113002. /**
  113003. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  113004. */
  113005. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  113006. /**
  113007. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  113008. */
  113009. protected _useAmbientInGrayScale: boolean;
  113010. /**
  113011. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  113012. * The material will try to infer what glossiness each pixel should be.
  113013. */
  113014. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  113015. /**
  113016. * Defines the falloff type used in this material.
  113017. * It by default is Physical.
  113018. */
  113019. protected _lightFalloff: number;
  113020. /**
  113021. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  113022. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  113023. */
  113024. protected _useRadianceOverAlpha: boolean;
  113025. /**
  113026. * Allows using an object space normal map (instead of tangent space).
  113027. */
  113028. protected _useObjectSpaceNormalMap: boolean;
  113029. /**
  113030. * Allows using the bump map in parallax mode.
  113031. */
  113032. protected _useParallax: boolean;
  113033. /**
  113034. * Allows using the bump map in parallax occlusion mode.
  113035. */
  113036. protected _useParallaxOcclusion: boolean;
  113037. /**
  113038. * Controls the scale bias of the parallax mode.
  113039. */
  113040. protected _parallaxScaleBias: number;
  113041. /**
  113042. * If sets to true, disables all the lights affecting the material.
  113043. */
  113044. protected _disableLighting: boolean;
  113045. /**
  113046. * Number of Simultaneous lights allowed on the material.
  113047. */
  113048. protected _maxSimultaneousLights: number;
  113049. /**
  113050. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  113051. */
  113052. protected _invertNormalMapX: boolean;
  113053. /**
  113054. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  113055. */
  113056. protected _invertNormalMapY: boolean;
  113057. /**
  113058. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  113059. */
  113060. protected _twoSidedLighting: boolean;
  113061. /**
  113062. * Defines the alpha limits in alpha test mode.
  113063. */
  113064. protected _alphaCutOff: number;
  113065. /**
  113066. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  113067. */
  113068. protected _forceAlphaTest: boolean;
  113069. /**
  113070. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  113071. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  113072. */
  113073. protected _useAlphaFresnel: boolean;
  113074. /**
  113075. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  113076. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  113077. */
  113078. protected _useLinearAlphaFresnel: boolean;
  113079. /**
  113080. * The transparency mode of the material.
  113081. */
  113082. protected _transparencyMode: Nullable<number>;
  113083. /**
  113084. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  113085. * from cos thetav and roughness:
  113086. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  113087. */
  113088. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  113089. /**
  113090. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  113091. */
  113092. protected _forceIrradianceInFragment: boolean;
  113093. /**
  113094. * Force normal to face away from face.
  113095. */
  113096. protected _forceNormalForward: boolean;
  113097. /**
  113098. * Enables specular anti aliasing in the PBR shader.
  113099. * It will both interacts on the Geometry for analytical and IBL lighting.
  113100. * It also prefilter the roughness map based on the bump values.
  113101. */
  113102. protected _enableSpecularAntiAliasing: boolean;
  113103. /**
  113104. * Default configuration related to image processing available in the PBR Material.
  113105. */
  113106. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  113107. /**
  113108. * Keep track of the image processing observer to allow dispose and replace.
  113109. */
  113110. private _imageProcessingObserver;
  113111. /**
  113112. * Attaches a new image processing configuration to the PBR Material.
  113113. * @param configuration
  113114. */
  113115. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  113116. /**
  113117. * Stores the available render targets.
  113118. */
  113119. private _renderTargets;
  113120. /**
  113121. * Sets the global ambient color for the material used in lighting calculations.
  113122. */
  113123. private _globalAmbientColor;
  113124. /**
  113125. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  113126. */
  113127. private _useLogarithmicDepth;
  113128. /**
  113129. * If set to true, no lighting calculations will be applied.
  113130. */
  113131. private _unlit;
  113132. private _debugMode;
  113133. /**
  113134. * @hidden
  113135. * This is reserved for the inspector.
  113136. * Defines the material debug mode.
  113137. * It helps seeing only some components of the material while troubleshooting.
  113138. */
  113139. debugMode: number;
  113140. /**
  113141. * @hidden
  113142. * This is reserved for the inspector.
  113143. * Specify from where on screen the debug mode should start.
  113144. * The value goes from -1 (full screen) to 1 (not visible)
  113145. * It helps with side by side comparison against the final render
  113146. * This defaults to -1
  113147. */
  113148. private debugLimit;
  113149. /**
  113150. * @hidden
  113151. * This is reserved for the inspector.
  113152. * As the default viewing range might not be enough (if the ambient is really small for instance)
  113153. * You can use the factor to better multiply the final value.
  113154. */
  113155. private debugFactor;
  113156. /**
  113157. * Defines the clear coat layer parameters for the material.
  113158. */
  113159. readonly clearCoat: PBRClearCoatConfiguration;
  113160. /**
  113161. * Defines the anisotropic parameters for the material.
  113162. */
  113163. readonly anisotropy: PBRAnisotropicConfiguration;
  113164. /**
  113165. * Defines the BRDF parameters for the material.
  113166. */
  113167. readonly brdf: PBRBRDFConfiguration;
  113168. /**
  113169. * Defines the Sheen parameters for the material.
  113170. */
  113171. readonly sheen: PBRSheenConfiguration;
  113172. /**
  113173. * Defines the SubSurface parameters for the material.
  113174. */
  113175. readonly subSurface: PBRSubSurfaceConfiguration;
  113176. /**
  113177. * Custom callback helping to override the default shader used in the material.
  113178. */
  113179. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  113180. protected _rebuildInParallel: boolean;
  113181. /**
  113182. * Instantiates a new PBRMaterial instance.
  113183. *
  113184. * @param name The material name
  113185. * @param scene The scene the material will be use in.
  113186. */
  113187. constructor(name: string, scene: Scene);
  113188. /**
  113189. * Gets a boolean indicating that current material needs to register RTT
  113190. */
  113191. readonly hasRenderTargetTextures: boolean;
  113192. /**
  113193. * Gets the name of the material class.
  113194. */
  113195. getClassName(): string;
  113196. /**
  113197. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  113198. */
  113199. /**
  113200. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  113201. */
  113202. useLogarithmicDepth: boolean;
  113203. /**
  113204. * Gets the current transparency mode.
  113205. */
  113206. /**
  113207. * Sets the transparency mode of the material.
  113208. *
  113209. * | Value | Type | Description |
  113210. * | ----- | ----------------------------------- | ----------- |
  113211. * | 0 | OPAQUE | |
  113212. * | 1 | ALPHATEST | |
  113213. * | 2 | ALPHABLEND | |
  113214. * | 3 | ALPHATESTANDBLEND | |
  113215. *
  113216. */
  113217. transparencyMode: Nullable<number>;
  113218. /**
  113219. * Returns true if alpha blending should be disabled.
  113220. */
  113221. private readonly _disableAlphaBlending;
  113222. /**
  113223. * Specifies whether or not this material should be rendered in alpha blend mode.
  113224. */
  113225. needAlphaBlending(): boolean;
  113226. /**
  113227. * Specifies if the mesh will require alpha blending.
  113228. * @param mesh - BJS mesh.
  113229. */
  113230. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  113231. /**
  113232. * Specifies whether or not this material should be rendered in alpha test mode.
  113233. */
  113234. needAlphaTesting(): boolean;
  113235. /**
  113236. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  113237. */
  113238. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  113239. /**
  113240. * Gets the texture used for the alpha test.
  113241. */
  113242. getAlphaTestTexture(): Nullable<BaseTexture>;
  113243. /**
  113244. * Specifies that the submesh is ready to be used.
  113245. * @param mesh - BJS mesh.
  113246. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  113247. * @param useInstances - Specifies that instances should be used.
  113248. * @returns - boolean indicating that the submesh is ready or not.
  113249. */
  113250. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  113251. /**
  113252. * Specifies if the material uses metallic roughness workflow.
  113253. * @returns boolean specifiying if the material uses metallic roughness workflow.
  113254. */
  113255. isMetallicWorkflow(): boolean;
  113256. private _prepareEffect;
  113257. private _prepareDefines;
  113258. /**
  113259. * Force shader compilation
  113260. */
  113261. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  113262. clipPlane: boolean;
  113263. }>): void;
  113264. /**
  113265. * Initializes the uniform buffer layout for the shader.
  113266. */
  113267. buildUniformLayout(): void;
  113268. /**
  113269. * Unbinds the material from the mesh
  113270. */
  113271. unbind(): void;
  113272. /**
  113273. * Binds the submesh data.
  113274. * @param world - The world matrix.
  113275. * @param mesh - The BJS mesh.
  113276. * @param subMesh - A submesh of the BJS mesh.
  113277. */
  113278. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  113279. /**
  113280. * Returns the animatable textures.
  113281. * @returns - Array of animatable textures.
  113282. */
  113283. getAnimatables(): IAnimatable[];
  113284. /**
  113285. * Returns the texture used for reflections.
  113286. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  113287. */
  113288. private _getReflectionTexture;
  113289. /**
  113290. * Returns an array of the actively used textures.
  113291. * @returns - Array of BaseTextures
  113292. */
  113293. getActiveTextures(): BaseTexture[];
  113294. /**
  113295. * Checks to see if a texture is used in the material.
  113296. * @param texture - Base texture to use.
  113297. * @returns - Boolean specifying if a texture is used in the material.
  113298. */
  113299. hasTexture(texture: BaseTexture): boolean;
  113300. /**
  113301. * Disposes the resources of the material.
  113302. * @param forceDisposeEffect - Forces the disposal of effects.
  113303. * @param forceDisposeTextures - Forces the disposal of all textures.
  113304. */
  113305. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  113306. }
  113307. }
  113308. declare module BABYLON {
  113309. /**
  113310. * The Physically based material of BJS.
  113311. *
  113312. * This offers the main features of a standard PBR material.
  113313. * For more information, please refer to the documentation :
  113314. * https://doc.babylonjs.com/how_to/physically_based_rendering
  113315. */
  113316. export class PBRMaterial extends PBRBaseMaterial {
  113317. /**
  113318. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  113319. */
  113320. static readonly PBRMATERIAL_OPAQUE: number;
  113321. /**
  113322. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  113323. */
  113324. static readonly PBRMATERIAL_ALPHATEST: number;
  113325. /**
  113326. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  113327. */
  113328. static readonly PBRMATERIAL_ALPHABLEND: number;
  113329. /**
  113330. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  113331. * They are also discarded below the alpha cutoff threshold to improve performances.
  113332. */
  113333. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  113334. /**
  113335. * Defines the default value of how much AO map is occluding the analytical lights
  113336. * (point spot...).
  113337. */
  113338. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  113339. /**
  113340. * Intensity of the direct lights e.g. the four lights available in your scene.
  113341. * This impacts both the direct diffuse and specular highlights.
  113342. */
  113343. directIntensity: number;
  113344. /**
  113345. * Intensity of the emissive part of the material.
  113346. * This helps controlling the emissive effect without modifying the emissive color.
  113347. */
  113348. emissiveIntensity: number;
  113349. /**
  113350. * Intensity of the environment e.g. how much the environment will light the object
  113351. * either through harmonics for rough material or through the refelction for shiny ones.
  113352. */
  113353. environmentIntensity: number;
  113354. /**
  113355. * This is a special control allowing the reduction of the specular highlights coming from the
  113356. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  113357. */
  113358. specularIntensity: number;
  113359. /**
  113360. * Debug Control allowing disabling the bump map on this material.
  113361. */
  113362. disableBumpMap: boolean;
  113363. /**
  113364. * AKA Diffuse Texture in standard nomenclature.
  113365. */
  113366. albedoTexture: BaseTexture;
  113367. /**
  113368. * AKA Occlusion Texture in other nomenclature.
  113369. */
  113370. ambientTexture: BaseTexture;
  113371. /**
  113372. * AKA Occlusion Texture Intensity in other nomenclature.
  113373. */
  113374. ambientTextureStrength: number;
  113375. /**
  113376. * Defines how much the AO map is occluding the analytical lights (point spot...).
  113377. * 1 means it completely occludes it
  113378. * 0 mean it has no impact
  113379. */
  113380. ambientTextureImpactOnAnalyticalLights: number;
  113381. /**
  113382. * Stores the alpha values in a texture.
  113383. */
  113384. opacityTexture: BaseTexture;
  113385. /**
  113386. * Stores the reflection values in a texture.
  113387. */
  113388. reflectionTexture: Nullable<BaseTexture>;
  113389. /**
  113390. * Stores the emissive values in a texture.
  113391. */
  113392. emissiveTexture: BaseTexture;
  113393. /**
  113394. * AKA Specular texture in other nomenclature.
  113395. */
  113396. reflectivityTexture: BaseTexture;
  113397. /**
  113398. * Used to switch from specular/glossiness to metallic/roughness workflow.
  113399. */
  113400. metallicTexture: BaseTexture;
  113401. /**
  113402. * Specifies the metallic scalar of the metallic/roughness workflow.
  113403. * Can also be used to scale the metalness values of the metallic texture.
  113404. */
  113405. metallic: Nullable<number>;
  113406. /**
  113407. * Specifies the roughness scalar of the metallic/roughness workflow.
  113408. * Can also be used to scale the roughness values of the metallic texture.
  113409. */
  113410. roughness: Nullable<number>;
  113411. /**
  113412. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  113413. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  113414. */
  113415. microSurfaceTexture: BaseTexture;
  113416. /**
  113417. * Stores surface normal data used to displace a mesh in a texture.
  113418. */
  113419. bumpTexture: BaseTexture;
  113420. /**
  113421. * Stores the pre-calculated light information of a mesh in a texture.
  113422. */
  113423. lightmapTexture: BaseTexture;
  113424. /**
  113425. * Stores the refracted light information in a texture.
  113426. */
  113427. refractionTexture: Nullable<BaseTexture>;
  113428. /**
  113429. * The color of a material in ambient lighting.
  113430. */
  113431. ambientColor: Color3;
  113432. /**
  113433. * AKA Diffuse Color in other nomenclature.
  113434. */
  113435. albedoColor: Color3;
  113436. /**
  113437. * AKA Specular Color in other nomenclature.
  113438. */
  113439. reflectivityColor: Color3;
  113440. /**
  113441. * The color reflected from the material.
  113442. */
  113443. reflectionColor: Color3;
  113444. /**
  113445. * The color emitted from the material.
  113446. */
  113447. emissiveColor: Color3;
  113448. /**
  113449. * AKA Glossiness in other nomenclature.
  113450. */
  113451. microSurface: number;
  113452. /**
  113453. * source material index of refraction (IOR)' / 'destination material IOR.
  113454. */
  113455. indexOfRefraction: number;
  113456. /**
  113457. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  113458. */
  113459. invertRefractionY: boolean;
  113460. /**
  113461. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  113462. * Materials half opaque for instance using refraction could benefit from this control.
  113463. */
  113464. linkRefractionWithTransparency: boolean;
  113465. /**
  113466. * If true, the light map contains occlusion information instead of lighting info.
  113467. */
  113468. useLightmapAsShadowmap: boolean;
  113469. /**
  113470. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  113471. */
  113472. useAlphaFromAlbedoTexture: boolean;
  113473. /**
  113474. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  113475. */
  113476. forceAlphaTest: boolean;
  113477. /**
  113478. * Defines the alpha limits in alpha test mode.
  113479. */
  113480. alphaCutOff: number;
  113481. /**
  113482. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  113483. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  113484. */
  113485. useSpecularOverAlpha: boolean;
  113486. /**
  113487. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  113488. */
  113489. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  113490. /**
  113491. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  113492. */
  113493. useRoughnessFromMetallicTextureAlpha: boolean;
  113494. /**
  113495. * Specifies if the metallic texture contains the roughness information in its green channel.
  113496. */
  113497. useRoughnessFromMetallicTextureGreen: boolean;
  113498. /**
  113499. * Specifies if the metallic texture contains the metallness information in its blue channel.
  113500. */
  113501. useMetallnessFromMetallicTextureBlue: boolean;
  113502. /**
  113503. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  113504. */
  113505. useAmbientOcclusionFromMetallicTextureRed: boolean;
  113506. /**
  113507. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  113508. */
  113509. useAmbientInGrayScale: boolean;
  113510. /**
  113511. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  113512. * The material will try to infer what glossiness each pixel should be.
  113513. */
  113514. useAutoMicroSurfaceFromReflectivityMap: boolean;
  113515. /**
  113516. * BJS is using an harcoded light falloff based on a manually sets up range.
  113517. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  113518. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  113519. */
  113520. /**
  113521. * BJS is using an harcoded light falloff based on a manually sets up range.
  113522. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  113523. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  113524. */
  113525. usePhysicalLightFalloff: boolean;
  113526. /**
  113527. * In order to support the falloff compatibility with gltf, a special mode has been added
  113528. * to reproduce the gltf light falloff.
  113529. */
  113530. /**
  113531. * In order to support the falloff compatibility with gltf, a special mode has been added
  113532. * to reproduce the gltf light falloff.
  113533. */
  113534. useGLTFLightFalloff: boolean;
  113535. /**
  113536. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  113537. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  113538. */
  113539. useRadianceOverAlpha: boolean;
  113540. /**
  113541. * Allows using an object space normal map (instead of tangent space).
  113542. */
  113543. useObjectSpaceNormalMap: boolean;
  113544. /**
  113545. * Allows using the bump map in parallax mode.
  113546. */
  113547. useParallax: boolean;
  113548. /**
  113549. * Allows using the bump map in parallax occlusion mode.
  113550. */
  113551. useParallaxOcclusion: boolean;
  113552. /**
  113553. * Controls the scale bias of the parallax mode.
  113554. */
  113555. parallaxScaleBias: number;
  113556. /**
  113557. * If sets to true, disables all the lights affecting the material.
  113558. */
  113559. disableLighting: boolean;
  113560. /**
  113561. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  113562. */
  113563. forceIrradianceInFragment: boolean;
  113564. /**
  113565. * Number of Simultaneous lights allowed on the material.
  113566. */
  113567. maxSimultaneousLights: number;
  113568. /**
  113569. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  113570. */
  113571. invertNormalMapX: boolean;
  113572. /**
  113573. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  113574. */
  113575. invertNormalMapY: boolean;
  113576. /**
  113577. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  113578. */
  113579. twoSidedLighting: boolean;
  113580. /**
  113581. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  113582. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  113583. */
  113584. useAlphaFresnel: boolean;
  113585. /**
  113586. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  113587. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  113588. */
  113589. useLinearAlphaFresnel: boolean;
  113590. /**
  113591. * Let user defines the brdf lookup texture used for IBL.
  113592. * A default 8bit version is embedded but you could point at :
  113593. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  113594. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  113595. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  113596. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  113597. */
  113598. environmentBRDFTexture: Nullable<BaseTexture>;
  113599. /**
  113600. * Force normal to face away from face.
  113601. */
  113602. forceNormalForward: boolean;
  113603. /**
  113604. * Enables specular anti aliasing in the PBR shader.
  113605. * It will both interacts on the Geometry for analytical and IBL lighting.
  113606. * It also prefilter the roughness map based on the bump values.
  113607. */
  113608. enableSpecularAntiAliasing: boolean;
  113609. /**
  113610. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  113611. * makes the reflect vector face the model (under horizon).
  113612. */
  113613. useHorizonOcclusion: boolean;
  113614. /**
  113615. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  113616. * too much the area relying on ambient texture to define their ambient occlusion.
  113617. */
  113618. useRadianceOcclusion: boolean;
  113619. /**
  113620. * If set to true, no lighting calculations will be applied.
  113621. */
  113622. unlit: boolean;
  113623. /**
  113624. * Gets the image processing configuration used either in this material.
  113625. */
  113626. /**
  113627. * Sets the Default image processing configuration used either in the this material.
  113628. *
  113629. * If sets to null, the scene one is in use.
  113630. */
  113631. imageProcessingConfiguration: ImageProcessingConfiguration;
  113632. /**
  113633. * Gets wether the color curves effect is enabled.
  113634. */
  113635. /**
  113636. * Sets wether the color curves effect is enabled.
  113637. */
  113638. cameraColorCurvesEnabled: boolean;
  113639. /**
  113640. * Gets wether the color grading effect is enabled.
  113641. */
  113642. /**
  113643. * Gets wether the color grading effect is enabled.
  113644. */
  113645. cameraColorGradingEnabled: boolean;
  113646. /**
  113647. * Gets wether tonemapping is enabled or not.
  113648. */
  113649. /**
  113650. * Sets wether tonemapping is enabled or not
  113651. */
  113652. cameraToneMappingEnabled: boolean;
  113653. /**
  113654. * The camera exposure used on this material.
  113655. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  113656. * This corresponds to a photographic exposure.
  113657. */
  113658. /**
  113659. * The camera exposure used on this material.
  113660. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  113661. * This corresponds to a photographic exposure.
  113662. */
  113663. cameraExposure: number;
  113664. /**
  113665. * Gets The camera contrast used on this material.
  113666. */
  113667. /**
  113668. * Sets The camera contrast used on this material.
  113669. */
  113670. cameraContrast: number;
  113671. /**
  113672. * Gets the Color Grading 2D Lookup Texture.
  113673. */
  113674. /**
  113675. * Sets the Color Grading 2D Lookup Texture.
  113676. */
  113677. cameraColorGradingTexture: Nullable<BaseTexture>;
  113678. /**
  113679. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  113680. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  113681. * 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;
  113682. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  113683. */
  113684. /**
  113685. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  113686. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  113687. * 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;
  113688. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  113689. */
  113690. cameraColorCurves: Nullable<ColorCurves>;
  113691. /**
  113692. * Instantiates a new PBRMaterial instance.
  113693. *
  113694. * @param name The material name
  113695. * @param scene The scene the material will be use in.
  113696. */
  113697. constructor(name: string, scene: Scene);
  113698. /**
  113699. * Returns the name of this material class.
  113700. */
  113701. getClassName(): string;
  113702. /**
  113703. * Makes a duplicate of the current material.
  113704. * @param name - name to use for the new material.
  113705. */
  113706. clone(name: string): PBRMaterial;
  113707. /**
  113708. * Serializes this PBR Material.
  113709. * @returns - An object with the serialized material.
  113710. */
  113711. serialize(): any;
  113712. /**
  113713. * Parses a PBR Material from a serialized object.
  113714. * @param source - Serialized object.
  113715. * @param scene - BJS scene instance.
  113716. * @param rootUrl - url for the scene object
  113717. * @returns - PBRMaterial
  113718. */
  113719. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  113720. }
  113721. }
  113722. declare module BABYLON {
  113723. /**
  113724. * Direct draw surface info
  113725. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  113726. */
  113727. export interface DDSInfo {
  113728. /**
  113729. * Width of the texture
  113730. */
  113731. width: number;
  113732. /**
  113733. * Width of the texture
  113734. */
  113735. height: number;
  113736. /**
  113737. * Number of Mipmaps for the texture
  113738. * @see https://en.wikipedia.org/wiki/Mipmap
  113739. */
  113740. mipmapCount: number;
  113741. /**
  113742. * If the textures format is a known fourCC format
  113743. * @see https://www.fourcc.org/
  113744. */
  113745. isFourCC: boolean;
  113746. /**
  113747. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  113748. */
  113749. isRGB: boolean;
  113750. /**
  113751. * If the texture is a lumincance format
  113752. */
  113753. isLuminance: boolean;
  113754. /**
  113755. * If this is a cube texture
  113756. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  113757. */
  113758. isCube: boolean;
  113759. /**
  113760. * If the texture is a compressed format eg. FOURCC_DXT1
  113761. */
  113762. isCompressed: boolean;
  113763. /**
  113764. * The dxgiFormat of the texture
  113765. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  113766. */
  113767. dxgiFormat: number;
  113768. /**
  113769. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  113770. */
  113771. textureType: number;
  113772. /**
  113773. * Sphericle polynomial created for the dds texture
  113774. */
  113775. sphericalPolynomial?: SphericalPolynomial;
  113776. }
  113777. /**
  113778. * Class used to provide DDS decompression tools
  113779. */
  113780. export class DDSTools {
  113781. /**
  113782. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  113783. */
  113784. static StoreLODInAlphaChannel: boolean;
  113785. /**
  113786. * Gets DDS information from an array buffer
  113787. * @param arrayBuffer defines the array buffer to read data from
  113788. * @returns the DDS information
  113789. */
  113790. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  113791. private static _FloatView;
  113792. private static _Int32View;
  113793. private static _ToHalfFloat;
  113794. private static _FromHalfFloat;
  113795. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  113796. private static _GetHalfFloatRGBAArrayBuffer;
  113797. private static _GetFloatRGBAArrayBuffer;
  113798. private static _GetFloatAsUIntRGBAArrayBuffer;
  113799. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  113800. private static _GetRGBAArrayBuffer;
  113801. private static _ExtractLongWordOrder;
  113802. private static _GetRGBArrayBuffer;
  113803. private static _GetLuminanceArrayBuffer;
  113804. /**
  113805. * Uploads DDS Levels to a Babylon Texture
  113806. * @hidden
  113807. */
  113808. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  113809. }
  113810. interface Engine {
  113811. /**
  113812. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  113813. * @param rootUrl defines the url where the file to load is located
  113814. * @param scene defines the current scene
  113815. * @param lodScale defines scale to apply to the mip map selection
  113816. * @param lodOffset defines offset to apply to the mip map selection
  113817. * @param onLoad defines an optional callback raised when the texture is loaded
  113818. * @param onError defines an optional callback raised if there is an issue to load the texture
  113819. * @param format defines the format of the data
  113820. * @param forcedExtension defines the extension to use to pick the right loader
  113821. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  113822. * @returns the cube texture as an InternalTexture
  113823. */
  113824. 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;
  113825. }
  113826. }
  113827. declare module BABYLON {
  113828. /**
  113829. * Implementation of the DDS Texture Loader.
  113830. * @hidden
  113831. */
  113832. export class _DDSTextureLoader implements IInternalTextureLoader {
  113833. /**
  113834. * Defines wether the loader supports cascade loading the different faces.
  113835. */
  113836. readonly supportCascades: boolean;
  113837. /**
  113838. * This returns if the loader support the current file information.
  113839. * @param extension defines the file extension of the file being loaded
  113840. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113841. * @param fallback defines the fallback internal texture if any
  113842. * @param isBase64 defines whether the texture is encoded as a base64
  113843. * @param isBuffer defines whether the texture data are stored as a buffer
  113844. * @returns true if the loader can load the specified file
  113845. */
  113846. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  113847. /**
  113848. * Transform the url before loading if required.
  113849. * @param rootUrl the url of the texture
  113850. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113851. * @returns the transformed texture
  113852. */
  113853. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  113854. /**
  113855. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  113856. * @param rootUrl the url of the texture
  113857. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113858. * @returns the fallback texture
  113859. */
  113860. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  113861. /**
  113862. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  113863. * @param data contains the texture data
  113864. * @param texture defines the BabylonJS internal texture
  113865. * @param createPolynomials will be true if polynomials have been requested
  113866. * @param onLoad defines the callback to trigger once the texture is ready
  113867. * @param onError defines the callback to trigger in case of error
  113868. */
  113869. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  113870. /**
  113871. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  113872. * @param data contains the texture data
  113873. * @param texture defines the BabylonJS internal texture
  113874. * @param callback defines the method to call once ready to upload
  113875. */
  113876. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  113877. }
  113878. }
  113879. declare module BABYLON {
  113880. /**
  113881. * Implementation of the ENV Texture Loader.
  113882. * @hidden
  113883. */
  113884. export class _ENVTextureLoader implements IInternalTextureLoader {
  113885. /**
  113886. * Defines wether the loader supports cascade loading the different faces.
  113887. */
  113888. readonly supportCascades: boolean;
  113889. /**
  113890. * This returns if the loader support the current file information.
  113891. * @param extension defines the file extension of the file being loaded
  113892. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113893. * @param fallback defines the fallback internal texture if any
  113894. * @param isBase64 defines whether the texture is encoded as a base64
  113895. * @param isBuffer defines whether the texture data are stored as a buffer
  113896. * @returns true if the loader can load the specified file
  113897. */
  113898. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  113899. /**
  113900. * Transform the url before loading if required.
  113901. * @param rootUrl the url of the texture
  113902. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113903. * @returns the transformed texture
  113904. */
  113905. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  113906. /**
  113907. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  113908. * @param rootUrl the url of the texture
  113909. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113910. * @returns the fallback texture
  113911. */
  113912. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  113913. /**
  113914. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  113915. * @param data contains the texture data
  113916. * @param texture defines the BabylonJS internal texture
  113917. * @param createPolynomials will be true if polynomials have been requested
  113918. * @param onLoad defines the callback to trigger once the texture is ready
  113919. * @param onError defines the callback to trigger in case of error
  113920. */
  113921. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  113922. /**
  113923. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  113924. * @param data contains the texture data
  113925. * @param texture defines the BabylonJS internal texture
  113926. * @param callback defines the method to call once ready to upload
  113927. */
  113928. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  113929. }
  113930. }
  113931. declare module BABYLON {
  113932. /**
  113933. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  113934. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  113935. */
  113936. export class KhronosTextureContainer {
  113937. /** contents of the KTX container file */
  113938. arrayBuffer: any;
  113939. private static HEADER_LEN;
  113940. private static COMPRESSED_2D;
  113941. private static COMPRESSED_3D;
  113942. private static TEX_2D;
  113943. private static TEX_3D;
  113944. /**
  113945. * Gets the openGL type
  113946. */
  113947. glType: number;
  113948. /**
  113949. * Gets the openGL type size
  113950. */
  113951. glTypeSize: number;
  113952. /**
  113953. * Gets the openGL format
  113954. */
  113955. glFormat: number;
  113956. /**
  113957. * Gets the openGL internal format
  113958. */
  113959. glInternalFormat: number;
  113960. /**
  113961. * Gets the base internal format
  113962. */
  113963. glBaseInternalFormat: number;
  113964. /**
  113965. * Gets image width in pixel
  113966. */
  113967. pixelWidth: number;
  113968. /**
  113969. * Gets image height in pixel
  113970. */
  113971. pixelHeight: number;
  113972. /**
  113973. * Gets image depth in pixels
  113974. */
  113975. pixelDepth: number;
  113976. /**
  113977. * Gets the number of array elements
  113978. */
  113979. numberOfArrayElements: number;
  113980. /**
  113981. * Gets the number of faces
  113982. */
  113983. numberOfFaces: number;
  113984. /**
  113985. * Gets the number of mipmap levels
  113986. */
  113987. numberOfMipmapLevels: number;
  113988. /**
  113989. * Gets the bytes of key value data
  113990. */
  113991. bytesOfKeyValueData: number;
  113992. /**
  113993. * Gets the load type
  113994. */
  113995. loadType: number;
  113996. /**
  113997. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  113998. */
  113999. isInvalid: boolean;
  114000. /**
  114001. * Creates a new KhronosTextureContainer
  114002. * @param arrayBuffer contents of the KTX container file
  114003. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  114004. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  114005. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  114006. */
  114007. constructor(
  114008. /** contents of the KTX container file */
  114009. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  114010. /**
  114011. * Uploads KTX content to a Babylon Texture.
  114012. * It is assumed that the texture has already been created & is currently bound
  114013. * @hidden
  114014. */
  114015. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  114016. private _upload2DCompressedLevels;
  114017. }
  114018. }
  114019. declare module BABYLON {
  114020. /**
  114021. * Implementation of the KTX Texture Loader.
  114022. * @hidden
  114023. */
  114024. export class _KTXTextureLoader implements IInternalTextureLoader {
  114025. /**
  114026. * Defines wether the loader supports cascade loading the different faces.
  114027. */
  114028. readonly supportCascades: boolean;
  114029. /**
  114030. * This returns if the loader support the current file information.
  114031. * @param extension defines the file extension of the file being loaded
  114032. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114033. * @param fallback defines the fallback internal texture if any
  114034. * @param isBase64 defines whether the texture is encoded as a base64
  114035. * @param isBuffer defines whether the texture data are stored as a buffer
  114036. * @returns true if the loader can load the specified file
  114037. */
  114038. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  114039. /**
  114040. * Transform the url before loading if required.
  114041. * @param rootUrl the url of the texture
  114042. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114043. * @returns the transformed texture
  114044. */
  114045. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  114046. /**
  114047. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  114048. * @param rootUrl the url of the texture
  114049. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114050. * @returns the fallback texture
  114051. */
  114052. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  114053. /**
  114054. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  114055. * @param data contains the texture data
  114056. * @param texture defines the BabylonJS internal texture
  114057. * @param createPolynomials will be true if polynomials have been requested
  114058. * @param onLoad defines the callback to trigger once the texture is ready
  114059. * @param onError defines the callback to trigger in case of error
  114060. */
  114061. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  114062. /**
  114063. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  114064. * @param data contains the texture data
  114065. * @param texture defines the BabylonJS internal texture
  114066. * @param callback defines the method to call once ready to upload
  114067. */
  114068. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  114069. }
  114070. }
  114071. declare module BABYLON {
  114072. /**
  114073. * Options for the default xr helper
  114074. */
  114075. export class WebXRDefaultExperienceOptions {
  114076. /**
  114077. * Floor meshes that should be used for teleporting
  114078. */
  114079. floorMeshes: Array<AbstractMesh>;
  114080. }
  114081. /**
  114082. * Default experience which provides a similar setup to the previous webVRExperience
  114083. */
  114084. export class WebXRDefaultExperience {
  114085. /**
  114086. * Base experience
  114087. */
  114088. baseExperience: WebXRExperienceHelper;
  114089. /**
  114090. * Input experience extension
  114091. */
  114092. input: WebXRInput;
  114093. /**
  114094. * Loads the controller models
  114095. */
  114096. controllerModelLoader: WebXRControllerModelLoader;
  114097. /**
  114098. * Enables laser pointer and selection
  114099. */
  114100. pointerSelection: WebXRControllerPointerSelection;
  114101. /**
  114102. * Enables teleportation
  114103. */
  114104. teleportation: WebXRControllerTeleportation;
  114105. /**
  114106. * Enables ui for enetering/exiting xr
  114107. */
  114108. enterExitUI: WebXREnterExitUI;
  114109. /**
  114110. * Default output canvas xr should render to
  114111. */
  114112. outputCanvas: WebXRManagedOutputCanvas;
  114113. /**
  114114. * Creates the default xr experience
  114115. * @param scene scene
  114116. * @param options options for basic configuration
  114117. * @returns resulting WebXRDefaultExperience
  114118. */
  114119. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  114120. private constructor();
  114121. /**
  114122. * DIsposes of the experience helper
  114123. */
  114124. dispose(): void;
  114125. }
  114126. }
  114127. declare module BABYLON {
  114128. /** @hidden */
  114129. export var _forceSceneHelpersToBundle: boolean;
  114130. interface Scene {
  114131. /**
  114132. * Creates a default light for the scene.
  114133. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  114134. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  114135. */
  114136. createDefaultLight(replace?: boolean): void;
  114137. /**
  114138. * Creates a default camera for the scene.
  114139. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  114140. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  114141. * @param replace has default false, when true replaces the active camera in the scene
  114142. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  114143. */
  114144. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  114145. /**
  114146. * Creates a default camera and a default light.
  114147. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  114148. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  114149. * @param replace has the default false, when true replaces the active camera/light in the scene
  114150. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  114151. */
  114152. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  114153. /**
  114154. * Creates a new sky box
  114155. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  114156. * @param environmentTexture defines the texture to use as environment texture
  114157. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  114158. * @param scale defines the overall scale of the skybox
  114159. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  114160. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  114161. * @returns a new mesh holding the sky box
  114162. */
  114163. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  114164. /**
  114165. * Creates a new environment
  114166. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  114167. * @param options defines the options you can use to configure the environment
  114168. * @returns the new EnvironmentHelper
  114169. */
  114170. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  114171. /**
  114172. * Creates a new VREXperienceHelper
  114173. * @see http://doc.babylonjs.com/how_to/webvr_helper
  114174. * @param webVROptions defines the options used to create the new VREXperienceHelper
  114175. * @returns a new VREXperienceHelper
  114176. */
  114177. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  114178. /**
  114179. * Creates a new WebXRDefaultExperience
  114180. * @see http://doc.babylonjs.com/how_to/webxr
  114181. * @param options experience options
  114182. * @returns a promise for a new WebXRDefaultExperience
  114183. */
  114184. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  114185. }
  114186. }
  114187. declare module BABYLON {
  114188. /**
  114189. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  114190. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  114191. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  114192. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  114193. */
  114194. export class VideoDome extends TransformNode {
  114195. /**
  114196. * Define the video source as a Monoscopic panoramic 360 video.
  114197. */
  114198. static readonly MODE_MONOSCOPIC: number;
  114199. /**
  114200. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  114201. */
  114202. static readonly MODE_TOPBOTTOM: number;
  114203. /**
  114204. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  114205. */
  114206. static readonly MODE_SIDEBYSIDE: number;
  114207. private _halfDome;
  114208. private _useDirectMapping;
  114209. /**
  114210. * The video texture being displayed on the sphere
  114211. */
  114212. protected _videoTexture: VideoTexture;
  114213. /**
  114214. * Gets the video texture being displayed on the sphere
  114215. */
  114216. readonly videoTexture: VideoTexture;
  114217. /**
  114218. * The skybox material
  114219. */
  114220. protected _material: BackgroundMaterial;
  114221. /**
  114222. * The surface used for the skybox
  114223. */
  114224. protected _mesh: Mesh;
  114225. /**
  114226. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  114227. */
  114228. private _halfDomeMask;
  114229. /**
  114230. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  114231. * Also see the options.resolution property.
  114232. */
  114233. fovMultiplier: number;
  114234. private _videoMode;
  114235. /**
  114236. * Gets or set the current video mode for the video. It can be:
  114237. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  114238. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  114239. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  114240. */
  114241. videoMode: number;
  114242. /**
  114243. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  114244. *
  114245. */
  114246. /**
  114247. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  114248. */
  114249. halfDome: boolean;
  114250. /**
  114251. * Oberserver used in Stereoscopic VR Mode.
  114252. */
  114253. private _onBeforeCameraRenderObserver;
  114254. /**
  114255. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  114256. * @param name Element's name, child elements will append suffixes for their own names.
  114257. * @param urlsOrVideo defines the url(s) or the video element to use
  114258. * @param options An object containing optional or exposed sub element properties
  114259. */
  114260. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  114261. resolution?: number;
  114262. clickToPlay?: boolean;
  114263. autoPlay?: boolean;
  114264. loop?: boolean;
  114265. size?: number;
  114266. poster?: string;
  114267. faceForward?: boolean;
  114268. useDirectMapping?: boolean;
  114269. halfDomeMode?: boolean;
  114270. }, scene: Scene);
  114271. private _changeVideoMode;
  114272. /**
  114273. * Releases resources associated with this node.
  114274. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  114275. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  114276. */
  114277. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  114278. }
  114279. }
  114280. declare module BABYLON {
  114281. /**
  114282. * This class can be used to get instrumentation data from a Babylon engine
  114283. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  114284. */
  114285. export class EngineInstrumentation implements IDisposable {
  114286. /**
  114287. * Define the instrumented engine.
  114288. */
  114289. engine: Engine;
  114290. private _captureGPUFrameTime;
  114291. private _gpuFrameTimeToken;
  114292. private _gpuFrameTime;
  114293. private _captureShaderCompilationTime;
  114294. private _shaderCompilationTime;
  114295. private _onBeginFrameObserver;
  114296. private _onEndFrameObserver;
  114297. private _onBeforeShaderCompilationObserver;
  114298. private _onAfterShaderCompilationObserver;
  114299. /**
  114300. * Gets the perf counter used for GPU frame time
  114301. */
  114302. readonly gpuFrameTimeCounter: PerfCounter;
  114303. /**
  114304. * Gets the GPU frame time capture status
  114305. */
  114306. /**
  114307. * Enable or disable the GPU frame time capture
  114308. */
  114309. captureGPUFrameTime: boolean;
  114310. /**
  114311. * Gets the perf counter used for shader compilation time
  114312. */
  114313. readonly shaderCompilationTimeCounter: PerfCounter;
  114314. /**
  114315. * Gets the shader compilation time capture status
  114316. */
  114317. /**
  114318. * Enable or disable the shader compilation time capture
  114319. */
  114320. captureShaderCompilationTime: boolean;
  114321. /**
  114322. * Instantiates a new engine instrumentation.
  114323. * This class can be used to get instrumentation data from a Babylon engine
  114324. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  114325. * @param engine Defines the engine to instrument
  114326. */
  114327. constructor(
  114328. /**
  114329. * Define the instrumented engine.
  114330. */
  114331. engine: Engine);
  114332. /**
  114333. * Dispose and release associated resources.
  114334. */
  114335. dispose(): void;
  114336. }
  114337. }
  114338. declare module BABYLON {
  114339. /**
  114340. * This class can be used to get instrumentation data from a Babylon engine
  114341. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  114342. */
  114343. export class SceneInstrumentation implements IDisposable {
  114344. /**
  114345. * Defines the scene to instrument
  114346. */
  114347. scene: Scene;
  114348. private _captureActiveMeshesEvaluationTime;
  114349. private _activeMeshesEvaluationTime;
  114350. private _captureRenderTargetsRenderTime;
  114351. private _renderTargetsRenderTime;
  114352. private _captureFrameTime;
  114353. private _frameTime;
  114354. private _captureRenderTime;
  114355. private _renderTime;
  114356. private _captureInterFrameTime;
  114357. private _interFrameTime;
  114358. private _captureParticlesRenderTime;
  114359. private _particlesRenderTime;
  114360. private _captureSpritesRenderTime;
  114361. private _spritesRenderTime;
  114362. private _capturePhysicsTime;
  114363. private _physicsTime;
  114364. private _captureAnimationsTime;
  114365. private _animationsTime;
  114366. private _captureCameraRenderTime;
  114367. private _cameraRenderTime;
  114368. private _onBeforeActiveMeshesEvaluationObserver;
  114369. private _onAfterActiveMeshesEvaluationObserver;
  114370. private _onBeforeRenderTargetsRenderObserver;
  114371. private _onAfterRenderTargetsRenderObserver;
  114372. private _onAfterRenderObserver;
  114373. private _onBeforeDrawPhaseObserver;
  114374. private _onAfterDrawPhaseObserver;
  114375. private _onBeforeAnimationsObserver;
  114376. private _onBeforeParticlesRenderingObserver;
  114377. private _onAfterParticlesRenderingObserver;
  114378. private _onBeforeSpritesRenderingObserver;
  114379. private _onAfterSpritesRenderingObserver;
  114380. private _onBeforePhysicsObserver;
  114381. private _onAfterPhysicsObserver;
  114382. private _onAfterAnimationsObserver;
  114383. private _onBeforeCameraRenderObserver;
  114384. private _onAfterCameraRenderObserver;
  114385. /**
  114386. * Gets the perf counter used for active meshes evaluation time
  114387. */
  114388. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  114389. /**
  114390. * Gets the active meshes evaluation time capture status
  114391. */
  114392. /**
  114393. * Enable or disable the active meshes evaluation time capture
  114394. */
  114395. captureActiveMeshesEvaluationTime: boolean;
  114396. /**
  114397. * Gets the perf counter used for render targets render time
  114398. */
  114399. readonly renderTargetsRenderTimeCounter: PerfCounter;
  114400. /**
  114401. * Gets the render targets render time capture status
  114402. */
  114403. /**
  114404. * Enable or disable the render targets render time capture
  114405. */
  114406. captureRenderTargetsRenderTime: boolean;
  114407. /**
  114408. * Gets the perf counter used for particles render time
  114409. */
  114410. readonly particlesRenderTimeCounter: PerfCounter;
  114411. /**
  114412. * Gets the particles render time capture status
  114413. */
  114414. /**
  114415. * Enable or disable the particles render time capture
  114416. */
  114417. captureParticlesRenderTime: boolean;
  114418. /**
  114419. * Gets the perf counter used for sprites render time
  114420. */
  114421. readonly spritesRenderTimeCounter: PerfCounter;
  114422. /**
  114423. * Gets the sprites render time capture status
  114424. */
  114425. /**
  114426. * Enable or disable the sprites render time capture
  114427. */
  114428. captureSpritesRenderTime: boolean;
  114429. /**
  114430. * Gets the perf counter used for physics time
  114431. */
  114432. readonly physicsTimeCounter: PerfCounter;
  114433. /**
  114434. * Gets the physics time capture status
  114435. */
  114436. /**
  114437. * Enable or disable the physics time capture
  114438. */
  114439. capturePhysicsTime: boolean;
  114440. /**
  114441. * Gets the perf counter used for animations time
  114442. */
  114443. readonly animationsTimeCounter: PerfCounter;
  114444. /**
  114445. * Gets the animations time capture status
  114446. */
  114447. /**
  114448. * Enable or disable the animations time capture
  114449. */
  114450. captureAnimationsTime: boolean;
  114451. /**
  114452. * Gets the perf counter used for frame time capture
  114453. */
  114454. readonly frameTimeCounter: PerfCounter;
  114455. /**
  114456. * Gets the frame time capture status
  114457. */
  114458. /**
  114459. * Enable or disable the frame time capture
  114460. */
  114461. captureFrameTime: boolean;
  114462. /**
  114463. * Gets the perf counter used for inter-frames time capture
  114464. */
  114465. readonly interFrameTimeCounter: PerfCounter;
  114466. /**
  114467. * Gets the inter-frames time capture status
  114468. */
  114469. /**
  114470. * Enable or disable the inter-frames time capture
  114471. */
  114472. captureInterFrameTime: boolean;
  114473. /**
  114474. * Gets the perf counter used for render time capture
  114475. */
  114476. readonly renderTimeCounter: PerfCounter;
  114477. /**
  114478. * Gets the render time capture status
  114479. */
  114480. /**
  114481. * Enable or disable the render time capture
  114482. */
  114483. captureRenderTime: boolean;
  114484. /**
  114485. * Gets the perf counter used for camera render time capture
  114486. */
  114487. readonly cameraRenderTimeCounter: PerfCounter;
  114488. /**
  114489. * Gets the camera render time capture status
  114490. */
  114491. /**
  114492. * Enable or disable the camera render time capture
  114493. */
  114494. captureCameraRenderTime: boolean;
  114495. /**
  114496. * Gets the perf counter used for draw calls
  114497. */
  114498. readonly drawCallsCounter: PerfCounter;
  114499. /**
  114500. * Instantiates a new scene instrumentation.
  114501. * This class can be used to get instrumentation data from a Babylon engine
  114502. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  114503. * @param scene Defines the scene to instrument
  114504. */
  114505. constructor(
  114506. /**
  114507. * Defines the scene to instrument
  114508. */
  114509. scene: Scene);
  114510. /**
  114511. * Dispose and release associated resources.
  114512. */
  114513. dispose(): void;
  114514. }
  114515. }
  114516. declare module BABYLON {
  114517. /** @hidden */
  114518. export var glowMapGenerationPixelShader: {
  114519. name: string;
  114520. shader: string;
  114521. };
  114522. }
  114523. declare module BABYLON {
  114524. /** @hidden */
  114525. export var glowMapGenerationVertexShader: {
  114526. name: string;
  114527. shader: string;
  114528. };
  114529. }
  114530. declare module BABYLON {
  114531. /**
  114532. * Effect layer options. This helps customizing the behaviour
  114533. * of the effect layer.
  114534. */
  114535. export interface IEffectLayerOptions {
  114536. /**
  114537. * Multiplication factor apply to the canvas size to compute the render target size
  114538. * used to generated the objects (the smaller the faster).
  114539. */
  114540. mainTextureRatio: number;
  114541. /**
  114542. * Enforces a fixed size texture to ensure effect stability across devices.
  114543. */
  114544. mainTextureFixedSize?: number;
  114545. /**
  114546. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  114547. */
  114548. alphaBlendingMode: number;
  114549. /**
  114550. * The camera attached to the layer.
  114551. */
  114552. camera: Nullable<Camera>;
  114553. /**
  114554. * The rendering group to draw the layer in.
  114555. */
  114556. renderingGroupId: number;
  114557. }
  114558. /**
  114559. * The effect layer Helps adding post process effect blended with the main pass.
  114560. *
  114561. * This can be for instance use to generate glow or higlight effects on the scene.
  114562. *
  114563. * The effect layer class can not be used directly and is intented to inherited from to be
  114564. * customized per effects.
  114565. */
  114566. export abstract class EffectLayer {
  114567. private _vertexBuffers;
  114568. private _indexBuffer;
  114569. private _cachedDefines;
  114570. private _effectLayerMapGenerationEffect;
  114571. private _effectLayerOptions;
  114572. private _mergeEffect;
  114573. protected _scene: Scene;
  114574. protected _engine: Engine;
  114575. protected _maxSize: number;
  114576. protected _mainTextureDesiredSize: ISize;
  114577. protected _mainTexture: RenderTargetTexture;
  114578. protected _shouldRender: boolean;
  114579. protected _postProcesses: PostProcess[];
  114580. protected _textures: BaseTexture[];
  114581. protected _emissiveTextureAndColor: {
  114582. texture: Nullable<BaseTexture>;
  114583. color: Color4;
  114584. };
  114585. /**
  114586. * The name of the layer
  114587. */
  114588. name: string;
  114589. /**
  114590. * The clear color of the texture used to generate the glow map.
  114591. */
  114592. neutralColor: Color4;
  114593. /**
  114594. * Specifies wether the highlight layer is enabled or not.
  114595. */
  114596. isEnabled: boolean;
  114597. /**
  114598. * Gets the camera attached to the layer.
  114599. */
  114600. readonly camera: Nullable<Camera>;
  114601. /**
  114602. * Gets the rendering group id the layer should render in.
  114603. */
  114604. renderingGroupId: number;
  114605. /**
  114606. * An event triggered when the effect layer has been disposed.
  114607. */
  114608. onDisposeObservable: Observable<EffectLayer>;
  114609. /**
  114610. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  114611. */
  114612. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  114613. /**
  114614. * An event triggered when the generated texture is being merged in the scene.
  114615. */
  114616. onBeforeComposeObservable: Observable<EffectLayer>;
  114617. /**
  114618. * An event triggered when the generated texture has been merged in the scene.
  114619. */
  114620. onAfterComposeObservable: Observable<EffectLayer>;
  114621. /**
  114622. * An event triggered when the efffect layer changes its size.
  114623. */
  114624. onSizeChangedObservable: Observable<EffectLayer>;
  114625. /** @hidden */
  114626. static _SceneComponentInitialization: (scene: Scene) => void;
  114627. /**
  114628. * Instantiates a new effect Layer and references it in the scene.
  114629. * @param name The name of the layer
  114630. * @param scene The scene to use the layer in
  114631. */
  114632. constructor(
  114633. /** The Friendly of the effect in the scene */
  114634. name: string, scene: Scene);
  114635. /**
  114636. * Get the effect name of the layer.
  114637. * @return The effect name
  114638. */
  114639. abstract getEffectName(): string;
  114640. /**
  114641. * Checks for the readiness of the element composing the layer.
  114642. * @param subMesh the mesh to check for
  114643. * @param useInstances specify wether or not to use instances to render the mesh
  114644. * @return true if ready otherwise, false
  114645. */
  114646. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  114647. /**
  114648. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  114649. * @returns true if the effect requires stencil during the main canvas render pass.
  114650. */
  114651. abstract needStencil(): boolean;
  114652. /**
  114653. * Create the merge effect. This is the shader use to blit the information back
  114654. * to the main canvas at the end of the scene rendering.
  114655. * @returns The effect containing the shader used to merge the effect on the main canvas
  114656. */
  114657. protected abstract _createMergeEffect(): Effect;
  114658. /**
  114659. * Creates the render target textures and post processes used in the effect layer.
  114660. */
  114661. protected abstract _createTextureAndPostProcesses(): void;
  114662. /**
  114663. * Implementation specific of rendering the generating effect on the main canvas.
  114664. * @param effect The effect used to render through
  114665. */
  114666. protected abstract _internalRender(effect: Effect): void;
  114667. /**
  114668. * Sets the required values for both the emissive texture and and the main color.
  114669. */
  114670. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  114671. /**
  114672. * Free any resources and references associated to a mesh.
  114673. * Internal use
  114674. * @param mesh The mesh to free.
  114675. */
  114676. abstract _disposeMesh(mesh: Mesh): void;
  114677. /**
  114678. * Serializes this layer (Glow or Highlight for example)
  114679. * @returns a serialized layer object
  114680. */
  114681. abstract serialize?(): any;
  114682. /**
  114683. * Initializes the effect layer with the required options.
  114684. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  114685. */
  114686. protected _init(options: Partial<IEffectLayerOptions>): void;
  114687. /**
  114688. * Generates the index buffer of the full screen quad blending to the main canvas.
  114689. */
  114690. private _generateIndexBuffer;
  114691. /**
  114692. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  114693. */
  114694. private _generateVertexBuffer;
  114695. /**
  114696. * Sets the main texture desired size which is the closest power of two
  114697. * of the engine canvas size.
  114698. */
  114699. private _setMainTextureSize;
  114700. /**
  114701. * Creates the main texture for the effect layer.
  114702. */
  114703. protected _createMainTexture(): void;
  114704. /**
  114705. * Adds specific effects defines.
  114706. * @param defines The defines to add specifics to.
  114707. */
  114708. protected _addCustomEffectDefines(defines: string[]): void;
  114709. /**
  114710. * Checks for the readiness of the element composing the layer.
  114711. * @param subMesh the mesh to check for
  114712. * @param useInstances specify wether or not to use instances to render the mesh
  114713. * @param emissiveTexture the associated emissive texture used to generate the glow
  114714. * @return true if ready otherwise, false
  114715. */
  114716. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  114717. /**
  114718. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  114719. */
  114720. render(): void;
  114721. /**
  114722. * Determine if a given mesh will be used in the current effect.
  114723. * @param mesh mesh to test
  114724. * @returns true if the mesh will be used
  114725. */
  114726. hasMesh(mesh: AbstractMesh): boolean;
  114727. /**
  114728. * Returns true if the layer contains information to display, otherwise false.
  114729. * @returns true if the glow layer should be rendered
  114730. */
  114731. shouldRender(): boolean;
  114732. /**
  114733. * Returns true if the mesh should render, otherwise false.
  114734. * @param mesh The mesh to render
  114735. * @returns true if it should render otherwise false
  114736. */
  114737. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  114738. /**
  114739. * Returns true if the mesh can be rendered, otherwise false.
  114740. * @param mesh The mesh to render
  114741. * @param material The material used on the mesh
  114742. * @returns true if it can be rendered otherwise false
  114743. */
  114744. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  114745. /**
  114746. * Returns true if the mesh should render, otherwise false.
  114747. * @param mesh The mesh to render
  114748. * @returns true if it should render otherwise false
  114749. */
  114750. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  114751. /**
  114752. * Renders the submesh passed in parameter to the generation map.
  114753. */
  114754. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  114755. /**
  114756. * Rebuild the required buffers.
  114757. * @hidden Internal use only.
  114758. */
  114759. _rebuild(): void;
  114760. /**
  114761. * Dispose only the render target textures and post process.
  114762. */
  114763. private _disposeTextureAndPostProcesses;
  114764. /**
  114765. * Dispose the highlight layer and free resources.
  114766. */
  114767. dispose(): void;
  114768. /**
  114769. * Gets the class name of the effect layer
  114770. * @returns the string with the class name of the effect layer
  114771. */
  114772. getClassName(): string;
  114773. /**
  114774. * Creates an effect layer from parsed effect layer data
  114775. * @param parsedEffectLayer defines effect layer data
  114776. * @param scene defines the current scene
  114777. * @param rootUrl defines the root URL containing the effect layer information
  114778. * @returns a parsed effect Layer
  114779. */
  114780. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  114781. }
  114782. }
  114783. declare module BABYLON {
  114784. interface AbstractScene {
  114785. /**
  114786. * The list of effect layers (highlights/glow) added to the scene
  114787. * @see http://doc.babylonjs.com/how_to/highlight_layer
  114788. * @see http://doc.babylonjs.com/how_to/glow_layer
  114789. */
  114790. effectLayers: Array<EffectLayer>;
  114791. /**
  114792. * Removes the given effect layer from this scene.
  114793. * @param toRemove defines the effect layer to remove
  114794. * @returns the index of the removed effect layer
  114795. */
  114796. removeEffectLayer(toRemove: EffectLayer): number;
  114797. /**
  114798. * Adds the given effect layer to this scene
  114799. * @param newEffectLayer defines the effect layer to add
  114800. */
  114801. addEffectLayer(newEffectLayer: EffectLayer): void;
  114802. }
  114803. /**
  114804. * Defines the layer scene component responsible to manage any effect layers
  114805. * in a given scene.
  114806. */
  114807. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  114808. /**
  114809. * The component name helpfull to identify the component in the list of scene components.
  114810. */
  114811. readonly name: string;
  114812. /**
  114813. * The scene the component belongs to.
  114814. */
  114815. scene: Scene;
  114816. private _engine;
  114817. private _renderEffects;
  114818. private _needStencil;
  114819. private _previousStencilState;
  114820. /**
  114821. * Creates a new instance of the component for the given scene
  114822. * @param scene Defines the scene to register the component in
  114823. */
  114824. constructor(scene: Scene);
  114825. /**
  114826. * Registers the component in a given scene
  114827. */
  114828. register(): void;
  114829. /**
  114830. * Rebuilds the elements related to this component in case of
  114831. * context lost for instance.
  114832. */
  114833. rebuild(): void;
  114834. /**
  114835. * Serializes the component data to the specified json object
  114836. * @param serializationObject The object to serialize to
  114837. */
  114838. serialize(serializationObject: any): void;
  114839. /**
  114840. * Adds all the elements from the container to the scene
  114841. * @param container the container holding the elements
  114842. */
  114843. addFromContainer(container: AbstractScene): void;
  114844. /**
  114845. * Removes all the elements in the container from the scene
  114846. * @param container contains the elements to remove
  114847. * @param dispose if the removed element should be disposed (default: false)
  114848. */
  114849. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  114850. /**
  114851. * Disposes the component and the associated ressources.
  114852. */
  114853. dispose(): void;
  114854. private _isReadyForMesh;
  114855. private _renderMainTexture;
  114856. private _setStencil;
  114857. private _setStencilBack;
  114858. private _draw;
  114859. private _drawCamera;
  114860. private _drawRenderingGroup;
  114861. }
  114862. }
  114863. declare module BABYLON {
  114864. /** @hidden */
  114865. export var glowMapMergePixelShader: {
  114866. name: string;
  114867. shader: string;
  114868. };
  114869. }
  114870. declare module BABYLON {
  114871. /** @hidden */
  114872. export var glowMapMergeVertexShader: {
  114873. name: string;
  114874. shader: string;
  114875. };
  114876. }
  114877. declare module BABYLON {
  114878. interface AbstractScene {
  114879. /**
  114880. * Return a the first highlight layer of the scene with a given name.
  114881. * @param name The name of the highlight layer to look for.
  114882. * @return The highlight layer if found otherwise null.
  114883. */
  114884. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  114885. }
  114886. /**
  114887. * Glow layer options. This helps customizing the behaviour
  114888. * of the glow layer.
  114889. */
  114890. export interface IGlowLayerOptions {
  114891. /**
  114892. * Multiplication factor apply to the canvas size to compute the render target size
  114893. * used to generated the glowing objects (the smaller the faster).
  114894. */
  114895. mainTextureRatio: number;
  114896. /**
  114897. * Enforces a fixed size texture to ensure resize independant blur.
  114898. */
  114899. mainTextureFixedSize?: number;
  114900. /**
  114901. * How big is the kernel of the blur texture.
  114902. */
  114903. blurKernelSize: number;
  114904. /**
  114905. * The camera attached to the layer.
  114906. */
  114907. camera: Nullable<Camera>;
  114908. /**
  114909. * Enable MSAA by chosing the number of samples.
  114910. */
  114911. mainTextureSamples?: number;
  114912. /**
  114913. * The rendering group to draw the layer in.
  114914. */
  114915. renderingGroupId: number;
  114916. }
  114917. /**
  114918. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  114919. *
  114920. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  114921. * glowy meshes to your scene.
  114922. *
  114923. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  114924. */
  114925. export class GlowLayer extends EffectLayer {
  114926. /**
  114927. * Effect Name of the layer.
  114928. */
  114929. static readonly EffectName: string;
  114930. /**
  114931. * The default blur kernel size used for the glow.
  114932. */
  114933. static DefaultBlurKernelSize: number;
  114934. /**
  114935. * The default texture size ratio used for the glow.
  114936. */
  114937. static DefaultTextureRatio: number;
  114938. /**
  114939. * Sets the kernel size of the blur.
  114940. */
  114941. /**
  114942. * Gets the kernel size of the blur.
  114943. */
  114944. blurKernelSize: number;
  114945. /**
  114946. * Sets the glow intensity.
  114947. */
  114948. /**
  114949. * Gets the glow intensity.
  114950. */
  114951. intensity: number;
  114952. private _options;
  114953. private _intensity;
  114954. private _horizontalBlurPostprocess1;
  114955. private _verticalBlurPostprocess1;
  114956. private _horizontalBlurPostprocess2;
  114957. private _verticalBlurPostprocess2;
  114958. private _blurTexture1;
  114959. private _blurTexture2;
  114960. private _postProcesses1;
  114961. private _postProcesses2;
  114962. private _includedOnlyMeshes;
  114963. private _excludedMeshes;
  114964. /**
  114965. * Callback used to let the user override the color selection on a per mesh basis
  114966. */
  114967. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  114968. /**
  114969. * Callback used to let the user override the texture selection on a per mesh basis
  114970. */
  114971. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  114972. /**
  114973. * Instantiates a new glow Layer and references it to the scene.
  114974. * @param name The name of the layer
  114975. * @param scene The scene to use the layer in
  114976. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  114977. */
  114978. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  114979. /**
  114980. * Get the effect name of the layer.
  114981. * @return The effect name
  114982. */
  114983. getEffectName(): string;
  114984. /**
  114985. * Create the merge effect. This is the shader use to blit the information back
  114986. * to the main canvas at the end of the scene rendering.
  114987. */
  114988. protected _createMergeEffect(): Effect;
  114989. /**
  114990. * Creates the render target textures and post processes used in the glow layer.
  114991. */
  114992. protected _createTextureAndPostProcesses(): void;
  114993. /**
  114994. * Checks for the readiness of the element composing the layer.
  114995. * @param subMesh the mesh to check for
  114996. * @param useInstances specify wether or not to use instances to render the mesh
  114997. * @param emissiveTexture the associated emissive texture used to generate the glow
  114998. * @return true if ready otherwise, false
  114999. */
  115000. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  115001. /**
  115002. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  115003. */
  115004. needStencil(): boolean;
  115005. /**
  115006. * Returns true if the mesh can be rendered, otherwise false.
  115007. * @param mesh The mesh to render
  115008. * @param material The material used on the mesh
  115009. * @returns true if it can be rendered otherwise false
  115010. */
  115011. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  115012. /**
  115013. * Implementation specific of rendering the generating effect on the main canvas.
  115014. * @param effect The effect used to render through
  115015. */
  115016. protected _internalRender(effect: Effect): void;
  115017. /**
  115018. * Sets the required values for both the emissive texture and and the main color.
  115019. */
  115020. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  115021. /**
  115022. * Returns true if the mesh should render, otherwise false.
  115023. * @param mesh The mesh to render
  115024. * @returns true if it should render otherwise false
  115025. */
  115026. protected _shouldRenderMesh(mesh: Mesh): boolean;
  115027. /**
  115028. * Adds specific effects defines.
  115029. * @param defines The defines to add specifics to.
  115030. */
  115031. protected _addCustomEffectDefines(defines: string[]): void;
  115032. /**
  115033. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  115034. * @param mesh The mesh to exclude from the glow layer
  115035. */
  115036. addExcludedMesh(mesh: Mesh): void;
  115037. /**
  115038. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  115039. * @param mesh The mesh to remove
  115040. */
  115041. removeExcludedMesh(mesh: Mesh): void;
  115042. /**
  115043. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  115044. * @param mesh The mesh to include in the glow layer
  115045. */
  115046. addIncludedOnlyMesh(mesh: Mesh): void;
  115047. /**
  115048. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  115049. * @param mesh The mesh to remove
  115050. */
  115051. removeIncludedOnlyMesh(mesh: Mesh): void;
  115052. /**
  115053. * Determine if a given mesh will be used in the glow layer
  115054. * @param mesh The mesh to test
  115055. * @returns true if the mesh will be highlighted by the current glow layer
  115056. */
  115057. hasMesh(mesh: AbstractMesh): boolean;
  115058. /**
  115059. * Free any resources and references associated to a mesh.
  115060. * Internal use
  115061. * @param mesh The mesh to free.
  115062. * @hidden
  115063. */
  115064. _disposeMesh(mesh: Mesh): void;
  115065. /**
  115066. * Gets the class name of the effect layer
  115067. * @returns the string with the class name of the effect layer
  115068. */
  115069. getClassName(): string;
  115070. /**
  115071. * Serializes this glow layer
  115072. * @returns a serialized glow layer object
  115073. */
  115074. serialize(): any;
  115075. /**
  115076. * Creates a Glow Layer from parsed glow layer data
  115077. * @param parsedGlowLayer defines glow layer data
  115078. * @param scene defines the current scene
  115079. * @param rootUrl defines the root URL containing the glow layer information
  115080. * @returns a parsed Glow Layer
  115081. */
  115082. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  115083. }
  115084. }
  115085. declare module BABYLON {
  115086. /** @hidden */
  115087. export var glowBlurPostProcessPixelShader: {
  115088. name: string;
  115089. shader: string;
  115090. };
  115091. }
  115092. declare module BABYLON {
  115093. interface AbstractScene {
  115094. /**
  115095. * Return a the first highlight layer of the scene with a given name.
  115096. * @param name The name of the highlight layer to look for.
  115097. * @return The highlight layer if found otherwise null.
  115098. */
  115099. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  115100. }
  115101. /**
  115102. * Highlight layer options. This helps customizing the behaviour
  115103. * of the highlight layer.
  115104. */
  115105. export interface IHighlightLayerOptions {
  115106. /**
  115107. * Multiplication factor apply to the canvas size to compute the render target size
  115108. * used to generated the glowing objects (the smaller the faster).
  115109. */
  115110. mainTextureRatio: number;
  115111. /**
  115112. * Enforces a fixed size texture to ensure resize independant blur.
  115113. */
  115114. mainTextureFixedSize?: number;
  115115. /**
  115116. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  115117. * of the picture to blur (the smaller the faster).
  115118. */
  115119. blurTextureSizeRatio: number;
  115120. /**
  115121. * How big in texel of the blur texture is the vertical blur.
  115122. */
  115123. blurVerticalSize: number;
  115124. /**
  115125. * How big in texel of the blur texture is the horizontal blur.
  115126. */
  115127. blurHorizontalSize: number;
  115128. /**
  115129. * Alpha blending mode used to apply the blur. Default is combine.
  115130. */
  115131. alphaBlendingMode: number;
  115132. /**
  115133. * The camera attached to the layer.
  115134. */
  115135. camera: Nullable<Camera>;
  115136. /**
  115137. * Should we display highlight as a solid stroke?
  115138. */
  115139. isStroke?: boolean;
  115140. /**
  115141. * The rendering group to draw the layer in.
  115142. */
  115143. renderingGroupId: number;
  115144. }
  115145. /**
  115146. * The highlight layer Helps adding a glow effect around a mesh.
  115147. *
  115148. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  115149. * glowy meshes to your scene.
  115150. *
  115151. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  115152. */
  115153. export class HighlightLayer extends EffectLayer {
  115154. name: string;
  115155. /**
  115156. * Effect Name of the highlight layer.
  115157. */
  115158. static readonly EffectName: string;
  115159. /**
  115160. * The neutral color used during the preparation of the glow effect.
  115161. * This is black by default as the blend operation is a blend operation.
  115162. */
  115163. static NeutralColor: Color4;
  115164. /**
  115165. * Stencil value used for glowing meshes.
  115166. */
  115167. static GlowingMeshStencilReference: number;
  115168. /**
  115169. * Stencil value used for the other meshes in the scene.
  115170. */
  115171. static NormalMeshStencilReference: number;
  115172. /**
  115173. * Specifies whether or not the inner glow is ACTIVE in the layer.
  115174. */
  115175. innerGlow: boolean;
  115176. /**
  115177. * Specifies whether or not the outer glow is ACTIVE in the layer.
  115178. */
  115179. outerGlow: boolean;
  115180. /**
  115181. * Specifies the horizontal size of the blur.
  115182. */
  115183. /**
  115184. * Gets the horizontal size of the blur.
  115185. */
  115186. blurHorizontalSize: number;
  115187. /**
  115188. * Specifies the vertical size of the blur.
  115189. */
  115190. /**
  115191. * Gets the vertical size of the blur.
  115192. */
  115193. blurVerticalSize: number;
  115194. /**
  115195. * An event triggered when the highlight layer is being blurred.
  115196. */
  115197. onBeforeBlurObservable: Observable<HighlightLayer>;
  115198. /**
  115199. * An event triggered when the highlight layer has been blurred.
  115200. */
  115201. onAfterBlurObservable: Observable<HighlightLayer>;
  115202. private _instanceGlowingMeshStencilReference;
  115203. private _options;
  115204. private _downSamplePostprocess;
  115205. private _horizontalBlurPostprocess;
  115206. private _verticalBlurPostprocess;
  115207. private _blurTexture;
  115208. private _meshes;
  115209. private _excludedMeshes;
  115210. /**
  115211. * Instantiates a new highlight Layer and references it to the scene..
  115212. * @param name The name of the layer
  115213. * @param scene The scene to use the layer in
  115214. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  115215. */
  115216. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  115217. /**
  115218. * Get the effect name of the layer.
  115219. * @return The effect name
  115220. */
  115221. getEffectName(): string;
  115222. /**
  115223. * Create the merge effect. This is the shader use to blit the information back
  115224. * to the main canvas at the end of the scene rendering.
  115225. */
  115226. protected _createMergeEffect(): Effect;
  115227. /**
  115228. * Creates the render target textures and post processes used in the highlight layer.
  115229. */
  115230. protected _createTextureAndPostProcesses(): void;
  115231. /**
  115232. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  115233. */
  115234. needStencil(): boolean;
  115235. /**
  115236. * Checks for the readiness of the element composing the layer.
  115237. * @param subMesh the mesh to check for
  115238. * @param useInstances specify wether or not to use instances to render the mesh
  115239. * @param emissiveTexture the associated emissive texture used to generate the glow
  115240. * @return true if ready otherwise, false
  115241. */
  115242. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  115243. /**
  115244. * Implementation specific of rendering the generating effect on the main canvas.
  115245. * @param effect The effect used to render through
  115246. */
  115247. protected _internalRender(effect: Effect): void;
  115248. /**
  115249. * Returns true if the layer contains information to display, otherwise false.
  115250. */
  115251. shouldRender(): boolean;
  115252. /**
  115253. * Returns true if the mesh should render, otherwise false.
  115254. * @param mesh The mesh to render
  115255. * @returns true if it should render otherwise false
  115256. */
  115257. protected _shouldRenderMesh(mesh: Mesh): boolean;
  115258. /**
  115259. * Sets the required values for both the emissive texture and and the main color.
  115260. */
  115261. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  115262. /**
  115263. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  115264. * @param mesh The mesh to exclude from the highlight layer
  115265. */
  115266. addExcludedMesh(mesh: Mesh): void;
  115267. /**
  115268. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  115269. * @param mesh The mesh to highlight
  115270. */
  115271. removeExcludedMesh(mesh: Mesh): void;
  115272. /**
  115273. * Determine if a given mesh will be highlighted by the current HighlightLayer
  115274. * @param mesh mesh to test
  115275. * @returns true if the mesh will be highlighted by the current HighlightLayer
  115276. */
  115277. hasMesh(mesh: AbstractMesh): boolean;
  115278. /**
  115279. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  115280. * @param mesh The mesh to highlight
  115281. * @param color The color of the highlight
  115282. * @param glowEmissiveOnly Extract the glow from the emissive texture
  115283. */
  115284. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  115285. /**
  115286. * Remove a mesh from the highlight layer in order to make it stop glowing.
  115287. * @param mesh The mesh to highlight
  115288. */
  115289. removeMesh(mesh: Mesh): void;
  115290. /**
  115291. * Force the stencil to the normal expected value for none glowing parts
  115292. */
  115293. private _defaultStencilReference;
  115294. /**
  115295. * Free any resources and references associated to a mesh.
  115296. * Internal use
  115297. * @param mesh The mesh to free.
  115298. * @hidden
  115299. */
  115300. _disposeMesh(mesh: Mesh): void;
  115301. /**
  115302. * Dispose the highlight layer and free resources.
  115303. */
  115304. dispose(): void;
  115305. /**
  115306. * Gets the class name of the effect layer
  115307. * @returns the string with the class name of the effect layer
  115308. */
  115309. getClassName(): string;
  115310. /**
  115311. * Serializes this Highlight layer
  115312. * @returns a serialized Highlight layer object
  115313. */
  115314. serialize(): any;
  115315. /**
  115316. * Creates a Highlight layer from parsed Highlight layer data
  115317. * @param parsedHightlightLayer defines the Highlight layer data
  115318. * @param scene defines the current scene
  115319. * @param rootUrl defines the root URL containing the Highlight layer information
  115320. * @returns a parsed Highlight layer
  115321. */
  115322. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  115323. }
  115324. }
  115325. declare module BABYLON {
  115326. interface AbstractScene {
  115327. /**
  115328. * The list of layers (background and foreground) of the scene
  115329. */
  115330. layers: Array<Layer>;
  115331. }
  115332. /**
  115333. * Defines the layer scene component responsible to manage any layers
  115334. * in a given scene.
  115335. */
  115336. export class LayerSceneComponent implements ISceneComponent {
  115337. /**
  115338. * The component name helpfull to identify the component in the list of scene components.
  115339. */
  115340. readonly name: string;
  115341. /**
  115342. * The scene the component belongs to.
  115343. */
  115344. scene: Scene;
  115345. private _engine;
  115346. /**
  115347. * Creates a new instance of the component for the given scene
  115348. * @param scene Defines the scene to register the component in
  115349. */
  115350. constructor(scene: Scene);
  115351. /**
  115352. * Registers the component in a given scene
  115353. */
  115354. register(): void;
  115355. /**
  115356. * Rebuilds the elements related to this component in case of
  115357. * context lost for instance.
  115358. */
  115359. rebuild(): void;
  115360. /**
  115361. * Disposes the component and the associated ressources.
  115362. */
  115363. dispose(): void;
  115364. private _draw;
  115365. private _drawCameraPredicate;
  115366. private _drawCameraBackground;
  115367. private _drawCameraForeground;
  115368. private _drawRenderTargetPredicate;
  115369. private _drawRenderTargetBackground;
  115370. private _drawRenderTargetForeground;
  115371. /**
  115372. * Adds all the elements from the container to the scene
  115373. * @param container the container holding the elements
  115374. */
  115375. addFromContainer(container: AbstractScene): void;
  115376. /**
  115377. * Removes all the elements in the container from the scene
  115378. * @param container contains the elements to remove
  115379. * @param dispose if the removed element should be disposed (default: false)
  115380. */
  115381. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  115382. }
  115383. }
  115384. declare module BABYLON {
  115385. /** @hidden */
  115386. export var layerPixelShader: {
  115387. name: string;
  115388. shader: string;
  115389. };
  115390. }
  115391. declare module BABYLON {
  115392. /** @hidden */
  115393. export var layerVertexShader: {
  115394. name: string;
  115395. shader: string;
  115396. };
  115397. }
  115398. declare module BABYLON {
  115399. /**
  115400. * This represents a full screen 2d layer.
  115401. * This can be useful to display a picture in the background of your scene for instance.
  115402. * @see https://www.babylonjs-playground.com/#08A2BS#1
  115403. */
  115404. export class Layer {
  115405. /**
  115406. * Define the name of the layer.
  115407. */
  115408. name: string;
  115409. /**
  115410. * Define the texture the layer should display.
  115411. */
  115412. texture: Nullable<Texture>;
  115413. /**
  115414. * Is the layer in background or foreground.
  115415. */
  115416. isBackground: boolean;
  115417. /**
  115418. * Define the color of the layer (instead of texture).
  115419. */
  115420. color: Color4;
  115421. /**
  115422. * Define the scale of the layer in order to zoom in out of the texture.
  115423. */
  115424. scale: Vector2;
  115425. /**
  115426. * Define an offset for the layer in order to shift the texture.
  115427. */
  115428. offset: Vector2;
  115429. /**
  115430. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  115431. */
  115432. alphaBlendingMode: number;
  115433. /**
  115434. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  115435. * Alpha test will not mix with the background color in case of transparency.
  115436. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  115437. */
  115438. alphaTest: boolean;
  115439. /**
  115440. * Define a mask to restrict the layer to only some of the scene cameras.
  115441. */
  115442. layerMask: number;
  115443. /**
  115444. * Define the list of render target the layer is visible into.
  115445. */
  115446. renderTargetTextures: RenderTargetTexture[];
  115447. /**
  115448. * Define if the layer is only used in renderTarget or if it also
  115449. * renders in the main frame buffer of the canvas.
  115450. */
  115451. renderOnlyInRenderTargetTextures: boolean;
  115452. private _scene;
  115453. private _vertexBuffers;
  115454. private _indexBuffer;
  115455. private _effect;
  115456. private _alphaTestEffect;
  115457. /**
  115458. * An event triggered when the layer is disposed.
  115459. */
  115460. onDisposeObservable: Observable<Layer>;
  115461. private _onDisposeObserver;
  115462. /**
  115463. * Back compatibility with callback before the onDisposeObservable existed.
  115464. * The set callback will be triggered when the layer has been disposed.
  115465. */
  115466. onDispose: () => void;
  115467. /**
  115468. * An event triggered before rendering the scene
  115469. */
  115470. onBeforeRenderObservable: Observable<Layer>;
  115471. private _onBeforeRenderObserver;
  115472. /**
  115473. * Back compatibility with callback before the onBeforeRenderObservable existed.
  115474. * The set callback will be triggered just before rendering the layer.
  115475. */
  115476. onBeforeRender: () => void;
  115477. /**
  115478. * An event triggered after rendering the scene
  115479. */
  115480. onAfterRenderObservable: Observable<Layer>;
  115481. private _onAfterRenderObserver;
  115482. /**
  115483. * Back compatibility with callback before the onAfterRenderObservable existed.
  115484. * The set callback will be triggered just after rendering the layer.
  115485. */
  115486. onAfterRender: () => void;
  115487. /**
  115488. * Instantiates a new layer.
  115489. * This represents a full screen 2d layer.
  115490. * This can be useful to display a picture in the background of your scene for instance.
  115491. * @see https://www.babylonjs-playground.com/#08A2BS#1
  115492. * @param name Define the name of the layer in the scene
  115493. * @param imgUrl Define the url of the texture to display in the layer
  115494. * @param scene Define the scene the layer belongs to
  115495. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  115496. * @param color Defines a color for the layer
  115497. */
  115498. constructor(
  115499. /**
  115500. * Define the name of the layer.
  115501. */
  115502. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  115503. private _createIndexBuffer;
  115504. /** @hidden */
  115505. _rebuild(): void;
  115506. /**
  115507. * Renders the layer in the scene.
  115508. */
  115509. render(): void;
  115510. /**
  115511. * Disposes and releases the associated ressources.
  115512. */
  115513. dispose(): void;
  115514. }
  115515. }
  115516. declare module BABYLON {
  115517. /** @hidden */
  115518. export var lensFlarePixelShader: {
  115519. name: string;
  115520. shader: string;
  115521. };
  115522. }
  115523. declare module BABYLON {
  115524. /** @hidden */
  115525. export var lensFlareVertexShader: {
  115526. name: string;
  115527. shader: string;
  115528. };
  115529. }
  115530. declare module BABYLON {
  115531. /**
  115532. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  115533. * It is usually composed of several `lensFlare`.
  115534. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115535. */
  115536. export class LensFlareSystem {
  115537. /**
  115538. * Define the name of the lens flare system
  115539. */
  115540. name: string;
  115541. /**
  115542. * List of lens flares used in this system.
  115543. */
  115544. lensFlares: LensFlare[];
  115545. /**
  115546. * Define a limit from the border the lens flare can be visible.
  115547. */
  115548. borderLimit: number;
  115549. /**
  115550. * Define a viewport border we do not want to see the lens flare in.
  115551. */
  115552. viewportBorder: number;
  115553. /**
  115554. * Define a predicate which could limit the list of meshes able to occlude the effect.
  115555. */
  115556. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  115557. /**
  115558. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  115559. */
  115560. layerMask: number;
  115561. /**
  115562. * Define the id of the lens flare system in the scene.
  115563. * (equal to name by default)
  115564. */
  115565. id: string;
  115566. private _scene;
  115567. private _emitter;
  115568. private _vertexBuffers;
  115569. private _indexBuffer;
  115570. private _effect;
  115571. private _positionX;
  115572. private _positionY;
  115573. private _isEnabled;
  115574. /** @hidden */
  115575. static _SceneComponentInitialization: (scene: Scene) => void;
  115576. /**
  115577. * Instantiates a lens flare system.
  115578. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  115579. * It is usually composed of several `lensFlare`.
  115580. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115581. * @param name Define the name of the lens flare system in the scene
  115582. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  115583. * @param scene Define the scene the lens flare system belongs to
  115584. */
  115585. constructor(
  115586. /**
  115587. * Define the name of the lens flare system
  115588. */
  115589. name: string, emitter: any, scene: Scene);
  115590. /**
  115591. * Define if the lens flare system is enabled.
  115592. */
  115593. isEnabled: boolean;
  115594. /**
  115595. * Get the scene the effects belongs to.
  115596. * @returns the scene holding the lens flare system
  115597. */
  115598. getScene(): Scene;
  115599. /**
  115600. * Get the emitter of the lens flare system.
  115601. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  115602. * @returns the emitter of the lens flare system
  115603. */
  115604. getEmitter(): any;
  115605. /**
  115606. * Set the emitter of the lens flare system.
  115607. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  115608. * @param newEmitter Define the new emitter of the system
  115609. */
  115610. setEmitter(newEmitter: any): void;
  115611. /**
  115612. * Get the lens flare system emitter position.
  115613. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  115614. * @returns the position
  115615. */
  115616. getEmitterPosition(): Vector3;
  115617. /**
  115618. * @hidden
  115619. */
  115620. computeEffectivePosition(globalViewport: Viewport): boolean;
  115621. /** @hidden */
  115622. _isVisible(): boolean;
  115623. /**
  115624. * @hidden
  115625. */
  115626. render(): boolean;
  115627. /**
  115628. * Dispose and release the lens flare with its associated resources.
  115629. */
  115630. dispose(): void;
  115631. /**
  115632. * Parse a lens flare system from a JSON repressentation
  115633. * @param parsedLensFlareSystem Define the JSON to parse
  115634. * @param scene Define the scene the parsed system should be instantiated in
  115635. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  115636. * @returns the parsed system
  115637. */
  115638. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  115639. /**
  115640. * Serialize the current Lens Flare System into a JSON representation.
  115641. * @returns the serialized JSON
  115642. */
  115643. serialize(): any;
  115644. }
  115645. }
  115646. declare module BABYLON {
  115647. /**
  115648. * This represents one of the lens effect in a `lensFlareSystem`.
  115649. * It controls one of the indiviual texture used in the effect.
  115650. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115651. */
  115652. export class LensFlare {
  115653. /**
  115654. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  115655. */
  115656. size: number;
  115657. /**
  115658. * 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.
  115659. */
  115660. position: number;
  115661. /**
  115662. * Define the lens color.
  115663. */
  115664. color: Color3;
  115665. /**
  115666. * Define the lens texture.
  115667. */
  115668. texture: Nullable<Texture>;
  115669. /**
  115670. * Define the alpha mode to render this particular lens.
  115671. */
  115672. alphaMode: number;
  115673. private _system;
  115674. /**
  115675. * Creates a new Lens Flare.
  115676. * This represents one of the lens effect in a `lensFlareSystem`.
  115677. * It controls one of the indiviual texture used in the effect.
  115678. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115679. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  115680. * @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.
  115681. * @param color Define the lens color
  115682. * @param imgUrl Define the lens texture url
  115683. * @param system Define the `lensFlareSystem` this flare is part of
  115684. * @returns The newly created Lens Flare
  115685. */
  115686. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  115687. /**
  115688. * Instantiates a new Lens Flare.
  115689. * This represents one of the lens effect in a `lensFlareSystem`.
  115690. * It controls one of the indiviual texture used in the effect.
  115691. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115692. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  115693. * @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.
  115694. * @param color Define the lens color
  115695. * @param imgUrl Define the lens texture url
  115696. * @param system Define the `lensFlareSystem` this flare is part of
  115697. */
  115698. constructor(
  115699. /**
  115700. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  115701. */
  115702. size: number,
  115703. /**
  115704. * 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.
  115705. */
  115706. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  115707. /**
  115708. * Dispose and release the lens flare with its associated resources.
  115709. */
  115710. dispose(): void;
  115711. }
  115712. }
  115713. declare module BABYLON {
  115714. interface AbstractScene {
  115715. /**
  115716. * The list of lens flare system added to the scene
  115717. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115718. */
  115719. lensFlareSystems: Array<LensFlareSystem>;
  115720. /**
  115721. * Removes the given lens flare system from this scene.
  115722. * @param toRemove The lens flare system to remove
  115723. * @returns The index of the removed lens flare system
  115724. */
  115725. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  115726. /**
  115727. * Adds the given lens flare system to this scene
  115728. * @param newLensFlareSystem The lens flare system to add
  115729. */
  115730. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  115731. /**
  115732. * Gets a lens flare system using its name
  115733. * @param name defines the name to look for
  115734. * @returns the lens flare system or null if not found
  115735. */
  115736. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  115737. /**
  115738. * Gets a lens flare system using its id
  115739. * @param id defines the id to look for
  115740. * @returns the lens flare system or null if not found
  115741. */
  115742. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  115743. }
  115744. /**
  115745. * Defines the lens flare scene component responsible to manage any lens flares
  115746. * in a given scene.
  115747. */
  115748. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  115749. /**
  115750. * The component name helpfull to identify the component in the list of scene components.
  115751. */
  115752. readonly name: string;
  115753. /**
  115754. * The scene the component belongs to.
  115755. */
  115756. scene: Scene;
  115757. /**
  115758. * Creates a new instance of the component for the given scene
  115759. * @param scene Defines the scene to register the component in
  115760. */
  115761. constructor(scene: Scene);
  115762. /**
  115763. * Registers the component in a given scene
  115764. */
  115765. register(): void;
  115766. /**
  115767. * Rebuilds the elements related to this component in case of
  115768. * context lost for instance.
  115769. */
  115770. rebuild(): void;
  115771. /**
  115772. * Adds all the elements from the container to the scene
  115773. * @param container the container holding the elements
  115774. */
  115775. addFromContainer(container: AbstractScene): void;
  115776. /**
  115777. * Removes all the elements in the container from the scene
  115778. * @param container contains the elements to remove
  115779. * @param dispose if the removed element should be disposed (default: false)
  115780. */
  115781. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  115782. /**
  115783. * Serializes the component data to the specified json object
  115784. * @param serializationObject The object to serialize to
  115785. */
  115786. serialize(serializationObject: any): void;
  115787. /**
  115788. * Disposes the component and the associated ressources.
  115789. */
  115790. dispose(): void;
  115791. private _draw;
  115792. }
  115793. }
  115794. declare module BABYLON {
  115795. /**
  115796. * Defines the shadow generator component responsible to manage any shadow generators
  115797. * in a given scene.
  115798. */
  115799. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  115800. /**
  115801. * The component name helpfull to identify the component in the list of scene components.
  115802. */
  115803. readonly name: string;
  115804. /**
  115805. * The scene the component belongs to.
  115806. */
  115807. scene: Scene;
  115808. /**
  115809. * Creates a new instance of the component for the given scene
  115810. * @param scene Defines the scene to register the component in
  115811. */
  115812. constructor(scene: Scene);
  115813. /**
  115814. * Registers the component in a given scene
  115815. */
  115816. register(): void;
  115817. /**
  115818. * Rebuilds the elements related to this component in case of
  115819. * context lost for instance.
  115820. */
  115821. rebuild(): void;
  115822. /**
  115823. * Serializes the component data to the specified json object
  115824. * @param serializationObject The object to serialize to
  115825. */
  115826. serialize(serializationObject: any): void;
  115827. /**
  115828. * Adds all the elements from the container to the scene
  115829. * @param container the container holding the elements
  115830. */
  115831. addFromContainer(container: AbstractScene): void;
  115832. /**
  115833. * Removes all the elements in the container from the scene
  115834. * @param container contains the elements to remove
  115835. * @param dispose if the removed element should be disposed (default: false)
  115836. */
  115837. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  115838. /**
  115839. * Rebuilds the elements related to this component in case of
  115840. * context lost for instance.
  115841. */
  115842. dispose(): void;
  115843. private _gatherRenderTargets;
  115844. }
  115845. }
  115846. declare module BABYLON {
  115847. /**
  115848. * A point light is a light defined by an unique point in world space.
  115849. * The light is emitted in every direction from this point.
  115850. * A good example of a point light is a standard light bulb.
  115851. * Documentation: https://doc.babylonjs.com/babylon101/lights
  115852. */
  115853. export class PointLight extends ShadowLight {
  115854. private _shadowAngle;
  115855. /**
  115856. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  115857. * This specifies what angle the shadow will use to be created.
  115858. *
  115859. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  115860. */
  115861. /**
  115862. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  115863. * This specifies what angle the shadow will use to be created.
  115864. *
  115865. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  115866. */
  115867. shadowAngle: number;
  115868. /**
  115869. * Gets the direction if it has been set.
  115870. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  115871. */
  115872. /**
  115873. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  115874. */
  115875. direction: Vector3;
  115876. /**
  115877. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  115878. * A PointLight emits the light in every direction.
  115879. * It can cast shadows.
  115880. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  115881. * ```javascript
  115882. * var pointLight = new PointLight("pl", camera.position, scene);
  115883. * ```
  115884. * Documentation : https://doc.babylonjs.com/babylon101/lights
  115885. * @param name The light friendly name
  115886. * @param position The position of the point light in the scene
  115887. * @param scene The scene the lights belongs to
  115888. */
  115889. constructor(name: string, position: Vector3, scene: Scene);
  115890. /**
  115891. * Returns the string "PointLight"
  115892. * @returns the class name
  115893. */
  115894. getClassName(): string;
  115895. /**
  115896. * Returns the integer 0.
  115897. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  115898. */
  115899. getTypeID(): number;
  115900. /**
  115901. * Specifies wether or not the shadowmap should be a cube texture.
  115902. * @returns true if the shadowmap needs to be a cube texture.
  115903. */
  115904. needCube(): boolean;
  115905. /**
  115906. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  115907. * @param faceIndex The index of the face we are computed the direction to generate shadow
  115908. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  115909. */
  115910. getShadowDirection(faceIndex?: number): Vector3;
  115911. /**
  115912. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  115913. * - fov = PI / 2
  115914. * - aspect ratio : 1.0
  115915. * - z-near and far equal to the active camera minZ and maxZ.
  115916. * Returns the PointLight.
  115917. */
  115918. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  115919. protected _buildUniformLayout(): void;
  115920. /**
  115921. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  115922. * @param effect The effect to update
  115923. * @param lightIndex The index of the light in the effect to update
  115924. * @returns The point light
  115925. */
  115926. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  115927. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  115928. /**
  115929. * Prepares the list of defines specific to the light type.
  115930. * @param defines the list of defines
  115931. * @param lightIndex defines the index of the light for the effect
  115932. */
  115933. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  115934. }
  115935. }
  115936. declare module BABYLON {
  115937. /**
  115938. * Header information of HDR texture files.
  115939. */
  115940. export interface HDRInfo {
  115941. /**
  115942. * The height of the texture in pixels.
  115943. */
  115944. height: number;
  115945. /**
  115946. * The width of the texture in pixels.
  115947. */
  115948. width: number;
  115949. /**
  115950. * The index of the beginning of the data in the binary file.
  115951. */
  115952. dataPosition: number;
  115953. }
  115954. /**
  115955. * This groups tools to convert HDR texture to native colors array.
  115956. */
  115957. export class HDRTools {
  115958. private static Ldexp;
  115959. private static Rgbe2float;
  115960. private static readStringLine;
  115961. /**
  115962. * Reads header information from an RGBE texture stored in a native array.
  115963. * More information on this format are available here:
  115964. * https://en.wikipedia.org/wiki/RGBE_image_format
  115965. *
  115966. * @param uint8array The binary file stored in native array.
  115967. * @return The header information.
  115968. */
  115969. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  115970. /**
  115971. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  115972. * This RGBE texture needs to store the information as a panorama.
  115973. *
  115974. * More information on this format are available here:
  115975. * https://en.wikipedia.org/wiki/RGBE_image_format
  115976. *
  115977. * @param buffer The binary file stored in an array buffer.
  115978. * @param size The expected size of the extracted cubemap.
  115979. * @return The Cube Map information.
  115980. */
  115981. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  115982. /**
  115983. * Returns the pixels data extracted from an RGBE texture.
  115984. * This pixels will be stored left to right up to down in the R G B order in one array.
  115985. *
  115986. * More information on this format are available here:
  115987. * https://en.wikipedia.org/wiki/RGBE_image_format
  115988. *
  115989. * @param uint8array The binary file stored in an array buffer.
  115990. * @param hdrInfo The header information of the file.
  115991. * @return The pixels data in RGB right to left up to down order.
  115992. */
  115993. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  115994. private static RGBE_ReadPixels_RLE;
  115995. }
  115996. }
  115997. declare module BABYLON {
  115998. /**
  115999. * This represents a texture coming from an HDR input.
  116000. *
  116001. * The only supported format is currently panorama picture stored in RGBE format.
  116002. * Example of such files can be found on HDRLib: http://hdrlib.com/
  116003. */
  116004. export class HDRCubeTexture extends BaseTexture {
  116005. private static _facesMapping;
  116006. private _generateHarmonics;
  116007. private _noMipmap;
  116008. private _textureMatrix;
  116009. private _size;
  116010. private _onLoad;
  116011. private _onError;
  116012. /**
  116013. * The texture URL.
  116014. */
  116015. url: string;
  116016. /**
  116017. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  116018. */
  116019. coordinatesMode: number;
  116020. protected _isBlocking: boolean;
  116021. /**
  116022. * Sets wether or not the texture is blocking during loading.
  116023. */
  116024. /**
  116025. * Gets wether or not the texture is blocking during loading.
  116026. */
  116027. isBlocking: boolean;
  116028. protected _rotationY: number;
  116029. /**
  116030. * Sets texture matrix rotation angle around Y axis in radians.
  116031. */
  116032. /**
  116033. * Gets texture matrix rotation angle around Y axis radians.
  116034. */
  116035. rotationY: number;
  116036. /**
  116037. * Gets or sets the center of the bounding box associated with the cube texture
  116038. * It must define where the camera used to render the texture was set
  116039. */
  116040. boundingBoxPosition: Vector3;
  116041. private _boundingBoxSize;
  116042. /**
  116043. * Gets or sets the size of the bounding box associated with the cube texture
  116044. * When defined, the cubemap will switch to local mode
  116045. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  116046. * @example https://www.babylonjs-playground.com/#RNASML
  116047. */
  116048. boundingBoxSize: Vector3;
  116049. /**
  116050. * Instantiates an HDRTexture from the following parameters.
  116051. *
  116052. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  116053. * @param scene The scene the texture will be used in
  116054. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  116055. * @param noMipmap Forces to not generate the mipmap if true
  116056. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  116057. * @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)
  116058. * @param reserved Reserved flag for internal use.
  116059. */
  116060. 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>);
  116061. /**
  116062. * Get the current class name of the texture useful for serialization or dynamic coding.
  116063. * @returns "HDRCubeTexture"
  116064. */
  116065. getClassName(): string;
  116066. /**
  116067. * Occurs when the file is raw .hdr file.
  116068. */
  116069. private loadTexture;
  116070. clone(): HDRCubeTexture;
  116071. delayLoad(): void;
  116072. /**
  116073. * Get the texture reflection matrix used to rotate/transform the reflection.
  116074. * @returns the reflection matrix
  116075. */
  116076. getReflectionTextureMatrix(): Matrix;
  116077. /**
  116078. * Set the texture reflection matrix used to rotate/transform the reflection.
  116079. * @param value Define the reflection matrix to set
  116080. */
  116081. setReflectionTextureMatrix(value: Matrix): void;
  116082. /**
  116083. * Parses a JSON representation of an HDR Texture in order to create the texture
  116084. * @param parsedTexture Define the JSON representation
  116085. * @param scene Define the scene the texture should be created in
  116086. * @param rootUrl Define the root url in case we need to load relative dependencies
  116087. * @returns the newly created texture after parsing
  116088. */
  116089. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  116090. serialize(): any;
  116091. }
  116092. }
  116093. declare module BABYLON {
  116094. /**
  116095. * Class used to control physics engine
  116096. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  116097. */
  116098. export class PhysicsEngine implements IPhysicsEngine {
  116099. private _physicsPlugin;
  116100. /**
  116101. * Global value used to control the smallest number supported by the simulation
  116102. */
  116103. static Epsilon: number;
  116104. private _impostors;
  116105. private _joints;
  116106. /**
  116107. * Gets the gravity vector used by the simulation
  116108. */
  116109. gravity: Vector3;
  116110. /**
  116111. * Factory used to create the default physics plugin.
  116112. * @returns The default physics plugin
  116113. */
  116114. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  116115. /**
  116116. * Creates a new Physics Engine
  116117. * @param gravity defines the gravity vector used by the simulation
  116118. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  116119. */
  116120. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  116121. /**
  116122. * Sets the gravity vector used by the simulation
  116123. * @param gravity defines the gravity vector to use
  116124. */
  116125. setGravity(gravity: Vector3): void;
  116126. /**
  116127. * Set the time step of the physics engine.
  116128. * Default is 1/60.
  116129. * To slow it down, enter 1/600 for example.
  116130. * To speed it up, 1/30
  116131. * @param newTimeStep defines the new timestep to apply to this world.
  116132. */
  116133. setTimeStep(newTimeStep?: number): void;
  116134. /**
  116135. * Get the time step of the physics engine.
  116136. * @returns the current time step
  116137. */
  116138. getTimeStep(): number;
  116139. /**
  116140. * Release all resources
  116141. */
  116142. dispose(): void;
  116143. /**
  116144. * Gets the name of the current physics plugin
  116145. * @returns the name of the plugin
  116146. */
  116147. getPhysicsPluginName(): string;
  116148. /**
  116149. * Adding a new impostor for the impostor tracking.
  116150. * This will be done by the impostor itself.
  116151. * @param impostor the impostor to add
  116152. */
  116153. addImpostor(impostor: PhysicsImpostor): void;
  116154. /**
  116155. * Remove an impostor from the engine.
  116156. * This impostor and its mesh will not longer be updated by the physics engine.
  116157. * @param impostor the impostor to remove
  116158. */
  116159. removeImpostor(impostor: PhysicsImpostor): void;
  116160. /**
  116161. * Add a joint to the physics engine
  116162. * @param mainImpostor defines the main impostor to which the joint is added.
  116163. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  116164. * @param joint defines the joint that will connect both impostors.
  116165. */
  116166. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  116167. /**
  116168. * Removes a joint from the simulation
  116169. * @param mainImpostor defines the impostor used with the joint
  116170. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  116171. * @param joint defines the joint to remove
  116172. */
  116173. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  116174. /**
  116175. * Called by the scene. No need to call it.
  116176. * @param delta defines the timespam between frames
  116177. */
  116178. _step(delta: number): void;
  116179. /**
  116180. * Gets the current plugin used to run the simulation
  116181. * @returns current plugin
  116182. */
  116183. getPhysicsPlugin(): IPhysicsEnginePlugin;
  116184. /**
  116185. * Gets the list of physic impostors
  116186. * @returns an array of PhysicsImpostor
  116187. */
  116188. getImpostors(): Array<PhysicsImpostor>;
  116189. /**
  116190. * Gets the impostor for a physics enabled object
  116191. * @param object defines the object impersonated by the impostor
  116192. * @returns the PhysicsImpostor or null if not found
  116193. */
  116194. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  116195. /**
  116196. * Gets the impostor for a physics body object
  116197. * @param body defines physics body used by the impostor
  116198. * @returns the PhysicsImpostor or null if not found
  116199. */
  116200. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  116201. /**
  116202. * Does a raycast in the physics world
  116203. * @param from when should the ray start?
  116204. * @param to when should the ray end?
  116205. * @returns PhysicsRaycastResult
  116206. */
  116207. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  116208. }
  116209. }
  116210. declare module BABYLON {
  116211. /** @hidden */
  116212. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  116213. private _useDeltaForWorldStep;
  116214. world: any;
  116215. name: string;
  116216. private _physicsMaterials;
  116217. private _fixedTimeStep;
  116218. private _cannonRaycastResult;
  116219. private _raycastResult;
  116220. private _physicsBodysToRemoveAfterStep;
  116221. BJSCANNON: any;
  116222. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  116223. setGravity(gravity: Vector3): void;
  116224. setTimeStep(timeStep: number): void;
  116225. getTimeStep(): number;
  116226. executeStep(delta: number): void;
  116227. private _removeMarkedPhysicsBodiesFromWorld;
  116228. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  116229. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  116230. generatePhysicsBody(impostor: PhysicsImpostor): void;
  116231. private _processChildMeshes;
  116232. removePhysicsBody(impostor: PhysicsImpostor): void;
  116233. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  116234. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  116235. private _addMaterial;
  116236. private _checkWithEpsilon;
  116237. private _createShape;
  116238. private _createHeightmap;
  116239. private _minus90X;
  116240. private _plus90X;
  116241. private _tmpPosition;
  116242. private _tmpDeltaPosition;
  116243. private _tmpUnityRotation;
  116244. private _updatePhysicsBodyTransformation;
  116245. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  116246. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  116247. isSupported(): boolean;
  116248. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  116249. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  116250. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  116251. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  116252. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  116253. getBodyMass(impostor: PhysicsImpostor): number;
  116254. getBodyFriction(impostor: PhysicsImpostor): number;
  116255. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  116256. getBodyRestitution(impostor: PhysicsImpostor): number;
  116257. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  116258. sleepBody(impostor: PhysicsImpostor): void;
  116259. wakeUpBody(impostor: PhysicsImpostor): void;
  116260. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  116261. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  116262. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  116263. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  116264. getRadius(impostor: PhysicsImpostor): number;
  116265. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  116266. dispose(): void;
  116267. private _extendNamespace;
  116268. /**
  116269. * Does a raycast in the physics world
  116270. * @param from when should the ray start?
  116271. * @param to when should the ray end?
  116272. * @returns PhysicsRaycastResult
  116273. */
  116274. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  116275. }
  116276. }
  116277. declare module BABYLON {
  116278. /** @hidden */
  116279. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  116280. world: any;
  116281. name: string;
  116282. BJSOIMO: any;
  116283. private _raycastResult;
  116284. constructor(iterations?: number, oimoInjection?: any);
  116285. setGravity(gravity: Vector3): void;
  116286. setTimeStep(timeStep: number): void;
  116287. getTimeStep(): number;
  116288. private _tmpImpostorsArray;
  116289. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  116290. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  116291. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  116292. generatePhysicsBody(impostor: PhysicsImpostor): void;
  116293. private _tmpPositionVector;
  116294. removePhysicsBody(impostor: PhysicsImpostor): void;
  116295. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  116296. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  116297. isSupported(): boolean;
  116298. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  116299. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  116300. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  116301. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  116302. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  116303. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  116304. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  116305. getBodyMass(impostor: PhysicsImpostor): number;
  116306. getBodyFriction(impostor: PhysicsImpostor): number;
  116307. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  116308. getBodyRestitution(impostor: PhysicsImpostor): number;
  116309. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  116310. sleepBody(impostor: PhysicsImpostor): void;
  116311. wakeUpBody(impostor: PhysicsImpostor): void;
  116312. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  116313. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  116314. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  116315. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  116316. getRadius(impostor: PhysicsImpostor): number;
  116317. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  116318. dispose(): void;
  116319. /**
  116320. * Does a raycast in the physics world
  116321. * @param from when should the ray start?
  116322. * @param to when should the ray end?
  116323. * @returns PhysicsRaycastResult
  116324. */
  116325. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  116326. }
  116327. }
  116328. declare module BABYLON {
  116329. /**
  116330. * Class containing static functions to help procedurally build meshes
  116331. */
  116332. export class RibbonBuilder {
  116333. /**
  116334. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  116335. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  116336. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  116337. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  116338. * * 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
  116339. * * 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
  116340. * * 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
  116341. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116342. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116343. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  116344. * * 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
  116345. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  116346. * * 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
  116347. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  116348. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116349. * @param name defines the name of the mesh
  116350. * @param options defines the options used to create the mesh
  116351. * @param scene defines the hosting scene
  116352. * @returns the ribbon mesh
  116353. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  116354. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  116355. */
  116356. static CreateRibbon(name: string, options: {
  116357. pathArray: Vector3[][];
  116358. closeArray?: boolean;
  116359. closePath?: boolean;
  116360. offset?: number;
  116361. updatable?: boolean;
  116362. sideOrientation?: number;
  116363. frontUVs?: Vector4;
  116364. backUVs?: Vector4;
  116365. instance?: Mesh;
  116366. invertUV?: boolean;
  116367. uvs?: Vector2[];
  116368. colors?: Color4[];
  116369. }, scene?: Nullable<Scene>): Mesh;
  116370. }
  116371. }
  116372. declare module BABYLON {
  116373. /**
  116374. * Class containing static functions to help procedurally build meshes
  116375. */
  116376. export class ShapeBuilder {
  116377. /**
  116378. * 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.
  116379. * * 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.
  116380. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  116381. * * 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.
  116382. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  116383. * * 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
  116384. * * 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
  116385. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  116386. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116387. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116388. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  116389. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116390. * @param name defines the name of the mesh
  116391. * @param options defines the options used to create the mesh
  116392. * @param scene defines the hosting scene
  116393. * @returns the extruded shape mesh
  116394. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  116395. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  116396. */
  116397. static ExtrudeShape(name: string, options: {
  116398. shape: Vector3[];
  116399. path: Vector3[];
  116400. scale?: number;
  116401. rotation?: number;
  116402. cap?: number;
  116403. updatable?: boolean;
  116404. sideOrientation?: number;
  116405. frontUVs?: Vector4;
  116406. backUVs?: Vector4;
  116407. instance?: Mesh;
  116408. invertUV?: boolean;
  116409. }, scene?: Nullable<Scene>): Mesh;
  116410. /**
  116411. * Creates an custom extruded shape mesh.
  116412. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  116413. * * 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.
  116414. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  116415. * * 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
  116416. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  116417. * * 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
  116418. * * It must returns a float value that will be the scale value applied to the shape on each path point
  116419. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  116420. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  116421. * * 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
  116422. * * 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
  116423. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  116424. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116425. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116426. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  116427. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116428. * @param name defines the name of the mesh
  116429. * @param options defines the options used to create the mesh
  116430. * @param scene defines the hosting scene
  116431. * @returns the custom extruded shape mesh
  116432. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  116433. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  116434. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  116435. */
  116436. static ExtrudeShapeCustom(name: string, options: {
  116437. shape: Vector3[];
  116438. path: Vector3[];
  116439. scaleFunction?: any;
  116440. rotationFunction?: any;
  116441. ribbonCloseArray?: boolean;
  116442. ribbonClosePath?: boolean;
  116443. cap?: number;
  116444. updatable?: boolean;
  116445. sideOrientation?: number;
  116446. frontUVs?: Vector4;
  116447. backUVs?: Vector4;
  116448. instance?: Mesh;
  116449. invertUV?: boolean;
  116450. }, scene?: Nullable<Scene>): Mesh;
  116451. private static _ExtrudeShapeGeneric;
  116452. }
  116453. }
  116454. declare module BABYLON {
  116455. /**
  116456. * AmmoJS Physics plugin
  116457. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  116458. * @see https://github.com/kripken/ammo.js/
  116459. */
  116460. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  116461. private _useDeltaForWorldStep;
  116462. /**
  116463. * Reference to the Ammo library
  116464. */
  116465. bjsAMMO: any;
  116466. /**
  116467. * Created ammoJS world which physics bodies are added to
  116468. */
  116469. world: any;
  116470. /**
  116471. * Name of the plugin
  116472. */
  116473. name: string;
  116474. private _timeStep;
  116475. private _fixedTimeStep;
  116476. private _maxSteps;
  116477. private _tmpQuaternion;
  116478. private _tmpAmmoTransform;
  116479. private _tmpAmmoQuaternion;
  116480. private _tmpAmmoConcreteContactResultCallback;
  116481. private _collisionConfiguration;
  116482. private _dispatcher;
  116483. private _overlappingPairCache;
  116484. private _solver;
  116485. private _softBodySolver;
  116486. private _tmpAmmoVectorA;
  116487. private _tmpAmmoVectorB;
  116488. private _tmpAmmoVectorC;
  116489. private _tmpAmmoVectorD;
  116490. private _tmpContactCallbackResult;
  116491. private _tmpAmmoVectorRCA;
  116492. private _tmpAmmoVectorRCB;
  116493. private _raycastResult;
  116494. private static readonly DISABLE_COLLISION_FLAG;
  116495. private static readonly KINEMATIC_FLAG;
  116496. private static readonly DISABLE_DEACTIVATION_FLAG;
  116497. /**
  116498. * Initializes the ammoJS plugin
  116499. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  116500. * @param ammoInjection can be used to inject your own ammo reference
  116501. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  116502. */
  116503. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  116504. /**
  116505. * Sets the gravity of the physics world (m/(s^2))
  116506. * @param gravity Gravity to set
  116507. */
  116508. setGravity(gravity: Vector3): void;
  116509. /**
  116510. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  116511. * @param timeStep timestep to use in seconds
  116512. */
  116513. setTimeStep(timeStep: number): void;
  116514. /**
  116515. * 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)
  116516. * @param fixedTimeStep fixedTimeStep to use in seconds
  116517. */
  116518. setFixedTimeStep(fixedTimeStep: number): void;
  116519. /**
  116520. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  116521. * @param maxSteps the maximum number of steps by the physics engine per frame
  116522. */
  116523. setMaxSteps(maxSteps: number): void;
  116524. /**
  116525. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  116526. * @returns the current timestep in seconds
  116527. */
  116528. getTimeStep(): number;
  116529. private _isImpostorInContact;
  116530. private _isImpostorPairInContact;
  116531. private _stepSimulation;
  116532. /**
  116533. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  116534. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  116535. * After the step the babylon meshes are set to the position of the physics imposters
  116536. * @param delta amount of time to step forward
  116537. * @param impostors array of imposters to update before/after the step
  116538. */
  116539. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  116540. /**
  116541. * Update babylon mesh to match physics world object
  116542. * @param impostor imposter to match
  116543. */
  116544. private _afterSoftStep;
  116545. /**
  116546. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  116547. * @param impostor imposter to match
  116548. */
  116549. private _ropeStep;
  116550. /**
  116551. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  116552. * @param impostor imposter to match
  116553. */
  116554. private _softbodyOrClothStep;
  116555. private _tmpVector;
  116556. private _tmpMatrix;
  116557. /**
  116558. * Applies an impulse on the imposter
  116559. * @param impostor imposter to apply impulse to
  116560. * @param force amount of force to be applied to the imposter
  116561. * @param contactPoint the location to apply the impulse on the imposter
  116562. */
  116563. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  116564. /**
  116565. * Applies a force on the imposter
  116566. * @param impostor imposter to apply force
  116567. * @param force amount of force to be applied to the imposter
  116568. * @param contactPoint the location to apply the force on the imposter
  116569. */
  116570. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  116571. /**
  116572. * Creates a physics body using the plugin
  116573. * @param impostor the imposter to create the physics body on
  116574. */
  116575. generatePhysicsBody(impostor: PhysicsImpostor): void;
  116576. /**
  116577. * Removes the physics body from the imposter and disposes of the body's memory
  116578. * @param impostor imposter to remove the physics body from
  116579. */
  116580. removePhysicsBody(impostor: PhysicsImpostor): void;
  116581. /**
  116582. * Generates a joint
  116583. * @param impostorJoint the imposter joint to create the joint with
  116584. */
  116585. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  116586. /**
  116587. * Removes a joint
  116588. * @param impostorJoint the imposter joint to remove the joint from
  116589. */
  116590. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  116591. private _addMeshVerts;
  116592. /**
  116593. * Initialise the soft body vertices to match its object's (mesh) vertices
  116594. * Softbody vertices (nodes) are in world space and to match this
  116595. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  116596. * @param impostor to create the softbody for
  116597. */
  116598. private _softVertexData;
  116599. /**
  116600. * Create an impostor's soft body
  116601. * @param impostor to create the softbody for
  116602. */
  116603. private _createSoftbody;
  116604. /**
  116605. * Create cloth for an impostor
  116606. * @param impostor to create the softbody for
  116607. */
  116608. private _createCloth;
  116609. /**
  116610. * Create rope for an impostor
  116611. * @param impostor to create the softbody for
  116612. */
  116613. private _createRope;
  116614. private _addHullVerts;
  116615. private _createShape;
  116616. /**
  116617. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  116618. * @param impostor imposter containing the physics body and babylon object
  116619. */
  116620. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  116621. /**
  116622. * Sets the babylon object's position/rotation from the physics body's position/rotation
  116623. * @param impostor imposter containing the physics body and babylon object
  116624. * @param newPosition new position
  116625. * @param newRotation new rotation
  116626. */
  116627. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  116628. /**
  116629. * If this plugin is supported
  116630. * @returns true if its supported
  116631. */
  116632. isSupported(): boolean;
  116633. /**
  116634. * Sets the linear velocity of the physics body
  116635. * @param impostor imposter to set the velocity on
  116636. * @param velocity velocity to set
  116637. */
  116638. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  116639. /**
  116640. * Sets the angular velocity of the physics body
  116641. * @param impostor imposter to set the velocity on
  116642. * @param velocity velocity to set
  116643. */
  116644. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  116645. /**
  116646. * gets the linear velocity
  116647. * @param impostor imposter to get linear velocity from
  116648. * @returns linear velocity
  116649. */
  116650. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  116651. /**
  116652. * gets the angular velocity
  116653. * @param impostor imposter to get angular velocity from
  116654. * @returns angular velocity
  116655. */
  116656. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  116657. /**
  116658. * Sets the mass of physics body
  116659. * @param impostor imposter to set the mass on
  116660. * @param mass mass to set
  116661. */
  116662. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  116663. /**
  116664. * Gets the mass of the physics body
  116665. * @param impostor imposter to get the mass from
  116666. * @returns mass
  116667. */
  116668. getBodyMass(impostor: PhysicsImpostor): number;
  116669. /**
  116670. * Gets friction of the impostor
  116671. * @param impostor impostor to get friction from
  116672. * @returns friction value
  116673. */
  116674. getBodyFriction(impostor: PhysicsImpostor): number;
  116675. /**
  116676. * Sets friction of the impostor
  116677. * @param impostor impostor to set friction on
  116678. * @param friction friction value
  116679. */
  116680. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  116681. /**
  116682. * Gets restitution of the impostor
  116683. * @param impostor impostor to get restitution from
  116684. * @returns restitution value
  116685. */
  116686. getBodyRestitution(impostor: PhysicsImpostor): number;
  116687. /**
  116688. * Sets resitution of the impostor
  116689. * @param impostor impostor to set resitution on
  116690. * @param restitution resitution value
  116691. */
  116692. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  116693. /**
  116694. * Gets pressure inside the impostor
  116695. * @param impostor impostor to get pressure from
  116696. * @returns pressure value
  116697. */
  116698. getBodyPressure(impostor: PhysicsImpostor): number;
  116699. /**
  116700. * Sets pressure inside a soft body impostor
  116701. * Cloth and rope must remain 0 pressure
  116702. * @param impostor impostor to set pressure on
  116703. * @param pressure pressure value
  116704. */
  116705. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  116706. /**
  116707. * Gets stiffness of the impostor
  116708. * @param impostor impostor to get stiffness from
  116709. * @returns pressure value
  116710. */
  116711. getBodyStiffness(impostor: PhysicsImpostor): number;
  116712. /**
  116713. * Sets stiffness of the impostor
  116714. * @param impostor impostor to set stiffness on
  116715. * @param stiffness stiffness value from 0 to 1
  116716. */
  116717. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  116718. /**
  116719. * Gets velocityIterations of the impostor
  116720. * @param impostor impostor to get velocity iterations from
  116721. * @returns velocityIterations value
  116722. */
  116723. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  116724. /**
  116725. * Sets velocityIterations of the impostor
  116726. * @param impostor impostor to set velocity iterations on
  116727. * @param velocityIterations velocityIterations value
  116728. */
  116729. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  116730. /**
  116731. * Gets positionIterations of the impostor
  116732. * @param impostor impostor to get position iterations from
  116733. * @returns positionIterations value
  116734. */
  116735. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  116736. /**
  116737. * Sets positionIterations of the impostor
  116738. * @param impostor impostor to set position on
  116739. * @param positionIterations positionIterations value
  116740. */
  116741. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  116742. /**
  116743. * Append an anchor to a cloth object
  116744. * @param impostor is the cloth impostor to add anchor to
  116745. * @param otherImpostor is the rigid impostor to anchor to
  116746. * @param width ratio across width from 0 to 1
  116747. * @param height ratio up height from 0 to 1
  116748. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  116749. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  116750. */
  116751. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  116752. /**
  116753. * Append an hook to a rope object
  116754. * @param impostor is the rope impostor to add hook to
  116755. * @param otherImpostor is the rigid impostor to hook to
  116756. * @param length ratio along the rope from 0 to 1
  116757. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  116758. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  116759. */
  116760. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  116761. /**
  116762. * Sleeps the physics body and stops it from being active
  116763. * @param impostor impostor to sleep
  116764. */
  116765. sleepBody(impostor: PhysicsImpostor): void;
  116766. /**
  116767. * Activates the physics body
  116768. * @param impostor impostor to activate
  116769. */
  116770. wakeUpBody(impostor: PhysicsImpostor): void;
  116771. /**
  116772. * Updates the distance parameters of the joint
  116773. * @param joint joint to update
  116774. * @param maxDistance maximum distance of the joint
  116775. * @param minDistance minimum distance of the joint
  116776. */
  116777. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  116778. /**
  116779. * Sets a motor on the joint
  116780. * @param joint joint to set motor on
  116781. * @param speed speed of the motor
  116782. * @param maxForce maximum force of the motor
  116783. * @param motorIndex index of the motor
  116784. */
  116785. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  116786. /**
  116787. * Sets the motors limit
  116788. * @param joint joint to set limit on
  116789. * @param upperLimit upper limit
  116790. * @param lowerLimit lower limit
  116791. */
  116792. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  116793. /**
  116794. * Syncs the position and rotation of a mesh with the impostor
  116795. * @param mesh mesh to sync
  116796. * @param impostor impostor to update the mesh with
  116797. */
  116798. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  116799. /**
  116800. * Gets the radius of the impostor
  116801. * @param impostor impostor to get radius from
  116802. * @returns the radius
  116803. */
  116804. getRadius(impostor: PhysicsImpostor): number;
  116805. /**
  116806. * Gets the box size of the impostor
  116807. * @param impostor impostor to get box size from
  116808. * @param result the resulting box size
  116809. */
  116810. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  116811. /**
  116812. * Disposes of the impostor
  116813. */
  116814. dispose(): void;
  116815. /**
  116816. * Does a raycast in the physics world
  116817. * @param from when should the ray start?
  116818. * @param to when should the ray end?
  116819. * @returns PhysicsRaycastResult
  116820. */
  116821. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  116822. }
  116823. }
  116824. declare module BABYLON {
  116825. interface AbstractScene {
  116826. /**
  116827. * The list of reflection probes added to the scene
  116828. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  116829. */
  116830. reflectionProbes: Array<ReflectionProbe>;
  116831. /**
  116832. * Removes the given reflection probe from this scene.
  116833. * @param toRemove The reflection probe to remove
  116834. * @returns The index of the removed reflection probe
  116835. */
  116836. removeReflectionProbe(toRemove: ReflectionProbe): number;
  116837. /**
  116838. * Adds the given reflection probe to this scene.
  116839. * @param newReflectionProbe The reflection probe to add
  116840. */
  116841. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  116842. }
  116843. /**
  116844. * Class used to generate realtime reflection / refraction cube textures
  116845. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  116846. */
  116847. export class ReflectionProbe {
  116848. /** defines the name of the probe */
  116849. name: string;
  116850. private _scene;
  116851. private _renderTargetTexture;
  116852. private _projectionMatrix;
  116853. private _viewMatrix;
  116854. private _target;
  116855. private _add;
  116856. private _attachedMesh;
  116857. private _invertYAxis;
  116858. /** Gets or sets probe position (center of the cube map) */
  116859. position: Vector3;
  116860. /**
  116861. * Creates a new reflection probe
  116862. * @param name defines the name of the probe
  116863. * @param size defines the texture resolution (for each face)
  116864. * @param scene defines the hosting scene
  116865. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  116866. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  116867. */
  116868. constructor(
  116869. /** defines the name of the probe */
  116870. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  116871. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  116872. samples: number;
  116873. /** Gets or sets the refresh rate to use (on every frame by default) */
  116874. refreshRate: number;
  116875. /**
  116876. * Gets the hosting scene
  116877. * @returns a Scene
  116878. */
  116879. getScene(): Scene;
  116880. /** Gets the internal CubeTexture used to render to */
  116881. readonly cubeTexture: RenderTargetTexture;
  116882. /** Gets the list of meshes to render */
  116883. readonly renderList: Nullable<AbstractMesh[]>;
  116884. /**
  116885. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  116886. * @param mesh defines the mesh to attach to
  116887. */
  116888. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  116889. /**
  116890. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  116891. * @param renderingGroupId The rendering group id corresponding to its index
  116892. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  116893. */
  116894. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  116895. /**
  116896. * Clean all associated resources
  116897. */
  116898. dispose(): void;
  116899. /**
  116900. * Converts the reflection probe information to a readable string for debug purpose.
  116901. * @param fullDetails Supports for multiple levels of logging within scene loading
  116902. * @returns the human readable reflection probe info
  116903. */
  116904. toString(fullDetails?: boolean): string;
  116905. /**
  116906. * Get the class name of the relfection probe.
  116907. * @returns "ReflectionProbe"
  116908. */
  116909. getClassName(): string;
  116910. /**
  116911. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  116912. * @returns The JSON representation of the texture
  116913. */
  116914. serialize(): any;
  116915. /**
  116916. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  116917. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  116918. * @param scene Define the scene the parsed reflection probe should be instantiated in
  116919. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  116920. * @returns The parsed reflection probe if successful
  116921. */
  116922. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  116923. }
  116924. }
  116925. declare module BABYLON {
  116926. /** @hidden */
  116927. export var _BabylonLoaderRegistered: boolean;
  116928. }
  116929. declare module BABYLON {
  116930. /**
  116931. * The Physically based simple base material of BJS.
  116932. *
  116933. * This enables better naming and convention enforcements on top of the pbrMaterial.
  116934. * It is used as the base class for both the specGloss and metalRough conventions.
  116935. */
  116936. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  116937. /**
  116938. * Number of Simultaneous lights allowed on the material.
  116939. */
  116940. maxSimultaneousLights: number;
  116941. /**
  116942. * If sets to true, disables all the lights affecting the material.
  116943. */
  116944. disableLighting: boolean;
  116945. /**
  116946. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  116947. */
  116948. environmentTexture: BaseTexture;
  116949. /**
  116950. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  116951. */
  116952. invertNormalMapX: boolean;
  116953. /**
  116954. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  116955. */
  116956. invertNormalMapY: boolean;
  116957. /**
  116958. * Normal map used in the model.
  116959. */
  116960. normalTexture: BaseTexture;
  116961. /**
  116962. * Emissivie color used to self-illuminate the model.
  116963. */
  116964. emissiveColor: Color3;
  116965. /**
  116966. * Emissivie texture used to self-illuminate the model.
  116967. */
  116968. emissiveTexture: BaseTexture;
  116969. /**
  116970. * Occlusion Channel Strenght.
  116971. */
  116972. occlusionStrength: number;
  116973. /**
  116974. * Occlusion Texture of the material (adding extra occlusion effects).
  116975. */
  116976. occlusionTexture: BaseTexture;
  116977. /**
  116978. * Defines the alpha limits in alpha test mode.
  116979. */
  116980. alphaCutOff: number;
  116981. /**
  116982. * Gets the current double sided mode.
  116983. */
  116984. /**
  116985. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  116986. */
  116987. doubleSided: boolean;
  116988. /**
  116989. * Stores the pre-calculated light information of a mesh in a texture.
  116990. */
  116991. lightmapTexture: BaseTexture;
  116992. /**
  116993. * If true, the light map contains occlusion information instead of lighting info.
  116994. */
  116995. useLightmapAsShadowmap: boolean;
  116996. /**
  116997. * Instantiates a new PBRMaterial instance.
  116998. *
  116999. * @param name The material name
  117000. * @param scene The scene the material will be use in.
  117001. */
  117002. constructor(name: string, scene: Scene);
  117003. getClassName(): string;
  117004. }
  117005. }
  117006. declare module BABYLON {
  117007. /**
  117008. * The PBR material of BJS following the metal roughness convention.
  117009. *
  117010. * This fits to the PBR convention in the GLTF definition:
  117011. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  117012. */
  117013. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  117014. /**
  117015. * The base color has two different interpretations depending on the value of metalness.
  117016. * When the material is a metal, the base color is the specific measured reflectance value
  117017. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  117018. * of the material.
  117019. */
  117020. baseColor: Color3;
  117021. /**
  117022. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  117023. * well as opacity information in the alpha channel.
  117024. */
  117025. baseTexture: BaseTexture;
  117026. /**
  117027. * Specifies the metallic scalar value of the material.
  117028. * Can also be used to scale the metalness values of the metallic texture.
  117029. */
  117030. metallic: number;
  117031. /**
  117032. * Specifies the roughness scalar value of the material.
  117033. * Can also be used to scale the roughness values of the metallic texture.
  117034. */
  117035. roughness: number;
  117036. /**
  117037. * Texture containing both the metallic value in the B channel and the
  117038. * roughness value in the G channel to keep better precision.
  117039. */
  117040. metallicRoughnessTexture: BaseTexture;
  117041. /**
  117042. * Instantiates a new PBRMetalRoughnessMaterial instance.
  117043. *
  117044. * @param name The material name
  117045. * @param scene The scene the material will be use in.
  117046. */
  117047. constructor(name: string, scene: Scene);
  117048. /**
  117049. * Return the currrent class name of the material.
  117050. */
  117051. getClassName(): string;
  117052. /**
  117053. * Makes a duplicate of the current material.
  117054. * @param name - name to use for the new material.
  117055. */
  117056. clone(name: string): PBRMetallicRoughnessMaterial;
  117057. /**
  117058. * Serialize the material to a parsable JSON object.
  117059. */
  117060. serialize(): any;
  117061. /**
  117062. * Parses a JSON object correponding to the serialize function.
  117063. */
  117064. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  117065. }
  117066. }
  117067. declare module BABYLON {
  117068. /**
  117069. * The PBR material of BJS following the specular glossiness convention.
  117070. *
  117071. * This fits to the PBR convention in the GLTF definition:
  117072. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  117073. */
  117074. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  117075. /**
  117076. * Specifies the diffuse color of the material.
  117077. */
  117078. diffuseColor: Color3;
  117079. /**
  117080. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  117081. * channel.
  117082. */
  117083. diffuseTexture: BaseTexture;
  117084. /**
  117085. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  117086. */
  117087. specularColor: Color3;
  117088. /**
  117089. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  117090. */
  117091. glossiness: number;
  117092. /**
  117093. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  117094. */
  117095. specularGlossinessTexture: BaseTexture;
  117096. /**
  117097. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  117098. *
  117099. * @param name The material name
  117100. * @param scene The scene the material will be use in.
  117101. */
  117102. constructor(name: string, scene: Scene);
  117103. /**
  117104. * Return the currrent class name of the material.
  117105. */
  117106. getClassName(): string;
  117107. /**
  117108. * Makes a duplicate of the current material.
  117109. * @param name - name to use for the new material.
  117110. */
  117111. clone(name: string): PBRSpecularGlossinessMaterial;
  117112. /**
  117113. * Serialize the material to a parsable JSON object.
  117114. */
  117115. serialize(): any;
  117116. /**
  117117. * Parses a JSON object correponding to the serialize function.
  117118. */
  117119. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  117120. }
  117121. }
  117122. declare module BABYLON {
  117123. /**
  117124. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  117125. * It can help converting any input color in a desired output one. This can then be used to create effects
  117126. * from sepia, black and white to sixties or futuristic rendering...
  117127. *
  117128. * The only supported format is currently 3dl.
  117129. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  117130. */
  117131. export class ColorGradingTexture extends BaseTexture {
  117132. /**
  117133. * The current texture matrix. (will always be identity in color grading texture)
  117134. */
  117135. private _textureMatrix;
  117136. /**
  117137. * The texture URL.
  117138. */
  117139. url: string;
  117140. /**
  117141. * Empty line regex stored for GC.
  117142. */
  117143. private static _noneEmptyLineRegex;
  117144. private _engine;
  117145. /**
  117146. * Instantiates a ColorGradingTexture from the following parameters.
  117147. *
  117148. * @param url The location of the color gradind data (currently only supporting 3dl)
  117149. * @param scene The scene the texture will be used in
  117150. */
  117151. constructor(url: string, scene: Scene);
  117152. /**
  117153. * Returns the texture matrix used in most of the material.
  117154. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  117155. */
  117156. getTextureMatrix(): Matrix;
  117157. /**
  117158. * Occurs when the file being loaded is a .3dl LUT file.
  117159. */
  117160. private load3dlTexture;
  117161. /**
  117162. * Starts the loading process of the texture.
  117163. */
  117164. private loadTexture;
  117165. /**
  117166. * Clones the color gradind texture.
  117167. */
  117168. clone(): ColorGradingTexture;
  117169. /**
  117170. * Called during delayed load for textures.
  117171. */
  117172. delayLoad(): void;
  117173. /**
  117174. * Parses a color grading texture serialized by Babylon.
  117175. * @param parsedTexture The texture information being parsedTexture
  117176. * @param scene The scene to load the texture in
  117177. * @param rootUrl The root url of the data assets to load
  117178. * @return A color gradind texture
  117179. */
  117180. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  117181. /**
  117182. * Serializes the LUT texture to json format.
  117183. */
  117184. serialize(): any;
  117185. }
  117186. }
  117187. declare module BABYLON {
  117188. /**
  117189. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  117190. */
  117191. export class EquiRectangularCubeTexture extends BaseTexture {
  117192. /** The six faces of the cube. */
  117193. private static _FacesMapping;
  117194. private _noMipmap;
  117195. private _onLoad;
  117196. private _onError;
  117197. /** The size of the cubemap. */
  117198. private _size;
  117199. /** The buffer of the image. */
  117200. private _buffer;
  117201. /** The width of the input image. */
  117202. private _width;
  117203. /** The height of the input image. */
  117204. private _height;
  117205. /** The URL to the image. */
  117206. url: string;
  117207. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  117208. coordinatesMode: number;
  117209. /**
  117210. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  117211. * @param url The location of the image
  117212. * @param scene The scene the texture will be used in
  117213. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  117214. * @param noMipmap Forces to not generate the mipmap if true
  117215. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  117216. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  117217. * @param onLoad — defines a callback called when texture is loaded
  117218. * @param onError — defines a callback called if there is an error
  117219. */
  117220. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  117221. /**
  117222. * Load the image data, by putting the image on a canvas and extracting its buffer.
  117223. */
  117224. private loadImage;
  117225. /**
  117226. * Convert the image buffer into a cubemap and create a CubeTexture.
  117227. */
  117228. private loadTexture;
  117229. /**
  117230. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  117231. * @param buffer The ArrayBuffer that should be converted.
  117232. * @returns The buffer as Float32Array.
  117233. */
  117234. private getFloat32ArrayFromArrayBuffer;
  117235. /**
  117236. * Get the current class name of the texture useful for serialization or dynamic coding.
  117237. * @returns "EquiRectangularCubeTexture"
  117238. */
  117239. getClassName(): string;
  117240. /**
  117241. * Create a clone of the current EquiRectangularCubeTexture and return it.
  117242. * @returns A clone of the current EquiRectangularCubeTexture.
  117243. */
  117244. clone(): EquiRectangularCubeTexture;
  117245. }
  117246. }
  117247. declare module BABYLON {
  117248. /**
  117249. * Based on jsTGALoader - Javascript loader for TGA file
  117250. * By Vincent Thibault
  117251. * @see http://blog.robrowser.com/javascript-tga-loader.html
  117252. */
  117253. export class TGATools {
  117254. private static _TYPE_INDEXED;
  117255. private static _TYPE_RGB;
  117256. private static _TYPE_GREY;
  117257. private static _TYPE_RLE_INDEXED;
  117258. private static _TYPE_RLE_RGB;
  117259. private static _TYPE_RLE_GREY;
  117260. private static _ORIGIN_MASK;
  117261. private static _ORIGIN_SHIFT;
  117262. private static _ORIGIN_BL;
  117263. private static _ORIGIN_BR;
  117264. private static _ORIGIN_UL;
  117265. private static _ORIGIN_UR;
  117266. /**
  117267. * Gets the header of a TGA file
  117268. * @param data defines the TGA data
  117269. * @returns the header
  117270. */
  117271. static GetTGAHeader(data: Uint8Array): any;
  117272. /**
  117273. * Uploads TGA content to a Babylon Texture
  117274. * @hidden
  117275. */
  117276. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  117277. /** @hidden */
  117278. 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;
  117279. /** @hidden */
  117280. 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;
  117281. /** @hidden */
  117282. 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;
  117283. /** @hidden */
  117284. 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;
  117285. /** @hidden */
  117286. 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;
  117287. /** @hidden */
  117288. 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;
  117289. }
  117290. }
  117291. declare module BABYLON {
  117292. /**
  117293. * Implementation of the TGA Texture Loader.
  117294. * @hidden
  117295. */
  117296. export class _TGATextureLoader implements IInternalTextureLoader {
  117297. /**
  117298. * Defines wether the loader supports cascade loading the different faces.
  117299. */
  117300. readonly supportCascades: boolean;
  117301. /**
  117302. * This returns if the loader support the current file information.
  117303. * @param extension defines the file extension of the file being loaded
  117304. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117305. * @param fallback defines the fallback internal texture if any
  117306. * @param isBase64 defines whether the texture is encoded as a base64
  117307. * @param isBuffer defines whether the texture data are stored as a buffer
  117308. * @returns true if the loader can load the specified file
  117309. */
  117310. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  117311. /**
  117312. * Transform the url before loading if required.
  117313. * @param rootUrl the url of the texture
  117314. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117315. * @returns the transformed texture
  117316. */
  117317. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  117318. /**
  117319. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  117320. * @param rootUrl the url of the texture
  117321. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117322. * @returns the fallback texture
  117323. */
  117324. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  117325. /**
  117326. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  117327. * @param data contains the texture data
  117328. * @param texture defines the BabylonJS internal texture
  117329. * @param createPolynomials will be true if polynomials have been requested
  117330. * @param onLoad defines the callback to trigger once the texture is ready
  117331. * @param onError defines the callback to trigger in case of error
  117332. */
  117333. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  117334. /**
  117335. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  117336. * @param data contains the texture data
  117337. * @param texture defines the BabylonJS internal texture
  117338. * @param callback defines the method to call once ready to upload
  117339. */
  117340. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  117341. }
  117342. }
  117343. declare module BABYLON {
  117344. /**
  117345. * Info about the .basis files
  117346. */
  117347. class BasisFileInfo {
  117348. /**
  117349. * If the file has alpha
  117350. */
  117351. hasAlpha: boolean;
  117352. /**
  117353. * Info about each image of the basis file
  117354. */
  117355. images: Array<{
  117356. levels: Array<{
  117357. width: number;
  117358. height: number;
  117359. transcodedPixels: ArrayBufferView;
  117360. }>;
  117361. }>;
  117362. }
  117363. /**
  117364. * Result of transcoding a basis file
  117365. */
  117366. class TranscodeResult {
  117367. /**
  117368. * Info about the .basis file
  117369. */
  117370. fileInfo: BasisFileInfo;
  117371. /**
  117372. * Format to use when loading the file
  117373. */
  117374. format: number;
  117375. }
  117376. /**
  117377. * Configuration options for the Basis transcoder
  117378. */
  117379. export class BasisTranscodeConfiguration {
  117380. /**
  117381. * Supported compression formats used to determine the supported output format of the transcoder
  117382. */
  117383. supportedCompressionFormats?: {
  117384. /**
  117385. * etc1 compression format
  117386. */
  117387. etc1?: boolean;
  117388. /**
  117389. * s3tc compression format
  117390. */
  117391. s3tc?: boolean;
  117392. /**
  117393. * pvrtc compression format
  117394. */
  117395. pvrtc?: boolean;
  117396. /**
  117397. * etc2 compression format
  117398. */
  117399. etc2?: boolean;
  117400. };
  117401. /**
  117402. * If mipmap levels should be loaded for transcoded images (Default: true)
  117403. */
  117404. loadMipmapLevels?: boolean;
  117405. /**
  117406. * Index of a single image to load (Default: all images)
  117407. */
  117408. loadSingleImage?: number;
  117409. }
  117410. /**
  117411. * Used to load .Basis files
  117412. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  117413. */
  117414. export class BasisTools {
  117415. private static _IgnoreSupportedFormats;
  117416. /**
  117417. * URL to use when loading the basis transcoder
  117418. */
  117419. static JSModuleURL: string;
  117420. /**
  117421. * URL to use when loading the wasm module for the transcoder
  117422. */
  117423. static WasmModuleURL: string;
  117424. /**
  117425. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  117426. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  117427. * @returns internal format corresponding to the Basis format
  117428. */
  117429. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  117430. private static _WorkerPromise;
  117431. private static _Worker;
  117432. private static _actionId;
  117433. private static _CreateWorkerAsync;
  117434. /**
  117435. * Transcodes a loaded image file to compressed pixel data
  117436. * @param imageData image data to transcode
  117437. * @param config configuration options for the transcoding
  117438. * @returns a promise resulting in the transcoded image
  117439. */
  117440. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  117441. /**
  117442. * Loads a texture from the transcode result
  117443. * @param texture texture load to
  117444. * @param transcodeResult the result of transcoding the basis file to load from
  117445. */
  117446. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  117447. }
  117448. }
  117449. declare module BABYLON {
  117450. /**
  117451. * Loader for .basis file format
  117452. */
  117453. export class _BasisTextureLoader implements IInternalTextureLoader {
  117454. /**
  117455. * Defines whether the loader supports cascade loading the different faces.
  117456. */
  117457. readonly supportCascades: boolean;
  117458. /**
  117459. * This returns if the loader support the current file information.
  117460. * @param extension defines the file extension of the file being loaded
  117461. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117462. * @param fallback defines the fallback internal texture if any
  117463. * @param isBase64 defines whether the texture is encoded as a base64
  117464. * @param isBuffer defines whether the texture data are stored as a buffer
  117465. * @returns true if the loader can load the specified file
  117466. */
  117467. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  117468. /**
  117469. * Transform the url before loading if required.
  117470. * @param rootUrl the url of the texture
  117471. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117472. * @returns the transformed texture
  117473. */
  117474. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  117475. /**
  117476. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  117477. * @param rootUrl the url of the texture
  117478. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117479. * @returns the fallback texture
  117480. */
  117481. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  117482. /**
  117483. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  117484. * @param data contains the texture data
  117485. * @param texture defines the BabylonJS internal texture
  117486. * @param createPolynomials will be true if polynomials have been requested
  117487. * @param onLoad defines the callback to trigger once the texture is ready
  117488. * @param onError defines the callback to trigger in case of error
  117489. */
  117490. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  117491. /**
  117492. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  117493. * @param data contains the texture data
  117494. * @param texture defines the BabylonJS internal texture
  117495. * @param callback defines the method to call once ready to upload
  117496. */
  117497. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  117498. }
  117499. }
  117500. declare module BABYLON {
  117501. /**
  117502. * 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.
  117503. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  117504. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  117505. */
  117506. export class CustomProceduralTexture extends ProceduralTexture {
  117507. private _animate;
  117508. private _time;
  117509. private _config;
  117510. private _texturePath;
  117511. /**
  117512. * Instantiates a new Custom Procedural Texture.
  117513. * 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.
  117514. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  117515. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  117516. * @param name Define the name of the texture
  117517. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  117518. * @param size Define the size of the texture to create
  117519. * @param scene Define the scene the texture belongs to
  117520. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  117521. * @param generateMipMaps Define if the texture should creates mip maps or not
  117522. */
  117523. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  117524. private _loadJson;
  117525. /**
  117526. * Is the texture ready to be used ? (rendered at least once)
  117527. * @returns true if ready, otherwise, false.
  117528. */
  117529. isReady(): boolean;
  117530. /**
  117531. * Render the texture to its associated render target.
  117532. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  117533. */
  117534. render(useCameraPostProcess?: boolean): void;
  117535. /**
  117536. * Update the list of dependant textures samplers in the shader.
  117537. */
  117538. updateTextures(): void;
  117539. /**
  117540. * Update the uniform values of the procedural texture in the shader.
  117541. */
  117542. updateShaderUniforms(): void;
  117543. /**
  117544. * Define if the texture animates or not.
  117545. */
  117546. animate: boolean;
  117547. }
  117548. }
  117549. declare module BABYLON {
  117550. /** @hidden */
  117551. export var noisePixelShader: {
  117552. name: string;
  117553. shader: string;
  117554. };
  117555. }
  117556. declare module BABYLON {
  117557. /**
  117558. * Class used to generate noise procedural textures
  117559. */
  117560. export class NoiseProceduralTexture extends ProceduralTexture {
  117561. private _time;
  117562. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  117563. brightness: number;
  117564. /** Defines the number of octaves to process */
  117565. octaves: number;
  117566. /** Defines the level of persistence (0.8 by default) */
  117567. persistence: number;
  117568. /** Gets or sets animation speed factor (default is 1) */
  117569. animationSpeedFactor: number;
  117570. /**
  117571. * Creates a new NoiseProceduralTexture
  117572. * @param name defines the name fo the texture
  117573. * @param size defines the size of the texture (default is 256)
  117574. * @param scene defines the hosting scene
  117575. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  117576. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  117577. */
  117578. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  117579. private _updateShaderUniforms;
  117580. protected _getDefines(): string;
  117581. /** Generate the current state of the procedural texture */
  117582. render(useCameraPostProcess?: boolean): void;
  117583. /**
  117584. * Serializes this noise procedural texture
  117585. * @returns a serialized noise procedural texture object
  117586. */
  117587. serialize(): any;
  117588. /**
  117589. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  117590. * @param parsedTexture defines parsed texture data
  117591. * @param scene defines the current scene
  117592. * @param rootUrl defines the root URL containing noise procedural texture information
  117593. * @returns a parsed NoiseProceduralTexture
  117594. */
  117595. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  117596. }
  117597. }
  117598. declare module BABYLON {
  117599. /**
  117600. * Raw cube texture where the raw buffers are passed in
  117601. */
  117602. export class RawCubeTexture extends CubeTexture {
  117603. /**
  117604. * Creates a cube texture where the raw buffers are passed in.
  117605. * @param scene defines the scene the texture is attached to
  117606. * @param data defines the array of data to use to create each face
  117607. * @param size defines the size of the textures
  117608. * @param format defines the format of the data
  117609. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  117610. * @param generateMipMaps defines if the engine should generate the mip levels
  117611. * @param invertY defines if data must be stored with Y axis inverted
  117612. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  117613. * @param compression defines the compression used (null by default)
  117614. */
  117615. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  117616. /**
  117617. * Updates the raw cube texture.
  117618. * @param data defines the data to store
  117619. * @param format defines the data format
  117620. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  117621. * @param invertY defines if data must be stored with Y axis inverted
  117622. * @param compression defines the compression used (null by default)
  117623. * @param level defines which level of the texture to update
  117624. */
  117625. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  117626. /**
  117627. * Updates a raw cube texture with RGBD encoded data.
  117628. * @param data defines the array of data [mipmap][face] to use to create each face
  117629. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  117630. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  117631. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  117632. * @returns a promsie that resolves when the operation is complete
  117633. */
  117634. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  117635. /**
  117636. * Clones the raw cube texture.
  117637. * @return a new cube texture
  117638. */
  117639. clone(): CubeTexture;
  117640. /** @hidden */
  117641. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  117642. }
  117643. }
  117644. declare module BABYLON {
  117645. /**
  117646. * Class used to store 3D textures containing user data
  117647. */
  117648. export class RawTexture3D extends Texture {
  117649. /** Gets or sets the texture format to use */
  117650. format: number;
  117651. private _engine;
  117652. /**
  117653. * Create a new RawTexture3D
  117654. * @param data defines the data of the texture
  117655. * @param width defines the width of the texture
  117656. * @param height defines the height of the texture
  117657. * @param depth defines the depth of the texture
  117658. * @param format defines the texture format to use
  117659. * @param scene defines the hosting scene
  117660. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  117661. * @param invertY defines if texture must be stored with Y axis inverted
  117662. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  117663. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  117664. */
  117665. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  117666. /** Gets or sets the texture format to use */
  117667. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  117668. /**
  117669. * Update the texture with new data
  117670. * @param data defines the data to store in the texture
  117671. */
  117672. update(data: ArrayBufferView): void;
  117673. }
  117674. }
  117675. declare module BABYLON {
  117676. /**
  117677. * Creates a refraction texture used by refraction channel of the standard material.
  117678. * It is like a mirror but to see through a material.
  117679. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  117680. */
  117681. export class RefractionTexture extends RenderTargetTexture {
  117682. /**
  117683. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  117684. * 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.
  117685. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  117686. */
  117687. refractionPlane: Plane;
  117688. /**
  117689. * Define how deep under the surface we should see.
  117690. */
  117691. depth: number;
  117692. /**
  117693. * Creates a refraction texture used by refraction channel of the standard material.
  117694. * It is like a mirror but to see through a material.
  117695. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  117696. * @param name Define the texture name
  117697. * @param size Define the size of the underlying texture
  117698. * @param scene Define the scene the refraction belongs to
  117699. * @param generateMipMaps Define if we need to generate mips level for the refraction
  117700. */
  117701. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  117702. /**
  117703. * Clone the refraction texture.
  117704. * @returns the cloned texture
  117705. */
  117706. clone(): RefractionTexture;
  117707. /**
  117708. * Serialize the texture to a JSON representation you could use in Parse later on
  117709. * @returns the serialized JSON representation
  117710. */
  117711. serialize(): any;
  117712. }
  117713. }
  117714. declare module BABYLON {
  117715. /**
  117716. * Defines the options related to the creation of an HtmlElementTexture
  117717. */
  117718. export interface IHtmlElementTextureOptions {
  117719. /**
  117720. * Defines wether mip maps should be created or not.
  117721. */
  117722. generateMipMaps?: boolean;
  117723. /**
  117724. * Defines the sampling mode of the texture.
  117725. */
  117726. samplingMode?: number;
  117727. /**
  117728. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  117729. */
  117730. engine: Nullable<Engine>;
  117731. /**
  117732. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  117733. */
  117734. scene: Nullable<Scene>;
  117735. }
  117736. /**
  117737. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  117738. * To be as efficient as possible depending on your constraints nothing aside the first upload
  117739. * is automatically managed.
  117740. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  117741. * in your application.
  117742. *
  117743. * As the update is not automatic, you need to call them manually.
  117744. */
  117745. export class HtmlElementTexture extends BaseTexture {
  117746. /**
  117747. * The texture URL.
  117748. */
  117749. element: HTMLVideoElement | HTMLCanvasElement;
  117750. private static readonly DefaultOptions;
  117751. private _textureMatrix;
  117752. private _engine;
  117753. private _isVideo;
  117754. private _generateMipMaps;
  117755. private _samplingMode;
  117756. /**
  117757. * Instantiates a HtmlElementTexture from the following parameters.
  117758. *
  117759. * @param name Defines the name of the texture
  117760. * @param element Defines the video or canvas the texture is filled with
  117761. * @param options Defines the other none mandatory texture creation options
  117762. */
  117763. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  117764. private _createInternalTexture;
  117765. /**
  117766. * Returns the texture matrix used in most of the material.
  117767. */
  117768. getTextureMatrix(): Matrix;
  117769. /**
  117770. * Updates the content of the texture.
  117771. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  117772. */
  117773. update(invertY?: Nullable<boolean>): void;
  117774. }
  117775. }
  117776. declare module BABYLON {
  117777. /**
  117778. * Enum used to define the target of a block
  117779. */
  117780. export enum NodeMaterialBlockTargets {
  117781. /** Vertex shader */
  117782. Vertex = 1,
  117783. /** Fragment shader */
  117784. Fragment = 2,
  117785. /** Neutral */
  117786. Neutral = 4,
  117787. /** Vertex and Fragment */
  117788. VertexAndFragment = 3
  117789. }
  117790. }
  117791. declare module BABYLON {
  117792. /**
  117793. * Defines the kind of connection point for node based material
  117794. */
  117795. export enum NodeMaterialBlockConnectionPointTypes {
  117796. /** Float */
  117797. Float = 1,
  117798. /** Int */
  117799. Int = 2,
  117800. /** Vector2 */
  117801. Vector2 = 4,
  117802. /** Vector3 */
  117803. Vector3 = 8,
  117804. /** Vector4 */
  117805. Vector4 = 16,
  117806. /** Color3 */
  117807. Color3 = 32,
  117808. /** Color4 */
  117809. Color4 = 64,
  117810. /** Matrix */
  117811. Matrix = 128,
  117812. /** Detect type based on connection */
  117813. AutoDetect = 1024,
  117814. /** Output type that will be defined by input type */
  117815. BasedOnInput = 2048
  117816. }
  117817. }
  117818. declare module BABYLON {
  117819. /**
  117820. * Root class for all node material optimizers
  117821. */
  117822. export class NodeMaterialOptimizer {
  117823. /**
  117824. * Function used to optimize a NodeMaterial graph
  117825. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  117826. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  117827. */
  117828. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  117829. }
  117830. }
  117831. declare module BABYLON {
  117832. /**
  117833. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  117834. */
  117835. export class TransformBlock extends NodeMaterialBlock {
  117836. /**
  117837. * Defines the value to use to complement W value to transform it to a Vector4
  117838. */
  117839. complementW: number;
  117840. /**
  117841. * Defines the value to use to complement z value to transform it to a Vector4
  117842. */
  117843. complementZ: number;
  117844. /**
  117845. * Creates a new TransformBlock
  117846. * @param name defines the block name
  117847. */
  117848. constructor(name: string);
  117849. /**
  117850. * Gets the current class name
  117851. * @returns the class name
  117852. */
  117853. getClassName(): string;
  117854. /**
  117855. * Gets the vector input
  117856. */
  117857. readonly vector: NodeMaterialConnectionPoint;
  117858. /**
  117859. * Gets the output component
  117860. */
  117861. readonly output: NodeMaterialConnectionPoint;
  117862. /**
  117863. * Gets the matrix transform input
  117864. */
  117865. readonly transform: NodeMaterialConnectionPoint;
  117866. protected _buildBlock(state: NodeMaterialBuildState): this;
  117867. serialize(): any;
  117868. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  117869. protected _dumpPropertiesCode(): string;
  117870. }
  117871. }
  117872. declare module BABYLON {
  117873. /**
  117874. * Block used to output the vertex position
  117875. */
  117876. export class VertexOutputBlock extends NodeMaterialBlock {
  117877. /**
  117878. * Creates a new VertexOutputBlock
  117879. * @param name defines the block name
  117880. */
  117881. constructor(name: string);
  117882. /**
  117883. * Gets the current class name
  117884. * @returns the class name
  117885. */
  117886. getClassName(): string;
  117887. /**
  117888. * Gets the vector input component
  117889. */
  117890. readonly vector: NodeMaterialConnectionPoint;
  117891. protected _buildBlock(state: NodeMaterialBuildState): this;
  117892. }
  117893. }
  117894. declare module BABYLON {
  117895. /**
  117896. * Block used to output the final color
  117897. */
  117898. export class FragmentOutputBlock extends NodeMaterialBlock {
  117899. /**
  117900. * Create a new FragmentOutputBlock
  117901. * @param name defines the block name
  117902. */
  117903. constructor(name: string);
  117904. /**
  117905. * Gets the current class name
  117906. * @returns the class name
  117907. */
  117908. getClassName(): string;
  117909. /**
  117910. * Gets the rgba input component
  117911. */
  117912. readonly rgba: NodeMaterialConnectionPoint;
  117913. /**
  117914. * Gets the rgb input component
  117915. */
  117916. readonly rgb: NodeMaterialConnectionPoint;
  117917. /**
  117918. * Gets the a input component
  117919. */
  117920. readonly a: NodeMaterialConnectionPoint;
  117921. protected _buildBlock(state: NodeMaterialBuildState): this;
  117922. }
  117923. }
  117924. declare module BABYLON {
  117925. /**
  117926. * Enum used to define system values e.g. values automatically provided by the system
  117927. */
  117928. export enum NodeMaterialSystemValues {
  117929. /** World */
  117930. World = 1,
  117931. /** View */
  117932. View = 2,
  117933. /** Projection */
  117934. Projection = 3,
  117935. /** ViewProjection */
  117936. ViewProjection = 4,
  117937. /** WorldView */
  117938. WorldView = 5,
  117939. /** WorldViewProjection */
  117940. WorldViewProjection = 6,
  117941. /** CameraPosition */
  117942. CameraPosition = 7,
  117943. /** Fog Color */
  117944. FogColor = 8
  117945. }
  117946. }
  117947. declare module BABYLON {
  117948. /**
  117949. * Block used to read a reflection texture from a sampler
  117950. */
  117951. export class ReflectionTextureBlock extends NodeMaterialBlock {
  117952. private _define3DName;
  117953. private _defineCubicName;
  117954. private _defineExplicitName;
  117955. private _defineProjectionName;
  117956. private _defineLocalCubicName;
  117957. private _defineSphericalName;
  117958. private _definePlanarName;
  117959. private _defineEquirectangularName;
  117960. private _defineMirroredEquirectangularFixedName;
  117961. private _defineEquirectangularFixedName;
  117962. private _defineSkyboxName;
  117963. private _cubeSamplerName;
  117964. private _2DSamplerName;
  117965. private _positionUVWName;
  117966. private _directionWName;
  117967. private _reflectionCoordsName;
  117968. private _reflection2DCoordsName;
  117969. private _reflectionColorName;
  117970. private _reflectionMatrixName;
  117971. /**
  117972. * Gets or sets the texture associated with the node
  117973. */
  117974. texture: Nullable<BaseTexture>;
  117975. /**
  117976. * Create a new TextureBlock
  117977. * @param name defines the block name
  117978. */
  117979. constructor(name: string);
  117980. /**
  117981. * Gets the current class name
  117982. * @returns the class name
  117983. */
  117984. getClassName(): string;
  117985. /**
  117986. * Gets the world position input component
  117987. */
  117988. readonly position: NodeMaterialConnectionPoint;
  117989. /**
  117990. * Gets the world position input component
  117991. */
  117992. readonly worldPosition: NodeMaterialConnectionPoint;
  117993. /**
  117994. * Gets the world normal input component
  117995. */
  117996. readonly worldNormal: NodeMaterialConnectionPoint;
  117997. /**
  117998. * Gets the world input component
  117999. */
  118000. readonly world: NodeMaterialConnectionPoint;
  118001. /**
  118002. * Gets the camera (or eye) position component
  118003. */
  118004. readonly cameraPosition: NodeMaterialConnectionPoint;
  118005. /**
  118006. * Gets the view input component
  118007. */
  118008. readonly view: NodeMaterialConnectionPoint;
  118009. /**
  118010. * Gets the rgb output component
  118011. */
  118012. readonly rgb: NodeMaterialConnectionPoint;
  118013. /**
  118014. * Gets the r output component
  118015. */
  118016. readonly r: NodeMaterialConnectionPoint;
  118017. /**
  118018. * Gets the g output component
  118019. */
  118020. readonly g: NodeMaterialConnectionPoint;
  118021. /**
  118022. * Gets the b output component
  118023. */
  118024. readonly b: NodeMaterialConnectionPoint;
  118025. autoConfigure(material: NodeMaterial): void;
  118026. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  118027. isReady(): boolean;
  118028. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  118029. private _injectVertexCode;
  118030. private _writeOutput;
  118031. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  118032. serialize(): any;
  118033. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  118034. }
  118035. }
  118036. declare module BABYLON {
  118037. /**
  118038. * Interface used to configure the node material editor
  118039. */
  118040. export interface INodeMaterialEditorOptions {
  118041. /** Define the URl to load node editor script */
  118042. editorURL?: string;
  118043. }
  118044. /** @hidden */
  118045. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  118046. /** BONES */
  118047. NUM_BONE_INFLUENCERS: number;
  118048. BonesPerMesh: number;
  118049. BONETEXTURE: boolean;
  118050. /** MORPH TARGETS */
  118051. MORPHTARGETS: boolean;
  118052. MORPHTARGETS_NORMAL: boolean;
  118053. MORPHTARGETS_TANGENT: boolean;
  118054. MORPHTARGETS_UV: boolean;
  118055. NUM_MORPH_INFLUENCERS: number;
  118056. /** IMAGE PROCESSING */
  118057. IMAGEPROCESSING: boolean;
  118058. VIGNETTE: boolean;
  118059. VIGNETTEBLENDMODEMULTIPLY: boolean;
  118060. VIGNETTEBLENDMODEOPAQUE: boolean;
  118061. TONEMAPPING: boolean;
  118062. TONEMAPPING_ACES: boolean;
  118063. CONTRAST: boolean;
  118064. EXPOSURE: boolean;
  118065. COLORCURVES: boolean;
  118066. COLORGRADING: boolean;
  118067. COLORGRADING3D: boolean;
  118068. SAMPLER3DGREENDEPTH: boolean;
  118069. SAMPLER3DBGRMAP: boolean;
  118070. IMAGEPROCESSINGPOSTPROCESS: boolean;
  118071. /** MISC. */
  118072. BUMPDIRECTUV: number;
  118073. constructor();
  118074. setValue(name: string, value: boolean): void;
  118075. }
  118076. /**
  118077. * Class used to configure NodeMaterial
  118078. */
  118079. export interface INodeMaterialOptions {
  118080. /**
  118081. * Defines if blocks should emit comments
  118082. */
  118083. emitComments: boolean;
  118084. }
  118085. /**
  118086. * Class used to create a node based material built by assembling shader blocks
  118087. */
  118088. export class NodeMaterial extends PushMaterial {
  118089. private static _BuildIdGenerator;
  118090. private _options;
  118091. private _vertexCompilationState;
  118092. private _fragmentCompilationState;
  118093. private _sharedData;
  118094. private _buildId;
  118095. private _buildWasSuccessful;
  118096. private _cachedWorldViewMatrix;
  118097. private _cachedWorldViewProjectionMatrix;
  118098. private _optimizers;
  118099. private _animationFrame;
  118100. /** Define the URl to load node editor script */
  118101. static EditorURL: string;
  118102. private BJSNODEMATERIALEDITOR;
  118103. /** Get the inspector from bundle or global */
  118104. private _getGlobalNodeMaterialEditor;
  118105. /**
  118106. * 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)
  118107. */
  118108. ignoreAlpha: boolean;
  118109. /**
  118110. * Defines the maximum number of lights that can be used in the material
  118111. */
  118112. maxSimultaneousLights: number;
  118113. /**
  118114. * Observable raised when the material is built
  118115. */
  118116. onBuildObservable: Observable<NodeMaterial>;
  118117. /**
  118118. * Gets or sets the root nodes of the material vertex shader
  118119. */
  118120. _vertexOutputNodes: NodeMaterialBlock[];
  118121. /**
  118122. * Gets or sets the root nodes of the material fragment (pixel) shader
  118123. */
  118124. _fragmentOutputNodes: NodeMaterialBlock[];
  118125. /** Gets or sets options to control the node material overall behavior */
  118126. options: INodeMaterialOptions;
  118127. /**
  118128. * Default configuration related to image processing available in the standard Material.
  118129. */
  118130. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  118131. /**
  118132. * Gets the image processing configuration used either in this material.
  118133. */
  118134. /**
  118135. * Sets the Default image processing configuration used either in the this material.
  118136. *
  118137. * If sets to null, the scene one is in use.
  118138. */
  118139. imageProcessingConfiguration: ImageProcessingConfiguration;
  118140. /**
  118141. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  118142. */
  118143. attachedBlocks: NodeMaterialBlock[];
  118144. /**
  118145. * Create a new node based material
  118146. * @param name defines the material name
  118147. * @param scene defines the hosting scene
  118148. * @param options defines creation option
  118149. */
  118150. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  118151. /**
  118152. * Gets the current class name of the material e.g. "NodeMaterial"
  118153. * @returns the class name
  118154. */
  118155. getClassName(): string;
  118156. /**
  118157. * Keep track of the image processing observer to allow dispose and replace.
  118158. */
  118159. private _imageProcessingObserver;
  118160. /**
  118161. * Attaches a new image processing configuration to the Standard Material.
  118162. * @param configuration
  118163. */
  118164. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  118165. /**
  118166. * Get a block by its name
  118167. * @param name defines the name of the block to retrieve
  118168. * @returns the required block or null if not found
  118169. */
  118170. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  118171. /**
  118172. * Get a block by its name
  118173. * @param predicate defines the predicate used to find the good candidate
  118174. * @returns the required block or null if not found
  118175. */
  118176. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  118177. /**
  118178. * Get an input block by its name
  118179. * @param predicate defines the predicate used to find the good candidate
  118180. * @returns the required input block or null if not found
  118181. */
  118182. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  118183. /**
  118184. * Gets the list of input blocks attached to this material
  118185. * @returns an array of InputBlocks
  118186. */
  118187. getInputBlocks(): InputBlock[];
  118188. /**
  118189. * Adds a new optimizer to the list of optimizers
  118190. * @param optimizer defines the optimizers to add
  118191. * @returns the current material
  118192. */
  118193. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  118194. /**
  118195. * Remove an optimizer from the list of optimizers
  118196. * @param optimizer defines the optimizers to remove
  118197. * @returns the current material
  118198. */
  118199. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  118200. /**
  118201. * Add a new block to the list of output nodes
  118202. * @param node defines the node to add
  118203. * @returns the current material
  118204. */
  118205. addOutputNode(node: NodeMaterialBlock): this;
  118206. /**
  118207. * Remove a block from the list of root nodes
  118208. * @param node defines the node to remove
  118209. * @returns the current material
  118210. */
  118211. removeOutputNode(node: NodeMaterialBlock): this;
  118212. private _addVertexOutputNode;
  118213. private _removeVertexOutputNode;
  118214. private _addFragmentOutputNode;
  118215. private _removeFragmentOutputNode;
  118216. /**
  118217. * Specifies if the material will require alpha blending
  118218. * @returns a boolean specifying if alpha blending is needed
  118219. */
  118220. needAlphaBlending(): boolean;
  118221. /**
  118222. * Specifies if this material should be rendered in alpha test mode
  118223. * @returns a boolean specifying if an alpha test is needed.
  118224. */
  118225. needAlphaTesting(): boolean;
  118226. private _initializeBlock;
  118227. private _resetDualBlocks;
  118228. /**
  118229. * Build the material and generates the inner effect
  118230. * @param verbose defines if the build should log activity
  118231. */
  118232. build(verbose?: boolean): void;
  118233. /**
  118234. * Runs an otpimization phase to try to improve the shader code
  118235. */
  118236. optimize(): void;
  118237. private _prepareDefinesForAttributes;
  118238. /**
  118239. * Get if the submesh is ready to be used and all its information available.
  118240. * Child classes can use it to update shaders
  118241. * @param mesh defines the mesh to check
  118242. * @param subMesh defines which submesh to check
  118243. * @param useInstances specifies that instances should be used
  118244. * @returns a boolean indicating that the submesh is ready or not
  118245. */
  118246. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  118247. /**
  118248. * Get a string representing the shaders built by the current node graph
  118249. */
  118250. readonly compiledShaders: string;
  118251. /**
  118252. * Binds the world matrix to the material
  118253. * @param world defines the world transformation matrix
  118254. */
  118255. bindOnlyWorldMatrix(world: Matrix): void;
  118256. /**
  118257. * Binds the submesh to this material by preparing the effect and shader to draw
  118258. * @param world defines the world transformation matrix
  118259. * @param mesh defines the mesh containing the submesh
  118260. * @param subMesh defines the submesh to bind the material to
  118261. */
  118262. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  118263. /**
  118264. * Gets the active textures from the material
  118265. * @returns an array of textures
  118266. */
  118267. getActiveTextures(): BaseTexture[];
  118268. /**
  118269. * Gets the list of texture blocks
  118270. * @returns an array of texture blocks
  118271. */
  118272. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  118273. /**
  118274. * Specifies if the material uses a texture
  118275. * @param texture defines the texture to check against the material
  118276. * @returns a boolean specifying if the material uses the texture
  118277. */
  118278. hasTexture(texture: BaseTexture): boolean;
  118279. /**
  118280. * Disposes the material
  118281. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  118282. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  118283. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  118284. */
  118285. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  118286. /** Creates the node editor window. */
  118287. private _createNodeEditor;
  118288. /**
  118289. * Launch the node material editor
  118290. * @param config Define the configuration of the editor
  118291. * @return a promise fulfilled when the node editor is visible
  118292. */
  118293. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  118294. /**
  118295. * Clear the current material
  118296. */
  118297. clear(): void;
  118298. /**
  118299. * Clear the current material and set it to a default state
  118300. */
  118301. setToDefault(): void;
  118302. /**
  118303. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  118304. * @param url defines the url to load from
  118305. * @returns a promise that will fullfil when the material is fully loaded
  118306. */
  118307. loadAsync(url: string): Promise<unknown>;
  118308. private _gatherBlocks;
  118309. /**
  118310. * Generate a string containing the code declaration required to create an equivalent of this material
  118311. * @returns a string
  118312. */
  118313. generateCode(): string;
  118314. /**
  118315. * Serializes this material in a JSON representation
  118316. * @returns the serialized material object
  118317. */
  118318. serialize(): any;
  118319. private _restoreConnections;
  118320. /**
  118321. * Clear the current graph and load a new one from a serialization object
  118322. * @param source defines the JSON representation of the material
  118323. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  118324. */
  118325. loadFromSerialization(source: any, rootUrl?: string): void;
  118326. /**
  118327. * Creates a node material from parsed material data
  118328. * @param source defines the JSON representation of the material
  118329. * @param scene defines the hosting scene
  118330. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  118331. * @returns a new node material
  118332. */
  118333. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  118334. /**
  118335. * Creates a new node material set to default basic configuration
  118336. * @param name defines the name of the material
  118337. * @param scene defines the hosting scene
  118338. * @returns a new NodeMaterial
  118339. */
  118340. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  118341. }
  118342. }
  118343. declare module BABYLON {
  118344. /**
  118345. * Block used to read a texture from a sampler
  118346. */
  118347. export class TextureBlock extends NodeMaterialBlock {
  118348. private _defineName;
  118349. private _samplerName;
  118350. private _transformedUVName;
  118351. private _textureTransformName;
  118352. private _textureInfoName;
  118353. private _mainUVName;
  118354. private _mainUVDefineName;
  118355. /**
  118356. * Gets or sets the texture associated with the node
  118357. */
  118358. texture: Nullable<Texture>;
  118359. /**
  118360. * Create a new TextureBlock
  118361. * @param name defines the block name
  118362. */
  118363. constructor(name: string);
  118364. /**
  118365. * Gets the current class name
  118366. * @returns the class name
  118367. */
  118368. getClassName(): string;
  118369. /**
  118370. * Gets the uv input component
  118371. */
  118372. readonly uv: NodeMaterialConnectionPoint;
  118373. /**
  118374. * Gets the rgba output component
  118375. */
  118376. readonly rgba: NodeMaterialConnectionPoint;
  118377. /**
  118378. * Gets the rgb output component
  118379. */
  118380. readonly rgb: NodeMaterialConnectionPoint;
  118381. /**
  118382. * Gets the r output component
  118383. */
  118384. readonly r: NodeMaterialConnectionPoint;
  118385. /**
  118386. * Gets the g output component
  118387. */
  118388. readonly g: NodeMaterialConnectionPoint;
  118389. /**
  118390. * Gets the b output component
  118391. */
  118392. readonly b: NodeMaterialConnectionPoint;
  118393. /**
  118394. * Gets the a output component
  118395. */
  118396. readonly a: NodeMaterialConnectionPoint;
  118397. readonly target: NodeMaterialBlockTargets;
  118398. autoConfigure(material: NodeMaterial): void;
  118399. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  118400. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  118401. isReady(): boolean;
  118402. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  118403. private readonly _isMixed;
  118404. private _injectVertexCode;
  118405. private _writeOutput;
  118406. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  118407. protected _dumpPropertiesCode(): string;
  118408. serialize(): any;
  118409. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  118410. }
  118411. }
  118412. declare module BABYLON {
  118413. /**
  118414. * Class used to store shared data between 2 NodeMaterialBuildState
  118415. */
  118416. export class NodeMaterialBuildStateSharedData {
  118417. /**
  118418. * Gets the list of emitted varyings
  118419. */
  118420. temps: string[];
  118421. /**
  118422. * Gets the list of emitted varyings
  118423. */
  118424. varyings: string[];
  118425. /**
  118426. * Gets the varying declaration string
  118427. */
  118428. varyingDeclaration: string;
  118429. /**
  118430. * Input blocks
  118431. */
  118432. inputBlocks: InputBlock[];
  118433. /**
  118434. * Input blocks
  118435. */
  118436. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  118437. /**
  118438. * Bindable blocks (Blocks that need to set data to the effect)
  118439. */
  118440. bindableBlocks: NodeMaterialBlock[];
  118441. /**
  118442. * List of blocks that can provide a compilation fallback
  118443. */
  118444. blocksWithFallbacks: NodeMaterialBlock[];
  118445. /**
  118446. * List of blocks that can provide a define update
  118447. */
  118448. blocksWithDefines: NodeMaterialBlock[];
  118449. /**
  118450. * List of blocks that can provide a repeatable content
  118451. */
  118452. repeatableContentBlocks: NodeMaterialBlock[];
  118453. /**
  118454. * List of blocks that can provide a dynamic list of uniforms
  118455. */
  118456. dynamicUniformBlocks: NodeMaterialBlock[];
  118457. /**
  118458. * List of blocks that can block the isReady function for the material
  118459. */
  118460. blockingBlocks: NodeMaterialBlock[];
  118461. /**
  118462. * Gets the list of animated inputs
  118463. */
  118464. animatedInputs: InputBlock[];
  118465. /**
  118466. * Build Id used to avoid multiple recompilations
  118467. */
  118468. buildId: number;
  118469. /** List of emitted variables */
  118470. variableNames: {
  118471. [key: string]: number;
  118472. };
  118473. /** List of emitted defines */
  118474. defineNames: {
  118475. [key: string]: number;
  118476. };
  118477. /** Should emit comments? */
  118478. emitComments: boolean;
  118479. /** Emit build activity */
  118480. verbose: boolean;
  118481. /** Gets or sets the hosting scene */
  118482. scene: Scene;
  118483. /**
  118484. * Gets the compilation hints emitted at compilation time
  118485. */
  118486. hints: {
  118487. needWorldViewMatrix: boolean;
  118488. needWorldViewProjectionMatrix: boolean;
  118489. needAlphaBlending: boolean;
  118490. needAlphaTesting: boolean;
  118491. };
  118492. /**
  118493. * List of compilation checks
  118494. */
  118495. checks: {
  118496. emitVertex: boolean;
  118497. emitFragment: boolean;
  118498. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  118499. };
  118500. /** Creates a new shared data */
  118501. constructor();
  118502. /**
  118503. * Emits console errors and exceptions if there is a failing check
  118504. */
  118505. emitErrors(): void;
  118506. }
  118507. }
  118508. declare module BABYLON {
  118509. /**
  118510. * Class used to store node based material build state
  118511. */
  118512. export class NodeMaterialBuildState {
  118513. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  118514. supportUniformBuffers: boolean;
  118515. /**
  118516. * Gets the list of emitted attributes
  118517. */
  118518. attributes: string[];
  118519. /**
  118520. * Gets the list of emitted uniforms
  118521. */
  118522. uniforms: string[];
  118523. /**
  118524. * Gets the list of emitted uniform buffers
  118525. */
  118526. uniformBuffers: string[];
  118527. /**
  118528. * Gets the list of emitted samplers
  118529. */
  118530. samplers: string[];
  118531. /**
  118532. * Gets the list of emitted functions
  118533. */
  118534. functions: {
  118535. [key: string]: string;
  118536. };
  118537. /**
  118538. * Gets the list of emitted extensions
  118539. */
  118540. extensions: {
  118541. [key: string]: string;
  118542. };
  118543. /**
  118544. * Gets the target of the compilation state
  118545. */
  118546. target: NodeMaterialBlockTargets;
  118547. /**
  118548. * Gets the list of emitted counters
  118549. */
  118550. counters: {
  118551. [key: string]: number;
  118552. };
  118553. /**
  118554. * Shared data between multiple NodeMaterialBuildState instances
  118555. */
  118556. sharedData: NodeMaterialBuildStateSharedData;
  118557. /** @hidden */
  118558. _vertexState: NodeMaterialBuildState;
  118559. /** @hidden */
  118560. _attributeDeclaration: string;
  118561. /** @hidden */
  118562. _uniformDeclaration: string;
  118563. /** @hidden */
  118564. _samplerDeclaration: string;
  118565. /** @hidden */
  118566. _varyingTransfer: string;
  118567. private _repeatableContentAnchorIndex;
  118568. /** @hidden */
  118569. _builtCompilationString: string;
  118570. /**
  118571. * Gets the emitted compilation strings
  118572. */
  118573. compilationString: string;
  118574. /**
  118575. * Finalize the compilation strings
  118576. * @param state defines the current compilation state
  118577. */
  118578. finalize(state: NodeMaterialBuildState): void;
  118579. /** @hidden */
  118580. readonly _repeatableContentAnchor: string;
  118581. /** @hidden */
  118582. _getFreeVariableName(prefix: string): string;
  118583. /** @hidden */
  118584. _getFreeDefineName(prefix: string): string;
  118585. /** @hidden */
  118586. _excludeVariableName(name: string): void;
  118587. /** @hidden */
  118588. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  118589. /** @hidden */
  118590. _emitExtension(name: string, extension: string): void;
  118591. /** @hidden */
  118592. _emitFunction(name: string, code: string, comments: string): void;
  118593. /** @hidden */
  118594. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  118595. replaceStrings?: {
  118596. search: RegExp;
  118597. replace: string;
  118598. }[];
  118599. repeatKey?: string;
  118600. }): string;
  118601. /** @hidden */
  118602. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  118603. repeatKey?: string;
  118604. removeAttributes?: boolean;
  118605. removeUniforms?: boolean;
  118606. removeVaryings?: boolean;
  118607. removeIfDef?: boolean;
  118608. replaceStrings?: {
  118609. search: RegExp;
  118610. replace: string;
  118611. }[];
  118612. }, storeKey?: string): void;
  118613. /** @hidden */
  118614. _registerTempVariable(name: string): boolean;
  118615. /** @hidden */
  118616. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  118617. /** @hidden */
  118618. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  118619. }
  118620. }
  118621. declare module BABYLON {
  118622. /**
  118623. * Defines a block that can be used inside a node based material
  118624. */
  118625. export class NodeMaterialBlock {
  118626. private _buildId;
  118627. private _buildTarget;
  118628. private _target;
  118629. private _isFinalMerger;
  118630. private _isInput;
  118631. /** @hidden */
  118632. _codeVariableName: string;
  118633. /** @hidden */
  118634. _inputs: NodeMaterialConnectionPoint[];
  118635. /** @hidden */
  118636. _outputs: NodeMaterialConnectionPoint[];
  118637. /** @hidden */
  118638. _preparationId: number;
  118639. /**
  118640. * Gets or sets the name of the block
  118641. */
  118642. name: string;
  118643. /**
  118644. * Gets or sets the unique id of the node
  118645. */
  118646. uniqueId: number;
  118647. /**
  118648. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  118649. */
  118650. readonly isFinalMerger: boolean;
  118651. /**
  118652. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  118653. */
  118654. readonly isInput: boolean;
  118655. /**
  118656. * Gets or sets the build Id
  118657. */
  118658. buildId: number;
  118659. /**
  118660. * Gets or sets the target of the block
  118661. */
  118662. target: NodeMaterialBlockTargets;
  118663. /**
  118664. * Gets the list of input points
  118665. */
  118666. readonly inputs: NodeMaterialConnectionPoint[];
  118667. /** Gets the list of output points */
  118668. readonly outputs: NodeMaterialConnectionPoint[];
  118669. /**
  118670. * Find an input by its name
  118671. * @param name defines the name of the input to look for
  118672. * @returns the input or null if not found
  118673. */
  118674. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  118675. /**
  118676. * Find an output by its name
  118677. * @param name defines the name of the outputto look for
  118678. * @returns the output or null if not found
  118679. */
  118680. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  118681. /**
  118682. * Creates a new NodeMaterialBlock
  118683. * @param name defines the block name
  118684. * @param target defines the target of that block (Vertex by default)
  118685. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  118686. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  118687. */
  118688. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  118689. /**
  118690. * Initialize the block and prepare the context for build
  118691. * @param state defines the state that will be used for the build
  118692. */
  118693. initialize(state: NodeMaterialBuildState): void;
  118694. /**
  118695. * Bind data to effect. Will only be called for blocks with isBindable === true
  118696. * @param effect defines the effect to bind data to
  118697. * @param nodeMaterial defines the hosting NodeMaterial
  118698. * @param mesh defines the mesh that will be rendered
  118699. */
  118700. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  118701. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  118702. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  118703. protected _writeFloat(value: number): string;
  118704. /**
  118705. * Gets the current class name e.g. "NodeMaterialBlock"
  118706. * @returns the class name
  118707. */
  118708. getClassName(): string;
  118709. /**
  118710. * Register a new input. Must be called inside a block constructor
  118711. * @param name defines the connection point name
  118712. * @param type defines the connection point type
  118713. * @param isOptional defines a boolean indicating that this input can be omitted
  118714. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  118715. * @returns the current block
  118716. */
  118717. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  118718. /**
  118719. * Register a new output. Must be called inside a block constructor
  118720. * @param name defines the connection point name
  118721. * @param type defines the connection point type
  118722. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  118723. * @returns the current block
  118724. */
  118725. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  118726. /**
  118727. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  118728. * @param forOutput defines an optional connection point to check compatibility with
  118729. * @returns the first available input or null
  118730. */
  118731. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  118732. /**
  118733. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  118734. * @param forBlock defines an optional block to check compatibility with
  118735. * @returns the first available input or null
  118736. */
  118737. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  118738. /**
  118739. * Gets the sibling of the given output
  118740. * @param current defines the current output
  118741. * @returns the next output in the list or null
  118742. */
  118743. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  118744. /**
  118745. * Connect current block with another block
  118746. * @param other defines the block to connect with
  118747. * @param options define the various options to help pick the right connections
  118748. * @returns the current block
  118749. */
  118750. connectTo(other: NodeMaterialBlock, options?: {
  118751. input?: string;
  118752. output?: string;
  118753. outputSwizzle?: string;
  118754. }): this | undefined;
  118755. protected _buildBlock(state: NodeMaterialBuildState): void;
  118756. /**
  118757. * Add uniforms, samplers and uniform buffers at compilation time
  118758. * @param state defines the state to update
  118759. * @param nodeMaterial defines the node material requesting the update
  118760. * @param defines defines the material defines to update
  118761. */
  118762. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  118763. /**
  118764. * Add potential fallbacks if shader compilation fails
  118765. * @param mesh defines the mesh to be rendered
  118766. * @param fallbacks defines the current prioritized list of fallbacks
  118767. */
  118768. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  118769. /**
  118770. * Initialize defines for shader compilation
  118771. * @param mesh defines the mesh to be rendered
  118772. * @param nodeMaterial defines the node material requesting the update
  118773. * @param defines defines the material defines to update
  118774. * @param useInstances specifies that instances should be used
  118775. */
  118776. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  118777. /**
  118778. * Update defines for shader compilation
  118779. * @param mesh defines the mesh to be rendered
  118780. * @param nodeMaterial defines the node material requesting the update
  118781. * @param defines defines the material defines to update
  118782. * @param useInstances specifies that instances should be used
  118783. */
  118784. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  118785. /**
  118786. * Lets the block try to connect some inputs automatically
  118787. * @param material defines the hosting NodeMaterial
  118788. */
  118789. autoConfigure(material: NodeMaterial): void;
  118790. /**
  118791. * Function called when a block is declared as repeatable content generator
  118792. * @param vertexShaderState defines the current compilation state for the vertex shader
  118793. * @param fragmentShaderState defines the current compilation state for the fragment shader
  118794. * @param mesh defines the mesh to be rendered
  118795. * @param defines defines the material defines to update
  118796. */
  118797. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  118798. /**
  118799. * Checks if the block is ready
  118800. * @param mesh defines the mesh to be rendered
  118801. * @param nodeMaterial defines the node material requesting the update
  118802. * @param defines defines the material defines to update
  118803. * @param useInstances specifies that instances should be used
  118804. * @returns true if the block is ready
  118805. */
  118806. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  118807. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  118808. private _processBuild;
  118809. /**
  118810. * Compile the current node and generate the shader code
  118811. * @param state defines the current compilation state (uniforms, samplers, current string)
  118812. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  118813. * @returns true if already built
  118814. */
  118815. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  118816. protected _inputRename(name: string): string;
  118817. protected _outputRename(name: string): string;
  118818. protected _dumpPropertiesCode(): string;
  118819. /** @hidden */
  118820. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  118821. /**
  118822. * Clone the current block to a new identical block
  118823. * @param scene defines the hosting scene
  118824. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  118825. * @returns a copy of the current block
  118826. */
  118827. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  118828. /**
  118829. * Serializes this block in a JSON representation
  118830. * @returns the serialized block object
  118831. */
  118832. serialize(): any;
  118833. /** @hidden */
  118834. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  118835. }
  118836. }
  118837. declare module BABYLON {
  118838. /**
  118839. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  118840. */
  118841. export enum NodeMaterialBlockConnectionPointMode {
  118842. /** Value is an uniform */
  118843. Uniform = 0,
  118844. /** Value is a mesh attribute */
  118845. Attribute = 1,
  118846. /** Value is a varying between vertex and fragment shaders */
  118847. Varying = 2,
  118848. /** Mode is undefined */
  118849. Undefined = 3
  118850. }
  118851. }
  118852. declare module BABYLON {
  118853. /**
  118854. * Enum defining the type of animations supported by InputBlock
  118855. */
  118856. export enum AnimatedInputBlockTypes {
  118857. /** No animation */
  118858. None = 0,
  118859. /** Time based animation. Will only work for floats */
  118860. Time = 1
  118861. }
  118862. }
  118863. declare module BABYLON {
  118864. /**
  118865. * Block used to expose an input value
  118866. */
  118867. export class InputBlock extends NodeMaterialBlock {
  118868. private _mode;
  118869. private _associatedVariableName;
  118870. private _storedValue;
  118871. private _valueCallback;
  118872. private _type;
  118873. private _animationType;
  118874. /** Gets or set a value used to limit the range of float values */
  118875. min: number;
  118876. /** Gets or set a value used to limit the range of float values */
  118877. max: number;
  118878. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  118879. matrixMode: number;
  118880. /** @hidden */
  118881. _systemValue: Nullable<NodeMaterialSystemValues>;
  118882. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  118883. visibleInInspector: boolean;
  118884. /**
  118885. * Gets or sets the connection point type (default is float)
  118886. */
  118887. readonly type: NodeMaterialBlockConnectionPointTypes;
  118888. /**
  118889. * Creates a new InputBlock
  118890. * @param name defines the block name
  118891. * @param target defines the target of that block (Vertex by default)
  118892. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  118893. */
  118894. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  118895. /**
  118896. * Gets the output component
  118897. */
  118898. readonly output: NodeMaterialConnectionPoint;
  118899. /**
  118900. * Set the source of this connection point to a vertex attribute
  118901. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  118902. * @returns the current connection point
  118903. */
  118904. setAsAttribute(attributeName?: string): InputBlock;
  118905. /**
  118906. * Set the source of this connection point to a system value
  118907. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  118908. * @returns the current connection point
  118909. */
  118910. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  118911. /**
  118912. * Gets or sets the value of that point.
  118913. * Please note that this value will be ignored if valueCallback is defined
  118914. */
  118915. value: any;
  118916. /**
  118917. * Gets or sets a callback used to get the value of that point.
  118918. * Please note that setting this value will force the connection point to ignore the value property
  118919. */
  118920. valueCallback: () => any;
  118921. /**
  118922. * Gets or sets the associated variable name in the shader
  118923. */
  118924. associatedVariableName: string;
  118925. /** Gets or sets the type of animation applied to the input */
  118926. animationType: AnimatedInputBlockTypes;
  118927. /**
  118928. * Gets a boolean indicating that this connection point not defined yet
  118929. */
  118930. readonly isUndefined: boolean;
  118931. /**
  118932. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  118933. * In this case the connection point name must be the name of the uniform to use.
  118934. * Can only be set on inputs
  118935. */
  118936. isUniform: boolean;
  118937. /**
  118938. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  118939. * In this case the connection point name must be the name of the attribute to use
  118940. * Can only be set on inputs
  118941. */
  118942. isAttribute: boolean;
  118943. /**
  118944. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  118945. * Can only be set on exit points
  118946. */
  118947. isVarying: boolean;
  118948. /**
  118949. * Gets a boolean indicating that the current connection point is a system value
  118950. */
  118951. readonly isSystemValue: boolean;
  118952. /**
  118953. * Gets or sets the current well known value or null if not defined as a system value
  118954. */
  118955. systemValue: Nullable<NodeMaterialSystemValues>;
  118956. /**
  118957. * Gets the current class name
  118958. * @returns the class name
  118959. */
  118960. getClassName(): string;
  118961. /**
  118962. * Animate the input if animationType !== None
  118963. * @param scene defines the rendering scene
  118964. */
  118965. animate(scene: Scene): void;
  118966. private _emitDefine;
  118967. initialize(state: NodeMaterialBuildState): void;
  118968. /**
  118969. * Set the input block to its default value (based on its type)
  118970. */
  118971. setDefaultValue(): void;
  118972. protected _dumpPropertiesCode(): string;
  118973. private _emit;
  118974. /** @hidden */
  118975. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  118976. /** @hidden */
  118977. _transmit(effect: Effect, scene: Scene): void;
  118978. protected _buildBlock(state: NodeMaterialBuildState): void;
  118979. serialize(): any;
  118980. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  118981. }
  118982. }
  118983. declare module BABYLON {
  118984. /**
  118985. * Defines a connection point for a block
  118986. */
  118987. export class NodeMaterialConnectionPoint {
  118988. /** @hidden */
  118989. _ownerBlock: NodeMaterialBlock;
  118990. /** @hidden */
  118991. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  118992. private _endpoints;
  118993. private _associatedVariableName;
  118994. /** @hidden */
  118995. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  118996. /** @hidden */
  118997. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  118998. private _type;
  118999. /** @hidden */
  119000. _enforceAssociatedVariableName: boolean;
  119001. /**
  119002. * Gets or sets the additional types supported byt this connection point
  119003. */
  119004. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  119005. /**
  119006. * Gets or sets the associated variable name in the shader
  119007. */
  119008. associatedVariableName: string;
  119009. /**
  119010. * Gets or sets the connection point type (default is float)
  119011. */
  119012. type: NodeMaterialBlockConnectionPointTypes;
  119013. /**
  119014. * Gets or sets the connection point name
  119015. */
  119016. name: string;
  119017. /**
  119018. * Gets or sets a boolean indicating that this connection point can be omitted
  119019. */
  119020. isOptional: boolean;
  119021. /**
  119022. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  119023. */
  119024. define: string;
  119025. /** Gets or sets the target of that connection point */
  119026. target: NodeMaterialBlockTargets;
  119027. /**
  119028. * Gets a boolean indicating that the current point is connected
  119029. */
  119030. readonly isConnected: boolean;
  119031. /**
  119032. * Gets a boolean indicating that the current point is connected to an input block
  119033. */
  119034. readonly isConnectedToInputBlock: boolean;
  119035. /**
  119036. * Gets a the connected input block (if any)
  119037. */
  119038. readonly connectInputBlock: Nullable<InputBlock>;
  119039. /** Get the other side of the connection (if any) */
  119040. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  119041. /** Get the block that owns this connection point */
  119042. readonly ownerBlock: NodeMaterialBlock;
  119043. /** Get the block connected on the other side of this connection (if any) */
  119044. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  119045. /** Get the block connected on the endpoints of this connection (if any) */
  119046. readonly connectedBlocks: Array<NodeMaterialBlock>;
  119047. /** Gets the list of connected endpoints */
  119048. readonly endpoints: NodeMaterialConnectionPoint[];
  119049. /** Gets a boolean indicating if that output point is connected to at least one input */
  119050. readonly hasEndpoints: boolean;
  119051. /**
  119052. * Creates a new connection point
  119053. * @param name defines the connection point name
  119054. * @param ownerBlock defines the block hosting this connection point
  119055. */
  119056. constructor(name: string, ownerBlock: NodeMaterialBlock);
  119057. /**
  119058. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  119059. * @returns the class name
  119060. */
  119061. getClassName(): string;
  119062. /**
  119063. * Gets an boolean indicating if the current point can be connected to another point
  119064. * @param connectionPoint defines the other connection point
  119065. * @returns true if the connection is possible
  119066. */
  119067. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  119068. /**
  119069. * Connect this point to another connection point
  119070. * @param connectionPoint defines the other connection point
  119071. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  119072. * @returns the current connection point
  119073. */
  119074. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  119075. /**
  119076. * Disconnect this point from one of his endpoint
  119077. * @param endpoint defines the other connection point
  119078. * @returns the current connection point
  119079. */
  119080. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  119081. /**
  119082. * Serializes this point in a JSON representation
  119083. * @returns the serialized point object
  119084. */
  119085. serialize(): any;
  119086. }
  119087. }
  119088. declare module BABYLON {
  119089. /**
  119090. * Block used to add support for vertex skinning (bones)
  119091. */
  119092. export class BonesBlock extends NodeMaterialBlock {
  119093. /**
  119094. * Creates a new BonesBlock
  119095. * @param name defines the block name
  119096. */
  119097. constructor(name: string);
  119098. /**
  119099. * Initialize the block and prepare the context for build
  119100. * @param state defines the state that will be used for the build
  119101. */
  119102. initialize(state: NodeMaterialBuildState): void;
  119103. /**
  119104. * Gets the current class name
  119105. * @returns the class name
  119106. */
  119107. getClassName(): string;
  119108. /**
  119109. * Gets the matrix indices input component
  119110. */
  119111. readonly matricesIndices: NodeMaterialConnectionPoint;
  119112. /**
  119113. * Gets the matrix weights input component
  119114. */
  119115. readonly matricesWeights: NodeMaterialConnectionPoint;
  119116. /**
  119117. * Gets the extra matrix indices input component
  119118. */
  119119. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  119120. /**
  119121. * Gets the extra matrix weights input component
  119122. */
  119123. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  119124. /**
  119125. * Gets the world input component
  119126. */
  119127. readonly world: NodeMaterialConnectionPoint;
  119128. /**
  119129. * Gets the output component
  119130. */
  119131. readonly output: NodeMaterialConnectionPoint;
  119132. autoConfigure(material: NodeMaterial): void;
  119133. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  119134. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119135. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119136. protected _buildBlock(state: NodeMaterialBuildState): this;
  119137. }
  119138. }
  119139. declare module BABYLON {
  119140. /**
  119141. * Block used to add support for instances
  119142. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  119143. */
  119144. export class InstancesBlock extends NodeMaterialBlock {
  119145. /**
  119146. * Creates a new InstancesBlock
  119147. * @param name defines the block name
  119148. */
  119149. constructor(name: string);
  119150. /**
  119151. * Gets the current class name
  119152. * @returns the class name
  119153. */
  119154. getClassName(): string;
  119155. /**
  119156. * Gets the first world row input component
  119157. */
  119158. readonly world0: NodeMaterialConnectionPoint;
  119159. /**
  119160. * Gets the second world row input component
  119161. */
  119162. readonly world1: NodeMaterialConnectionPoint;
  119163. /**
  119164. * Gets the third world row input component
  119165. */
  119166. readonly world2: NodeMaterialConnectionPoint;
  119167. /**
  119168. * Gets the forth world row input component
  119169. */
  119170. readonly world3: NodeMaterialConnectionPoint;
  119171. /**
  119172. * Gets the world input component
  119173. */
  119174. readonly world: NodeMaterialConnectionPoint;
  119175. /**
  119176. * Gets the output component
  119177. */
  119178. readonly output: NodeMaterialConnectionPoint;
  119179. autoConfigure(material: NodeMaterial): void;
  119180. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  119181. protected _buildBlock(state: NodeMaterialBuildState): this;
  119182. }
  119183. }
  119184. declare module BABYLON {
  119185. /**
  119186. * Block used to add morph targets support to vertex shader
  119187. */
  119188. export class MorphTargetsBlock extends NodeMaterialBlock {
  119189. private _repeatableContentAnchor;
  119190. private _repeatebleContentGenerated;
  119191. /**
  119192. * Create a new MorphTargetsBlock
  119193. * @param name defines the block name
  119194. */
  119195. constructor(name: string);
  119196. /**
  119197. * Gets the current class name
  119198. * @returns the class name
  119199. */
  119200. getClassName(): string;
  119201. /**
  119202. * Gets the position input component
  119203. */
  119204. readonly position: NodeMaterialConnectionPoint;
  119205. /**
  119206. * Gets the normal input component
  119207. */
  119208. readonly normal: NodeMaterialConnectionPoint;
  119209. /**
  119210. * Gets the tangent input component
  119211. */
  119212. readonly tangent: NodeMaterialConnectionPoint;
  119213. /**
  119214. * Gets the tangent input component
  119215. */
  119216. readonly uv: NodeMaterialConnectionPoint;
  119217. /**
  119218. * Gets the position output component
  119219. */
  119220. readonly positionOutput: NodeMaterialConnectionPoint;
  119221. /**
  119222. * Gets the normal output component
  119223. */
  119224. readonly normalOutput: NodeMaterialConnectionPoint;
  119225. /**
  119226. * Gets the tangent output component
  119227. */
  119228. readonly tangentOutput: NodeMaterialConnectionPoint;
  119229. /**
  119230. * Gets the tangent output component
  119231. */
  119232. readonly uvOutput: NodeMaterialConnectionPoint;
  119233. initialize(state: NodeMaterialBuildState): void;
  119234. autoConfigure(material: NodeMaterial): void;
  119235. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119236. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119237. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  119238. protected _buildBlock(state: NodeMaterialBuildState): this;
  119239. }
  119240. }
  119241. declare module BABYLON {
  119242. /**
  119243. * Block used to get data information from a light
  119244. */
  119245. export class LightInformationBlock extends NodeMaterialBlock {
  119246. private _lightDataDefineName;
  119247. private _lightColorDefineName;
  119248. /**
  119249. * Gets or sets the light associated with this block
  119250. */
  119251. light: Nullable<Light>;
  119252. /**
  119253. * Creates a new LightInformationBlock
  119254. * @param name defines the block name
  119255. */
  119256. constructor(name: string);
  119257. /**
  119258. * Gets the current class name
  119259. * @returns the class name
  119260. */
  119261. getClassName(): string;
  119262. /**
  119263. * Gets the world position input component
  119264. */
  119265. readonly worldPosition: NodeMaterialConnectionPoint;
  119266. /**
  119267. * Gets the direction output component
  119268. */
  119269. readonly direction: NodeMaterialConnectionPoint;
  119270. /**
  119271. * Gets the direction output component
  119272. */
  119273. readonly color: NodeMaterialConnectionPoint;
  119274. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119275. protected _buildBlock(state: NodeMaterialBuildState): this;
  119276. serialize(): any;
  119277. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119278. }
  119279. }
  119280. declare module BABYLON {
  119281. /**
  119282. * Block used to add an alpha test in the fragment shader
  119283. */
  119284. export class AlphaTestBlock extends NodeMaterialBlock {
  119285. /**
  119286. * Gets or sets the alpha value where alpha testing happens
  119287. */
  119288. alphaCutOff: number;
  119289. /**
  119290. * Create a new AlphaTestBlock
  119291. * @param name defines the block name
  119292. */
  119293. constructor(name: string);
  119294. /**
  119295. * Gets the current class name
  119296. * @returns the class name
  119297. */
  119298. getClassName(): string;
  119299. /**
  119300. * Gets the color input component
  119301. */
  119302. readonly color: NodeMaterialConnectionPoint;
  119303. /**
  119304. * Gets the alpha input component
  119305. */
  119306. readonly alpha: NodeMaterialConnectionPoint;
  119307. protected _buildBlock(state: NodeMaterialBuildState): this;
  119308. protected _dumpPropertiesCode(): string;
  119309. serialize(): any;
  119310. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119311. }
  119312. }
  119313. declare module BABYLON {
  119314. /**
  119315. * Block used to add image processing support to fragment shader
  119316. */
  119317. export class ImageProcessingBlock extends NodeMaterialBlock {
  119318. /**
  119319. * Create a new ImageProcessingBlock
  119320. * @param name defines the block name
  119321. */
  119322. constructor(name: string);
  119323. /**
  119324. * Gets the current class name
  119325. * @returns the class name
  119326. */
  119327. getClassName(): string;
  119328. /**
  119329. * Gets the color input component
  119330. */
  119331. readonly color: NodeMaterialConnectionPoint;
  119332. /**
  119333. * Gets the output component
  119334. */
  119335. readonly output: NodeMaterialConnectionPoint;
  119336. /**
  119337. * Initialize the block and prepare the context for build
  119338. * @param state defines the state that will be used for the build
  119339. */
  119340. initialize(state: NodeMaterialBuildState): void;
  119341. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  119342. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119343. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119344. protected _buildBlock(state: NodeMaterialBuildState): this;
  119345. }
  119346. }
  119347. declare module BABYLON {
  119348. /**
  119349. * Block used to pertub normals based on a normal map
  119350. */
  119351. export class PerturbNormalBlock extends NodeMaterialBlock {
  119352. private _tangentSpaceParameterName;
  119353. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  119354. invertX: boolean;
  119355. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  119356. invertY: boolean;
  119357. /**
  119358. * Create a new PerturbNormalBlock
  119359. * @param name defines the block name
  119360. */
  119361. constructor(name: string);
  119362. /**
  119363. * Gets the current class name
  119364. * @returns the class name
  119365. */
  119366. getClassName(): string;
  119367. /**
  119368. * Gets the world position input component
  119369. */
  119370. readonly worldPosition: NodeMaterialConnectionPoint;
  119371. /**
  119372. * Gets the world normal input component
  119373. */
  119374. readonly worldNormal: NodeMaterialConnectionPoint;
  119375. /**
  119376. * Gets the uv input component
  119377. */
  119378. readonly uv: NodeMaterialConnectionPoint;
  119379. /**
  119380. * Gets the normal map color input component
  119381. */
  119382. readonly normalMapColor: NodeMaterialConnectionPoint;
  119383. /**
  119384. * Gets the strength input component
  119385. */
  119386. readonly strength: NodeMaterialConnectionPoint;
  119387. /**
  119388. * Gets the output component
  119389. */
  119390. readonly output: NodeMaterialConnectionPoint;
  119391. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119392. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119393. autoConfigure(material: NodeMaterial): void;
  119394. protected _buildBlock(state: NodeMaterialBuildState): this;
  119395. protected _dumpPropertiesCode(): string;
  119396. serialize(): any;
  119397. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119398. }
  119399. }
  119400. declare module BABYLON {
  119401. /**
  119402. * Block used to add support for scene fog
  119403. */
  119404. export class FogBlock extends NodeMaterialBlock {
  119405. private _fogDistanceName;
  119406. private _fogParameters;
  119407. /**
  119408. * Create a new FogBlock
  119409. * @param name defines the block name
  119410. */
  119411. constructor(name: string);
  119412. /**
  119413. * Gets the current class name
  119414. * @returns the class name
  119415. */
  119416. getClassName(): string;
  119417. /**
  119418. * Gets the world position input component
  119419. */
  119420. readonly worldPosition: NodeMaterialConnectionPoint;
  119421. /**
  119422. * Gets the view input component
  119423. */
  119424. readonly view: NodeMaterialConnectionPoint;
  119425. /**
  119426. * Gets the color input component
  119427. */
  119428. readonly input: NodeMaterialConnectionPoint;
  119429. /**
  119430. * Gets the fog color input component
  119431. */
  119432. readonly fogColor: NodeMaterialConnectionPoint;
  119433. /**
  119434. * Gets the output component
  119435. */
  119436. readonly output: NodeMaterialConnectionPoint;
  119437. autoConfigure(material: NodeMaterial): void;
  119438. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119439. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119440. protected _buildBlock(state: NodeMaterialBuildState): this;
  119441. }
  119442. }
  119443. declare module BABYLON {
  119444. /**
  119445. * Block used to add light in the fragment shader
  119446. */
  119447. export class LightBlock extends NodeMaterialBlock {
  119448. private _lightId;
  119449. /**
  119450. * Gets or sets the light associated with this block
  119451. */
  119452. light: Nullable<Light>;
  119453. /**
  119454. * Create a new LightBlock
  119455. * @param name defines the block name
  119456. */
  119457. constructor(name: string);
  119458. /**
  119459. * Gets the current class name
  119460. * @returns the class name
  119461. */
  119462. getClassName(): string;
  119463. /**
  119464. * Gets the world position input component
  119465. */
  119466. readonly worldPosition: NodeMaterialConnectionPoint;
  119467. /**
  119468. * Gets the world normal input component
  119469. */
  119470. readonly worldNormal: NodeMaterialConnectionPoint;
  119471. /**
  119472. * Gets the camera (or eye) position component
  119473. */
  119474. readonly cameraPosition: NodeMaterialConnectionPoint;
  119475. /**
  119476. * Gets the diffuse output component
  119477. */
  119478. readonly diffuseOutput: NodeMaterialConnectionPoint;
  119479. /**
  119480. * Gets the specular output component
  119481. */
  119482. readonly specularOutput: NodeMaterialConnectionPoint;
  119483. autoConfigure(material: NodeMaterial): void;
  119484. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119485. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119486. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119487. private _injectVertexCode;
  119488. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  119489. serialize(): any;
  119490. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119491. }
  119492. }
  119493. declare module BABYLON {
  119494. /**
  119495. * Block used to multiply 2 values
  119496. */
  119497. export class MultiplyBlock extends NodeMaterialBlock {
  119498. /**
  119499. * Creates a new MultiplyBlock
  119500. * @param name defines the block name
  119501. */
  119502. constructor(name: string);
  119503. /**
  119504. * Gets the current class name
  119505. * @returns the class name
  119506. */
  119507. getClassName(): string;
  119508. /**
  119509. * Gets the left operand input component
  119510. */
  119511. readonly left: NodeMaterialConnectionPoint;
  119512. /**
  119513. * Gets the right operand input component
  119514. */
  119515. readonly right: NodeMaterialConnectionPoint;
  119516. /**
  119517. * Gets the output component
  119518. */
  119519. readonly output: NodeMaterialConnectionPoint;
  119520. protected _buildBlock(state: NodeMaterialBuildState): this;
  119521. }
  119522. }
  119523. declare module BABYLON {
  119524. /**
  119525. * Block used to add 2 vectors
  119526. */
  119527. export class AddBlock extends NodeMaterialBlock {
  119528. /**
  119529. * Creates a new AddBlock
  119530. * @param name defines the block name
  119531. */
  119532. constructor(name: string);
  119533. /**
  119534. * Gets the current class name
  119535. * @returns the class name
  119536. */
  119537. getClassName(): string;
  119538. /**
  119539. * Gets the left operand input component
  119540. */
  119541. readonly left: NodeMaterialConnectionPoint;
  119542. /**
  119543. * Gets the right operand input component
  119544. */
  119545. readonly right: NodeMaterialConnectionPoint;
  119546. /**
  119547. * Gets the output component
  119548. */
  119549. readonly output: NodeMaterialConnectionPoint;
  119550. protected _buildBlock(state: NodeMaterialBuildState): this;
  119551. }
  119552. }
  119553. declare module BABYLON {
  119554. /**
  119555. * Block used to scale a vector by a float
  119556. */
  119557. export class ScaleBlock extends NodeMaterialBlock {
  119558. /**
  119559. * Creates a new ScaleBlock
  119560. * @param name defines the block name
  119561. */
  119562. constructor(name: string);
  119563. /**
  119564. * Gets the current class name
  119565. * @returns the class name
  119566. */
  119567. getClassName(): string;
  119568. /**
  119569. * Gets the input component
  119570. */
  119571. readonly input: NodeMaterialConnectionPoint;
  119572. /**
  119573. * Gets the factor input component
  119574. */
  119575. readonly factor: NodeMaterialConnectionPoint;
  119576. /**
  119577. * Gets the output component
  119578. */
  119579. readonly output: NodeMaterialConnectionPoint;
  119580. protected _buildBlock(state: NodeMaterialBuildState): this;
  119581. }
  119582. }
  119583. declare module BABYLON {
  119584. /**
  119585. * Block used to clamp a float
  119586. */
  119587. export class ClampBlock extends NodeMaterialBlock {
  119588. /** Gets or sets the minimum range */
  119589. minimum: number;
  119590. /** Gets or sets the maximum range */
  119591. maximum: number;
  119592. /**
  119593. * Creates a new ClampBlock
  119594. * @param name defines the block name
  119595. */
  119596. constructor(name: string);
  119597. /**
  119598. * Gets the current class name
  119599. * @returns the class name
  119600. */
  119601. getClassName(): string;
  119602. /**
  119603. * Gets the value input component
  119604. */
  119605. readonly value: NodeMaterialConnectionPoint;
  119606. /**
  119607. * Gets the output component
  119608. */
  119609. readonly output: NodeMaterialConnectionPoint;
  119610. protected _buildBlock(state: NodeMaterialBuildState): this;
  119611. protected _dumpPropertiesCode(): string;
  119612. serialize(): any;
  119613. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119614. }
  119615. }
  119616. declare module BABYLON {
  119617. /**
  119618. * Block used to apply a cross product between 2 vectors
  119619. */
  119620. export class CrossBlock extends NodeMaterialBlock {
  119621. /**
  119622. * Creates a new CrossBlock
  119623. * @param name defines the block name
  119624. */
  119625. constructor(name: string);
  119626. /**
  119627. * Gets the current class name
  119628. * @returns the class name
  119629. */
  119630. getClassName(): string;
  119631. /**
  119632. * Gets the left operand input component
  119633. */
  119634. readonly left: NodeMaterialConnectionPoint;
  119635. /**
  119636. * Gets the right operand input component
  119637. */
  119638. readonly right: NodeMaterialConnectionPoint;
  119639. /**
  119640. * Gets the output component
  119641. */
  119642. readonly output: NodeMaterialConnectionPoint;
  119643. protected _buildBlock(state: NodeMaterialBuildState): this;
  119644. }
  119645. }
  119646. declare module BABYLON {
  119647. /**
  119648. * Block used to apply a dot product between 2 vectors
  119649. */
  119650. export class DotBlock extends NodeMaterialBlock {
  119651. /**
  119652. * Creates a new DotBlock
  119653. * @param name defines the block name
  119654. */
  119655. constructor(name: string);
  119656. /**
  119657. * Gets the current class name
  119658. * @returns the class name
  119659. */
  119660. getClassName(): string;
  119661. /**
  119662. * Gets the left operand input component
  119663. */
  119664. readonly left: NodeMaterialConnectionPoint;
  119665. /**
  119666. * Gets the right operand input component
  119667. */
  119668. readonly right: NodeMaterialConnectionPoint;
  119669. /**
  119670. * Gets the output component
  119671. */
  119672. readonly output: NodeMaterialConnectionPoint;
  119673. protected _buildBlock(state: NodeMaterialBuildState): this;
  119674. }
  119675. }
  119676. declare module BABYLON {
  119677. /**
  119678. * Block used to remap a float from a range to a new one
  119679. */
  119680. export class RemapBlock extends NodeMaterialBlock {
  119681. /**
  119682. * Gets or sets the source range
  119683. */
  119684. sourceRange: Vector2;
  119685. /**
  119686. * Gets or sets the target range
  119687. */
  119688. targetRange: Vector2;
  119689. /**
  119690. * Creates a new RemapBlock
  119691. * @param name defines the block name
  119692. */
  119693. constructor(name: string);
  119694. /**
  119695. * Gets the current class name
  119696. * @returns the class name
  119697. */
  119698. getClassName(): string;
  119699. /**
  119700. * Gets the input component
  119701. */
  119702. readonly input: NodeMaterialConnectionPoint;
  119703. /**
  119704. * Gets the source min input component
  119705. */
  119706. readonly sourceMin: NodeMaterialConnectionPoint;
  119707. /**
  119708. * Gets the source max input component
  119709. */
  119710. readonly sourceMax: NodeMaterialConnectionPoint;
  119711. /**
  119712. * Gets the target min input component
  119713. */
  119714. readonly targetMin: NodeMaterialConnectionPoint;
  119715. /**
  119716. * Gets the target max input component
  119717. */
  119718. readonly targetMax: NodeMaterialConnectionPoint;
  119719. /**
  119720. * Gets the output component
  119721. */
  119722. readonly output: NodeMaterialConnectionPoint;
  119723. protected _buildBlock(state: NodeMaterialBuildState): this;
  119724. protected _dumpPropertiesCode(): string;
  119725. serialize(): any;
  119726. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119727. }
  119728. }
  119729. declare module BABYLON {
  119730. /**
  119731. * Block used to normalize a vector
  119732. */
  119733. export class NormalizeBlock extends NodeMaterialBlock {
  119734. /**
  119735. * Creates a new NormalizeBlock
  119736. * @param name defines the block name
  119737. */
  119738. constructor(name: string);
  119739. /**
  119740. * Gets the current class name
  119741. * @returns the class name
  119742. */
  119743. getClassName(): string;
  119744. /**
  119745. * Gets the input component
  119746. */
  119747. readonly input: NodeMaterialConnectionPoint;
  119748. /**
  119749. * Gets the output component
  119750. */
  119751. readonly output: NodeMaterialConnectionPoint;
  119752. protected _buildBlock(state: NodeMaterialBuildState): this;
  119753. }
  119754. }
  119755. declare module BABYLON {
  119756. /**
  119757. * Operations supported by the Trigonometry block
  119758. */
  119759. export enum TrigonometryBlockOperations {
  119760. /** Cos */
  119761. Cos = 0,
  119762. /** Sin */
  119763. Sin = 1,
  119764. /** Abs */
  119765. Abs = 2,
  119766. /** Exp */
  119767. Exp = 3,
  119768. /** Exp2 */
  119769. Exp2 = 4,
  119770. /** Round */
  119771. Round = 5,
  119772. /** Floor */
  119773. Floor = 6,
  119774. /** Ceiling */
  119775. Ceiling = 7,
  119776. /** Square root */
  119777. Sqrt = 8
  119778. }
  119779. /**
  119780. * Block used to apply trigonometry operation to floats
  119781. */
  119782. export class TrigonometryBlock extends NodeMaterialBlock {
  119783. /**
  119784. * Gets or sets the operation applied by the block
  119785. */
  119786. operation: TrigonometryBlockOperations;
  119787. /**
  119788. * Creates a new TrigonometryBlock
  119789. * @param name defines the block name
  119790. */
  119791. constructor(name: string);
  119792. /**
  119793. * Gets the current class name
  119794. * @returns the class name
  119795. */
  119796. getClassName(): string;
  119797. /**
  119798. * Gets the input component
  119799. */
  119800. readonly input: NodeMaterialConnectionPoint;
  119801. /**
  119802. * Gets the output component
  119803. */
  119804. readonly output: NodeMaterialConnectionPoint;
  119805. protected _buildBlock(state: NodeMaterialBuildState): this;
  119806. serialize(): any;
  119807. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119808. }
  119809. }
  119810. declare module BABYLON {
  119811. /**
  119812. * Block used to create a Color3/4 out of individual inputs (one for each component)
  119813. */
  119814. export class ColorMergerBlock extends NodeMaterialBlock {
  119815. /**
  119816. * Create a new ColorMergerBlock
  119817. * @param name defines the block name
  119818. */
  119819. constructor(name: string);
  119820. /**
  119821. * Gets the current class name
  119822. * @returns the class name
  119823. */
  119824. getClassName(): string;
  119825. /**
  119826. * Gets the r component (input)
  119827. */
  119828. readonly r: NodeMaterialConnectionPoint;
  119829. /**
  119830. * Gets the g component (input)
  119831. */
  119832. readonly g: NodeMaterialConnectionPoint;
  119833. /**
  119834. * Gets the b component (input)
  119835. */
  119836. readonly b: NodeMaterialConnectionPoint;
  119837. /**
  119838. * Gets the a component (input)
  119839. */
  119840. readonly a: NodeMaterialConnectionPoint;
  119841. /**
  119842. * Gets the rgba component (output)
  119843. */
  119844. readonly rgba: NodeMaterialConnectionPoint;
  119845. /**
  119846. * Gets the rgb component (output)
  119847. */
  119848. readonly rgb: NodeMaterialConnectionPoint;
  119849. protected _buildBlock(state: NodeMaterialBuildState): this;
  119850. }
  119851. }
  119852. declare module BABYLON {
  119853. /**
  119854. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  119855. */
  119856. export class VectorMergerBlock extends NodeMaterialBlock {
  119857. /**
  119858. * Create a new VectorMergerBlock
  119859. * @param name defines the block name
  119860. */
  119861. constructor(name: string);
  119862. /**
  119863. * Gets the current class name
  119864. * @returns the class name
  119865. */
  119866. getClassName(): string;
  119867. /**
  119868. * Gets the x component (input)
  119869. */
  119870. readonly x: NodeMaterialConnectionPoint;
  119871. /**
  119872. * Gets the y component (input)
  119873. */
  119874. readonly y: NodeMaterialConnectionPoint;
  119875. /**
  119876. * Gets the z component (input)
  119877. */
  119878. readonly z: NodeMaterialConnectionPoint;
  119879. /**
  119880. * Gets the w component (input)
  119881. */
  119882. readonly w: NodeMaterialConnectionPoint;
  119883. /**
  119884. * Gets the xyzw component (output)
  119885. */
  119886. readonly xyzw: NodeMaterialConnectionPoint;
  119887. /**
  119888. * Gets the xyz component (output)
  119889. */
  119890. readonly xyz: NodeMaterialConnectionPoint;
  119891. /**
  119892. * Gets the xy component (output)
  119893. */
  119894. readonly xy: NodeMaterialConnectionPoint;
  119895. protected _buildBlock(state: NodeMaterialBuildState): this;
  119896. }
  119897. }
  119898. declare module BABYLON {
  119899. /**
  119900. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  119901. */
  119902. export class ColorSplitterBlock extends NodeMaterialBlock {
  119903. /**
  119904. * Create a new ColorSplitterBlock
  119905. * @param name defines the block name
  119906. */
  119907. constructor(name: string);
  119908. /**
  119909. * Gets the current class name
  119910. * @returns the class name
  119911. */
  119912. getClassName(): string;
  119913. /**
  119914. * Gets the rgba component (input)
  119915. */
  119916. readonly rgba: NodeMaterialConnectionPoint;
  119917. /**
  119918. * Gets the rgb component (input)
  119919. */
  119920. readonly rgbIn: NodeMaterialConnectionPoint;
  119921. /**
  119922. * Gets the rgb component (output)
  119923. */
  119924. readonly rgbOut: NodeMaterialConnectionPoint;
  119925. /**
  119926. * Gets the r component (output)
  119927. */
  119928. readonly r: NodeMaterialConnectionPoint;
  119929. /**
  119930. * Gets the g component (output)
  119931. */
  119932. readonly g: NodeMaterialConnectionPoint;
  119933. /**
  119934. * Gets the b component (output)
  119935. */
  119936. readonly b: NodeMaterialConnectionPoint;
  119937. /**
  119938. * Gets the a component (output)
  119939. */
  119940. readonly a: NodeMaterialConnectionPoint;
  119941. protected _inputRename(name: string): string;
  119942. protected _outputRename(name: string): string;
  119943. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  119944. }
  119945. }
  119946. declare module BABYLON {
  119947. /**
  119948. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  119949. */
  119950. export class VectorSplitterBlock extends NodeMaterialBlock {
  119951. /**
  119952. * Create a new VectorSplitterBlock
  119953. * @param name defines the block name
  119954. */
  119955. constructor(name: string);
  119956. /**
  119957. * Gets the current class name
  119958. * @returns the class name
  119959. */
  119960. getClassName(): string;
  119961. /**
  119962. * Gets the xyzw component (input)
  119963. */
  119964. readonly xyzw: NodeMaterialConnectionPoint;
  119965. /**
  119966. * Gets the xyz component (input)
  119967. */
  119968. readonly xyzIn: NodeMaterialConnectionPoint;
  119969. /**
  119970. * Gets the xy component (input)
  119971. */
  119972. readonly xyIn: NodeMaterialConnectionPoint;
  119973. /**
  119974. * Gets the xyz component (output)
  119975. */
  119976. readonly xyzOut: NodeMaterialConnectionPoint;
  119977. /**
  119978. * Gets the xy component (output)
  119979. */
  119980. readonly xyOut: NodeMaterialConnectionPoint;
  119981. /**
  119982. * Gets the x component (output)
  119983. */
  119984. readonly x: NodeMaterialConnectionPoint;
  119985. /**
  119986. * Gets the y component (output)
  119987. */
  119988. readonly y: NodeMaterialConnectionPoint;
  119989. /**
  119990. * Gets the z component (output)
  119991. */
  119992. readonly z: NodeMaterialConnectionPoint;
  119993. /**
  119994. * Gets the w component (output)
  119995. */
  119996. readonly w: NodeMaterialConnectionPoint;
  119997. protected _inputRename(name: string): string;
  119998. protected _outputRename(name: string): string;
  119999. protected _buildBlock(state: NodeMaterialBuildState): this;
  120000. }
  120001. }
  120002. declare module BABYLON {
  120003. /**
  120004. * Block used to lerp 2 values
  120005. */
  120006. export class LerpBlock extends NodeMaterialBlock {
  120007. /**
  120008. * Creates a new LerpBlock
  120009. * @param name defines the block name
  120010. */
  120011. constructor(name: string);
  120012. /**
  120013. * Gets the current class name
  120014. * @returns the class name
  120015. */
  120016. getClassName(): string;
  120017. /**
  120018. * Gets the left operand input component
  120019. */
  120020. readonly left: NodeMaterialConnectionPoint;
  120021. /**
  120022. * Gets the right operand input component
  120023. */
  120024. readonly right: NodeMaterialConnectionPoint;
  120025. /**
  120026. * Gets the gradient operand input component
  120027. */
  120028. readonly gradient: NodeMaterialConnectionPoint;
  120029. /**
  120030. * Gets the output component
  120031. */
  120032. readonly output: NodeMaterialConnectionPoint;
  120033. protected _buildBlock(state: NodeMaterialBuildState): this;
  120034. }
  120035. }
  120036. declare module BABYLON {
  120037. /**
  120038. * Block used to divide 2 vectors
  120039. */
  120040. export class DivideBlock extends NodeMaterialBlock {
  120041. /**
  120042. * Creates a new DivideBlock
  120043. * @param name defines the block name
  120044. */
  120045. constructor(name: string);
  120046. /**
  120047. * Gets the current class name
  120048. * @returns the class name
  120049. */
  120050. getClassName(): string;
  120051. /**
  120052. * Gets the left operand input component
  120053. */
  120054. readonly left: NodeMaterialConnectionPoint;
  120055. /**
  120056. * Gets the right operand input component
  120057. */
  120058. readonly right: NodeMaterialConnectionPoint;
  120059. /**
  120060. * Gets the output component
  120061. */
  120062. readonly output: NodeMaterialConnectionPoint;
  120063. protected _buildBlock(state: NodeMaterialBuildState): this;
  120064. }
  120065. }
  120066. declare module BABYLON {
  120067. /**
  120068. * Block used to subtract 2 vectors
  120069. */
  120070. export class SubtractBlock extends NodeMaterialBlock {
  120071. /**
  120072. * Creates a new SubtractBlock
  120073. * @param name defines the block name
  120074. */
  120075. constructor(name: string);
  120076. /**
  120077. * Gets the current class name
  120078. * @returns the class name
  120079. */
  120080. getClassName(): string;
  120081. /**
  120082. * Gets the left operand input component
  120083. */
  120084. readonly left: NodeMaterialConnectionPoint;
  120085. /**
  120086. * Gets the right operand input component
  120087. */
  120088. readonly right: NodeMaterialConnectionPoint;
  120089. /**
  120090. * Gets the output component
  120091. */
  120092. readonly output: NodeMaterialConnectionPoint;
  120093. protected _buildBlock(state: NodeMaterialBuildState): this;
  120094. }
  120095. }
  120096. declare module BABYLON {
  120097. /**
  120098. * Block used to step a value
  120099. */
  120100. export class StepBlock extends NodeMaterialBlock {
  120101. /**
  120102. * Creates a new AddBlock
  120103. * @param name defines the block name
  120104. */
  120105. constructor(name: string);
  120106. /**
  120107. * Gets the current class name
  120108. * @returns the class name
  120109. */
  120110. getClassName(): string;
  120111. /**
  120112. * Gets the value operand input component
  120113. */
  120114. readonly value: NodeMaterialConnectionPoint;
  120115. /**
  120116. * Gets the edge operand input component
  120117. */
  120118. readonly edge: NodeMaterialConnectionPoint;
  120119. /**
  120120. * Gets the output component
  120121. */
  120122. readonly output: NodeMaterialConnectionPoint;
  120123. protected _buildBlock(state: NodeMaterialBuildState): this;
  120124. }
  120125. }
  120126. declare module BABYLON {
  120127. /**
  120128. * Block used to get the opposite (1 - x) of a value
  120129. */
  120130. export class OneMinusBlock extends NodeMaterialBlock {
  120131. /**
  120132. * Creates a new OneMinusBlock
  120133. * @param name defines the block name
  120134. */
  120135. constructor(name: string);
  120136. /**
  120137. * Gets the current class name
  120138. * @returns the class name
  120139. */
  120140. getClassName(): string;
  120141. /**
  120142. * Gets the input component
  120143. */
  120144. readonly input: NodeMaterialConnectionPoint;
  120145. /**
  120146. * Gets the output component
  120147. */
  120148. readonly output: NodeMaterialConnectionPoint;
  120149. protected _buildBlock(state: NodeMaterialBuildState): this;
  120150. }
  120151. }
  120152. declare module BABYLON {
  120153. /**
  120154. * Block used to get the view direction
  120155. */
  120156. export class ViewDirectionBlock extends NodeMaterialBlock {
  120157. /**
  120158. * Creates a new ViewDirectionBlock
  120159. * @param name defines the block name
  120160. */
  120161. constructor(name: string);
  120162. /**
  120163. * Gets the current class name
  120164. * @returns the class name
  120165. */
  120166. getClassName(): string;
  120167. /**
  120168. * Gets the world position component
  120169. */
  120170. readonly worldPosition: NodeMaterialConnectionPoint;
  120171. /**
  120172. * Gets the camera position component
  120173. */
  120174. readonly cameraPosition: NodeMaterialConnectionPoint;
  120175. /**
  120176. * Gets the output component
  120177. */
  120178. readonly output: NodeMaterialConnectionPoint;
  120179. autoConfigure(material: NodeMaterial): void;
  120180. protected _buildBlock(state: NodeMaterialBuildState): this;
  120181. }
  120182. }
  120183. declare module BABYLON {
  120184. /**
  120185. * Block used to compute fresnel value
  120186. */
  120187. export class FresnelBlock extends NodeMaterialBlock {
  120188. /**
  120189. * Create a new FresnelBlock
  120190. * @param name defines the block name
  120191. */
  120192. constructor(name: string);
  120193. /**
  120194. * Gets the current class name
  120195. * @returns the class name
  120196. */
  120197. getClassName(): string;
  120198. /**
  120199. * Gets the world normal input component
  120200. */
  120201. readonly worldNormal: NodeMaterialConnectionPoint;
  120202. /**
  120203. * Gets the view direction input component
  120204. */
  120205. readonly viewDirection: NodeMaterialConnectionPoint;
  120206. /**
  120207. * Gets the bias input component
  120208. */
  120209. readonly bias: NodeMaterialConnectionPoint;
  120210. /**
  120211. * Gets the camera (or eye) position component
  120212. */
  120213. readonly power: NodeMaterialConnectionPoint;
  120214. /**
  120215. * Gets the fresnel output component
  120216. */
  120217. readonly fresnel: NodeMaterialConnectionPoint;
  120218. autoConfigure(material: NodeMaterial): void;
  120219. protected _buildBlock(state: NodeMaterialBuildState): this;
  120220. }
  120221. }
  120222. declare module BABYLON {
  120223. /**
  120224. * Block used to get the max of 2 values
  120225. */
  120226. export class MaxBlock extends NodeMaterialBlock {
  120227. /**
  120228. * Creates a new MaxBlock
  120229. * @param name defines the block name
  120230. */
  120231. constructor(name: string);
  120232. /**
  120233. * Gets the current class name
  120234. * @returns the class name
  120235. */
  120236. getClassName(): string;
  120237. /**
  120238. * Gets the left operand input component
  120239. */
  120240. readonly left: NodeMaterialConnectionPoint;
  120241. /**
  120242. * Gets the right operand input component
  120243. */
  120244. readonly right: NodeMaterialConnectionPoint;
  120245. /**
  120246. * Gets the output component
  120247. */
  120248. readonly output: NodeMaterialConnectionPoint;
  120249. protected _buildBlock(state: NodeMaterialBuildState): this;
  120250. }
  120251. }
  120252. declare module BABYLON {
  120253. /**
  120254. * Block used to get the min of 2 values
  120255. */
  120256. export class MinBlock extends NodeMaterialBlock {
  120257. /**
  120258. * Creates a new MinBlock
  120259. * @param name defines the block name
  120260. */
  120261. constructor(name: string);
  120262. /**
  120263. * Gets the current class name
  120264. * @returns the class name
  120265. */
  120266. getClassName(): string;
  120267. /**
  120268. * Gets the left operand input component
  120269. */
  120270. readonly left: NodeMaterialConnectionPoint;
  120271. /**
  120272. * Gets the right operand input component
  120273. */
  120274. readonly right: NodeMaterialConnectionPoint;
  120275. /**
  120276. * Gets the output component
  120277. */
  120278. readonly output: NodeMaterialConnectionPoint;
  120279. protected _buildBlock(state: NodeMaterialBuildState): this;
  120280. }
  120281. }
  120282. declare module BABYLON {
  120283. /**
  120284. * Block used to get the distance between 2 values
  120285. */
  120286. export class DistanceBlock extends NodeMaterialBlock {
  120287. /**
  120288. * Creates a new DistanceBlock
  120289. * @param name defines the block name
  120290. */
  120291. constructor(name: string);
  120292. /**
  120293. * Gets the current class name
  120294. * @returns the class name
  120295. */
  120296. getClassName(): string;
  120297. /**
  120298. * Gets the left operand input component
  120299. */
  120300. readonly left: NodeMaterialConnectionPoint;
  120301. /**
  120302. * Gets the right operand input component
  120303. */
  120304. readonly right: NodeMaterialConnectionPoint;
  120305. /**
  120306. * Gets the output component
  120307. */
  120308. readonly output: NodeMaterialConnectionPoint;
  120309. protected _buildBlock(state: NodeMaterialBuildState): this;
  120310. }
  120311. }
  120312. declare module BABYLON {
  120313. /**
  120314. * Block used to get the length of a vector
  120315. */
  120316. export class LengthBlock extends NodeMaterialBlock {
  120317. /**
  120318. * Creates a new LengthBlock
  120319. * @param name defines the block name
  120320. */
  120321. constructor(name: string);
  120322. /**
  120323. * Gets the current class name
  120324. * @returns the class name
  120325. */
  120326. getClassName(): string;
  120327. /**
  120328. * Gets the value input component
  120329. */
  120330. readonly value: NodeMaterialConnectionPoint;
  120331. /**
  120332. * Gets the output component
  120333. */
  120334. readonly output: NodeMaterialConnectionPoint;
  120335. protected _buildBlock(state: NodeMaterialBuildState): this;
  120336. }
  120337. }
  120338. declare module BABYLON {
  120339. /**
  120340. * Block used to get negative version of a value (i.e. x * -1)
  120341. */
  120342. export class NegateBlock extends NodeMaterialBlock {
  120343. /**
  120344. * Creates a new NegateBlock
  120345. * @param name defines the block name
  120346. */
  120347. constructor(name: string);
  120348. /**
  120349. * Gets the current class name
  120350. * @returns the class name
  120351. */
  120352. getClassName(): string;
  120353. /**
  120354. * Gets the value input component
  120355. */
  120356. readonly value: NodeMaterialConnectionPoint;
  120357. /**
  120358. * Gets the output component
  120359. */
  120360. readonly output: NodeMaterialConnectionPoint;
  120361. protected _buildBlock(state: NodeMaterialBuildState): this;
  120362. }
  120363. }
  120364. declare module BABYLON {
  120365. /**
  120366. * Block used to get the value of the first parameter raised to the power of the second
  120367. */
  120368. export class PowBlock extends NodeMaterialBlock {
  120369. /**
  120370. * Creates a new PowBlock
  120371. * @param name defines the block name
  120372. */
  120373. constructor(name: string);
  120374. /**
  120375. * Gets the current class name
  120376. * @returns the class name
  120377. */
  120378. getClassName(): string;
  120379. /**
  120380. * Gets the value operand input component
  120381. */
  120382. readonly value: NodeMaterialConnectionPoint;
  120383. /**
  120384. * Gets the power operand input component
  120385. */
  120386. readonly power: NodeMaterialConnectionPoint;
  120387. /**
  120388. * Gets the output component
  120389. */
  120390. readonly output: NodeMaterialConnectionPoint;
  120391. protected _buildBlock(state: NodeMaterialBuildState): this;
  120392. }
  120393. }
  120394. declare module BABYLON {
  120395. /**
  120396. * Effect Render Options
  120397. */
  120398. export interface IEffectRendererOptions {
  120399. /**
  120400. * Defines the vertices positions.
  120401. */
  120402. positions?: number[];
  120403. /**
  120404. * Defines the indices.
  120405. */
  120406. indices?: number[];
  120407. }
  120408. /**
  120409. * Helper class to render one or more effects
  120410. */
  120411. export class EffectRenderer {
  120412. private engine;
  120413. private static _DefaultOptions;
  120414. private _vertexBuffers;
  120415. private _indexBuffer;
  120416. private _ringBufferIndex;
  120417. private _ringScreenBuffer;
  120418. private _fullscreenViewport;
  120419. private _getNextFrameBuffer;
  120420. /**
  120421. * Creates an effect renderer
  120422. * @param engine the engine to use for rendering
  120423. * @param options defines the options of the effect renderer
  120424. */
  120425. constructor(engine: Engine, options?: IEffectRendererOptions);
  120426. /**
  120427. * Sets the current viewport in normalized coordinates 0-1
  120428. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  120429. */
  120430. setViewport(viewport?: Viewport): void;
  120431. /**
  120432. * Binds the embedded attributes buffer to the effect.
  120433. * @param effect Defines the effect to bind the attributes for
  120434. */
  120435. bindBuffers(effect: Effect): void;
  120436. /**
  120437. * Sets the current effect wrapper to use during draw.
  120438. * The effect needs to be ready before calling this api.
  120439. * This also sets the default full screen position attribute.
  120440. * @param effectWrapper Defines the effect to draw with
  120441. */
  120442. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  120443. /**
  120444. * Draws a full screen quad.
  120445. */
  120446. draw(): void;
  120447. /**
  120448. * renders one or more effects to a specified texture
  120449. * @param effectWrappers list of effects to renderer
  120450. * @param outputTexture texture to draw to, if null it will render to the screen
  120451. */
  120452. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  120453. /**
  120454. * Disposes of the effect renderer
  120455. */
  120456. dispose(): void;
  120457. }
  120458. /**
  120459. * Options to create an EffectWrapper
  120460. */
  120461. interface EffectWrapperCreationOptions {
  120462. /**
  120463. * Engine to use to create the effect
  120464. */
  120465. engine: Engine;
  120466. /**
  120467. * Fragment shader for the effect
  120468. */
  120469. fragmentShader: string;
  120470. /**
  120471. * Vertex shader for the effect
  120472. */
  120473. vertexShader?: string;
  120474. /**
  120475. * Attributes to use in the shader
  120476. */
  120477. attributeNames?: Array<string>;
  120478. /**
  120479. * Uniforms to use in the shader
  120480. */
  120481. uniformNames?: Array<string>;
  120482. /**
  120483. * Texture sampler names to use in the shader
  120484. */
  120485. samplerNames?: Array<string>;
  120486. /**
  120487. * The friendly name of the effect displayed in Spector.
  120488. */
  120489. name?: string;
  120490. }
  120491. /**
  120492. * Wraps an effect to be used for rendering
  120493. */
  120494. export class EffectWrapper {
  120495. /**
  120496. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  120497. */
  120498. onApplyObservable: Observable<{}>;
  120499. /**
  120500. * The underlying effect
  120501. */
  120502. effect: Effect;
  120503. /**
  120504. * Creates an effect to be renderer
  120505. * @param creationOptions options to create the effect
  120506. */
  120507. constructor(creationOptions: EffectWrapperCreationOptions);
  120508. /**
  120509. * Disposes of the effect wrapper
  120510. */
  120511. dispose(): void;
  120512. }
  120513. }
  120514. declare module BABYLON {
  120515. /**
  120516. * Helper class to push actions to a pool of workers.
  120517. */
  120518. export class WorkerPool implements IDisposable {
  120519. private _workerInfos;
  120520. private _pendingActions;
  120521. /**
  120522. * Constructor
  120523. * @param workers Array of workers to use for actions
  120524. */
  120525. constructor(workers: Array<Worker>);
  120526. /**
  120527. * Terminates all workers and clears any pending actions.
  120528. */
  120529. dispose(): void;
  120530. /**
  120531. * Pushes an action to the worker pool. If all the workers are active, the action will be
  120532. * pended until a worker has completed its action.
  120533. * @param action The action to perform. Call onComplete when the action is complete.
  120534. */
  120535. push(action: (worker: Worker, onComplete: () => void) => void): void;
  120536. private _execute;
  120537. }
  120538. }
  120539. declare module BABYLON {
  120540. /**
  120541. * Configuration for Draco compression
  120542. */
  120543. export interface IDracoCompressionConfiguration {
  120544. /**
  120545. * Configuration for the decoder.
  120546. */
  120547. decoder: {
  120548. /**
  120549. * The url to the WebAssembly module.
  120550. */
  120551. wasmUrl?: string;
  120552. /**
  120553. * The url to the WebAssembly binary.
  120554. */
  120555. wasmBinaryUrl?: string;
  120556. /**
  120557. * The url to the fallback JavaScript module.
  120558. */
  120559. fallbackUrl?: string;
  120560. };
  120561. }
  120562. /**
  120563. * Draco compression (https://google.github.io/draco/)
  120564. *
  120565. * This class wraps the Draco module.
  120566. *
  120567. * **Encoder**
  120568. *
  120569. * The encoder is not currently implemented.
  120570. *
  120571. * **Decoder**
  120572. *
  120573. * 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.
  120574. *
  120575. * To update the configuration, use the following code:
  120576. * ```javascript
  120577. * DracoCompression.Configuration = {
  120578. * decoder: {
  120579. * wasmUrl: "<url to the WebAssembly library>",
  120580. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  120581. * fallbackUrl: "<url to the fallback JavaScript library>",
  120582. * }
  120583. * };
  120584. * ```
  120585. *
  120586. * 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.
  120587. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  120588. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  120589. *
  120590. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  120591. * ```javascript
  120592. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  120593. * ```
  120594. *
  120595. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  120596. */
  120597. export class DracoCompression implements IDisposable {
  120598. private _workerPoolPromise?;
  120599. private _decoderModulePromise?;
  120600. /**
  120601. * The configuration. Defaults to the following urls:
  120602. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  120603. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  120604. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  120605. */
  120606. static Configuration: IDracoCompressionConfiguration;
  120607. /**
  120608. * Returns true if the decoder configuration is available.
  120609. */
  120610. static readonly DecoderAvailable: boolean;
  120611. /**
  120612. * Default number of workers to create when creating the draco compression object.
  120613. */
  120614. static DefaultNumWorkers: number;
  120615. private static GetDefaultNumWorkers;
  120616. private static _Default;
  120617. /**
  120618. * Default instance for the draco compression object.
  120619. */
  120620. static readonly Default: DracoCompression;
  120621. /**
  120622. * Constructor
  120623. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  120624. */
  120625. constructor(numWorkers?: number);
  120626. /**
  120627. * Stop all async operations and release resources.
  120628. */
  120629. dispose(): void;
  120630. /**
  120631. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  120632. * @returns a promise that resolves when ready
  120633. */
  120634. whenReadyAsync(): Promise<void>;
  120635. /**
  120636. * Decode Draco compressed mesh data to vertex data.
  120637. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  120638. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  120639. * @returns A promise that resolves with the decoded vertex data
  120640. */
  120641. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  120642. [kind: string]: number;
  120643. }): Promise<VertexData>;
  120644. }
  120645. }
  120646. declare module BABYLON {
  120647. /**
  120648. * Class for building Constructive Solid Geometry
  120649. */
  120650. export class CSG {
  120651. private polygons;
  120652. /**
  120653. * The world matrix
  120654. */
  120655. matrix: Matrix;
  120656. /**
  120657. * Stores the position
  120658. */
  120659. position: Vector3;
  120660. /**
  120661. * Stores the rotation
  120662. */
  120663. rotation: Vector3;
  120664. /**
  120665. * Stores the rotation quaternion
  120666. */
  120667. rotationQuaternion: Nullable<Quaternion>;
  120668. /**
  120669. * Stores the scaling vector
  120670. */
  120671. scaling: Vector3;
  120672. /**
  120673. * Convert the Mesh to CSG
  120674. * @param mesh The Mesh to convert to CSG
  120675. * @returns A new CSG from the Mesh
  120676. */
  120677. static FromMesh(mesh: Mesh): CSG;
  120678. /**
  120679. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  120680. * @param polygons Polygons used to construct a CSG solid
  120681. */
  120682. private static FromPolygons;
  120683. /**
  120684. * Clones, or makes a deep copy, of the CSG
  120685. * @returns A new CSG
  120686. */
  120687. clone(): CSG;
  120688. /**
  120689. * Unions this CSG with another CSG
  120690. * @param csg The CSG to union against this CSG
  120691. * @returns The unioned CSG
  120692. */
  120693. union(csg: CSG): CSG;
  120694. /**
  120695. * Unions this CSG with another CSG in place
  120696. * @param csg The CSG to union against this CSG
  120697. */
  120698. unionInPlace(csg: CSG): void;
  120699. /**
  120700. * Subtracts this CSG with another CSG
  120701. * @param csg The CSG to subtract against this CSG
  120702. * @returns A new CSG
  120703. */
  120704. subtract(csg: CSG): CSG;
  120705. /**
  120706. * Subtracts this CSG with another CSG in place
  120707. * @param csg The CSG to subtact against this CSG
  120708. */
  120709. subtractInPlace(csg: CSG): void;
  120710. /**
  120711. * Intersect this CSG with another CSG
  120712. * @param csg The CSG to intersect against this CSG
  120713. * @returns A new CSG
  120714. */
  120715. intersect(csg: CSG): CSG;
  120716. /**
  120717. * Intersects this CSG with another CSG in place
  120718. * @param csg The CSG to intersect against this CSG
  120719. */
  120720. intersectInPlace(csg: CSG): void;
  120721. /**
  120722. * Return a new CSG solid with solid and empty space switched. This solid is
  120723. * not modified.
  120724. * @returns A new CSG solid with solid and empty space switched
  120725. */
  120726. inverse(): CSG;
  120727. /**
  120728. * Inverses the CSG in place
  120729. */
  120730. inverseInPlace(): void;
  120731. /**
  120732. * This is used to keep meshes transformations so they can be restored
  120733. * when we build back a Babylon Mesh
  120734. * NB : All CSG operations are performed in world coordinates
  120735. * @param csg The CSG to copy the transform attributes from
  120736. * @returns This CSG
  120737. */
  120738. copyTransformAttributes(csg: CSG): CSG;
  120739. /**
  120740. * Build Raw mesh from CSG
  120741. * Coordinates here are in world space
  120742. * @param name The name of the mesh geometry
  120743. * @param scene The Scene
  120744. * @param keepSubMeshes Specifies if the submeshes should be kept
  120745. * @returns A new Mesh
  120746. */
  120747. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  120748. /**
  120749. * Build Mesh from CSG taking material and transforms into account
  120750. * @param name The name of the Mesh
  120751. * @param material The material of the Mesh
  120752. * @param scene The Scene
  120753. * @param keepSubMeshes Specifies if submeshes should be kept
  120754. * @returns The new Mesh
  120755. */
  120756. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  120757. }
  120758. }
  120759. declare module BABYLON {
  120760. /**
  120761. * Class used to create a trail following a mesh
  120762. */
  120763. export class TrailMesh extends Mesh {
  120764. private _generator;
  120765. private _autoStart;
  120766. private _running;
  120767. private _diameter;
  120768. private _length;
  120769. private _sectionPolygonPointsCount;
  120770. private _sectionVectors;
  120771. private _sectionNormalVectors;
  120772. private _beforeRenderObserver;
  120773. /**
  120774. * @constructor
  120775. * @param name The value used by scene.getMeshByName() to do a lookup.
  120776. * @param generator The mesh to generate a trail.
  120777. * @param scene The scene to add this mesh to.
  120778. * @param diameter Diameter of trailing mesh. Default is 1.
  120779. * @param length Length of trailing mesh. Default is 60.
  120780. * @param autoStart Automatically start trailing mesh. Default true.
  120781. */
  120782. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  120783. /**
  120784. * "TrailMesh"
  120785. * @returns "TrailMesh"
  120786. */
  120787. getClassName(): string;
  120788. private _createMesh;
  120789. /**
  120790. * Start trailing mesh.
  120791. */
  120792. start(): void;
  120793. /**
  120794. * Stop trailing mesh.
  120795. */
  120796. stop(): void;
  120797. /**
  120798. * Update trailing mesh geometry.
  120799. */
  120800. update(): void;
  120801. /**
  120802. * Returns a new TrailMesh object.
  120803. * @param name is a string, the name given to the new mesh
  120804. * @param newGenerator use new generator object for cloned trail mesh
  120805. * @returns a new mesh
  120806. */
  120807. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  120808. /**
  120809. * Serializes this trail mesh
  120810. * @param serializationObject object to write serialization to
  120811. */
  120812. serialize(serializationObject: any): void;
  120813. /**
  120814. * Parses a serialized trail mesh
  120815. * @param parsedMesh the serialized mesh
  120816. * @param scene the scene to create the trail mesh in
  120817. * @returns the created trail mesh
  120818. */
  120819. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  120820. }
  120821. }
  120822. declare module BABYLON {
  120823. /**
  120824. * Class containing static functions to help procedurally build meshes
  120825. */
  120826. export class TiledBoxBuilder {
  120827. /**
  120828. * Creates a box mesh
  120829. * 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)
  120830. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  120831. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120832. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120833. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120834. * @param name defines the name of the mesh
  120835. * @param options defines the options used to create the mesh
  120836. * @param scene defines the hosting scene
  120837. * @returns the box mesh
  120838. */
  120839. static CreateTiledBox(name: string, options: {
  120840. pattern?: number;
  120841. width?: number;
  120842. height?: number;
  120843. depth?: number;
  120844. tileSize?: number;
  120845. tileWidth?: number;
  120846. tileHeight?: number;
  120847. alignHorizontal?: number;
  120848. alignVertical?: number;
  120849. faceUV?: Vector4[];
  120850. faceColors?: Color4[];
  120851. sideOrientation?: number;
  120852. updatable?: boolean;
  120853. }, scene?: Nullable<Scene>): Mesh;
  120854. }
  120855. }
  120856. declare module BABYLON {
  120857. /**
  120858. * Class containing static functions to help procedurally build meshes
  120859. */
  120860. export class TorusKnotBuilder {
  120861. /**
  120862. * Creates a torus knot mesh
  120863. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  120864. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  120865. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  120866. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  120867. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120868. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120869. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  120870. * @param name defines the name of the mesh
  120871. * @param options defines the options used to create the mesh
  120872. * @param scene defines the hosting scene
  120873. * @returns the torus knot mesh
  120874. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  120875. */
  120876. static CreateTorusKnot(name: string, options: {
  120877. radius?: number;
  120878. tube?: number;
  120879. radialSegments?: number;
  120880. tubularSegments?: number;
  120881. p?: number;
  120882. q?: number;
  120883. updatable?: boolean;
  120884. sideOrientation?: number;
  120885. frontUVs?: Vector4;
  120886. backUVs?: Vector4;
  120887. }, scene: any): Mesh;
  120888. }
  120889. }
  120890. declare module BABYLON {
  120891. /**
  120892. * Polygon
  120893. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  120894. */
  120895. export class Polygon {
  120896. /**
  120897. * Creates a rectangle
  120898. * @param xmin bottom X coord
  120899. * @param ymin bottom Y coord
  120900. * @param xmax top X coord
  120901. * @param ymax top Y coord
  120902. * @returns points that make the resulting rectation
  120903. */
  120904. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  120905. /**
  120906. * Creates a circle
  120907. * @param radius radius of circle
  120908. * @param cx scale in x
  120909. * @param cy scale in y
  120910. * @param numberOfSides number of sides that make up the circle
  120911. * @returns points that make the resulting circle
  120912. */
  120913. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  120914. /**
  120915. * Creates a polygon from input string
  120916. * @param input Input polygon data
  120917. * @returns the parsed points
  120918. */
  120919. static Parse(input: string): Vector2[];
  120920. /**
  120921. * Starts building a polygon from x and y coordinates
  120922. * @param x x coordinate
  120923. * @param y y coordinate
  120924. * @returns the started path2
  120925. */
  120926. static StartingAt(x: number, y: number): Path2;
  120927. }
  120928. /**
  120929. * Builds a polygon
  120930. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  120931. */
  120932. export class PolygonMeshBuilder {
  120933. private _points;
  120934. private _outlinepoints;
  120935. private _holes;
  120936. private _name;
  120937. private _scene;
  120938. private _epoints;
  120939. private _eholes;
  120940. private _addToepoint;
  120941. /**
  120942. * Babylon reference to the earcut plugin.
  120943. */
  120944. bjsEarcut: any;
  120945. /**
  120946. * Creates a PolygonMeshBuilder
  120947. * @param name name of the builder
  120948. * @param contours Path of the polygon
  120949. * @param scene scene to add to when creating the mesh
  120950. * @param earcutInjection can be used to inject your own earcut reference
  120951. */
  120952. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  120953. /**
  120954. * Adds a whole within the polygon
  120955. * @param hole Array of points defining the hole
  120956. * @returns this
  120957. */
  120958. addHole(hole: Vector2[]): PolygonMeshBuilder;
  120959. /**
  120960. * Creates the polygon
  120961. * @param updatable If the mesh should be updatable
  120962. * @param depth The depth of the mesh created
  120963. * @returns the created mesh
  120964. */
  120965. build(updatable?: boolean, depth?: number): Mesh;
  120966. /**
  120967. * Creates the polygon
  120968. * @param depth The depth of the mesh created
  120969. * @returns the created VertexData
  120970. */
  120971. buildVertexData(depth?: number): VertexData;
  120972. /**
  120973. * Adds a side to the polygon
  120974. * @param positions points that make the polygon
  120975. * @param normals normals of the polygon
  120976. * @param uvs uvs of the polygon
  120977. * @param indices indices of the polygon
  120978. * @param bounds bounds of the polygon
  120979. * @param points points of the polygon
  120980. * @param depth depth of the polygon
  120981. * @param flip flip of the polygon
  120982. */
  120983. private addSide;
  120984. }
  120985. }
  120986. declare module BABYLON {
  120987. /**
  120988. * Class containing static functions to help procedurally build meshes
  120989. */
  120990. export class PolygonBuilder {
  120991. /**
  120992. * Creates a polygon mesh
  120993. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  120994. * * 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
  120995. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  120996. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120997. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  120998. * * Remember you can only change the shape positions, not their number when updating a polygon
  120999. * @param name defines the name of the mesh
  121000. * @param options defines the options used to create the mesh
  121001. * @param scene defines the hosting scene
  121002. * @param earcutInjection can be used to inject your own earcut reference
  121003. * @returns the polygon mesh
  121004. */
  121005. static CreatePolygon(name: string, options: {
  121006. shape: Vector3[];
  121007. holes?: Vector3[][];
  121008. depth?: number;
  121009. faceUV?: Vector4[];
  121010. faceColors?: Color4[];
  121011. updatable?: boolean;
  121012. sideOrientation?: number;
  121013. frontUVs?: Vector4;
  121014. backUVs?: Vector4;
  121015. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  121016. /**
  121017. * Creates an extruded polygon mesh, with depth in the Y direction.
  121018. * * 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)
  121019. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  121020. * @param name defines the name of the mesh
  121021. * @param options defines the options used to create the mesh
  121022. * @param scene defines the hosting scene
  121023. * @param earcutInjection can be used to inject your own earcut reference
  121024. * @returns the polygon mesh
  121025. */
  121026. static ExtrudePolygon(name: string, options: {
  121027. shape: Vector3[];
  121028. holes?: Vector3[][];
  121029. depth?: number;
  121030. faceUV?: Vector4[];
  121031. faceColors?: Color4[];
  121032. updatable?: boolean;
  121033. sideOrientation?: number;
  121034. frontUVs?: Vector4;
  121035. backUVs?: Vector4;
  121036. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  121037. }
  121038. }
  121039. declare module BABYLON {
  121040. /**
  121041. * Class containing static functions to help procedurally build meshes
  121042. */
  121043. export class LatheBuilder {
  121044. /**
  121045. * Creates lathe mesh.
  121046. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  121047. * * 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
  121048. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  121049. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  121050. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  121051. * * 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
  121052. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  121053. * * 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
  121054. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121055. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121056. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121057. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121058. * @param name defines the name of the mesh
  121059. * @param options defines the options used to create the mesh
  121060. * @param scene defines the hosting scene
  121061. * @returns the lathe mesh
  121062. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  121063. */
  121064. static CreateLathe(name: string, options: {
  121065. shape: Vector3[];
  121066. radius?: number;
  121067. tessellation?: number;
  121068. clip?: number;
  121069. arc?: number;
  121070. closed?: boolean;
  121071. updatable?: boolean;
  121072. sideOrientation?: number;
  121073. frontUVs?: Vector4;
  121074. backUVs?: Vector4;
  121075. cap?: number;
  121076. invertUV?: boolean;
  121077. }, scene?: Nullable<Scene>): Mesh;
  121078. }
  121079. }
  121080. declare module BABYLON {
  121081. /**
  121082. * Class containing static functions to help procedurally build meshes
  121083. */
  121084. export class TiledPlaneBuilder {
  121085. /**
  121086. * Creates a tiled plane mesh
  121087. * * The parameter `pattern` will, depending on value, do nothing or
  121088. * * * flip (reflect about central vertical) alternate tiles across and up
  121089. * * * flip every tile on alternate rows
  121090. * * * rotate (180 degs) alternate tiles across and up
  121091. * * * rotate every tile on alternate rows
  121092. * * * flip and rotate alternate tiles across and up
  121093. * * * flip and rotate every tile on alternate rows
  121094. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  121095. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  121096. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121097. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  121098. * * 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)
  121099. * * 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)
  121100. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  121101. * @param name defines the name of the mesh
  121102. * @param options defines the options used to create the mesh
  121103. * @param scene defines the hosting scene
  121104. * @returns the box mesh
  121105. */
  121106. static CreateTiledPlane(name: string, options: {
  121107. pattern?: number;
  121108. tileSize?: number;
  121109. tileWidth?: number;
  121110. tileHeight?: number;
  121111. size?: number;
  121112. width?: number;
  121113. height?: number;
  121114. alignHorizontal?: number;
  121115. alignVertical?: number;
  121116. sideOrientation?: number;
  121117. frontUVs?: Vector4;
  121118. backUVs?: Vector4;
  121119. updatable?: boolean;
  121120. }, scene?: Nullable<Scene>): Mesh;
  121121. }
  121122. }
  121123. declare module BABYLON {
  121124. /**
  121125. * Class containing static functions to help procedurally build meshes
  121126. */
  121127. export class TubeBuilder {
  121128. /**
  121129. * Creates a tube mesh.
  121130. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  121131. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  121132. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  121133. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  121134. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  121135. * * 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)
  121136. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  121137. * * 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
  121138. * * 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
  121139. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121140. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121141. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121142. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121143. * @param name defines the name of the mesh
  121144. * @param options defines the options used to create the mesh
  121145. * @param scene defines the hosting scene
  121146. * @returns the tube mesh
  121147. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121148. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  121149. */
  121150. static CreateTube(name: string, options: {
  121151. path: Vector3[];
  121152. radius?: number;
  121153. tessellation?: number;
  121154. radiusFunction?: {
  121155. (i: number, distance: number): number;
  121156. };
  121157. cap?: number;
  121158. arc?: number;
  121159. updatable?: boolean;
  121160. sideOrientation?: number;
  121161. frontUVs?: Vector4;
  121162. backUVs?: Vector4;
  121163. instance?: Mesh;
  121164. invertUV?: boolean;
  121165. }, scene?: Nullable<Scene>): Mesh;
  121166. }
  121167. }
  121168. declare module BABYLON {
  121169. /**
  121170. * Class containing static functions to help procedurally build meshes
  121171. */
  121172. export class IcoSphereBuilder {
  121173. /**
  121174. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  121175. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  121176. * * 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`)
  121177. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  121178. * * 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
  121179. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121180. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121181. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121182. * @param name defines the name of the mesh
  121183. * @param options defines the options used to create the mesh
  121184. * @param scene defines the hosting scene
  121185. * @returns the icosahedron mesh
  121186. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  121187. */
  121188. static CreateIcoSphere(name: string, options: {
  121189. radius?: number;
  121190. radiusX?: number;
  121191. radiusY?: number;
  121192. radiusZ?: number;
  121193. flat?: boolean;
  121194. subdivisions?: number;
  121195. sideOrientation?: number;
  121196. frontUVs?: Vector4;
  121197. backUVs?: Vector4;
  121198. updatable?: boolean;
  121199. }, scene?: Nullable<Scene>): Mesh;
  121200. }
  121201. }
  121202. declare module BABYLON {
  121203. /**
  121204. * Class containing static functions to help procedurally build meshes
  121205. */
  121206. export class DecalBuilder {
  121207. /**
  121208. * Creates a decal mesh.
  121209. * 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
  121210. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  121211. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  121212. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  121213. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  121214. * @param name defines the name of the mesh
  121215. * @param sourceMesh defines the mesh where the decal must be applied
  121216. * @param options defines the options used to create the mesh
  121217. * @param scene defines the hosting scene
  121218. * @returns the decal mesh
  121219. * @see https://doc.babylonjs.com/how_to/decals
  121220. */
  121221. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  121222. position?: Vector3;
  121223. normal?: Vector3;
  121224. size?: Vector3;
  121225. angle?: number;
  121226. }): Mesh;
  121227. }
  121228. }
  121229. declare module BABYLON {
  121230. /**
  121231. * Class containing static functions to help procedurally build meshes
  121232. */
  121233. export class MeshBuilder {
  121234. /**
  121235. * Creates a box mesh
  121236. * * The parameter `size` sets the size (float) of each box side (default 1)
  121237. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  121238. * * 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)
  121239. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  121240. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121241. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121242. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121243. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  121244. * @param name defines the name of the mesh
  121245. * @param options defines the options used to create the mesh
  121246. * @param scene defines the hosting scene
  121247. * @returns the box mesh
  121248. */
  121249. static CreateBox(name: string, options: {
  121250. size?: number;
  121251. width?: number;
  121252. height?: number;
  121253. depth?: number;
  121254. faceUV?: Vector4[];
  121255. faceColors?: Color4[];
  121256. sideOrientation?: number;
  121257. frontUVs?: Vector4;
  121258. backUVs?: Vector4;
  121259. updatable?: boolean;
  121260. }, scene?: Nullable<Scene>): Mesh;
  121261. /**
  121262. * Creates a tiled box mesh
  121263. * * faceTiles sets the pattern, tile size and number of tiles for a face
  121264. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121265. * @param name defines the name of the mesh
  121266. * @param options defines the options used to create the mesh
  121267. * @param scene defines the hosting scene
  121268. * @returns the tiled box mesh
  121269. */
  121270. static CreateTiledBox(name: string, options: {
  121271. pattern?: number;
  121272. size?: number;
  121273. width?: number;
  121274. height?: number;
  121275. depth: number;
  121276. tileSize?: number;
  121277. tileWidth?: number;
  121278. tileHeight?: number;
  121279. faceUV?: Vector4[];
  121280. faceColors?: Color4[];
  121281. alignHorizontal?: number;
  121282. alignVertical?: number;
  121283. sideOrientation?: number;
  121284. updatable?: boolean;
  121285. }, scene?: Nullable<Scene>): Mesh;
  121286. /**
  121287. * Creates a sphere mesh
  121288. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  121289. * * 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`)
  121290. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  121291. * * 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
  121292. * * 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)
  121293. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121294. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121295. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121296. * @param name defines the name of the mesh
  121297. * @param options defines the options used to create the mesh
  121298. * @param scene defines the hosting scene
  121299. * @returns the sphere mesh
  121300. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  121301. */
  121302. static CreateSphere(name: string, options: {
  121303. segments?: number;
  121304. diameter?: number;
  121305. diameterX?: number;
  121306. diameterY?: number;
  121307. diameterZ?: number;
  121308. arc?: number;
  121309. slice?: number;
  121310. sideOrientation?: number;
  121311. frontUVs?: Vector4;
  121312. backUVs?: Vector4;
  121313. updatable?: boolean;
  121314. }, scene?: Nullable<Scene>): Mesh;
  121315. /**
  121316. * Creates a plane polygonal mesh. By default, this is a disc
  121317. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  121318. * * 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
  121319. * * 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
  121320. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121321. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121322. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121323. * @param name defines the name of the mesh
  121324. * @param options defines the options used to create the mesh
  121325. * @param scene defines the hosting scene
  121326. * @returns the plane polygonal mesh
  121327. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  121328. */
  121329. static CreateDisc(name: string, options: {
  121330. radius?: number;
  121331. tessellation?: number;
  121332. arc?: number;
  121333. updatable?: boolean;
  121334. sideOrientation?: number;
  121335. frontUVs?: Vector4;
  121336. backUVs?: Vector4;
  121337. }, scene?: Nullable<Scene>): Mesh;
  121338. /**
  121339. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  121340. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  121341. * * 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`)
  121342. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  121343. * * 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
  121344. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121345. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121346. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121347. * @param name defines the name of the mesh
  121348. * @param options defines the options used to create the mesh
  121349. * @param scene defines the hosting scene
  121350. * @returns the icosahedron mesh
  121351. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  121352. */
  121353. static CreateIcoSphere(name: string, options: {
  121354. radius?: number;
  121355. radiusX?: number;
  121356. radiusY?: number;
  121357. radiusZ?: number;
  121358. flat?: boolean;
  121359. subdivisions?: number;
  121360. sideOrientation?: number;
  121361. frontUVs?: Vector4;
  121362. backUVs?: Vector4;
  121363. updatable?: boolean;
  121364. }, scene?: Nullable<Scene>): Mesh;
  121365. /**
  121366. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  121367. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  121368. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  121369. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  121370. * * 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
  121371. * * 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
  121372. * * 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
  121373. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121374. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121375. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121376. * * 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
  121377. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  121378. * * 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
  121379. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  121380. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121381. * @param name defines the name of the mesh
  121382. * @param options defines the options used to create the mesh
  121383. * @param scene defines the hosting scene
  121384. * @returns the ribbon mesh
  121385. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  121386. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121387. */
  121388. static CreateRibbon(name: string, options: {
  121389. pathArray: Vector3[][];
  121390. closeArray?: boolean;
  121391. closePath?: boolean;
  121392. offset?: number;
  121393. updatable?: boolean;
  121394. sideOrientation?: number;
  121395. frontUVs?: Vector4;
  121396. backUVs?: Vector4;
  121397. instance?: Mesh;
  121398. invertUV?: boolean;
  121399. uvs?: Vector2[];
  121400. colors?: Color4[];
  121401. }, scene?: Nullable<Scene>): Mesh;
  121402. /**
  121403. * Creates a cylinder or a cone mesh
  121404. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  121405. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  121406. * * 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.
  121407. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  121408. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  121409. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  121410. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  121411. * * 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).
  121412. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  121413. * * 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).
  121414. * * 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
  121415. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  121416. * * 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
  121417. * * 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.
  121418. * * If `enclose` is false, a ring surface is one element.
  121419. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  121420. * * 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
  121421. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121422. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121423. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121424. * @param name defines the name of the mesh
  121425. * @param options defines the options used to create the mesh
  121426. * @param scene defines the hosting scene
  121427. * @returns the cylinder mesh
  121428. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  121429. */
  121430. static CreateCylinder(name: string, options: {
  121431. height?: number;
  121432. diameterTop?: number;
  121433. diameterBottom?: number;
  121434. diameter?: number;
  121435. tessellation?: number;
  121436. subdivisions?: number;
  121437. arc?: number;
  121438. faceColors?: Color4[];
  121439. faceUV?: Vector4[];
  121440. updatable?: boolean;
  121441. hasRings?: boolean;
  121442. enclose?: boolean;
  121443. cap?: number;
  121444. sideOrientation?: number;
  121445. frontUVs?: Vector4;
  121446. backUVs?: Vector4;
  121447. }, scene?: Nullable<Scene>): Mesh;
  121448. /**
  121449. * Creates a torus mesh
  121450. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  121451. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  121452. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  121453. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121454. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121455. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121456. * @param name defines the name of the mesh
  121457. * @param options defines the options used to create the mesh
  121458. * @param scene defines the hosting scene
  121459. * @returns the torus mesh
  121460. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  121461. */
  121462. static CreateTorus(name: string, options: {
  121463. diameter?: number;
  121464. thickness?: number;
  121465. tessellation?: number;
  121466. updatable?: boolean;
  121467. sideOrientation?: number;
  121468. frontUVs?: Vector4;
  121469. backUVs?: Vector4;
  121470. }, scene?: Nullable<Scene>): Mesh;
  121471. /**
  121472. * Creates a torus knot mesh
  121473. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  121474. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  121475. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  121476. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  121477. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121478. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121479. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121480. * @param name defines the name of the mesh
  121481. * @param options defines the options used to create the mesh
  121482. * @param scene defines the hosting scene
  121483. * @returns the torus knot mesh
  121484. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  121485. */
  121486. static CreateTorusKnot(name: string, options: {
  121487. radius?: number;
  121488. tube?: number;
  121489. radialSegments?: number;
  121490. tubularSegments?: number;
  121491. p?: number;
  121492. q?: number;
  121493. updatable?: boolean;
  121494. sideOrientation?: number;
  121495. frontUVs?: Vector4;
  121496. backUVs?: Vector4;
  121497. }, scene?: Nullable<Scene>): Mesh;
  121498. /**
  121499. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  121500. * * 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
  121501. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  121502. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  121503. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  121504. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  121505. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  121506. * * 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
  121507. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  121508. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121509. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  121510. * @param name defines the name of the new line system
  121511. * @param options defines the options used to create the line system
  121512. * @param scene defines the hosting scene
  121513. * @returns a new line system mesh
  121514. */
  121515. static CreateLineSystem(name: string, options: {
  121516. lines: Vector3[][];
  121517. updatable?: boolean;
  121518. instance?: Nullable<LinesMesh>;
  121519. colors?: Nullable<Color4[][]>;
  121520. useVertexAlpha?: boolean;
  121521. }, scene: Nullable<Scene>): LinesMesh;
  121522. /**
  121523. * Creates a line mesh
  121524. * 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
  121525. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  121526. * * The parameter `points` is an array successive Vector3
  121527. * * 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
  121528. * * The optional parameter `colors` is an array of successive Color4, one per line point
  121529. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  121530. * * When updating an instance, remember that only point positions can change, not the number of points
  121531. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121532. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  121533. * @param name defines the name of the new line system
  121534. * @param options defines the options used to create the line system
  121535. * @param scene defines the hosting scene
  121536. * @returns a new line mesh
  121537. */
  121538. static CreateLines(name: string, options: {
  121539. points: Vector3[];
  121540. updatable?: boolean;
  121541. instance?: Nullable<LinesMesh>;
  121542. colors?: Color4[];
  121543. useVertexAlpha?: boolean;
  121544. }, scene?: Nullable<Scene>): LinesMesh;
  121545. /**
  121546. * Creates a dashed line mesh
  121547. * * 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
  121548. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  121549. * * The parameter `points` is an array successive Vector3
  121550. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  121551. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  121552. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  121553. * * 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
  121554. * * When updating an instance, remember that only point positions can change, not the number of points
  121555. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121556. * @param name defines the name of the mesh
  121557. * @param options defines the options used to create the mesh
  121558. * @param scene defines the hosting scene
  121559. * @returns the dashed line mesh
  121560. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  121561. */
  121562. static CreateDashedLines(name: string, options: {
  121563. points: Vector3[];
  121564. dashSize?: number;
  121565. gapSize?: number;
  121566. dashNb?: number;
  121567. updatable?: boolean;
  121568. instance?: LinesMesh;
  121569. }, scene?: Nullable<Scene>): LinesMesh;
  121570. /**
  121571. * 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.
  121572. * * 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.
  121573. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  121574. * * 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.
  121575. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  121576. * * 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
  121577. * * 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
  121578. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  121579. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121580. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121581. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  121582. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121583. * @param name defines the name of the mesh
  121584. * @param options defines the options used to create the mesh
  121585. * @param scene defines the hosting scene
  121586. * @returns the extruded shape mesh
  121587. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121588. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  121589. */
  121590. static ExtrudeShape(name: string, options: {
  121591. shape: Vector3[];
  121592. path: Vector3[];
  121593. scale?: number;
  121594. rotation?: number;
  121595. cap?: number;
  121596. updatable?: boolean;
  121597. sideOrientation?: number;
  121598. frontUVs?: Vector4;
  121599. backUVs?: Vector4;
  121600. instance?: Mesh;
  121601. invertUV?: boolean;
  121602. }, scene?: Nullable<Scene>): Mesh;
  121603. /**
  121604. * Creates an custom extruded shape mesh.
  121605. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  121606. * * 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.
  121607. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  121608. * * 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
  121609. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  121610. * * 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
  121611. * * It must returns a float value that will be the scale value applied to the shape on each path point
  121612. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  121613. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  121614. * * 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
  121615. * * 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
  121616. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  121617. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121618. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121619. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121620. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121621. * @param name defines the name of the mesh
  121622. * @param options defines the options used to create the mesh
  121623. * @param scene defines the hosting scene
  121624. * @returns the custom extruded shape mesh
  121625. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  121626. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121627. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  121628. */
  121629. static ExtrudeShapeCustom(name: string, options: {
  121630. shape: Vector3[];
  121631. path: Vector3[];
  121632. scaleFunction?: any;
  121633. rotationFunction?: any;
  121634. ribbonCloseArray?: boolean;
  121635. ribbonClosePath?: boolean;
  121636. cap?: number;
  121637. updatable?: boolean;
  121638. sideOrientation?: number;
  121639. frontUVs?: Vector4;
  121640. backUVs?: Vector4;
  121641. instance?: Mesh;
  121642. invertUV?: boolean;
  121643. }, scene?: Nullable<Scene>): Mesh;
  121644. /**
  121645. * Creates lathe mesh.
  121646. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  121647. * * 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
  121648. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  121649. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  121650. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  121651. * * 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
  121652. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  121653. * * 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
  121654. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121655. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121656. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121657. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121658. * @param name defines the name of the mesh
  121659. * @param options defines the options used to create the mesh
  121660. * @param scene defines the hosting scene
  121661. * @returns the lathe mesh
  121662. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  121663. */
  121664. static CreateLathe(name: string, options: {
  121665. shape: Vector3[];
  121666. radius?: number;
  121667. tessellation?: number;
  121668. clip?: number;
  121669. arc?: number;
  121670. closed?: boolean;
  121671. updatable?: boolean;
  121672. sideOrientation?: number;
  121673. frontUVs?: Vector4;
  121674. backUVs?: Vector4;
  121675. cap?: number;
  121676. invertUV?: boolean;
  121677. }, scene?: Nullable<Scene>): Mesh;
  121678. /**
  121679. * Creates a tiled plane mesh
  121680. * * You can set a limited pattern arrangement with the tiles
  121681. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121682. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121683. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121684. * @param name defines the name of the mesh
  121685. * @param options defines the options used to create the mesh
  121686. * @param scene defines the hosting scene
  121687. * @returns the plane mesh
  121688. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  121689. */
  121690. static CreateTiledPlane(name: string, options: {
  121691. pattern?: number;
  121692. tileSize?: number;
  121693. tileWidth?: number;
  121694. tileHeight?: number;
  121695. size?: number;
  121696. width?: number;
  121697. height?: number;
  121698. alignHorizontal?: number;
  121699. alignVertical?: number;
  121700. sideOrientation?: number;
  121701. frontUVs?: Vector4;
  121702. backUVs?: Vector4;
  121703. updatable?: boolean;
  121704. }, scene?: Nullable<Scene>): Mesh;
  121705. /**
  121706. * Creates a plane mesh
  121707. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  121708. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  121709. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  121710. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121711. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121712. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121713. * @param name defines the name of the mesh
  121714. * @param options defines the options used to create the mesh
  121715. * @param scene defines the hosting scene
  121716. * @returns the plane mesh
  121717. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  121718. */
  121719. static CreatePlane(name: string, options: {
  121720. size?: number;
  121721. width?: number;
  121722. height?: number;
  121723. sideOrientation?: number;
  121724. frontUVs?: Vector4;
  121725. backUVs?: Vector4;
  121726. updatable?: boolean;
  121727. sourcePlane?: Plane;
  121728. }, scene?: Nullable<Scene>): Mesh;
  121729. /**
  121730. * Creates a ground mesh
  121731. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  121732. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  121733. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121734. * @param name defines the name of the mesh
  121735. * @param options defines the options used to create the mesh
  121736. * @param scene defines the hosting scene
  121737. * @returns the ground mesh
  121738. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  121739. */
  121740. static CreateGround(name: string, options: {
  121741. width?: number;
  121742. height?: number;
  121743. subdivisions?: number;
  121744. subdivisionsX?: number;
  121745. subdivisionsY?: number;
  121746. updatable?: boolean;
  121747. }, scene?: Nullable<Scene>): Mesh;
  121748. /**
  121749. * Creates a tiled ground mesh
  121750. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  121751. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  121752. * * 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
  121753. * * 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
  121754. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121755. * @param name defines the name of the mesh
  121756. * @param options defines the options used to create the mesh
  121757. * @param scene defines the hosting scene
  121758. * @returns the tiled ground mesh
  121759. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  121760. */
  121761. static CreateTiledGround(name: string, options: {
  121762. xmin: number;
  121763. zmin: number;
  121764. xmax: number;
  121765. zmax: number;
  121766. subdivisions?: {
  121767. w: number;
  121768. h: number;
  121769. };
  121770. precision?: {
  121771. w: number;
  121772. h: number;
  121773. };
  121774. updatable?: boolean;
  121775. }, scene?: Nullable<Scene>): Mesh;
  121776. /**
  121777. * Creates a ground mesh from a height map
  121778. * * The parameter `url` sets the URL of the height map image resource.
  121779. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  121780. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  121781. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  121782. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  121783. * * 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.
  121784. * * 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).
  121785. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  121786. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121787. * @param name defines the name of the mesh
  121788. * @param url defines the url to the height map
  121789. * @param options defines the options used to create the mesh
  121790. * @param scene defines the hosting scene
  121791. * @returns the ground mesh
  121792. * @see https://doc.babylonjs.com/babylon101/height_map
  121793. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  121794. */
  121795. static CreateGroundFromHeightMap(name: string, url: string, options: {
  121796. width?: number;
  121797. height?: number;
  121798. subdivisions?: number;
  121799. minHeight?: number;
  121800. maxHeight?: number;
  121801. colorFilter?: Color3;
  121802. alphaFilter?: number;
  121803. updatable?: boolean;
  121804. onReady?: (mesh: GroundMesh) => void;
  121805. }, scene?: Nullable<Scene>): GroundMesh;
  121806. /**
  121807. * Creates a polygon mesh
  121808. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  121809. * * 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
  121810. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  121811. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121812. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  121813. * * Remember you can only change the shape positions, not their number when updating a polygon
  121814. * @param name defines the name of the mesh
  121815. * @param options defines the options used to create the mesh
  121816. * @param scene defines the hosting scene
  121817. * @param earcutInjection can be used to inject your own earcut reference
  121818. * @returns the polygon mesh
  121819. */
  121820. static CreatePolygon(name: string, options: {
  121821. shape: Vector3[];
  121822. holes?: Vector3[][];
  121823. depth?: number;
  121824. faceUV?: Vector4[];
  121825. faceColors?: Color4[];
  121826. updatable?: boolean;
  121827. sideOrientation?: number;
  121828. frontUVs?: Vector4;
  121829. backUVs?: Vector4;
  121830. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  121831. /**
  121832. * Creates an extruded polygon mesh, with depth in the Y direction.
  121833. * * 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)
  121834. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  121835. * @param name defines the name of the mesh
  121836. * @param options defines the options used to create the mesh
  121837. * @param scene defines the hosting scene
  121838. * @param earcutInjection can be used to inject your own earcut reference
  121839. * @returns the polygon mesh
  121840. */
  121841. static ExtrudePolygon(name: string, options: {
  121842. shape: Vector3[];
  121843. holes?: Vector3[][];
  121844. depth?: number;
  121845. faceUV?: Vector4[];
  121846. faceColors?: Color4[];
  121847. updatable?: boolean;
  121848. sideOrientation?: number;
  121849. frontUVs?: Vector4;
  121850. backUVs?: Vector4;
  121851. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  121852. /**
  121853. * Creates a tube mesh.
  121854. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  121855. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  121856. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  121857. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  121858. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  121859. * * 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)
  121860. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  121861. * * 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
  121862. * * 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
  121863. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121864. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121865. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121866. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121867. * @param name defines the name of the mesh
  121868. * @param options defines the options used to create the mesh
  121869. * @param scene defines the hosting scene
  121870. * @returns the tube mesh
  121871. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121872. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  121873. */
  121874. static CreateTube(name: string, options: {
  121875. path: Vector3[];
  121876. radius?: number;
  121877. tessellation?: number;
  121878. radiusFunction?: {
  121879. (i: number, distance: number): number;
  121880. };
  121881. cap?: number;
  121882. arc?: number;
  121883. updatable?: boolean;
  121884. sideOrientation?: number;
  121885. frontUVs?: Vector4;
  121886. backUVs?: Vector4;
  121887. instance?: Mesh;
  121888. invertUV?: boolean;
  121889. }, scene?: Nullable<Scene>): Mesh;
  121890. /**
  121891. * Creates a polyhedron mesh
  121892. * * 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
  121893. * * The parameter `size` (positive float, default 1) sets the polygon size
  121894. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  121895. * * 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`
  121896. * * 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
  121897. * * 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)`)
  121898. * * 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
  121899. * * 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
  121900. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121901. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121902. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121903. * @param name defines the name of the mesh
  121904. * @param options defines the options used to create the mesh
  121905. * @param scene defines the hosting scene
  121906. * @returns the polyhedron mesh
  121907. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  121908. */
  121909. static CreatePolyhedron(name: string, options: {
  121910. type?: number;
  121911. size?: number;
  121912. sizeX?: number;
  121913. sizeY?: number;
  121914. sizeZ?: number;
  121915. custom?: any;
  121916. faceUV?: Vector4[];
  121917. faceColors?: Color4[];
  121918. flat?: boolean;
  121919. updatable?: boolean;
  121920. sideOrientation?: number;
  121921. frontUVs?: Vector4;
  121922. backUVs?: Vector4;
  121923. }, scene?: Nullable<Scene>): Mesh;
  121924. /**
  121925. * Creates a decal mesh.
  121926. * 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
  121927. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  121928. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  121929. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  121930. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  121931. * @param name defines the name of the mesh
  121932. * @param sourceMesh defines the mesh where the decal must be applied
  121933. * @param options defines the options used to create the mesh
  121934. * @param scene defines the hosting scene
  121935. * @returns the decal mesh
  121936. * @see https://doc.babylonjs.com/how_to/decals
  121937. */
  121938. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  121939. position?: Vector3;
  121940. normal?: Vector3;
  121941. size?: Vector3;
  121942. angle?: number;
  121943. }): Mesh;
  121944. }
  121945. }
  121946. declare module BABYLON {
  121947. /**
  121948. * A simplifier interface for future simplification implementations
  121949. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  121950. */
  121951. export interface ISimplifier {
  121952. /**
  121953. * Simplification of a given mesh according to the given settings.
  121954. * Since this requires computation, it is assumed that the function runs async.
  121955. * @param settings The settings of the simplification, including quality and distance
  121956. * @param successCallback A callback that will be called after the mesh was simplified.
  121957. * @param errorCallback in case of an error, this callback will be called. optional.
  121958. */
  121959. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  121960. }
  121961. /**
  121962. * Expected simplification settings.
  121963. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  121964. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  121965. */
  121966. export interface ISimplificationSettings {
  121967. /**
  121968. * Gets or sets the expected quality
  121969. */
  121970. quality: number;
  121971. /**
  121972. * Gets or sets the distance when this optimized version should be used
  121973. */
  121974. distance: number;
  121975. /**
  121976. * Gets an already optimized mesh
  121977. */
  121978. optimizeMesh?: boolean;
  121979. }
  121980. /**
  121981. * Class used to specify simplification options
  121982. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  121983. */
  121984. export class SimplificationSettings implements ISimplificationSettings {
  121985. /** expected quality */
  121986. quality: number;
  121987. /** distance when this optimized version should be used */
  121988. distance: number;
  121989. /** already optimized mesh */
  121990. optimizeMesh?: boolean | undefined;
  121991. /**
  121992. * Creates a SimplificationSettings
  121993. * @param quality expected quality
  121994. * @param distance distance when this optimized version should be used
  121995. * @param optimizeMesh already optimized mesh
  121996. */
  121997. constructor(
  121998. /** expected quality */
  121999. quality: number,
  122000. /** distance when this optimized version should be used */
  122001. distance: number,
  122002. /** already optimized mesh */
  122003. optimizeMesh?: boolean | undefined);
  122004. }
  122005. /**
  122006. * Interface used to define a simplification task
  122007. */
  122008. export interface ISimplificationTask {
  122009. /**
  122010. * Array of settings
  122011. */
  122012. settings: Array<ISimplificationSettings>;
  122013. /**
  122014. * Simplification type
  122015. */
  122016. simplificationType: SimplificationType;
  122017. /**
  122018. * Mesh to simplify
  122019. */
  122020. mesh: Mesh;
  122021. /**
  122022. * Callback called on success
  122023. */
  122024. successCallback?: () => void;
  122025. /**
  122026. * Defines if parallel processing can be used
  122027. */
  122028. parallelProcessing: boolean;
  122029. }
  122030. /**
  122031. * Queue used to order the simplification tasks
  122032. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  122033. */
  122034. export class SimplificationQueue {
  122035. private _simplificationArray;
  122036. /**
  122037. * Gets a boolean indicating that the process is still running
  122038. */
  122039. running: boolean;
  122040. /**
  122041. * Creates a new queue
  122042. */
  122043. constructor();
  122044. /**
  122045. * Adds a new simplification task
  122046. * @param task defines a task to add
  122047. */
  122048. addTask(task: ISimplificationTask): void;
  122049. /**
  122050. * Execute next task
  122051. */
  122052. executeNext(): void;
  122053. /**
  122054. * Execute a simplification task
  122055. * @param task defines the task to run
  122056. */
  122057. runSimplification(task: ISimplificationTask): void;
  122058. private getSimplifier;
  122059. }
  122060. /**
  122061. * The implemented types of simplification
  122062. * At the moment only Quadratic Error Decimation is implemented
  122063. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  122064. */
  122065. export enum SimplificationType {
  122066. /** Quadratic error decimation */
  122067. QUADRATIC = 0
  122068. }
  122069. }
  122070. declare module BABYLON {
  122071. interface Scene {
  122072. /** @hidden (Backing field) */
  122073. _simplificationQueue: SimplificationQueue;
  122074. /**
  122075. * Gets or sets the simplification queue attached to the scene
  122076. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  122077. */
  122078. simplificationQueue: SimplificationQueue;
  122079. }
  122080. interface Mesh {
  122081. /**
  122082. * Simplify the mesh according to the given array of settings.
  122083. * Function will return immediately and will simplify async
  122084. * @param settings a collection of simplification settings
  122085. * @param parallelProcessing should all levels calculate parallel or one after the other
  122086. * @param simplificationType the type of simplification to run
  122087. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  122088. * @returns the current mesh
  122089. */
  122090. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  122091. }
  122092. /**
  122093. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  122094. * created in a scene
  122095. */
  122096. export class SimplicationQueueSceneComponent implements ISceneComponent {
  122097. /**
  122098. * The component name helpfull to identify the component in the list of scene components.
  122099. */
  122100. readonly name: string;
  122101. /**
  122102. * The scene the component belongs to.
  122103. */
  122104. scene: Scene;
  122105. /**
  122106. * Creates a new instance of the component for the given scene
  122107. * @param scene Defines the scene to register the component in
  122108. */
  122109. constructor(scene: Scene);
  122110. /**
  122111. * Registers the component in a given scene
  122112. */
  122113. register(): void;
  122114. /**
  122115. * Rebuilds the elements related to this component in case of
  122116. * context lost for instance.
  122117. */
  122118. rebuild(): void;
  122119. /**
  122120. * Disposes the component and the associated ressources
  122121. */
  122122. dispose(): void;
  122123. private _beforeCameraUpdate;
  122124. }
  122125. }
  122126. declare module BABYLON {
  122127. /**
  122128. * Navigation plugin interface to add navigation constrained by a navigation mesh
  122129. */
  122130. export interface INavigationEnginePlugin {
  122131. /**
  122132. * plugin name
  122133. */
  122134. name: string;
  122135. /**
  122136. * Creates a navigation mesh
  122137. * @param meshes array of all the geometry used to compute the navigatio mesh
  122138. * @param parameters bunch of parameters used to filter geometry
  122139. */
  122140. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  122141. /**
  122142. * Create a navigation mesh debug mesh
  122143. * @param scene is where the mesh will be added
  122144. * @returns debug display mesh
  122145. */
  122146. createDebugNavMesh(scene: Scene): Mesh;
  122147. /**
  122148. * Get a navigation mesh constrained position, closest to the parameter position
  122149. * @param position world position
  122150. * @returns the closest point to position constrained by the navigation mesh
  122151. */
  122152. getClosestPoint(position: Vector3): Vector3;
  122153. /**
  122154. * Get a navigation mesh constrained position, within a particular radius
  122155. * @param position world position
  122156. * @param maxRadius the maximum distance to the constrained world position
  122157. * @returns the closest point to position constrained by the navigation mesh
  122158. */
  122159. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  122160. /**
  122161. * Compute the final position from a segment made of destination-position
  122162. * @param position world position
  122163. * @param destination world position
  122164. * @returns the resulting point along the navmesh
  122165. */
  122166. moveAlong(position: Vector3, destination: Vector3): Vector3;
  122167. /**
  122168. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  122169. * @param start world position
  122170. * @param end world position
  122171. * @returns array containing world position composing the path
  122172. */
  122173. computePath(start: Vector3, end: Vector3): Vector3[];
  122174. /**
  122175. * If this plugin is supported
  122176. * @returns true if plugin is supported
  122177. */
  122178. isSupported(): boolean;
  122179. /**
  122180. * Create a new Crowd so you can add agents
  122181. * @param maxAgents the maximum agent count in the crowd
  122182. * @param maxAgentRadius the maximum radius an agent can have
  122183. * @param scene to attach the crowd to
  122184. * @returns the crowd you can add agents to
  122185. */
  122186. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  122187. /**
  122188. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  122189. * The queries will try to find a solution within those bounds
  122190. * default is (1,1,1)
  122191. * @param extent x,y,z value that define the extent around the queries point of reference
  122192. */
  122193. setDefaultQueryExtent(extent: Vector3): void;
  122194. /**
  122195. * Get the Bounding box extent specified by setDefaultQueryExtent
  122196. * @returns the box extent values
  122197. */
  122198. getDefaultQueryExtent(): Vector3;
  122199. /**
  122200. * Release all resources
  122201. */
  122202. dispose(): void;
  122203. }
  122204. /**
  122205. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  122206. */
  122207. export interface ICrowd {
  122208. /**
  122209. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  122210. * You can attach anything to that node. The node position is updated in the scene update tick.
  122211. * @param pos world position that will be constrained by the navigation mesh
  122212. * @param parameters agent parameters
  122213. * @param transform hooked to the agent that will be update by the scene
  122214. * @returns agent index
  122215. */
  122216. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  122217. /**
  122218. * Returns the agent position in world space
  122219. * @param index agent index returned by addAgent
  122220. * @returns world space position
  122221. */
  122222. getAgentPosition(index: number): Vector3;
  122223. /**
  122224. * Gets the agent velocity in world space
  122225. * @param index agent index returned by addAgent
  122226. * @returns world space velocity
  122227. */
  122228. getAgentVelocity(index: number): Vector3;
  122229. /**
  122230. * remove a particular agent previously created
  122231. * @param index agent index returned by addAgent
  122232. */
  122233. removeAgent(index: number): void;
  122234. /**
  122235. * get the list of all agents attached to this crowd
  122236. * @returns list of agent indices
  122237. */
  122238. getAgents(): number[];
  122239. /**
  122240. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  122241. * @param deltaTime in seconds
  122242. */
  122243. update(deltaTime: number): void;
  122244. /**
  122245. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  122246. * @param index agent index returned by addAgent
  122247. * @param destination targeted world position
  122248. */
  122249. agentGoto(index: number, destination: Vector3): void;
  122250. /**
  122251. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  122252. * The queries will try to find a solution within those bounds
  122253. * default is (1,1,1)
  122254. * @param extent x,y,z value that define the extent around the queries point of reference
  122255. */
  122256. setDefaultQueryExtent(extent: Vector3): void;
  122257. /**
  122258. * Get the Bounding box extent specified by setDefaultQueryExtent
  122259. * @returns the box extent values
  122260. */
  122261. getDefaultQueryExtent(): Vector3;
  122262. /**
  122263. * Release all resources
  122264. */
  122265. dispose(): void;
  122266. }
  122267. /**
  122268. * Configures an agent
  122269. */
  122270. export interface IAgentParameters {
  122271. /**
  122272. * Agent radius. [Limit: >= 0]
  122273. */
  122274. radius: number;
  122275. /**
  122276. * Agent height. [Limit: > 0]
  122277. */
  122278. height: number;
  122279. /**
  122280. * Maximum allowed acceleration. [Limit: >= 0]
  122281. */
  122282. maxAcceleration: number;
  122283. /**
  122284. * Maximum allowed speed. [Limit: >= 0]
  122285. */
  122286. maxSpeed: number;
  122287. /**
  122288. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  122289. */
  122290. collisionQueryRange: number;
  122291. /**
  122292. * The path visibility optimization range. [Limit: > 0]
  122293. */
  122294. pathOptimizationRange: number;
  122295. /**
  122296. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  122297. */
  122298. separationWeight: number;
  122299. }
  122300. /**
  122301. * Configures the navigation mesh creation
  122302. */
  122303. export interface INavMeshParameters {
  122304. /**
  122305. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  122306. */
  122307. cs: number;
  122308. /**
  122309. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  122310. */
  122311. ch: number;
  122312. /**
  122313. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  122314. */
  122315. walkableSlopeAngle: number;
  122316. /**
  122317. * Minimum floor to 'ceiling' height that will still allow the floor area to
  122318. * be considered walkable. [Limit: >= 3] [Units: vx]
  122319. */
  122320. walkableHeight: number;
  122321. /**
  122322. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  122323. */
  122324. walkableClimb: number;
  122325. /**
  122326. * The distance to erode/shrink the walkable area of the heightfield away from
  122327. * obstructions. [Limit: >=0] [Units: vx]
  122328. */
  122329. walkableRadius: number;
  122330. /**
  122331. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  122332. */
  122333. maxEdgeLen: number;
  122334. /**
  122335. * The maximum distance a simplfied contour's border edges should deviate
  122336. * the original raw contour. [Limit: >=0] [Units: vx]
  122337. */
  122338. maxSimplificationError: number;
  122339. /**
  122340. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  122341. */
  122342. minRegionArea: number;
  122343. /**
  122344. * Any regions with a span count smaller than this value will, if possible,
  122345. * be merged with larger regions. [Limit: >=0] [Units: vx]
  122346. */
  122347. mergeRegionArea: number;
  122348. /**
  122349. * The maximum number of vertices allowed for polygons generated during the
  122350. * contour to polygon conversion process. [Limit: >= 3]
  122351. */
  122352. maxVertsPerPoly: number;
  122353. /**
  122354. * Sets the sampling distance to use when generating the detail mesh.
  122355. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  122356. */
  122357. detailSampleDist: number;
  122358. /**
  122359. * The maximum distance the detail mesh surface should deviate from heightfield
  122360. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  122361. */
  122362. detailSampleMaxError: number;
  122363. }
  122364. }
  122365. declare module BABYLON {
  122366. /**
  122367. * RecastJS navigation plugin
  122368. */
  122369. export class RecastJSPlugin implements INavigationEnginePlugin {
  122370. /**
  122371. * Reference to the Recast library
  122372. */
  122373. bjsRECAST: any;
  122374. /**
  122375. * plugin name
  122376. */
  122377. name: string;
  122378. /**
  122379. * the first navmesh created. We might extend this to support multiple navmeshes
  122380. */
  122381. navMesh: any;
  122382. /**
  122383. * Initializes the recastJS plugin
  122384. * @param recastInjection can be used to inject your own recast reference
  122385. */
  122386. constructor(recastInjection?: any);
  122387. /**
  122388. * Creates a navigation mesh
  122389. * @param meshes array of all the geometry used to compute the navigatio mesh
  122390. * @param parameters bunch of parameters used to filter geometry
  122391. */
  122392. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  122393. /**
  122394. * Create a navigation mesh debug mesh
  122395. * @param scene is where the mesh will be added
  122396. * @returns debug display mesh
  122397. */
  122398. createDebugNavMesh(scene: Scene): Mesh;
  122399. /**
  122400. * Get a navigation mesh constrained position, closest to the parameter position
  122401. * @param position world position
  122402. * @returns the closest point to position constrained by the navigation mesh
  122403. */
  122404. getClosestPoint(position: Vector3): Vector3;
  122405. /**
  122406. * Get a navigation mesh constrained position, within a particular radius
  122407. * @param position world position
  122408. * @param maxRadius the maximum distance to the constrained world position
  122409. * @returns the closest point to position constrained by the navigation mesh
  122410. */
  122411. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  122412. /**
  122413. * Compute the final position from a segment made of destination-position
  122414. * @param position world position
  122415. * @param destination world position
  122416. * @returns the resulting point along the navmesh
  122417. */
  122418. moveAlong(position: Vector3, destination: Vector3): Vector3;
  122419. /**
  122420. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  122421. * @param start world position
  122422. * @param end world position
  122423. * @returns array containing world position composing the path
  122424. */
  122425. computePath(start: Vector3, end: Vector3): Vector3[];
  122426. /**
  122427. * Create a new Crowd so you can add agents
  122428. * @param maxAgents the maximum agent count in the crowd
  122429. * @param maxAgentRadius the maximum radius an agent can have
  122430. * @param scene to attach the crowd to
  122431. * @returns the crowd you can add agents to
  122432. */
  122433. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  122434. /**
  122435. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  122436. * The queries will try to find a solution within those bounds
  122437. * default is (1,1,1)
  122438. * @param extent x,y,z value that define the extent around the queries point of reference
  122439. */
  122440. setDefaultQueryExtent(extent: Vector3): void;
  122441. /**
  122442. * Get the Bounding box extent specified by setDefaultQueryExtent
  122443. * @returns the box extent values
  122444. */
  122445. getDefaultQueryExtent(): Vector3;
  122446. /**
  122447. * Disposes
  122448. */
  122449. dispose(): void;
  122450. /**
  122451. * If this plugin is supported
  122452. * @returns true if plugin is supported
  122453. */
  122454. isSupported(): boolean;
  122455. }
  122456. /**
  122457. * Recast detour crowd implementation
  122458. */
  122459. export class RecastJSCrowd implements ICrowd {
  122460. /**
  122461. * Recast/detour plugin
  122462. */
  122463. bjsRECASTPlugin: RecastJSPlugin;
  122464. /**
  122465. * Link to the detour crowd
  122466. */
  122467. recastCrowd: any;
  122468. /**
  122469. * One transform per agent
  122470. */
  122471. transforms: TransformNode[];
  122472. /**
  122473. * All agents created
  122474. */
  122475. agents: number[];
  122476. /**
  122477. * Link to the scene is kept to unregister the crowd from the scene
  122478. */
  122479. private _scene;
  122480. /**
  122481. * Observer for crowd updates
  122482. */
  122483. private _onBeforeAnimationsObserver;
  122484. /**
  122485. * Constructor
  122486. * @param plugin recastJS plugin
  122487. * @param maxAgents the maximum agent count in the crowd
  122488. * @param maxAgentRadius the maximum radius an agent can have
  122489. * @param scene to attach the crowd to
  122490. * @returns the crowd you can add agents to
  122491. */
  122492. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  122493. /**
  122494. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  122495. * You can attach anything to that node. The node position is updated in the scene update tick.
  122496. * @param pos world position that will be constrained by the navigation mesh
  122497. * @param parameters agent parameters
  122498. * @param transform hooked to the agent that will be update by the scene
  122499. * @returns agent index
  122500. */
  122501. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  122502. /**
  122503. * Returns the agent position in world space
  122504. * @param index agent index returned by addAgent
  122505. * @returns world space position
  122506. */
  122507. getAgentPosition(index: number): Vector3;
  122508. /**
  122509. * Returns the agent velocity in world space
  122510. * @param index agent index returned by addAgent
  122511. * @returns world space velocity
  122512. */
  122513. getAgentVelocity(index: number): Vector3;
  122514. /**
  122515. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  122516. * @param index agent index returned by addAgent
  122517. * @param destination targeted world position
  122518. */
  122519. agentGoto(index: number, destination: Vector3): void;
  122520. /**
  122521. * remove a particular agent previously created
  122522. * @param index agent index returned by addAgent
  122523. */
  122524. removeAgent(index: number): void;
  122525. /**
  122526. * get the list of all agents attached to this crowd
  122527. * @returns list of agent indices
  122528. */
  122529. getAgents(): number[];
  122530. /**
  122531. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  122532. * @param deltaTime in seconds
  122533. */
  122534. update(deltaTime: number): void;
  122535. /**
  122536. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  122537. * The queries will try to find a solution within those bounds
  122538. * default is (1,1,1)
  122539. * @param extent x,y,z value that define the extent around the queries point of reference
  122540. */
  122541. setDefaultQueryExtent(extent: Vector3): void;
  122542. /**
  122543. * Get the Bounding box extent specified by setDefaultQueryExtent
  122544. * @returns the box extent values
  122545. */
  122546. getDefaultQueryExtent(): Vector3;
  122547. /**
  122548. * Release all resources
  122549. */
  122550. dispose(): void;
  122551. }
  122552. }
  122553. declare module BABYLON {
  122554. /**
  122555. * Class used to enable access to IndexedDB
  122556. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  122557. */
  122558. export class Database implements IOfflineProvider {
  122559. private _callbackManifestChecked;
  122560. private _currentSceneUrl;
  122561. private _db;
  122562. private _enableSceneOffline;
  122563. private _enableTexturesOffline;
  122564. private _manifestVersionFound;
  122565. private _mustUpdateRessources;
  122566. private _hasReachedQuota;
  122567. private _isSupported;
  122568. private _idbFactory;
  122569. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  122570. private static IsUASupportingBlobStorage;
  122571. /**
  122572. * Gets a boolean indicating if Database storate is enabled (off by default)
  122573. */
  122574. static IDBStorageEnabled: boolean;
  122575. /**
  122576. * Gets a boolean indicating if scene must be saved in the database
  122577. */
  122578. readonly enableSceneOffline: boolean;
  122579. /**
  122580. * Gets a boolean indicating if textures must be saved in the database
  122581. */
  122582. readonly enableTexturesOffline: boolean;
  122583. /**
  122584. * Creates a new Database
  122585. * @param urlToScene defines the url to load the scene
  122586. * @param callbackManifestChecked defines the callback to use when manifest is checked
  122587. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  122588. */
  122589. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  122590. private static _ParseURL;
  122591. private static _ReturnFullUrlLocation;
  122592. private _checkManifestFile;
  122593. /**
  122594. * Open the database and make it available
  122595. * @param successCallback defines the callback to call on success
  122596. * @param errorCallback defines the callback to call on error
  122597. */
  122598. open(successCallback: () => void, errorCallback: () => void): void;
  122599. /**
  122600. * Loads an image from the database
  122601. * @param url defines the url to load from
  122602. * @param image defines the target DOM image
  122603. */
  122604. loadImage(url: string, image: HTMLImageElement): void;
  122605. private _loadImageFromDBAsync;
  122606. private _saveImageIntoDBAsync;
  122607. private _checkVersionFromDB;
  122608. private _loadVersionFromDBAsync;
  122609. private _saveVersionIntoDBAsync;
  122610. /**
  122611. * Loads a file from database
  122612. * @param url defines the URL to load from
  122613. * @param sceneLoaded defines a callback to call on success
  122614. * @param progressCallBack defines a callback to call when progress changed
  122615. * @param errorCallback defines a callback to call on error
  122616. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  122617. */
  122618. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  122619. private _loadFileAsync;
  122620. private _saveFileAsync;
  122621. /**
  122622. * Validates if xhr data is correct
  122623. * @param xhr defines the request to validate
  122624. * @param dataType defines the expected data type
  122625. * @returns true if data is correct
  122626. */
  122627. private static _ValidateXHRData;
  122628. }
  122629. }
  122630. declare module BABYLON {
  122631. /** @hidden */
  122632. export var gpuUpdateParticlesPixelShader: {
  122633. name: string;
  122634. shader: string;
  122635. };
  122636. }
  122637. declare module BABYLON {
  122638. /** @hidden */
  122639. export var gpuUpdateParticlesVertexShader: {
  122640. name: string;
  122641. shader: string;
  122642. };
  122643. }
  122644. declare module BABYLON {
  122645. /** @hidden */
  122646. export var clipPlaneFragmentDeclaration2: {
  122647. name: string;
  122648. shader: string;
  122649. };
  122650. }
  122651. declare module BABYLON {
  122652. /** @hidden */
  122653. export var gpuRenderParticlesPixelShader: {
  122654. name: string;
  122655. shader: string;
  122656. };
  122657. }
  122658. declare module BABYLON {
  122659. /** @hidden */
  122660. export var clipPlaneVertexDeclaration2: {
  122661. name: string;
  122662. shader: string;
  122663. };
  122664. }
  122665. declare module BABYLON {
  122666. /** @hidden */
  122667. export var gpuRenderParticlesVertexShader: {
  122668. name: string;
  122669. shader: string;
  122670. };
  122671. }
  122672. declare module BABYLON {
  122673. /**
  122674. * This represents a GPU particle system in Babylon
  122675. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  122676. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  122677. */
  122678. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  122679. /**
  122680. * The layer mask we are rendering the particles through.
  122681. */
  122682. layerMask: number;
  122683. private _capacity;
  122684. private _activeCount;
  122685. private _currentActiveCount;
  122686. private _accumulatedCount;
  122687. private _renderEffect;
  122688. private _updateEffect;
  122689. private _buffer0;
  122690. private _buffer1;
  122691. private _spriteBuffer;
  122692. private _updateVAO;
  122693. private _renderVAO;
  122694. private _targetIndex;
  122695. private _sourceBuffer;
  122696. private _targetBuffer;
  122697. private _engine;
  122698. private _currentRenderId;
  122699. private _started;
  122700. private _stopped;
  122701. private _timeDelta;
  122702. private _randomTexture;
  122703. private _randomTexture2;
  122704. private _attributesStrideSize;
  122705. private _updateEffectOptions;
  122706. private _randomTextureSize;
  122707. private _actualFrame;
  122708. private readonly _rawTextureWidth;
  122709. /**
  122710. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  122711. */
  122712. static readonly IsSupported: boolean;
  122713. /**
  122714. * An event triggered when the system is disposed.
  122715. */
  122716. onDisposeObservable: Observable<GPUParticleSystem>;
  122717. /**
  122718. * Gets the maximum number of particles active at the same time.
  122719. * @returns The max number of active particles.
  122720. */
  122721. getCapacity(): number;
  122722. /**
  122723. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  122724. * to override the particles.
  122725. */
  122726. forceDepthWrite: boolean;
  122727. /**
  122728. * Gets or set the number of active particles
  122729. */
  122730. activeParticleCount: number;
  122731. private _preWarmDone;
  122732. /**
  122733. * Is this system ready to be used/rendered
  122734. * @return true if the system is ready
  122735. */
  122736. isReady(): boolean;
  122737. /**
  122738. * Gets if the system has been started. (Note: this will still be true after stop is called)
  122739. * @returns True if it has been started, otherwise false.
  122740. */
  122741. isStarted(): boolean;
  122742. /**
  122743. * Starts the particle system and begins to emit
  122744. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  122745. */
  122746. start(delay?: number): void;
  122747. /**
  122748. * Stops the particle system.
  122749. */
  122750. stop(): void;
  122751. /**
  122752. * Remove all active particles
  122753. */
  122754. reset(): void;
  122755. /**
  122756. * Returns the string "GPUParticleSystem"
  122757. * @returns a string containing the class name
  122758. */
  122759. getClassName(): string;
  122760. private _colorGradientsTexture;
  122761. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  122762. /**
  122763. * Adds a new color gradient
  122764. * @param gradient defines the gradient to use (between 0 and 1)
  122765. * @param color1 defines the color to affect to the specified gradient
  122766. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  122767. * @returns the current particle system
  122768. */
  122769. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  122770. /**
  122771. * Remove a specific color gradient
  122772. * @param gradient defines the gradient to remove
  122773. * @returns the current particle system
  122774. */
  122775. removeColorGradient(gradient: number): GPUParticleSystem;
  122776. private _angularSpeedGradientsTexture;
  122777. private _sizeGradientsTexture;
  122778. private _velocityGradientsTexture;
  122779. private _limitVelocityGradientsTexture;
  122780. private _dragGradientsTexture;
  122781. private _addFactorGradient;
  122782. /**
  122783. * Adds a new size gradient
  122784. * @param gradient defines the gradient to use (between 0 and 1)
  122785. * @param factor defines the size factor to affect to the specified gradient
  122786. * @returns the current particle system
  122787. */
  122788. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  122789. /**
  122790. * Remove a specific size gradient
  122791. * @param gradient defines the gradient to remove
  122792. * @returns the current particle system
  122793. */
  122794. removeSizeGradient(gradient: number): GPUParticleSystem;
  122795. /**
  122796. * Adds a new angular speed gradient
  122797. * @param gradient defines the gradient to use (between 0 and 1)
  122798. * @param factor defines the angular speed to affect to the specified gradient
  122799. * @returns the current particle system
  122800. */
  122801. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  122802. /**
  122803. * Remove a specific angular speed gradient
  122804. * @param gradient defines the gradient to remove
  122805. * @returns the current particle system
  122806. */
  122807. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  122808. /**
  122809. * Adds a new velocity gradient
  122810. * @param gradient defines the gradient to use (between 0 and 1)
  122811. * @param factor defines the velocity to affect to the specified gradient
  122812. * @returns the current particle system
  122813. */
  122814. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  122815. /**
  122816. * Remove a specific velocity gradient
  122817. * @param gradient defines the gradient to remove
  122818. * @returns the current particle system
  122819. */
  122820. removeVelocityGradient(gradient: number): GPUParticleSystem;
  122821. /**
  122822. * Adds a new limit velocity gradient
  122823. * @param gradient defines the gradient to use (between 0 and 1)
  122824. * @param factor defines the limit velocity value to affect to the specified gradient
  122825. * @returns the current particle system
  122826. */
  122827. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  122828. /**
  122829. * Remove a specific limit velocity gradient
  122830. * @param gradient defines the gradient to remove
  122831. * @returns the current particle system
  122832. */
  122833. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  122834. /**
  122835. * Adds a new drag gradient
  122836. * @param gradient defines the gradient to use (between 0 and 1)
  122837. * @param factor defines the drag value to affect to the specified gradient
  122838. * @returns the current particle system
  122839. */
  122840. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  122841. /**
  122842. * Remove a specific drag gradient
  122843. * @param gradient defines the gradient to remove
  122844. * @returns the current particle system
  122845. */
  122846. removeDragGradient(gradient: number): GPUParticleSystem;
  122847. /**
  122848. * Not supported by GPUParticleSystem
  122849. * @param gradient defines the gradient to use (between 0 and 1)
  122850. * @param factor defines the emit rate value to affect to the specified gradient
  122851. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  122852. * @returns the current particle system
  122853. */
  122854. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  122855. /**
  122856. * Not supported by GPUParticleSystem
  122857. * @param gradient defines the gradient to remove
  122858. * @returns the current particle system
  122859. */
  122860. removeEmitRateGradient(gradient: number): IParticleSystem;
  122861. /**
  122862. * Not supported by GPUParticleSystem
  122863. * @param gradient defines the gradient to use (between 0 and 1)
  122864. * @param factor defines the start size value to affect to the specified gradient
  122865. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  122866. * @returns the current particle system
  122867. */
  122868. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  122869. /**
  122870. * Not supported by GPUParticleSystem
  122871. * @param gradient defines the gradient to remove
  122872. * @returns the current particle system
  122873. */
  122874. removeStartSizeGradient(gradient: number): IParticleSystem;
  122875. /**
  122876. * Not supported by GPUParticleSystem
  122877. * @param gradient defines the gradient to use (between 0 and 1)
  122878. * @param min defines the color remap minimal range
  122879. * @param max defines the color remap maximal range
  122880. * @returns the current particle system
  122881. */
  122882. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  122883. /**
  122884. * Not supported by GPUParticleSystem
  122885. * @param gradient defines the gradient to remove
  122886. * @returns the current particle system
  122887. */
  122888. removeColorRemapGradient(): IParticleSystem;
  122889. /**
  122890. * Not supported by GPUParticleSystem
  122891. * @param gradient defines the gradient to use (between 0 and 1)
  122892. * @param min defines the alpha remap minimal range
  122893. * @param max defines the alpha remap maximal range
  122894. * @returns the current particle system
  122895. */
  122896. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  122897. /**
  122898. * Not supported by GPUParticleSystem
  122899. * @param gradient defines the gradient to remove
  122900. * @returns the current particle system
  122901. */
  122902. removeAlphaRemapGradient(): IParticleSystem;
  122903. /**
  122904. * Not supported by GPUParticleSystem
  122905. * @param gradient defines the gradient to use (between 0 and 1)
  122906. * @param color defines the color to affect to the specified gradient
  122907. * @returns the current particle system
  122908. */
  122909. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  122910. /**
  122911. * Not supported by GPUParticleSystem
  122912. * @param gradient defines the gradient to remove
  122913. * @returns the current particle system
  122914. */
  122915. removeRampGradient(): IParticleSystem;
  122916. /**
  122917. * Not supported by GPUParticleSystem
  122918. * @returns the list of ramp gradients
  122919. */
  122920. getRampGradients(): Nullable<Array<Color3Gradient>>;
  122921. /**
  122922. * Not supported by GPUParticleSystem
  122923. * Gets or sets a boolean indicating that ramp gradients must be used
  122924. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  122925. */
  122926. useRampGradients: boolean;
  122927. /**
  122928. * Not supported by GPUParticleSystem
  122929. * @param gradient defines the gradient to use (between 0 and 1)
  122930. * @param factor defines the life time factor to affect to the specified gradient
  122931. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  122932. * @returns the current particle system
  122933. */
  122934. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  122935. /**
  122936. * Not supported by GPUParticleSystem
  122937. * @param gradient defines the gradient to remove
  122938. * @returns the current particle system
  122939. */
  122940. removeLifeTimeGradient(gradient: number): IParticleSystem;
  122941. /**
  122942. * Instantiates a GPU particle system.
  122943. * 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.
  122944. * @param name The name of the particle system
  122945. * @param options The options used to create the system
  122946. * @param scene The scene the particle system belongs to
  122947. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  122948. */
  122949. constructor(name: string, options: Partial<{
  122950. capacity: number;
  122951. randomTextureSize: number;
  122952. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  122953. protected _reset(): void;
  122954. private _createUpdateVAO;
  122955. private _createRenderVAO;
  122956. private _initialize;
  122957. /** @hidden */
  122958. _recreateUpdateEffect(): void;
  122959. /** @hidden */
  122960. _recreateRenderEffect(): void;
  122961. /**
  122962. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  122963. * @param preWarm defines if we are in the pre-warmimg phase
  122964. */
  122965. animate(preWarm?: boolean): void;
  122966. private _createFactorGradientTexture;
  122967. private _createSizeGradientTexture;
  122968. private _createAngularSpeedGradientTexture;
  122969. private _createVelocityGradientTexture;
  122970. private _createLimitVelocityGradientTexture;
  122971. private _createDragGradientTexture;
  122972. private _createColorGradientTexture;
  122973. /**
  122974. * Renders the particle system in its current state
  122975. * @param preWarm defines if the system should only update the particles but not render them
  122976. * @returns the current number of particles
  122977. */
  122978. render(preWarm?: boolean): number;
  122979. /**
  122980. * Rebuilds the particle system
  122981. */
  122982. rebuild(): void;
  122983. private _releaseBuffers;
  122984. private _releaseVAOs;
  122985. /**
  122986. * Disposes the particle system and free the associated resources
  122987. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  122988. */
  122989. dispose(disposeTexture?: boolean): void;
  122990. /**
  122991. * Clones the particle system.
  122992. * @param name The name of the cloned object
  122993. * @param newEmitter The new emitter to use
  122994. * @returns the cloned particle system
  122995. */
  122996. clone(name: string, newEmitter: any): GPUParticleSystem;
  122997. /**
  122998. * Serializes the particle system to a JSON object.
  122999. * @returns the JSON object
  123000. */
  123001. serialize(): any;
  123002. /**
  123003. * Parses a JSON object to create a GPU particle system.
  123004. * @param parsedParticleSystem The JSON object to parse
  123005. * @param scene The scene to create the particle system in
  123006. * @param rootUrl The root url to use to load external dependencies like texture
  123007. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  123008. * @returns the parsed GPU particle system
  123009. */
  123010. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  123011. }
  123012. }
  123013. declare module BABYLON {
  123014. /**
  123015. * Represents a set of particle systems working together to create a specific effect
  123016. */
  123017. export class ParticleSystemSet implements IDisposable {
  123018. private _emitterCreationOptions;
  123019. private _emitterNode;
  123020. /**
  123021. * Gets the particle system list
  123022. */
  123023. systems: IParticleSystem[];
  123024. /**
  123025. * Gets the emitter node used with this set
  123026. */
  123027. readonly emitterNode: Nullable<TransformNode>;
  123028. /**
  123029. * Creates a new emitter mesh as a sphere
  123030. * @param options defines the options used to create the sphere
  123031. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  123032. * @param scene defines the hosting scene
  123033. */
  123034. setEmitterAsSphere(options: {
  123035. diameter: number;
  123036. segments: number;
  123037. color: Color3;
  123038. }, renderingGroupId: number, scene: Scene): void;
  123039. /**
  123040. * Starts all particle systems of the set
  123041. * @param emitter defines an optional mesh to use as emitter for the particle systems
  123042. */
  123043. start(emitter?: AbstractMesh): void;
  123044. /**
  123045. * Release all associated resources
  123046. */
  123047. dispose(): void;
  123048. /**
  123049. * Serialize the set into a JSON compatible object
  123050. * @returns a JSON compatible representation of the set
  123051. */
  123052. serialize(): any;
  123053. /**
  123054. * Parse a new ParticleSystemSet from a serialized source
  123055. * @param data defines a JSON compatible representation of the set
  123056. * @param scene defines the hosting scene
  123057. * @param gpu defines if we want GPU particles or CPU particles
  123058. * @returns a new ParticleSystemSet
  123059. */
  123060. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  123061. }
  123062. }
  123063. declare module BABYLON {
  123064. /**
  123065. * This class is made for on one-liner static method to help creating particle system set.
  123066. */
  123067. export class ParticleHelper {
  123068. /**
  123069. * Gets or sets base Assets URL
  123070. */
  123071. static BaseAssetsUrl: string;
  123072. /**
  123073. * Create a default particle system that you can tweak
  123074. * @param emitter defines the emitter to use
  123075. * @param capacity defines the system capacity (default is 500 particles)
  123076. * @param scene defines the hosting scene
  123077. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  123078. * @returns the new Particle system
  123079. */
  123080. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  123081. /**
  123082. * This is the main static method (one-liner) of this helper to create different particle systems
  123083. * @param type This string represents the type to the particle system to create
  123084. * @param scene The scene where the particle system should live
  123085. * @param gpu If the system will use gpu
  123086. * @returns the ParticleSystemSet created
  123087. */
  123088. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  123089. /**
  123090. * Static function used to export a particle system to a ParticleSystemSet variable.
  123091. * Please note that the emitter shape is not exported
  123092. * @param systems defines the particle systems to export
  123093. * @returns the created particle system set
  123094. */
  123095. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  123096. }
  123097. }
  123098. declare module BABYLON {
  123099. interface Engine {
  123100. /**
  123101. * Create an effect to use with particle systems.
  123102. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  123103. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  123104. * @param uniformsNames defines a list of attribute names
  123105. * @param samplers defines an array of string used to represent textures
  123106. * @param defines defines the string containing the defines to use to compile the shaders
  123107. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  123108. * @param onCompiled defines a function to call when the effect creation is successful
  123109. * @param onError defines a function to call when the effect creation has failed
  123110. * @returns the new Effect
  123111. */
  123112. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  123113. }
  123114. interface Mesh {
  123115. /**
  123116. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  123117. * @returns an array of IParticleSystem
  123118. */
  123119. getEmittedParticleSystems(): IParticleSystem[];
  123120. /**
  123121. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  123122. * @returns an array of IParticleSystem
  123123. */
  123124. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  123125. }
  123126. /**
  123127. * @hidden
  123128. */
  123129. export var _IDoNeedToBeInTheBuild: number;
  123130. }
  123131. declare module BABYLON {
  123132. interface Scene {
  123133. /** @hidden (Backing field) */
  123134. _physicsEngine: Nullable<IPhysicsEngine>;
  123135. /**
  123136. * Gets the current physics engine
  123137. * @returns a IPhysicsEngine or null if none attached
  123138. */
  123139. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  123140. /**
  123141. * Enables physics to the current scene
  123142. * @param gravity defines the scene's gravity for the physics engine
  123143. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  123144. * @return a boolean indicating if the physics engine was initialized
  123145. */
  123146. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  123147. /**
  123148. * Disables and disposes the physics engine associated with the scene
  123149. */
  123150. disablePhysicsEngine(): void;
  123151. /**
  123152. * Gets a boolean indicating if there is an active physics engine
  123153. * @returns a boolean indicating if there is an active physics engine
  123154. */
  123155. isPhysicsEnabled(): boolean;
  123156. /**
  123157. * Deletes a physics compound impostor
  123158. * @param compound defines the compound to delete
  123159. */
  123160. deleteCompoundImpostor(compound: any): void;
  123161. /**
  123162. * An event triggered when physic simulation is about to be run
  123163. */
  123164. onBeforePhysicsObservable: Observable<Scene>;
  123165. /**
  123166. * An event triggered when physic simulation has been done
  123167. */
  123168. onAfterPhysicsObservable: Observable<Scene>;
  123169. }
  123170. interface AbstractMesh {
  123171. /** @hidden */
  123172. _physicsImpostor: Nullable<PhysicsImpostor>;
  123173. /**
  123174. * Gets or sets impostor used for physic simulation
  123175. * @see http://doc.babylonjs.com/features/physics_engine
  123176. */
  123177. physicsImpostor: Nullable<PhysicsImpostor>;
  123178. /**
  123179. * Gets the current physics impostor
  123180. * @see http://doc.babylonjs.com/features/physics_engine
  123181. * @returns a physics impostor or null
  123182. */
  123183. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  123184. /** Apply a physic impulse to the mesh
  123185. * @param force defines the force to apply
  123186. * @param contactPoint defines where to apply the force
  123187. * @returns the current mesh
  123188. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  123189. */
  123190. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  123191. /**
  123192. * Creates a physic joint between two meshes
  123193. * @param otherMesh defines the other mesh to use
  123194. * @param pivot1 defines the pivot to use on this mesh
  123195. * @param pivot2 defines the pivot to use on the other mesh
  123196. * @param options defines additional options (can be plugin dependent)
  123197. * @returns the current mesh
  123198. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  123199. */
  123200. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  123201. /** @hidden */
  123202. _disposePhysicsObserver: Nullable<Observer<Node>>;
  123203. }
  123204. /**
  123205. * Defines the physics engine scene component responsible to manage a physics engine
  123206. */
  123207. export class PhysicsEngineSceneComponent implements ISceneComponent {
  123208. /**
  123209. * The component name helpful to identify the component in the list of scene components.
  123210. */
  123211. readonly name: string;
  123212. /**
  123213. * The scene the component belongs to.
  123214. */
  123215. scene: Scene;
  123216. /**
  123217. * Creates a new instance of the component for the given scene
  123218. * @param scene Defines the scene to register the component in
  123219. */
  123220. constructor(scene: Scene);
  123221. /**
  123222. * Registers the component in a given scene
  123223. */
  123224. register(): void;
  123225. /**
  123226. * Rebuilds the elements related to this component in case of
  123227. * context lost for instance.
  123228. */
  123229. rebuild(): void;
  123230. /**
  123231. * Disposes the component and the associated ressources
  123232. */
  123233. dispose(): void;
  123234. }
  123235. }
  123236. declare module BABYLON {
  123237. /**
  123238. * A helper for physics simulations
  123239. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123240. */
  123241. export class PhysicsHelper {
  123242. private _scene;
  123243. private _physicsEngine;
  123244. /**
  123245. * Initializes the Physics helper
  123246. * @param scene Babylon.js scene
  123247. */
  123248. constructor(scene: Scene);
  123249. /**
  123250. * Applies a radial explosion impulse
  123251. * @param origin the origin of the explosion
  123252. * @param radiusOrEventOptions the radius or the options of radial explosion
  123253. * @param strength the explosion strength
  123254. * @param falloff possible options: Constant & Linear. Defaults to Constant
  123255. * @returns A physics radial explosion event, or null
  123256. */
  123257. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  123258. /**
  123259. * Applies a radial explosion force
  123260. * @param origin the origin of the explosion
  123261. * @param radiusOrEventOptions the radius or the options of radial explosion
  123262. * @param strength the explosion strength
  123263. * @param falloff possible options: Constant & Linear. Defaults to Constant
  123264. * @returns A physics radial explosion event, or null
  123265. */
  123266. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  123267. /**
  123268. * Creates a gravitational field
  123269. * @param origin the origin of the explosion
  123270. * @param radiusOrEventOptions the radius or the options of radial explosion
  123271. * @param strength the explosion strength
  123272. * @param falloff possible options: Constant & Linear. Defaults to Constant
  123273. * @returns A physics gravitational field event, or null
  123274. */
  123275. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  123276. /**
  123277. * Creates a physics updraft event
  123278. * @param origin the origin of the updraft
  123279. * @param radiusOrEventOptions the radius or the options of the updraft
  123280. * @param strength the strength of the updraft
  123281. * @param height the height of the updraft
  123282. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  123283. * @returns A physics updraft event, or null
  123284. */
  123285. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  123286. /**
  123287. * Creates a physics vortex event
  123288. * @param origin the of the vortex
  123289. * @param radiusOrEventOptions the radius or the options of the vortex
  123290. * @param strength the strength of the vortex
  123291. * @param height the height of the vortex
  123292. * @returns a Physics vortex event, or null
  123293. * A physics vortex event or null
  123294. */
  123295. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  123296. }
  123297. /**
  123298. * Represents a physics radial explosion event
  123299. */
  123300. class PhysicsRadialExplosionEvent {
  123301. private _scene;
  123302. private _options;
  123303. private _sphere;
  123304. private _dataFetched;
  123305. /**
  123306. * Initializes a radial explosioin event
  123307. * @param _scene BabylonJS scene
  123308. * @param _options The options for the vortex event
  123309. */
  123310. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  123311. /**
  123312. * Returns the data related to the radial explosion event (sphere).
  123313. * @returns The radial explosion event data
  123314. */
  123315. getData(): PhysicsRadialExplosionEventData;
  123316. /**
  123317. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  123318. * @param impostor A physics imposter
  123319. * @param origin the origin of the explosion
  123320. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  123321. */
  123322. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  123323. /**
  123324. * Triggers affecterd impostors callbacks
  123325. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  123326. */
  123327. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  123328. /**
  123329. * Disposes the sphere.
  123330. * @param force Specifies if the sphere should be disposed by force
  123331. */
  123332. dispose(force?: boolean): void;
  123333. /*** Helpers ***/
  123334. private _prepareSphere;
  123335. private _intersectsWithSphere;
  123336. }
  123337. /**
  123338. * Represents a gravitational field event
  123339. */
  123340. class PhysicsGravitationalFieldEvent {
  123341. private _physicsHelper;
  123342. private _scene;
  123343. private _origin;
  123344. private _options;
  123345. private _tickCallback;
  123346. private _sphere;
  123347. private _dataFetched;
  123348. /**
  123349. * Initializes the physics gravitational field event
  123350. * @param _physicsHelper A physics helper
  123351. * @param _scene BabylonJS scene
  123352. * @param _origin The origin position of the gravitational field event
  123353. * @param _options The options for the vortex event
  123354. */
  123355. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  123356. /**
  123357. * Returns the data related to the gravitational field event (sphere).
  123358. * @returns A gravitational field event
  123359. */
  123360. getData(): PhysicsGravitationalFieldEventData;
  123361. /**
  123362. * Enables the gravitational field.
  123363. */
  123364. enable(): void;
  123365. /**
  123366. * Disables the gravitational field.
  123367. */
  123368. disable(): void;
  123369. /**
  123370. * Disposes the sphere.
  123371. * @param force The force to dispose from the gravitational field event
  123372. */
  123373. dispose(force?: boolean): void;
  123374. private _tick;
  123375. }
  123376. /**
  123377. * Represents a physics updraft event
  123378. */
  123379. class PhysicsUpdraftEvent {
  123380. private _scene;
  123381. private _origin;
  123382. private _options;
  123383. private _physicsEngine;
  123384. private _originTop;
  123385. private _originDirection;
  123386. private _tickCallback;
  123387. private _cylinder;
  123388. private _cylinderPosition;
  123389. private _dataFetched;
  123390. /**
  123391. * Initializes the physics updraft event
  123392. * @param _scene BabylonJS scene
  123393. * @param _origin The origin position of the updraft
  123394. * @param _options The options for the updraft event
  123395. */
  123396. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  123397. /**
  123398. * Returns the data related to the updraft event (cylinder).
  123399. * @returns A physics updraft event
  123400. */
  123401. getData(): PhysicsUpdraftEventData;
  123402. /**
  123403. * Enables the updraft.
  123404. */
  123405. enable(): void;
  123406. /**
  123407. * Disables the updraft.
  123408. */
  123409. disable(): void;
  123410. /**
  123411. * Disposes the cylinder.
  123412. * @param force Specifies if the updraft should be disposed by force
  123413. */
  123414. dispose(force?: boolean): void;
  123415. private getImpostorHitData;
  123416. private _tick;
  123417. /*** Helpers ***/
  123418. private _prepareCylinder;
  123419. private _intersectsWithCylinder;
  123420. }
  123421. /**
  123422. * Represents a physics vortex event
  123423. */
  123424. class PhysicsVortexEvent {
  123425. private _scene;
  123426. private _origin;
  123427. private _options;
  123428. private _physicsEngine;
  123429. private _originTop;
  123430. private _tickCallback;
  123431. private _cylinder;
  123432. private _cylinderPosition;
  123433. private _dataFetched;
  123434. /**
  123435. * Initializes the physics vortex event
  123436. * @param _scene The BabylonJS scene
  123437. * @param _origin The origin position of the vortex
  123438. * @param _options The options for the vortex event
  123439. */
  123440. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  123441. /**
  123442. * Returns the data related to the vortex event (cylinder).
  123443. * @returns The physics vortex event data
  123444. */
  123445. getData(): PhysicsVortexEventData;
  123446. /**
  123447. * Enables the vortex.
  123448. */
  123449. enable(): void;
  123450. /**
  123451. * Disables the cortex.
  123452. */
  123453. disable(): void;
  123454. /**
  123455. * Disposes the sphere.
  123456. * @param force
  123457. */
  123458. dispose(force?: boolean): void;
  123459. private getImpostorHitData;
  123460. private _tick;
  123461. /*** Helpers ***/
  123462. private _prepareCylinder;
  123463. private _intersectsWithCylinder;
  123464. }
  123465. /**
  123466. * Options fot the radial explosion event
  123467. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123468. */
  123469. export class PhysicsRadialExplosionEventOptions {
  123470. /**
  123471. * The radius of the sphere for the radial explosion.
  123472. */
  123473. radius: number;
  123474. /**
  123475. * The strenth of the explosion.
  123476. */
  123477. strength: number;
  123478. /**
  123479. * The strenght of the force in correspondence to the distance of the affected object
  123480. */
  123481. falloff: PhysicsRadialImpulseFalloff;
  123482. /**
  123483. * Sphere options for the radial explosion.
  123484. */
  123485. sphere: {
  123486. segments: number;
  123487. diameter: number;
  123488. };
  123489. /**
  123490. * Sphere options for the radial explosion.
  123491. */
  123492. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  123493. }
  123494. /**
  123495. * Options fot the updraft event
  123496. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123497. */
  123498. export class PhysicsUpdraftEventOptions {
  123499. /**
  123500. * The radius of the cylinder for the vortex
  123501. */
  123502. radius: number;
  123503. /**
  123504. * The strenth of the updraft.
  123505. */
  123506. strength: number;
  123507. /**
  123508. * The height of the cylinder for the updraft.
  123509. */
  123510. height: number;
  123511. /**
  123512. * The mode for the the updraft.
  123513. */
  123514. updraftMode: PhysicsUpdraftMode;
  123515. }
  123516. /**
  123517. * Options fot the vortex event
  123518. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123519. */
  123520. export class PhysicsVortexEventOptions {
  123521. /**
  123522. * The radius of the cylinder for the vortex
  123523. */
  123524. radius: number;
  123525. /**
  123526. * The strenth of the vortex.
  123527. */
  123528. strength: number;
  123529. /**
  123530. * The height of the cylinder for the vortex.
  123531. */
  123532. height: number;
  123533. /**
  123534. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  123535. */
  123536. centripetalForceThreshold: number;
  123537. /**
  123538. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  123539. */
  123540. centripetalForceMultiplier: number;
  123541. /**
  123542. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  123543. */
  123544. centrifugalForceMultiplier: number;
  123545. /**
  123546. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  123547. */
  123548. updraftForceMultiplier: number;
  123549. }
  123550. /**
  123551. * The strenght of the force in correspondence to the distance of the affected object
  123552. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123553. */
  123554. export enum PhysicsRadialImpulseFalloff {
  123555. /** Defines that impulse is constant in strength across it's whole radius */
  123556. Constant = 0,
  123557. /** Defines that impulse gets weaker if it's further from the origin */
  123558. Linear = 1
  123559. }
  123560. /**
  123561. * The strength of the force in correspondence to the distance of the affected object
  123562. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123563. */
  123564. export enum PhysicsUpdraftMode {
  123565. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  123566. Center = 0,
  123567. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  123568. Perpendicular = 1
  123569. }
  123570. /**
  123571. * Interface for a physics hit data
  123572. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123573. */
  123574. export interface PhysicsHitData {
  123575. /**
  123576. * The force applied at the contact point
  123577. */
  123578. force: Vector3;
  123579. /**
  123580. * The contact point
  123581. */
  123582. contactPoint: Vector3;
  123583. /**
  123584. * The distance from the origin to the contact point
  123585. */
  123586. distanceFromOrigin: number;
  123587. }
  123588. /**
  123589. * Interface for radial explosion event data
  123590. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123591. */
  123592. export interface PhysicsRadialExplosionEventData {
  123593. /**
  123594. * A sphere used for the radial explosion event
  123595. */
  123596. sphere: Mesh;
  123597. }
  123598. /**
  123599. * Interface for gravitational field event data
  123600. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123601. */
  123602. export interface PhysicsGravitationalFieldEventData {
  123603. /**
  123604. * A sphere mesh used for the gravitational field event
  123605. */
  123606. sphere: Mesh;
  123607. }
  123608. /**
  123609. * Interface for updraft event data
  123610. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123611. */
  123612. export interface PhysicsUpdraftEventData {
  123613. /**
  123614. * A cylinder used for the updraft event
  123615. */
  123616. cylinder: Mesh;
  123617. }
  123618. /**
  123619. * Interface for vortex event data
  123620. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123621. */
  123622. export interface PhysicsVortexEventData {
  123623. /**
  123624. * A cylinder used for the vortex event
  123625. */
  123626. cylinder: Mesh;
  123627. }
  123628. /**
  123629. * Interface for an affected physics impostor
  123630. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123631. */
  123632. export interface PhysicsAffectedImpostorWithData {
  123633. /**
  123634. * The impostor affected by the effect
  123635. */
  123636. impostor: PhysicsImpostor;
  123637. /**
  123638. * The data about the hit/horce from the explosion
  123639. */
  123640. hitData: PhysicsHitData;
  123641. }
  123642. }
  123643. declare module BABYLON {
  123644. /** @hidden */
  123645. export var blackAndWhitePixelShader: {
  123646. name: string;
  123647. shader: string;
  123648. };
  123649. }
  123650. declare module BABYLON {
  123651. /**
  123652. * Post process used to render in black and white
  123653. */
  123654. export class BlackAndWhitePostProcess extends PostProcess {
  123655. /**
  123656. * Linear about to convert he result to black and white (default: 1)
  123657. */
  123658. degree: number;
  123659. /**
  123660. * Creates a black and white post process
  123661. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  123662. * @param name The name of the effect.
  123663. * @param options The required width/height ratio to downsize to before computing the render pass.
  123664. * @param camera The camera to apply the render pass to.
  123665. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123666. * @param engine The engine which the post process will be applied. (default: current engine)
  123667. * @param reusable If the post process can be reused on the same frame. (default: false)
  123668. */
  123669. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  123670. }
  123671. }
  123672. declare module BABYLON {
  123673. /**
  123674. * This represents a set of one or more post processes in Babylon.
  123675. * A post process can be used to apply a shader to a texture after it is rendered.
  123676. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  123677. */
  123678. export class PostProcessRenderEffect {
  123679. private _postProcesses;
  123680. private _getPostProcesses;
  123681. private _singleInstance;
  123682. private _cameras;
  123683. private _indicesForCamera;
  123684. /**
  123685. * Name of the effect
  123686. * @hidden
  123687. */
  123688. _name: string;
  123689. /**
  123690. * Instantiates a post process render effect.
  123691. * A post process can be used to apply a shader to a texture after it is rendered.
  123692. * @param engine The engine the effect is tied to
  123693. * @param name The name of the effect
  123694. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  123695. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  123696. */
  123697. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  123698. /**
  123699. * Checks if all the post processes in the effect are supported.
  123700. */
  123701. readonly isSupported: boolean;
  123702. /**
  123703. * Updates the current state of the effect
  123704. * @hidden
  123705. */
  123706. _update(): void;
  123707. /**
  123708. * Attaches the effect on cameras
  123709. * @param cameras The camera to attach to.
  123710. * @hidden
  123711. */
  123712. _attachCameras(cameras: Camera): void;
  123713. /**
  123714. * Attaches the effect on cameras
  123715. * @param cameras The camera to attach to.
  123716. * @hidden
  123717. */
  123718. _attachCameras(cameras: Camera[]): void;
  123719. /**
  123720. * Detaches the effect on cameras
  123721. * @param cameras The camera to detatch from.
  123722. * @hidden
  123723. */
  123724. _detachCameras(cameras: Camera): void;
  123725. /**
  123726. * Detatches the effect on cameras
  123727. * @param cameras The camera to detatch from.
  123728. * @hidden
  123729. */
  123730. _detachCameras(cameras: Camera[]): void;
  123731. /**
  123732. * Enables the effect on given cameras
  123733. * @param cameras The camera to enable.
  123734. * @hidden
  123735. */
  123736. _enable(cameras: Camera): void;
  123737. /**
  123738. * Enables the effect on given cameras
  123739. * @param cameras The camera to enable.
  123740. * @hidden
  123741. */
  123742. _enable(cameras: Nullable<Camera[]>): void;
  123743. /**
  123744. * Disables the effect on the given cameras
  123745. * @param cameras The camera to disable.
  123746. * @hidden
  123747. */
  123748. _disable(cameras: Camera): void;
  123749. /**
  123750. * Disables the effect on the given cameras
  123751. * @param cameras The camera to disable.
  123752. * @hidden
  123753. */
  123754. _disable(cameras: Nullable<Camera[]>): void;
  123755. /**
  123756. * Gets a list of the post processes contained in the effect.
  123757. * @param camera The camera to get the post processes on.
  123758. * @returns The list of the post processes in the effect.
  123759. */
  123760. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  123761. }
  123762. }
  123763. declare module BABYLON {
  123764. /** @hidden */
  123765. export var extractHighlightsPixelShader: {
  123766. name: string;
  123767. shader: string;
  123768. };
  123769. }
  123770. declare module BABYLON {
  123771. /**
  123772. * 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.
  123773. */
  123774. export class ExtractHighlightsPostProcess extends PostProcess {
  123775. /**
  123776. * The luminance threshold, pixels below this value will be set to black.
  123777. */
  123778. threshold: number;
  123779. /** @hidden */
  123780. _exposure: number;
  123781. /**
  123782. * Post process which has the input texture to be used when performing highlight extraction
  123783. * @hidden
  123784. */
  123785. _inputPostProcess: Nullable<PostProcess>;
  123786. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  123787. }
  123788. }
  123789. declare module BABYLON {
  123790. /** @hidden */
  123791. export var bloomMergePixelShader: {
  123792. name: string;
  123793. shader: string;
  123794. };
  123795. }
  123796. declare module BABYLON {
  123797. /**
  123798. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  123799. */
  123800. export class BloomMergePostProcess extends PostProcess {
  123801. /** Weight of the bloom to be added to the original input. */
  123802. weight: number;
  123803. /**
  123804. * Creates a new instance of @see BloomMergePostProcess
  123805. * @param name The name of the effect.
  123806. * @param originalFromInput Post process which's input will be used for the merge.
  123807. * @param blurred Blurred highlights post process which's output will be used.
  123808. * @param weight Weight of the bloom to be added to the original input.
  123809. * @param options The required width/height ratio to downsize to before computing the render pass.
  123810. * @param camera The camera to apply the render pass to.
  123811. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123812. * @param engine The engine which the post process will be applied. (default: current engine)
  123813. * @param reusable If the post process can be reused on the same frame. (default: false)
  123814. * @param textureType Type of textures used when performing the post process. (default: 0)
  123815. * @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)
  123816. */
  123817. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  123818. /** Weight of the bloom to be added to the original input. */
  123819. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  123820. }
  123821. }
  123822. declare module BABYLON {
  123823. /**
  123824. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  123825. */
  123826. export class BloomEffect extends PostProcessRenderEffect {
  123827. private bloomScale;
  123828. /**
  123829. * @hidden Internal
  123830. */
  123831. _effects: Array<PostProcess>;
  123832. /**
  123833. * @hidden Internal
  123834. */
  123835. _downscale: ExtractHighlightsPostProcess;
  123836. private _blurX;
  123837. private _blurY;
  123838. private _merge;
  123839. /**
  123840. * The luminance threshold to find bright areas of the image to bloom.
  123841. */
  123842. threshold: number;
  123843. /**
  123844. * The strength of the bloom.
  123845. */
  123846. weight: number;
  123847. /**
  123848. * Specifies the size of the bloom blur kernel, relative to the final output size
  123849. */
  123850. kernel: number;
  123851. /**
  123852. * Creates a new instance of @see BloomEffect
  123853. * @param scene The scene the effect belongs to.
  123854. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  123855. * @param bloomKernel The size of the kernel to be used when applying the blur.
  123856. * @param bloomWeight The the strength of bloom.
  123857. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  123858. * @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)
  123859. */
  123860. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  123861. /**
  123862. * Disposes each of the internal effects for a given camera.
  123863. * @param camera The camera to dispose the effect on.
  123864. */
  123865. disposeEffects(camera: Camera): void;
  123866. /**
  123867. * @hidden Internal
  123868. */
  123869. _updateEffects(): void;
  123870. /**
  123871. * Internal
  123872. * @returns if all the contained post processes are ready.
  123873. * @hidden
  123874. */
  123875. _isReady(): boolean;
  123876. }
  123877. }
  123878. declare module BABYLON {
  123879. /** @hidden */
  123880. export var chromaticAberrationPixelShader: {
  123881. name: string;
  123882. shader: string;
  123883. };
  123884. }
  123885. declare module BABYLON {
  123886. /**
  123887. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  123888. */
  123889. export class ChromaticAberrationPostProcess extends PostProcess {
  123890. /**
  123891. * The amount of seperation of rgb channels (default: 30)
  123892. */
  123893. aberrationAmount: number;
  123894. /**
  123895. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  123896. */
  123897. radialIntensity: number;
  123898. /**
  123899. * 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))
  123900. */
  123901. direction: Vector2;
  123902. /**
  123903. * 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))
  123904. */
  123905. centerPosition: Vector2;
  123906. /**
  123907. * Creates a new instance ChromaticAberrationPostProcess
  123908. * @param name The name of the effect.
  123909. * @param screenWidth The width of the screen to apply the effect on.
  123910. * @param screenHeight The height of the screen to apply the effect on.
  123911. * @param options The required width/height ratio to downsize to before computing the render pass.
  123912. * @param camera The camera to apply the render pass to.
  123913. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123914. * @param engine The engine which the post process will be applied. (default: current engine)
  123915. * @param reusable If the post process can be reused on the same frame. (default: false)
  123916. * @param textureType Type of textures used when performing the post process. (default: 0)
  123917. * @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)
  123918. */
  123919. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  123920. }
  123921. }
  123922. declare module BABYLON {
  123923. /** @hidden */
  123924. export var circleOfConfusionPixelShader: {
  123925. name: string;
  123926. shader: string;
  123927. };
  123928. }
  123929. declare module BABYLON {
  123930. /**
  123931. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  123932. */
  123933. export class CircleOfConfusionPostProcess extends PostProcess {
  123934. /**
  123935. * 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.
  123936. */
  123937. lensSize: number;
  123938. /**
  123939. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  123940. */
  123941. fStop: number;
  123942. /**
  123943. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  123944. */
  123945. focusDistance: number;
  123946. /**
  123947. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  123948. */
  123949. focalLength: number;
  123950. private _depthTexture;
  123951. /**
  123952. * Creates a new instance CircleOfConfusionPostProcess
  123953. * @param name The name of the effect.
  123954. * @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.
  123955. * @param options The required width/height ratio to downsize to before computing the render pass.
  123956. * @param camera The camera to apply the render pass to.
  123957. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123958. * @param engine The engine which the post process will be applied. (default: current engine)
  123959. * @param reusable If the post process can be reused on the same frame. (default: false)
  123960. * @param textureType Type of textures used when performing the post process. (default: 0)
  123961. * @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)
  123962. */
  123963. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  123964. /**
  123965. * 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.
  123966. */
  123967. depthTexture: RenderTargetTexture;
  123968. }
  123969. }
  123970. declare module BABYLON {
  123971. /** @hidden */
  123972. export var colorCorrectionPixelShader: {
  123973. name: string;
  123974. shader: string;
  123975. };
  123976. }
  123977. declare module BABYLON {
  123978. /**
  123979. *
  123980. * This post-process allows the modification of rendered colors by using
  123981. * a 'look-up table' (LUT). This effect is also called Color Grading.
  123982. *
  123983. * The object needs to be provided an url to a texture containing the color
  123984. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  123985. * Use an image editing software to tweak the LUT to match your needs.
  123986. *
  123987. * For an example of a color LUT, see here:
  123988. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  123989. * For explanations on color grading, see here:
  123990. * @see http://udn.epicgames.com/Three/ColorGrading.html
  123991. *
  123992. */
  123993. export class ColorCorrectionPostProcess extends PostProcess {
  123994. private _colorTableTexture;
  123995. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  123996. }
  123997. }
  123998. declare module BABYLON {
  123999. /** @hidden */
  124000. export var convolutionPixelShader: {
  124001. name: string;
  124002. shader: string;
  124003. };
  124004. }
  124005. declare module BABYLON {
  124006. /**
  124007. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  124008. * input texture to perform effects such as edge detection or sharpening
  124009. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  124010. */
  124011. export class ConvolutionPostProcess extends PostProcess {
  124012. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  124013. kernel: number[];
  124014. /**
  124015. * Creates a new instance ConvolutionPostProcess
  124016. * @param name The name of the effect.
  124017. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  124018. * @param options The required width/height ratio to downsize to before computing the render pass.
  124019. * @param camera The camera to apply the render pass to.
  124020. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124021. * @param engine The engine which the post process will be applied. (default: current engine)
  124022. * @param reusable If the post process can be reused on the same frame. (default: false)
  124023. * @param textureType Type of textures used when performing the post process. (default: 0)
  124024. */
  124025. constructor(name: string,
  124026. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  124027. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  124028. /**
  124029. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  124030. */
  124031. static EdgeDetect0Kernel: number[];
  124032. /**
  124033. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  124034. */
  124035. static EdgeDetect1Kernel: number[];
  124036. /**
  124037. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  124038. */
  124039. static EdgeDetect2Kernel: number[];
  124040. /**
  124041. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  124042. */
  124043. static SharpenKernel: number[];
  124044. /**
  124045. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  124046. */
  124047. static EmbossKernel: number[];
  124048. /**
  124049. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  124050. */
  124051. static GaussianKernel: number[];
  124052. }
  124053. }
  124054. declare module BABYLON {
  124055. /**
  124056. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  124057. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  124058. * based on samples that have a large difference in distance than the center pixel.
  124059. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  124060. */
  124061. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  124062. direction: Vector2;
  124063. /**
  124064. * Creates a new instance CircleOfConfusionPostProcess
  124065. * @param name The name of the effect.
  124066. * @param scene The scene the effect belongs to.
  124067. * @param direction The direction the blur should be applied.
  124068. * @param kernel The size of the kernel used to blur.
  124069. * @param options The required width/height ratio to downsize to before computing the render pass.
  124070. * @param camera The camera to apply the render pass to.
  124071. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  124072. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  124073. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124074. * @param engine The engine which the post process will be applied. (default: current engine)
  124075. * @param reusable If the post process can be reused on the same frame. (default: false)
  124076. * @param textureType Type of textures used when performing the post process. (default: 0)
  124077. * @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)
  124078. */
  124079. 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);
  124080. }
  124081. }
  124082. declare module BABYLON {
  124083. /** @hidden */
  124084. export var depthOfFieldMergePixelShader: {
  124085. name: string;
  124086. shader: string;
  124087. };
  124088. }
  124089. declare module BABYLON {
  124090. /**
  124091. * Options to be set when merging outputs from the default pipeline.
  124092. */
  124093. export class DepthOfFieldMergePostProcessOptions {
  124094. /**
  124095. * The original image to merge on top of
  124096. */
  124097. originalFromInput: PostProcess;
  124098. /**
  124099. * Parameters to perform the merge of the depth of field effect
  124100. */
  124101. depthOfField?: {
  124102. circleOfConfusion: PostProcess;
  124103. blurSteps: Array<PostProcess>;
  124104. };
  124105. /**
  124106. * Parameters to perform the merge of bloom effect
  124107. */
  124108. bloom?: {
  124109. blurred: PostProcess;
  124110. weight: number;
  124111. };
  124112. }
  124113. /**
  124114. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  124115. */
  124116. export class DepthOfFieldMergePostProcess extends PostProcess {
  124117. private blurSteps;
  124118. /**
  124119. * Creates a new instance of DepthOfFieldMergePostProcess
  124120. * @param name The name of the effect.
  124121. * @param originalFromInput Post process which's input will be used for the merge.
  124122. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  124123. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  124124. * @param options The required width/height ratio to downsize to before computing the render pass.
  124125. * @param camera The camera to apply the render pass to.
  124126. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124127. * @param engine The engine which the post process will be applied. (default: current engine)
  124128. * @param reusable If the post process can be reused on the same frame. (default: false)
  124129. * @param textureType Type of textures used when performing the post process. (default: 0)
  124130. * @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)
  124131. */
  124132. 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);
  124133. /**
  124134. * Updates the effect with the current post process compile time values and recompiles the shader.
  124135. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  124136. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  124137. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  124138. * @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
  124139. * @param onCompiled Called when the shader has been compiled.
  124140. * @param onError Called if there is an error when compiling a shader.
  124141. */
  124142. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  124143. }
  124144. }
  124145. declare module BABYLON {
  124146. /**
  124147. * Specifies the level of max blur that should be applied when using the depth of field effect
  124148. */
  124149. export enum DepthOfFieldEffectBlurLevel {
  124150. /**
  124151. * Subtle blur
  124152. */
  124153. Low = 0,
  124154. /**
  124155. * Medium blur
  124156. */
  124157. Medium = 1,
  124158. /**
  124159. * Large blur
  124160. */
  124161. High = 2
  124162. }
  124163. /**
  124164. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  124165. */
  124166. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  124167. private _circleOfConfusion;
  124168. /**
  124169. * @hidden Internal, blurs from high to low
  124170. */
  124171. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  124172. private _depthOfFieldBlurY;
  124173. private _dofMerge;
  124174. /**
  124175. * @hidden Internal post processes in depth of field effect
  124176. */
  124177. _effects: Array<PostProcess>;
  124178. /**
  124179. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  124180. */
  124181. focalLength: number;
  124182. /**
  124183. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  124184. */
  124185. fStop: number;
  124186. /**
  124187. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  124188. */
  124189. focusDistance: number;
  124190. /**
  124191. * 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.
  124192. */
  124193. lensSize: number;
  124194. /**
  124195. * Creates a new instance DepthOfFieldEffect
  124196. * @param scene The scene the effect belongs to.
  124197. * @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.
  124198. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  124199. * @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)
  124200. */
  124201. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  124202. /**
  124203. * Get the current class name of the current effet
  124204. * @returns "DepthOfFieldEffect"
  124205. */
  124206. getClassName(): string;
  124207. /**
  124208. * 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.
  124209. */
  124210. depthTexture: RenderTargetTexture;
  124211. /**
  124212. * Disposes each of the internal effects for a given camera.
  124213. * @param camera The camera to dispose the effect on.
  124214. */
  124215. disposeEffects(camera: Camera): void;
  124216. /**
  124217. * @hidden Internal
  124218. */
  124219. _updateEffects(): void;
  124220. /**
  124221. * Internal
  124222. * @returns if all the contained post processes are ready.
  124223. * @hidden
  124224. */
  124225. _isReady(): boolean;
  124226. }
  124227. }
  124228. declare module BABYLON {
  124229. /** @hidden */
  124230. export var displayPassPixelShader: {
  124231. name: string;
  124232. shader: string;
  124233. };
  124234. }
  124235. declare module BABYLON {
  124236. /**
  124237. * DisplayPassPostProcess which produces an output the same as it's input
  124238. */
  124239. export class DisplayPassPostProcess extends PostProcess {
  124240. /**
  124241. * Creates the DisplayPassPostProcess
  124242. * @param name The name of the effect.
  124243. * @param options The required width/height ratio to downsize to before computing the render pass.
  124244. * @param camera The camera to apply the render pass to.
  124245. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124246. * @param engine The engine which the post process will be applied. (default: current engine)
  124247. * @param reusable If the post process can be reused on the same frame. (default: false)
  124248. */
  124249. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  124250. }
  124251. }
  124252. declare module BABYLON {
  124253. /** @hidden */
  124254. export var filterPixelShader: {
  124255. name: string;
  124256. shader: string;
  124257. };
  124258. }
  124259. declare module BABYLON {
  124260. /**
  124261. * Applies a kernel filter to the image
  124262. */
  124263. export class FilterPostProcess extends PostProcess {
  124264. /** The matrix to be applied to the image */
  124265. kernelMatrix: Matrix;
  124266. /**
  124267. *
  124268. * @param name The name of the effect.
  124269. * @param kernelMatrix The matrix to be applied to the image
  124270. * @param options The required width/height ratio to downsize to before computing the render pass.
  124271. * @param camera The camera to apply the render pass to.
  124272. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124273. * @param engine The engine which the post process will be applied. (default: current engine)
  124274. * @param reusable If the post process can be reused on the same frame. (default: false)
  124275. */
  124276. constructor(name: string,
  124277. /** The matrix to be applied to the image */
  124278. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  124279. }
  124280. }
  124281. declare module BABYLON {
  124282. /** @hidden */
  124283. export var fxaaPixelShader: {
  124284. name: string;
  124285. shader: string;
  124286. };
  124287. }
  124288. declare module BABYLON {
  124289. /** @hidden */
  124290. export var fxaaVertexShader: {
  124291. name: string;
  124292. shader: string;
  124293. };
  124294. }
  124295. declare module BABYLON {
  124296. /**
  124297. * Fxaa post process
  124298. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  124299. */
  124300. export class FxaaPostProcess extends PostProcess {
  124301. /** @hidden */
  124302. texelWidth: number;
  124303. /** @hidden */
  124304. texelHeight: number;
  124305. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  124306. private _getDefines;
  124307. }
  124308. }
  124309. declare module BABYLON {
  124310. /** @hidden */
  124311. export var grainPixelShader: {
  124312. name: string;
  124313. shader: string;
  124314. };
  124315. }
  124316. declare module BABYLON {
  124317. /**
  124318. * The GrainPostProcess adds noise to the image at mid luminance levels
  124319. */
  124320. export class GrainPostProcess extends PostProcess {
  124321. /**
  124322. * The intensity of the grain added (default: 30)
  124323. */
  124324. intensity: number;
  124325. /**
  124326. * If the grain should be randomized on every frame
  124327. */
  124328. animated: boolean;
  124329. /**
  124330. * Creates a new instance of @see GrainPostProcess
  124331. * @param name The name of the effect.
  124332. * @param options The required width/height ratio to downsize to before computing the render pass.
  124333. * @param camera The camera to apply the render pass to.
  124334. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124335. * @param engine The engine which the post process will be applied. (default: current engine)
  124336. * @param reusable If the post process can be reused on the same frame. (default: false)
  124337. * @param textureType Type of textures used when performing the post process. (default: 0)
  124338. * @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)
  124339. */
  124340. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  124341. }
  124342. }
  124343. declare module BABYLON {
  124344. /** @hidden */
  124345. export var highlightsPixelShader: {
  124346. name: string;
  124347. shader: string;
  124348. };
  124349. }
  124350. declare module BABYLON {
  124351. /**
  124352. * Extracts highlights from the image
  124353. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  124354. */
  124355. export class HighlightsPostProcess extends PostProcess {
  124356. /**
  124357. * Extracts highlights from the image
  124358. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  124359. * @param name The name of the effect.
  124360. * @param options The required width/height ratio to downsize to before computing the render pass.
  124361. * @param camera The camera to apply the render pass to.
  124362. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124363. * @param engine The engine which the post process will be applied. (default: current engine)
  124364. * @param reusable If the post process can be reused on the same frame. (default: false)
  124365. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  124366. */
  124367. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  124368. }
  124369. }
  124370. declare module BABYLON {
  124371. /** @hidden */
  124372. export var mrtFragmentDeclaration: {
  124373. name: string;
  124374. shader: string;
  124375. };
  124376. }
  124377. declare module BABYLON {
  124378. /** @hidden */
  124379. export var geometryPixelShader: {
  124380. name: string;
  124381. shader: string;
  124382. };
  124383. }
  124384. declare module BABYLON {
  124385. /** @hidden */
  124386. export var geometryVertexShader: {
  124387. name: string;
  124388. shader: string;
  124389. };
  124390. }
  124391. declare module BABYLON {
  124392. /** @hidden */
  124393. interface ISavedTransformationMatrix {
  124394. world: Matrix;
  124395. viewProjection: Matrix;
  124396. }
  124397. /**
  124398. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  124399. */
  124400. export class GeometryBufferRenderer {
  124401. /**
  124402. * Constant used to retrieve the position texture index in the G-Buffer textures array
  124403. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  124404. */
  124405. static readonly POSITION_TEXTURE_TYPE: number;
  124406. /**
  124407. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  124408. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  124409. */
  124410. static readonly VELOCITY_TEXTURE_TYPE: number;
  124411. /**
  124412. * Dictionary used to store the previous transformation matrices of each rendered mesh
  124413. * in order to compute objects velocities when enableVelocity is set to "true"
  124414. * @hidden
  124415. */
  124416. _previousTransformationMatrices: {
  124417. [index: number]: ISavedTransformationMatrix;
  124418. };
  124419. /**
  124420. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  124421. * in order to compute objects velocities when enableVelocity is set to "true"
  124422. * @hidden
  124423. */
  124424. _previousBonesTransformationMatrices: {
  124425. [index: number]: Float32Array;
  124426. };
  124427. /**
  124428. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  124429. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  124430. */
  124431. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  124432. private _scene;
  124433. private _multiRenderTarget;
  124434. private _ratio;
  124435. private _enablePosition;
  124436. private _enableVelocity;
  124437. private _positionIndex;
  124438. private _velocityIndex;
  124439. protected _effect: Effect;
  124440. protected _cachedDefines: string;
  124441. /**
  124442. * Set the render list (meshes to be rendered) used in the G buffer.
  124443. */
  124444. renderList: Mesh[];
  124445. /**
  124446. * Gets wether or not G buffer are supported by the running hardware.
  124447. * This requires draw buffer supports
  124448. */
  124449. readonly isSupported: boolean;
  124450. /**
  124451. * Returns the index of the given texture type in the G-Buffer textures array
  124452. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  124453. * @returns the index of the given texture type in the G-Buffer textures array
  124454. */
  124455. getTextureIndex(textureType: number): number;
  124456. /**
  124457. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  124458. */
  124459. /**
  124460. * Sets whether or not objects positions are enabled for the G buffer.
  124461. */
  124462. enablePosition: boolean;
  124463. /**
  124464. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  124465. */
  124466. /**
  124467. * Sets wether or not objects velocities are enabled for the G buffer.
  124468. */
  124469. enableVelocity: boolean;
  124470. /**
  124471. * Gets the scene associated with the buffer.
  124472. */
  124473. readonly scene: Scene;
  124474. /**
  124475. * Gets the ratio used by the buffer during its creation.
  124476. * How big is the buffer related to the main canvas.
  124477. */
  124478. readonly ratio: number;
  124479. /** @hidden */
  124480. static _SceneComponentInitialization: (scene: Scene) => void;
  124481. /**
  124482. * Creates a new G Buffer for the scene
  124483. * @param scene The scene the buffer belongs to
  124484. * @param ratio How big is the buffer related to the main canvas.
  124485. */
  124486. constructor(scene: Scene, ratio?: number);
  124487. /**
  124488. * Checks wether everything is ready to render a submesh to the G buffer.
  124489. * @param subMesh the submesh to check readiness for
  124490. * @param useInstances is the mesh drawn using instance or not
  124491. * @returns true if ready otherwise false
  124492. */
  124493. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  124494. /**
  124495. * Gets the current underlying G Buffer.
  124496. * @returns the buffer
  124497. */
  124498. getGBuffer(): MultiRenderTarget;
  124499. /**
  124500. * Gets the number of samples used to render the buffer (anti aliasing).
  124501. */
  124502. /**
  124503. * Sets the number of samples used to render the buffer (anti aliasing).
  124504. */
  124505. samples: number;
  124506. /**
  124507. * Disposes the renderer and frees up associated resources.
  124508. */
  124509. dispose(): void;
  124510. protected _createRenderTargets(): void;
  124511. private _copyBonesTransformationMatrices;
  124512. }
  124513. }
  124514. declare module BABYLON {
  124515. interface Scene {
  124516. /** @hidden (Backing field) */
  124517. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  124518. /**
  124519. * Gets or Sets the current geometry buffer associated to the scene.
  124520. */
  124521. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  124522. /**
  124523. * Enables a GeometryBufferRender and associates it with the scene
  124524. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  124525. * @returns the GeometryBufferRenderer
  124526. */
  124527. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  124528. /**
  124529. * Disables the GeometryBufferRender associated with the scene
  124530. */
  124531. disableGeometryBufferRenderer(): void;
  124532. }
  124533. /**
  124534. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  124535. * in several rendering techniques.
  124536. */
  124537. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  124538. /**
  124539. * The component name helpful to identify the component in the list of scene components.
  124540. */
  124541. readonly name: string;
  124542. /**
  124543. * The scene the component belongs to.
  124544. */
  124545. scene: Scene;
  124546. /**
  124547. * Creates a new instance of the component for the given scene
  124548. * @param scene Defines the scene to register the component in
  124549. */
  124550. constructor(scene: Scene);
  124551. /**
  124552. * Registers the component in a given scene
  124553. */
  124554. register(): void;
  124555. /**
  124556. * Rebuilds the elements related to this component in case of
  124557. * context lost for instance.
  124558. */
  124559. rebuild(): void;
  124560. /**
  124561. * Disposes the component and the associated ressources
  124562. */
  124563. dispose(): void;
  124564. private _gatherRenderTargets;
  124565. }
  124566. }
  124567. declare module BABYLON {
  124568. /** @hidden */
  124569. export var motionBlurPixelShader: {
  124570. name: string;
  124571. shader: string;
  124572. };
  124573. }
  124574. declare module BABYLON {
  124575. /**
  124576. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  124577. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  124578. * As an example, all you have to do is to create the post-process:
  124579. * var mb = new BABYLON.MotionBlurPostProcess(
  124580. * 'mb', // The name of the effect.
  124581. * scene, // The scene containing the objects to blur according to their velocity.
  124582. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  124583. * camera // The camera to apply the render pass to.
  124584. * );
  124585. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  124586. */
  124587. export class MotionBlurPostProcess extends PostProcess {
  124588. /**
  124589. * Defines how much the image is blurred by the movement. Default value is equal to 1
  124590. */
  124591. motionStrength: number;
  124592. /**
  124593. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  124594. */
  124595. /**
  124596. * Sets the number of iterations to be used for motion blur quality
  124597. */
  124598. motionBlurSamples: number;
  124599. private _motionBlurSamples;
  124600. private _geometryBufferRenderer;
  124601. /**
  124602. * Creates a new instance MotionBlurPostProcess
  124603. * @param name The name of the effect.
  124604. * @param scene The scene containing the objects to blur according to their velocity.
  124605. * @param options The required width/height ratio to downsize to before computing the render pass.
  124606. * @param camera The camera to apply the render pass to.
  124607. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124608. * @param engine The engine which the post process will be applied. (default: current engine)
  124609. * @param reusable If the post process can be reused on the same frame. (default: false)
  124610. * @param textureType Type of textures used when performing the post process. (default: 0)
  124611. * @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)
  124612. */
  124613. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  124614. /**
  124615. * Excludes the given skinned mesh from computing bones velocities.
  124616. * 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.
  124617. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  124618. */
  124619. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  124620. /**
  124621. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  124622. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  124623. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  124624. */
  124625. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  124626. /**
  124627. * Disposes the post process.
  124628. * @param camera The camera to dispose the post process on.
  124629. */
  124630. dispose(camera?: Camera): void;
  124631. }
  124632. }
  124633. declare module BABYLON {
  124634. /** @hidden */
  124635. export var refractionPixelShader: {
  124636. name: string;
  124637. shader: string;
  124638. };
  124639. }
  124640. declare module BABYLON {
  124641. /**
  124642. * Post process which applies a refractin texture
  124643. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  124644. */
  124645. export class RefractionPostProcess extends PostProcess {
  124646. /** the base color of the refraction (used to taint the rendering) */
  124647. color: Color3;
  124648. /** simulated refraction depth */
  124649. depth: number;
  124650. /** the coefficient of the base color (0 to remove base color tainting) */
  124651. colorLevel: number;
  124652. private _refTexture;
  124653. private _ownRefractionTexture;
  124654. /**
  124655. * Gets or sets the refraction texture
  124656. * Please note that you are responsible for disposing the texture if you set it manually
  124657. */
  124658. refractionTexture: Texture;
  124659. /**
  124660. * Initializes the RefractionPostProcess
  124661. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  124662. * @param name The name of the effect.
  124663. * @param refractionTextureUrl Url of the refraction texture to use
  124664. * @param color the base color of the refraction (used to taint the rendering)
  124665. * @param depth simulated refraction depth
  124666. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  124667. * @param camera The camera to apply the render pass to.
  124668. * @param options The required width/height ratio to downsize to before computing the render pass.
  124669. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124670. * @param engine The engine which the post process will be applied. (default: current engine)
  124671. * @param reusable If the post process can be reused on the same frame. (default: false)
  124672. */
  124673. constructor(name: string, refractionTextureUrl: string,
  124674. /** the base color of the refraction (used to taint the rendering) */
  124675. color: Color3,
  124676. /** simulated refraction depth */
  124677. depth: number,
  124678. /** the coefficient of the base color (0 to remove base color tainting) */
  124679. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  124680. /**
  124681. * Disposes of the post process
  124682. * @param camera Camera to dispose post process on
  124683. */
  124684. dispose(camera: Camera): void;
  124685. }
  124686. }
  124687. declare module BABYLON {
  124688. /** @hidden */
  124689. export var sharpenPixelShader: {
  124690. name: string;
  124691. shader: string;
  124692. };
  124693. }
  124694. declare module BABYLON {
  124695. /**
  124696. * The SharpenPostProcess applies a sharpen kernel to every pixel
  124697. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  124698. */
  124699. export class SharpenPostProcess extends PostProcess {
  124700. /**
  124701. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  124702. */
  124703. colorAmount: number;
  124704. /**
  124705. * How much sharpness should be applied (default: 0.3)
  124706. */
  124707. edgeAmount: number;
  124708. /**
  124709. * Creates a new instance ConvolutionPostProcess
  124710. * @param name The name of the effect.
  124711. * @param options The required width/height ratio to downsize to before computing the render pass.
  124712. * @param camera The camera to apply the render pass to.
  124713. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124714. * @param engine The engine which the post process will be applied. (default: current engine)
  124715. * @param reusable If the post process can be reused on the same frame. (default: false)
  124716. * @param textureType Type of textures used when performing the post process. (default: 0)
  124717. * @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)
  124718. */
  124719. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  124720. }
  124721. }
  124722. declare module BABYLON {
  124723. /**
  124724. * PostProcessRenderPipeline
  124725. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  124726. */
  124727. export class PostProcessRenderPipeline {
  124728. private engine;
  124729. private _renderEffects;
  124730. private _renderEffectsForIsolatedPass;
  124731. /**
  124732. * List of inspectable custom properties (used by the Inspector)
  124733. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  124734. */
  124735. inspectableCustomProperties: IInspectable[];
  124736. /**
  124737. * @hidden
  124738. */
  124739. protected _cameras: Camera[];
  124740. /** @hidden */
  124741. _name: string;
  124742. /**
  124743. * Gets pipeline name
  124744. */
  124745. readonly name: string;
  124746. /**
  124747. * Initializes a PostProcessRenderPipeline
  124748. * @param engine engine to add the pipeline to
  124749. * @param name name of the pipeline
  124750. */
  124751. constructor(engine: Engine, name: string);
  124752. /**
  124753. * Gets the class name
  124754. * @returns "PostProcessRenderPipeline"
  124755. */
  124756. getClassName(): string;
  124757. /**
  124758. * If all the render effects in the pipeline are supported
  124759. */
  124760. readonly isSupported: boolean;
  124761. /**
  124762. * Adds an effect to the pipeline
  124763. * @param renderEffect the effect to add
  124764. */
  124765. addEffect(renderEffect: PostProcessRenderEffect): void;
  124766. /** @hidden */
  124767. _rebuild(): void;
  124768. /** @hidden */
  124769. _enableEffect(renderEffectName: string, cameras: Camera): void;
  124770. /** @hidden */
  124771. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  124772. /** @hidden */
  124773. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  124774. /** @hidden */
  124775. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  124776. /** @hidden */
  124777. _attachCameras(cameras: Camera, unique: boolean): void;
  124778. /** @hidden */
  124779. _attachCameras(cameras: Camera[], unique: boolean): void;
  124780. /** @hidden */
  124781. _detachCameras(cameras: Camera): void;
  124782. /** @hidden */
  124783. _detachCameras(cameras: Nullable<Camera[]>): void;
  124784. /** @hidden */
  124785. _update(): void;
  124786. /** @hidden */
  124787. _reset(): void;
  124788. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  124789. /**
  124790. * Disposes of the pipeline
  124791. */
  124792. dispose(): void;
  124793. }
  124794. }
  124795. declare module BABYLON {
  124796. /**
  124797. * PostProcessRenderPipelineManager class
  124798. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  124799. */
  124800. export class PostProcessRenderPipelineManager {
  124801. private _renderPipelines;
  124802. /**
  124803. * Initializes a PostProcessRenderPipelineManager
  124804. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  124805. */
  124806. constructor();
  124807. /**
  124808. * Gets the list of supported render pipelines
  124809. */
  124810. readonly supportedPipelines: PostProcessRenderPipeline[];
  124811. /**
  124812. * Adds a pipeline to the manager
  124813. * @param renderPipeline The pipeline to add
  124814. */
  124815. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  124816. /**
  124817. * Attaches a camera to the pipeline
  124818. * @param renderPipelineName The name of the pipeline to attach to
  124819. * @param cameras the camera to attach
  124820. * @param unique if the camera can be attached multiple times to the pipeline
  124821. */
  124822. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  124823. /**
  124824. * Detaches a camera from the pipeline
  124825. * @param renderPipelineName The name of the pipeline to detach from
  124826. * @param cameras the camera to detach
  124827. */
  124828. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  124829. /**
  124830. * Enables an effect by name on a pipeline
  124831. * @param renderPipelineName the name of the pipeline to enable the effect in
  124832. * @param renderEffectName the name of the effect to enable
  124833. * @param cameras the cameras that the effect should be enabled on
  124834. */
  124835. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  124836. /**
  124837. * Disables an effect by name on a pipeline
  124838. * @param renderPipelineName the name of the pipeline to disable the effect in
  124839. * @param renderEffectName the name of the effect to disable
  124840. * @param cameras the cameras that the effect should be disabled on
  124841. */
  124842. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  124843. /**
  124844. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  124845. */
  124846. update(): void;
  124847. /** @hidden */
  124848. _rebuild(): void;
  124849. /**
  124850. * Disposes of the manager and pipelines
  124851. */
  124852. dispose(): void;
  124853. }
  124854. }
  124855. declare module BABYLON {
  124856. interface Scene {
  124857. /** @hidden (Backing field) */
  124858. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  124859. /**
  124860. * Gets the postprocess render pipeline manager
  124861. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  124862. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  124863. */
  124864. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  124865. }
  124866. /**
  124867. * Defines the Render Pipeline scene component responsible to rendering pipelines
  124868. */
  124869. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  124870. /**
  124871. * The component name helpfull to identify the component in the list of scene components.
  124872. */
  124873. readonly name: string;
  124874. /**
  124875. * The scene the component belongs to.
  124876. */
  124877. scene: Scene;
  124878. /**
  124879. * Creates a new instance of the component for the given scene
  124880. * @param scene Defines the scene to register the component in
  124881. */
  124882. constructor(scene: Scene);
  124883. /**
  124884. * Registers the component in a given scene
  124885. */
  124886. register(): void;
  124887. /**
  124888. * Rebuilds the elements related to this component in case of
  124889. * context lost for instance.
  124890. */
  124891. rebuild(): void;
  124892. /**
  124893. * Disposes the component and the associated ressources
  124894. */
  124895. dispose(): void;
  124896. private _gatherRenderTargets;
  124897. }
  124898. }
  124899. declare module BABYLON {
  124900. /**
  124901. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  124902. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  124903. */
  124904. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  124905. private _scene;
  124906. private _camerasToBeAttached;
  124907. /**
  124908. * ID of the sharpen post process,
  124909. */
  124910. private readonly SharpenPostProcessId;
  124911. /**
  124912. * @ignore
  124913. * ID of the image processing post process;
  124914. */
  124915. readonly ImageProcessingPostProcessId: string;
  124916. /**
  124917. * @ignore
  124918. * ID of the Fast Approximate Anti-Aliasing post process;
  124919. */
  124920. readonly FxaaPostProcessId: string;
  124921. /**
  124922. * ID of the chromatic aberration post process,
  124923. */
  124924. private readonly ChromaticAberrationPostProcessId;
  124925. /**
  124926. * ID of the grain post process
  124927. */
  124928. private readonly GrainPostProcessId;
  124929. /**
  124930. * Sharpen post process which will apply a sharpen convolution to enhance edges
  124931. */
  124932. sharpen: SharpenPostProcess;
  124933. private _sharpenEffect;
  124934. private bloom;
  124935. /**
  124936. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  124937. */
  124938. depthOfField: DepthOfFieldEffect;
  124939. /**
  124940. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  124941. */
  124942. fxaa: FxaaPostProcess;
  124943. /**
  124944. * Image post processing pass used to perform operations such as tone mapping or color grading.
  124945. */
  124946. imageProcessing: ImageProcessingPostProcess;
  124947. /**
  124948. * Chromatic aberration post process which will shift rgb colors in the image
  124949. */
  124950. chromaticAberration: ChromaticAberrationPostProcess;
  124951. private _chromaticAberrationEffect;
  124952. /**
  124953. * Grain post process which add noise to the image
  124954. */
  124955. grain: GrainPostProcess;
  124956. private _grainEffect;
  124957. /**
  124958. * Glow post process which adds a glow to emissive areas of the image
  124959. */
  124960. private _glowLayer;
  124961. /**
  124962. * Animations which can be used to tweak settings over a period of time
  124963. */
  124964. animations: Animation[];
  124965. private _imageProcessingConfigurationObserver;
  124966. private _sharpenEnabled;
  124967. private _bloomEnabled;
  124968. private _depthOfFieldEnabled;
  124969. private _depthOfFieldBlurLevel;
  124970. private _fxaaEnabled;
  124971. private _imageProcessingEnabled;
  124972. private _defaultPipelineTextureType;
  124973. private _bloomScale;
  124974. private _chromaticAberrationEnabled;
  124975. private _grainEnabled;
  124976. private _buildAllowed;
  124977. /**
  124978. * Gets active scene
  124979. */
  124980. readonly scene: Scene;
  124981. /**
  124982. * Enable or disable the sharpen process from the pipeline
  124983. */
  124984. sharpenEnabled: boolean;
  124985. private _resizeObserver;
  124986. private _hardwareScaleLevel;
  124987. private _bloomKernel;
  124988. /**
  124989. * Specifies the size of the bloom blur kernel, relative to the final output size
  124990. */
  124991. bloomKernel: number;
  124992. /**
  124993. * Specifies the weight of the bloom in the final rendering
  124994. */
  124995. private _bloomWeight;
  124996. /**
  124997. * Specifies the luma threshold for the area that will be blurred by the bloom
  124998. */
  124999. private _bloomThreshold;
  125000. private _hdr;
  125001. /**
  125002. * The strength of the bloom.
  125003. */
  125004. bloomWeight: number;
  125005. /**
  125006. * The strength of the bloom.
  125007. */
  125008. bloomThreshold: number;
  125009. /**
  125010. * The scale of the bloom, lower value will provide better performance.
  125011. */
  125012. bloomScale: number;
  125013. /**
  125014. * Enable or disable the bloom from the pipeline
  125015. */
  125016. bloomEnabled: boolean;
  125017. private _rebuildBloom;
  125018. /**
  125019. * If the depth of field is enabled.
  125020. */
  125021. depthOfFieldEnabled: boolean;
  125022. /**
  125023. * Blur level of the depth of field effect. (Higher blur will effect performance)
  125024. */
  125025. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  125026. /**
  125027. * If the anti aliasing is enabled.
  125028. */
  125029. fxaaEnabled: boolean;
  125030. private _samples;
  125031. /**
  125032. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  125033. */
  125034. samples: number;
  125035. /**
  125036. * If image processing is enabled.
  125037. */
  125038. imageProcessingEnabled: boolean;
  125039. /**
  125040. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  125041. */
  125042. glowLayerEnabled: boolean;
  125043. /**
  125044. * Gets the glow layer (or null if not defined)
  125045. */
  125046. readonly glowLayer: Nullable<GlowLayer>;
  125047. /**
  125048. * Enable or disable the chromaticAberration process from the pipeline
  125049. */
  125050. chromaticAberrationEnabled: boolean;
  125051. /**
  125052. * Enable or disable the grain process from the pipeline
  125053. */
  125054. grainEnabled: boolean;
  125055. /**
  125056. * @constructor
  125057. * @param name - The rendering pipeline name (default: "")
  125058. * @param hdr - If high dynamic range textures should be used (default: true)
  125059. * @param scene - The scene linked to this pipeline (default: the last created scene)
  125060. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  125061. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  125062. */
  125063. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  125064. /**
  125065. * Get the class name
  125066. * @returns "DefaultRenderingPipeline"
  125067. */
  125068. getClassName(): string;
  125069. /**
  125070. * Force the compilation of the entire pipeline.
  125071. */
  125072. prepare(): void;
  125073. private _hasCleared;
  125074. private _prevPostProcess;
  125075. private _prevPrevPostProcess;
  125076. private _setAutoClearAndTextureSharing;
  125077. private _depthOfFieldSceneObserver;
  125078. private _buildPipeline;
  125079. private _disposePostProcesses;
  125080. /**
  125081. * Adds a camera to the pipeline
  125082. * @param camera the camera to be added
  125083. */
  125084. addCamera(camera: Camera): void;
  125085. /**
  125086. * Removes a camera from the pipeline
  125087. * @param camera the camera to remove
  125088. */
  125089. removeCamera(camera: Camera): void;
  125090. /**
  125091. * Dispose of the pipeline and stop all post processes
  125092. */
  125093. dispose(): void;
  125094. /**
  125095. * Serialize the rendering pipeline (Used when exporting)
  125096. * @returns the serialized object
  125097. */
  125098. serialize(): any;
  125099. /**
  125100. * Parse the serialized pipeline
  125101. * @param source Source pipeline.
  125102. * @param scene The scene to load the pipeline to.
  125103. * @param rootUrl The URL of the serialized pipeline.
  125104. * @returns An instantiated pipeline from the serialized object.
  125105. */
  125106. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  125107. }
  125108. }
  125109. declare module BABYLON {
  125110. /** @hidden */
  125111. export var lensHighlightsPixelShader: {
  125112. name: string;
  125113. shader: string;
  125114. };
  125115. }
  125116. declare module BABYLON {
  125117. /** @hidden */
  125118. export var depthOfFieldPixelShader: {
  125119. name: string;
  125120. shader: string;
  125121. };
  125122. }
  125123. declare module BABYLON {
  125124. /**
  125125. * BABYLON.JS Chromatic Aberration GLSL Shader
  125126. * Author: Olivier Guyot
  125127. * Separates very slightly R, G and B colors on the edges of the screen
  125128. * Inspired by Francois Tarlier & Martins Upitis
  125129. */
  125130. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  125131. /**
  125132. * @ignore
  125133. * The chromatic aberration PostProcess id in the pipeline
  125134. */
  125135. LensChromaticAberrationEffect: string;
  125136. /**
  125137. * @ignore
  125138. * The highlights enhancing PostProcess id in the pipeline
  125139. */
  125140. HighlightsEnhancingEffect: string;
  125141. /**
  125142. * @ignore
  125143. * The depth-of-field PostProcess id in the pipeline
  125144. */
  125145. LensDepthOfFieldEffect: string;
  125146. private _scene;
  125147. private _depthTexture;
  125148. private _grainTexture;
  125149. private _chromaticAberrationPostProcess;
  125150. private _highlightsPostProcess;
  125151. private _depthOfFieldPostProcess;
  125152. private _edgeBlur;
  125153. private _grainAmount;
  125154. private _chromaticAberration;
  125155. private _distortion;
  125156. private _highlightsGain;
  125157. private _highlightsThreshold;
  125158. private _dofDistance;
  125159. private _dofAperture;
  125160. private _dofDarken;
  125161. private _dofPentagon;
  125162. private _blurNoise;
  125163. /**
  125164. * @constructor
  125165. *
  125166. * Effect parameters are as follow:
  125167. * {
  125168. * chromatic_aberration: number; // from 0 to x (1 for realism)
  125169. * edge_blur: number; // from 0 to x (1 for realism)
  125170. * distortion: number; // from 0 to x (1 for realism)
  125171. * grain_amount: number; // from 0 to 1
  125172. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  125173. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  125174. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  125175. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  125176. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  125177. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  125178. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  125179. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  125180. * }
  125181. * Note: if an effect parameter is unset, effect is disabled
  125182. *
  125183. * @param name The rendering pipeline name
  125184. * @param parameters - An object containing all parameters (see above)
  125185. * @param scene The scene linked to this pipeline
  125186. * @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)
  125187. * @param cameras The array of cameras that the rendering pipeline will be attached to
  125188. */
  125189. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  125190. /**
  125191. * Get the class name
  125192. * @returns "LensRenderingPipeline"
  125193. */
  125194. getClassName(): string;
  125195. /**
  125196. * Gets associated scene
  125197. */
  125198. readonly scene: Scene;
  125199. /**
  125200. * Gets or sets the edge blur
  125201. */
  125202. edgeBlur: number;
  125203. /**
  125204. * Gets or sets the grain amount
  125205. */
  125206. grainAmount: number;
  125207. /**
  125208. * Gets or sets the chromatic aberration amount
  125209. */
  125210. chromaticAberration: number;
  125211. /**
  125212. * Gets or sets the depth of field aperture
  125213. */
  125214. dofAperture: number;
  125215. /**
  125216. * Gets or sets the edge distortion
  125217. */
  125218. edgeDistortion: number;
  125219. /**
  125220. * Gets or sets the depth of field distortion
  125221. */
  125222. dofDistortion: number;
  125223. /**
  125224. * Gets or sets the darken out of focus amount
  125225. */
  125226. darkenOutOfFocus: number;
  125227. /**
  125228. * Gets or sets a boolean indicating if blur noise is enabled
  125229. */
  125230. blurNoise: boolean;
  125231. /**
  125232. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  125233. */
  125234. pentagonBokeh: boolean;
  125235. /**
  125236. * Gets or sets the highlight grain amount
  125237. */
  125238. highlightsGain: number;
  125239. /**
  125240. * Gets or sets the highlight threshold
  125241. */
  125242. highlightsThreshold: number;
  125243. /**
  125244. * Sets the amount of blur at the edges
  125245. * @param amount blur amount
  125246. */
  125247. setEdgeBlur(amount: number): void;
  125248. /**
  125249. * Sets edge blur to 0
  125250. */
  125251. disableEdgeBlur(): void;
  125252. /**
  125253. * Sets the amout of grain
  125254. * @param amount Amount of grain
  125255. */
  125256. setGrainAmount(amount: number): void;
  125257. /**
  125258. * Set grain amount to 0
  125259. */
  125260. disableGrain(): void;
  125261. /**
  125262. * Sets the chromatic aberration amount
  125263. * @param amount amount of chromatic aberration
  125264. */
  125265. setChromaticAberration(amount: number): void;
  125266. /**
  125267. * Sets chromatic aberration amount to 0
  125268. */
  125269. disableChromaticAberration(): void;
  125270. /**
  125271. * Sets the EdgeDistortion amount
  125272. * @param amount amount of EdgeDistortion
  125273. */
  125274. setEdgeDistortion(amount: number): void;
  125275. /**
  125276. * Sets edge distortion to 0
  125277. */
  125278. disableEdgeDistortion(): void;
  125279. /**
  125280. * Sets the FocusDistance amount
  125281. * @param amount amount of FocusDistance
  125282. */
  125283. setFocusDistance(amount: number): void;
  125284. /**
  125285. * Disables depth of field
  125286. */
  125287. disableDepthOfField(): void;
  125288. /**
  125289. * Sets the Aperture amount
  125290. * @param amount amount of Aperture
  125291. */
  125292. setAperture(amount: number): void;
  125293. /**
  125294. * Sets the DarkenOutOfFocus amount
  125295. * @param amount amount of DarkenOutOfFocus
  125296. */
  125297. setDarkenOutOfFocus(amount: number): void;
  125298. private _pentagonBokehIsEnabled;
  125299. /**
  125300. * Creates a pentagon bokeh effect
  125301. */
  125302. enablePentagonBokeh(): void;
  125303. /**
  125304. * Disables the pentagon bokeh effect
  125305. */
  125306. disablePentagonBokeh(): void;
  125307. /**
  125308. * Enables noise blur
  125309. */
  125310. enableNoiseBlur(): void;
  125311. /**
  125312. * Disables noise blur
  125313. */
  125314. disableNoiseBlur(): void;
  125315. /**
  125316. * Sets the HighlightsGain amount
  125317. * @param amount amount of HighlightsGain
  125318. */
  125319. setHighlightsGain(amount: number): void;
  125320. /**
  125321. * Sets the HighlightsThreshold amount
  125322. * @param amount amount of HighlightsThreshold
  125323. */
  125324. setHighlightsThreshold(amount: number): void;
  125325. /**
  125326. * Disables highlights
  125327. */
  125328. disableHighlights(): void;
  125329. /**
  125330. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  125331. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  125332. */
  125333. dispose(disableDepthRender?: boolean): void;
  125334. private _createChromaticAberrationPostProcess;
  125335. private _createHighlightsPostProcess;
  125336. private _createDepthOfFieldPostProcess;
  125337. private _createGrainTexture;
  125338. }
  125339. }
  125340. declare module BABYLON {
  125341. /** @hidden */
  125342. export var ssao2PixelShader: {
  125343. name: string;
  125344. shader: string;
  125345. };
  125346. }
  125347. declare module BABYLON {
  125348. /** @hidden */
  125349. export var ssaoCombinePixelShader: {
  125350. name: string;
  125351. shader: string;
  125352. };
  125353. }
  125354. declare module BABYLON {
  125355. /**
  125356. * Render pipeline to produce ssao effect
  125357. */
  125358. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  125359. /**
  125360. * @ignore
  125361. * The PassPostProcess id in the pipeline that contains the original scene color
  125362. */
  125363. SSAOOriginalSceneColorEffect: string;
  125364. /**
  125365. * @ignore
  125366. * The SSAO PostProcess id in the pipeline
  125367. */
  125368. SSAORenderEffect: string;
  125369. /**
  125370. * @ignore
  125371. * The horizontal blur PostProcess id in the pipeline
  125372. */
  125373. SSAOBlurHRenderEffect: string;
  125374. /**
  125375. * @ignore
  125376. * The vertical blur PostProcess id in the pipeline
  125377. */
  125378. SSAOBlurVRenderEffect: string;
  125379. /**
  125380. * @ignore
  125381. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  125382. */
  125383. SSAOCombineRenderEffect: string;
  125384. /**
  125385. * The output strength of the SSAO post-process. Default value is 1.0.
  125386. */
  125387. totalStrength: number;
  125388. /**
  125389. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  125390. */
  125391. maxZ: number;
  125392. /**
  125393. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  125394. */
  125395. minZAspect: number;
  125396. private _samples;
  125397. /**
  125398. * Number of samples used for the SSAO calculations. Default value is 8
  125399. */
  125400. samples: number;
  125401. private _textureSamples;
  125402. /**
  125403. * Number of samples to use for antialiasing
  125404. */
  125405. textureSamples: number;
  125406. /**
  125407. * Ratio object used for SSAO ratio and blur ratio
  125408. */
  125409. private _ratio;
  125410. /**
  125411. * Dynamically generated sphere sampler.
  125412. */
  125413. private _sampleSphere;
  125414. /**
  125415. * Blur filter offsets
  125416. */
  125417. private _samplerOffsets;
  125418. private _expensiveBlur;
  125419. /**
  125420. * If bilateral blur should be used
  125421. */
  125422. expensiveBlur: boolean;
  125423. /**
  125424. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  125425. */
  125426. radius: number;
  125427. /**
  125428. * The base color of the SSAO post-process
  125429. * The final result is "base + ssao" between [0, 1]
  125430. */
  125431. base: number;
  125432. /**
  125433. * Support test.
  125434. */
  125435. static readonly IsSupported: boolean;
  125436. private _scene;
  125437. private _depthTexture;
  125438. private _normalTexture;
  125439. private _randomTexture;
  125440. private _originalColorPostProcess;
  125441. private _ssaoPostProcess;
  125442. private _blurHPostProcess;
  125443. private _blurVPostProcess;
  125444. private _ssaoCombinePostProcess;
  125445. private _firstUpdate;
  125446. /**
  125447. * Gets active scene
  125448. */
  125449. readonly scene: Scene;
  125450. /**
  125451. * @constructor
  125452. * @param name The rendering pipeline name
  125453. * @param scene The scene linked to this pipeline
  125454. * @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 }
  125455. * @param cameras The array of cameras that the rendering pipeline will be attached to
  125456. */
  125457. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  125458. /**
  125459. * Get the class name
  125460. * @returns "SSAO2RenderingPipeline"
  125461. */
  125462. getClassName(): string;
  125463. /**
  125464. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  125465. */
  125466. dispose(disableGeometryBufferRenderer?: boolean): void;
  125467. private _createBlurPostProcess;
  125468. /** @hidden */
  125469. _rebuild(): void;
  125470. private _bits;
  125471. private _radicalInverse_VdC;
  125472. private _hammersley;
  125473. private _hemisphereSample_uniform;
  125474. private _generateHemisphere;
  125475. private _createSSAOPostProcess;
  125476. private _createSSAOCombinePostProcess;
  125477. private _createRandomTexture;
  125478. /**
  125479. * Serialize the rendering pipeline (Used when exporting)
  125480. * @returns the serialized object
  125481. */
  125482. serialize(): any;
  125483. /**
  125484. * Parse the serialized pipeline
  125485. * @param source Source pipeline.
  125486. * @param scene The scene to load the pipeline to.
  125487. * @param rootUrl The URL of the serialized pipeline.
  125488. * @returns An instantiated pipeline from the serialized object.
  125489. */
  125490. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  125491. }
  125492. }
  125493. declare module BABYLON {
  125494. /** @hidden */
  125495. export var ssaoPixelShader: {
  125496. name: string;
  125497. shader: string;
  125498. };
  125499. }
  125500. declare module BABYLON {
  125501. /**
  125502. * Render pipeline to produce ssao effect
  125503. */
  125504. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  125505. /**
  125506. * @ignore
  125507. * The PassPostProcess id in the pipeline that contains the original scene color
  125508. */
  125509. SSAOOriginalSceneColorEffect: string;
  125510. /**
  125511. * @ignore
  125512. * The SSAO PostProcess id in the pipeline
  125513. */
  125514. SSAORenderEffect: string;
  125515. /**
  125516. * @ignore
  125517. * The horizontal blur PostProcess id in the pipeline
  125518. */
  125519. SSAOBlurHRenderEffect: string;
  125520. /**
  125521. * @ignore
  125522. * The vertical blur PostProcess id in the pipeline
  125523. */
  125524. SSAOBlurVRenderEffect: string;
  125525. /**
  125526. * @ignore
  125527. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  125528. */
  125529. SSAOCombineRenderEffect: string;
  125530. /**
  125531. * The output strength of the SSAO post-process. Default value is 1.0.
  125532. */
  125533. totalStrength: number;
  125534. /**
  125535. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  125536. */
  125537. radius: number;
  125538. /**
  125539. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  125540. * Must not be equal to fallOff and superior to fallOff.
  125541. * Default value is 0.0075
  125542. */
  125543. area: number;
  125544. /**
  125545. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  125546. * Must not be equal to area and inferior to area.
  125547. * Default value is 0.000001
  125548. */
  125549. fallOff: number;
  125550. /**
  125551. * The base color of the SSAO post-process
  125552. * The final result is "base + ssao" between [0, 1]
  125553. */
  125554. base: number;
  125555. private _scene;
  125556. private _depthTexture;
  125557. private _randomTexture;
  125558. private _originalColorPostProcess;
  125559. private _ssaoPostProcess;
  125560. private _blurHPostProcess;
  125561. private _blurVPostProcess;
  125562. private _ssaoCombinePostProcess;
  125563. private _firstUpdate;
  125564. /**
  125565. * Gets active scene
  125566. */
  125567. readonly scene: Scene;
  125568. /**
  125569. * @constructor
  125570. * @param name - The rendering pipeline name
  125571. * @param scene - The scene linked to this pipeline
  125572. * @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 }
  125573. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  125574. */
  125575. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  125576. /**
  125577. * Get the class name
  125578. * @returns "SSAORenderingPipeline"
  125579. */
  125580. getClassName(): string;
  125581. /**
  125582. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  125583. */
  125584. dispose(disableDepthRender?: boolean): void;
  125585. private _createBlurPostProcess;
  125586. /** @hidden */
  125587. _rebuild(): void;
  125588. private _createSSAOPostProcess;
  125589. private _createSSAOCombinePostProcess;
  125590. private _createRandomTexture;
  125591. }
  125592. }
  125593. declare module BABYLON {
  125594. /** @hidden */
  125595. export var standardPixelShader: {
  125596. name: string;
  125597. shader: string;
  125598. };
  125599. }
  125600. declare module BABYLON {
  125601. /**
  125602. * Standard rendering pipeline
  125603. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  125604. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  125605. */
  125606. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  125607. /**
  125608. * Public members
  125609. */
  125610. /**
  125611. * Post-process which contains the original scene color before the pipeline applies all the effects
  125612. */
  125613. originalPostProcess: Nullable<PostProcess>;
  125614. /**
  125615. * Post-process used to down scale an image x4
  125616. */
  125617. downSampleX4PostProcess: Nullable<PostProcess>;
  125618. /**
  125619. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  125620. */
  125621. brightPassPostProcess: Nullable<PostProcess>;
  125622. /**
  125623. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  125624. */
  125625. blurHPostProcesses: PostProcess[];
  125626. /**
  125627. * Post-process array storing all the vertical blur post-processes used by the pipeline
  125628. */
  125629. blurVPostProcesses: PostProcess[];
  125630. /**
  125631. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  125632. */
  125633. textureAdderPostProcess: Nullable<PostProcess>;
  125634. /**
  125635. * Post-process used to create volumetric lighting effect
  125636. */
  125637. volumetricLightPostProcess: Nullable<PostProcess>;
  125638. /**
  125639. * Post-process used to smooth the previous volumetric light post-process on the X axis
  125640. */
  125641. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  125642. /**
  125643. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  125644. */
  125645. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  125646. /**
  125647. * Post-process used to merge the volumetric light effect and the real scene color
  125648. */
  125649. volumetricLightMergePostProces: Nullable<PostProcess>;
  125650. /**
  125651. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  125652. */
  125653. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  125654. /**
  125655. * Base post-process used to calculate the average luminance of the final image for HDR
  125656. */
  125657. luminancePostProcess: Nullable<PostProcess>;
  125658. /**
  125659. * Post-processes used to create down sample post-processes in order to get
  125660. * the average luminance of the final image for HDR
  125661. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  125662. */
  125663. luminanceDownSamplePostProcesses: PostProcess[];
  125664. /**
  125665. * Post-process used to create a HDR effect (light adaptation)
  125666. */
  125667. hdrPostProcess: Nullable<PostProcess>;
  125668. /**
  125669. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  125670. */
  125671. textureAdderFinalPostProcess: Nullable<PostProcess>;
  125672. /**
  125673. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  125674. */
  125675. lensFlareFinalPostProcess: Nullable<PostProcess>;
  125676. /**
  125677. * Post-process used to merge the final HDR post-process and the real scene color
  125678. */
  125679. hdrFinalPostProcess: Nullable<PostProcess>;
  125680. /**
  125681. * Post-process used to create a lens flare effect
  125682. */
  125683. lensFlarePostProcess: Nullable<PostProcess>;
  125684. /**
  125685. * Post-process that merges the result of the lens flare post-process and the real scene color
  125686. */
  125687. lensFlareComposePostProcess: Nullable<PostProcess>;
  125688. /**
  125689. * Post-process used to create a motion blur effect
  125690. */
  125691. motionBlurPostProcess: Nullable<PostProcess>;
  125692. /**
  125693. * Post-process used to create a depth of field effect
  125694. */
  125695. depthOfFieldPostProcess: Nullable<PostProcess>;
  125696. /**
  125697. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  125698. */
  125699. fxaaPostProcess: Nullable<FxaaPostProcess>;
  125700. /**
  125701. * Represents the brightness threshold in order to configure the illuminated surfaces
  125702. */
  125703. brightThreshold: number;
  125704. /**
  125705. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  125706. */
  125707. blurWidth: number;
  125708. /**
  125709. * Sets if the blur for highlighted surfaces must be only horizontal
  125710. */
  125711. horizontalBlur: boolean;
  125712. /**
  125713. * Gets the overall exposure used by the pipeline
  125714. */
  125715. /**
  125716. * Sets the overall exposure used by the pipeline
  125717. */
  125718. exposure: number;
  125719. /**
  125720. * Texture used typically to simulate "dirty" on camera lens
  125721. */
  125722. lensTexture: Nullable<Texture>;
  125723. /**
  125724. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  125725. */
  125726. volumetricLightCoefficient: number;
  125727. /**
  125728. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  125729. */
  125730. volumetricLightPower: number;
  125731. /**
  125732. * Used the set the blur intensity to smooth the volumetric lights
  125733. */
  125734. volumetricLightBlurScale: number;
  125735. /**
  125736. * Light (spot or directional) used to generate the volumetric lights rays
  125737. * The source light must have a shadow generate so the pipeline can get its
  125738. * depth map
  125739. */
  125740. sourceLight: Nullable<SpotLight | DirectionalLight>;
  125741. /**
  125742. * For eye adaptation, represents the minimum luminance the eye can see
  125743. */
  125744. hdrMinimumLuminance: number;
  125745. /**
  125746. * For eye adaptation, represents the decrease luminance speed
  125747. */
  125748. hdrDecreaseRate: number;
  125749. /**
  125750. * For eye adaptation, represents the increase luminance speed
  125751. */
  125752. hdrIncreaseRate: number;
  125753. /**
  125754. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  125755. */
  125756. /**
  125757. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  125758. */
  125759. hdrAutoExposure: boolean;
  125760. /**
  125761. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  125762. */
  125763. lensColorTexture: Nullable<Texture>;
  125764. /**
  125765. * The overall strengh for the lens flare effect
  125766. */
  125767. lensFlareStrength: number;
  125768. /**
  125769. * Dispersion coefficient for lens flare ghosts
  125770. */
  125771. lensFlareGhostDispersal: number;
  125772. /**
  125773. * Main lens flare halo width
  125774. */
  125775. lensFlareHaloWidth: number;
  125776. /**
  125777. * Based on the lens distortion effect, defines how much the lens flare result
  125778. * is distorted
  125779. */
  125780. lensFlareDistortionStrength: number;
  125781. /**
  125782. * Configures the blur intensity used for for lens flare (halo)
  125783. */
  125784. lensFlareBlurWidth: number;
  125785. /**
  125786. * Lens star texture must be used to simulate rays on the flares and is available
  125787. * in the documentation
  125788. */
  125789. lensStarTexture: Nullable<Texture>;
  125790. /**
  125791. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  125792. * flare effect by taking account of the dirt texture
  125793. */
  125794. lensFlareDirtTexture: Nullable<Texture>;
  125795. /**
  125796. * Represents the focal length for the depth of field effect
  125797. */
  125798. depthOfFieldDistance: number;
  125799. /**
  125800. * Represents the blur intensity for the blurred part of the depth of field effect
  125801. */
  125802. depthOfFieldBlurWidth: number;
  125803. /**
  125804. * Gets how much the image is blurred by the movement while using the motion blur post-process
  125805. */
  125806. /**
  125807. * Sets how much the image is blurred by the movement while using the motion blur post-process
  125808. */
  125809. motionStrength: number;
  125810. /**
  125811. * Gets wether or not the motion blur post-process is object based or screen based.
  125812. */
  125813. /**
  125814. * Sets wether or not the motion blur post-process should be object based or screen based
  125815. */
  125816. objectBasedMotionBlur: boolean;
  125817. /**
  125818. * List of animations for the pipeline (IAnimatable implementation)
  125819. */
  125820. animations: Animation[];
  125821. /**
  125822. * Private members
  125823. */
  125824. private _scene;
  125825. private _currentDepthOfFieldSource;
  125826. private _basePostProcess;
  125827. private _fixedExposure;
  125828. private _currentExposure;
  125829. private _hdrAutoExposure;
  125830. private _hdrCurrentLuminance;
  125831. private _motionStrength;
  125832. private _isObjectBasedMotionBlur;
  125833. private _floatTextureType;
  125834. private _camerasToBeAttached;
  125835. private _ratio;
  125836. private _bloomEnabled;
  125837. private _depthOfFieldEnabled;
  125838. private _vlsEnabled;
  125839. private _lensFlareEnabled;
  125840. private _hdrEnabled;
  125841. private _motionBlurEnabled;
  125842. private _fxaaEnabled;
  125843. private _motionBlurSamples;
  125844. private _volumetricLightStepsCount;
  125845. private _samples;
  125846. /**
  125847. * @ignore
  125848. * Specifies if the bloom pipeline is enabled
  125849. */
  125850. BloomEnabled: boolean;
  125851. /**
  125852. * @ignore
  125853. * Specifies if the depth of field pipeline is enabed
  125854. */
  125855. DepthOfFieldEnabled: boolean;
  125856. /**
  125857. * @ignore
  125858. * Specifies if the lens flare pipeline is enabed
  125859. */
  125860. LensFlareEnabled: boolean;
  125861. /**
  125862. * @ignore
  125863. * Specifies if the HDR pipeline is enabled
  125864. */
  125865. HDREnabled: boolean;
  125866. /**
  125867. * @ignore
  125868. * Specifies if the volumetric lights scattering effect is enabled
  125869. */
  125870. VLSEnabled: boolean;
  125871. /**
  125872. * @ignore
  125873. * Specifies if the motion blur effect is enabled
  125874. */
  125875. MotionBlurEnabled: boolean;
  125876. /**
  125877. * Specifies if anti-aliasing is enabled
  125878. */
  125879. fxaaEnabled: boolean;
  125880. /**
  125881. * Specifies the number of steps used to calculate the volumetric lights
  125882. * Typically in interval [50, 200]
  125883. */
  125884. volumetricLightStepsCount: number;
  125885. /**
  125886. * Specifies the number of samples used for the motion blur effect
  125887. * Typically in interval [16, 64]
  125888. */
  125889. motionBlurSamples: number;
  125890. /**
  125891. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  125892. */
  125893. samples: number;
  125894. /**
  125895. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  125896. * @constructor
  125897. * @param name The rendering pipeline name
  125898. * @param scene The scene linked to this pipeline
  125899. * @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)
  125900. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  125901. * @param cameras The array of cameras that the rendering pipeline will be attached to
  125902. */
  125903. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  125904. private _buildPipeline;
  125905. private _createDownSampleX4PostProcess;
  125906. private _createBrightPassPostProcess;
  125907. private _createBlurPostProcesses;
  125908. private _createTextureAdderPostProcess;
  125909. private _createVolumetricLightPostProcess;
  125910. private _createLuminancePostProcesses;
  125911. private _createHdrPostProcess;
  125912. private _createLensFlarePostProcess;
  125913. private _createDepthOfFieldPostProcess;
  125914. private _createMotionBlurPostProcess;
  125915. private _getDepthTexture;
  125916. private _disposePostProcesses;
  125917. /**
  125918. * Dispose of the pipeline and stop all post processes
  125919. */
  125920. dispose(): void;
  125921. /**
  125922. * Serialize the rendering pipeline (Used when exporting)
  125923. * @returns the serialized object
  125924. */
  125925. serialize(): any;
  125926. /**
  125927. * Parse the serialized pipeline
  125928. * @param source Source pipeline.
  125929. * @param scene The scene to load the pipeline to.
  125930. * @param rootUrl The URL of the serialized pipeline.
  125931. * @returns An instantiated pipeline from the serialized object.
  125932. */
  125933. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  125934. /**
  125935. * Luminance steps
  125936. */
  125937. static LuminanceSteps: number;
  125938. }
  125939. }
  125940. declare module BABYLON {
  125941. /** @hidden */
  125942. export var tonemapPixelShader: {
  125943. name: string;
  125944. shader: string;
  125945. };
  125946. }
  125947. declare module BABYLON {
  125948. /** Defines operator used for tonemapping */
  125949. export enum TonemappingOperator {
  125950. /** Hable */
  125951. Hable = 0,
  125952. /** Reinhard */
  125953. Reinhard = 1,
  125954. /** HejiDawson */
  125955. HejiDawson = 2,
  125956. /** Photographic */
  125957. Photographic = 3
  125958. }
  125959. /**
  125960. * Defines a post process to apply tone mapping
  125961. */
  125962. export class TonemapPostProcess extends PostProcess {
  125963. private _operator;
  125964. /** Defines the required exposure adjustement */
  125965. exposureAdjustment: number;
  125966. /**
  125967. * Creates a new TonemapPostProcess
  125968. * @param name defines the name of the postprocess
  125969. * @param _operator defines the operator to use
  125970. * @param exposureAdjustment defines the required exposure adjustement
  125971. * @param camera defines the camera to use (can be null)
  125972. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  125973. * @param engine defines the hosting engine (can be ignore if camera is set)
  125974. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  125975. */
  125976. constructor(name: string, _operator: TonemappingOperator,
  125977. /** Defines the required exposure adjustement */
  125978. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  125979. }
  125980. }
  125981. declare module BABYLON {
  125982. /** @hidden */
  125983. export var depthVertexShader: {
  125984. name: string;
  125985. shader: string;
  125986. };
  125987. }
  125988. declare module BABYLON {
  125989. /** @hidden */
  125990. export var volumetricLightScatteringPixelShader: {
  125991. name: string;
  125992. shader: string;
  125993. };
  125994. }
  125995. declare module BABYLON {
  125996. /** @hidden */
  125997. export var volumetricLightScatteringPassVertexShader: {
  125998. name: string;
  125999. shader: string;
  126000. };
  126001. }
  126002. declare module BABYLON {
  126003. /** @hidden */
  126004. export var volumetricLightScatteringPassPixelShader: {
  126005. name: string;
  126006. shader: string;
  126007. };
  126008. }
  126009. declare module BABYLON {
  126010. /**
  126011. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  126012. */
  126013. export class VolumetricLightScatteringPostProcess extends PostProcess {
  126014. private _volumetricLightScatteringPass;
  126015. private _volumetricLightScatteringRTT;
  126016. private _viewPort;
  126017. private _screenCoordinates;
  126018. private _cachedDefines;
  126019. /**
  126020. * If not undefined, the mesh position is computed from the attached node position
  126021. */
  126022. attachedNode: {
  126023. position: Vector3;
  126024. };
  126025. /**
  126026. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  126027. */
  126028. customMeshPosition: Vector3;
  126029. /**
  126030. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  126031. */
  126032. useCustomMeshPosition: boolean;
  126033. /**
  126034. * If the post-process should inverse the light scattering direction
  126035. */
  126036. invert: boolean;
  126037. /**
  126038. * The internal mesh used by the post-process
  126039. */
  126040. mesh: Mesh;
  126041. /**
  126042. * @hidden
  126043. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  126044. */
  126045. useDiffuseColor: boolean;
  126046. /**
  126047. * Array containing the excluded meshes not rendered in the internal pass
  126048. */
  126049. excludedMeshes: AbstractMesh[];
  126050. /**
  126051. * Controls the overall intensity of the post-process
  126052. */
  126053. exposure: number;
  126054. /**
  126055. * Dissipates each sample's contribution in range [0, 1]
  126056. */
  126057. decay: number;
  126058. /**
  126059. * Controls the overall intensity of each sample
  126060. */
  126061. weight: number;
  126062. /**
  126063. * Controls the density of each sample
  126064. */
  126065. density: number;
  126066. /**
  126067. * @constructor
  126068. * @param name The post-process name
  126069. * @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)
  126070. * @param camera The camera that the post-process will be attached to
  126071. * @param mesh The mesh used to create the light scattering
  126072. * @param samples The post-process quality, default 100
  126073. * @param samplingModeThe post-process filtering mode
  126074. * @param engine The babylon engine
  126075. * @param reusable If the post-process is reusable
  126076. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  126077. */
  126078. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  126079. /**
  126080. * Returns the string "VolumetricLightScatteringPostProcess"
  126081. * @returns "VolumetricLightScatteringPostProcess"
  126082. */
  126083. getClassName(): string;
  126084. private _isReady;
  126085. /**
  126086. * Sets the new light position for light scattering effect
  126087. * @param position The new custom light position
  126088. */
  126089. setCustomMeshPosition(position: Vector3): void;
  126090. /**
  126091. * Returns the light position for light scattering effect
  126092. * @return Vector3 The custom light position
  126093. */
  126094. getCustomMeshPosition(): Vector3;
  126095. /**
  126096. * Disposes the internal assets and detaches the post-process from the camera
  126097. */
  126098. dispose(camera: Camera): void;
  126099. /**
  126100. * Returns the render target texture used by the post-process
  126101. * @return the render target texture used by the post-process
  126102. */
  126103. getPass(): RenderTargetTexture;
  126104. private _meshExcluded;
  126105. private _createPass;
  126106. private _updateMeshScreenCoordinates;
  126107. /**
  126108. * Creates a default mesh for the Volumeric Light Scattering post-process
  126109. * @param name The mesh name
  126110. * @param scene The scene where to create the mesh
  126111. * @return the default mesh
  126112. */
  126113. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  126114. }
  126115. }
  126116. declare module BABYLON {
  126117. interface Scene {
  126118. /** @hidden (Backing field) */
  126119. _boundingBoxRenderer: BoundingBoxRenderer;
  126120. /** @hidden (Backing field) */
  126121. _forceShowBoundingBoxes: boolean;
  126122. /**
  126123. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  126124. */
  126125. forceShowBoundingBoxes: boolean;
  126126. /**
  126127. * Gets the bounding box renderer associated with the scene
  126128. * @returns a BoundingBoxRenderer
  126129. */
  126130. getBoundingBoxRenderer(): BoundingBoxRenderer;
  126131. }
  126132. interface AbstractMesh {
  126133. /** @hidden (Backing field) */
  126134. _showBoundingBox: boolean;
  126135. /**
  126136. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  126137. */
  126138. showBoundingBox: boolean;
  126139. }
  126140. /**
  126141. * Component responsible of rendering the bounding box of the meshes in a scene.
  126142. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  126143. */
  126144. export class BoundingBoxRenderer implements ISceneComponent {
  126145. /**
  126146. * The component name helpfull to identify the component in the list of scene components.
  126147. */
  126148. readonly name: string;
  126149. /**
  126150. * The scene the component belongs to.
  126151. */
  126152. scene: Scene;
  126153. /**
  126154. * Color of the bounding box lines placed in front of an object
  126155. */
  126156. frontColor: Color3;
  126157. /**
  126158. * Color of the bounding box lines placed behind an object
  126159. */
  126160. backColor: Color3;
  126161. /**
  126162. * Defines if the renderer should show the back lines or not
  126163. */
  126164. showBackLines: boolean;
  126165. /**
  126166. * @hidden
  126167. */
  126168. renderList: SmartArray<BoundingBox>;
  126169. private _colorShader;
  126170. private _vertexBuffers;
  126171. private _indexBuffer;
  126172. private _fillIndexBuffer;
  126173. private _fillIndexData;
  126174. /**
  126175. * Instantiates a new bounding box renderer in a scene.
  126176. * @param scene the scene the renderer renders in
  126177. */
  126178. constructor(scene: Scene);
  126179. /**
  126180. * Registers the component in a given scene
  126181. */
  126182. register(): void;
  126183. private _evaluateSubMesh;
  126184. private _activeMesh;
  126185. private _prepareRessources;
  126186. private _createIndexBuffer;
  126187. /**
  126188. * Rebuilds the elements related to this component in case of
  126189. * context lost for instance.
  126190. */
  126191. rebuild(): void;
  126192. /**
  126193. * @hidden
  126194. */
  126195. reset(): void;
  126196. /**
  126197. * Render the bounding boxes of a specific rendering group
  126198. * @param renderingGroupId defines the rendering group to render
  126199. */
  126200. render(renderingGroupId: number): void;
  126201. /**
  126202. * In case of occlusion queries, we can render the occlusion bounding box through this method
  126203. * @param mesh Define the mesh to render the occlusion bounding box for
  126204. */
  126205. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  126206. /**
  126207. * Dispose and release the resources attached to this renderer.
  126208. */
  126209. dispose(): void;
  126210. }
  126211. }
  126212. declare module BABYLON {
  126213. /** @hidden */
  126214. export var depthPixelShader: {
  126215. name: string;
  126216. shader: string;
  126217. };
  126218. }
  126219. declare module BABYLON {
  126220. /**
  126221. * This represents a depth renderer in Babylon.
  126222. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  126223. */
  126224. export class DepthRenderer {
  126225. private _scene;
  126226. private _depthMap;
  126227. private _effect;
  126228. private readonly _storeNonLinearDepth;
  126229. private readonly _clearColor;
  126230. /** Get if the depth renderer is using packed depth or not */
  126231. readonly isPacked: boolean;
  126232. private _cachedDefines;
  126233. private _camera;
  126234. /**
  126235. * Specifiess that the depth renderer will only be used within
  126236. * the camera it is created for.
  126237. * This can help forcing its rendering during the camera processing.
  126238. */
  126239. useOnlyInActiveCamera: boolean;
  126240. /** @hidden */
  126241. static _SceneComponentInitialization: (scene: Scene) => void;
  126242. /**
  126243. * Instantiates a depth renderer
  126244. * @param scene The scene the renderer belongs to
  126245. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  126246. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  126247. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  126248. */
  126249. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  126250. /**
  126251. * Creates the depth rendering effect and checks if the effect is ready.
  126252. * @param subMesh The submesh to be used to render the depth map of
  126253. * @param useInstances If multiple world instances should be used
  126254. * @returns if the depth renderer is ready to render the depth map
  126255. */
  126256. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126257. /**
  126258. * Gets the texture which the depth map will be written to.
  126259. * @returns The depth map texture
  126260. */
  126261. getDepthMap(): RenderTargetTexture;
  126262. /**
  126263. * Disposes of the depth renderer.
  126264. */
  126265. dispose(): void;
  126266. }
  126267. }
  126268. declare module BABYLON {
  126269. interface Scene {
  126270. /** @hidden (Backing field) */
  126271. _depthRenderer: {
  126272. [id: string]: DepthRenderer;
  126273. };
  126274. /**
  126275. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  126276. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  126277. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  126278. * @returns the created depth renderer
  126279. */
  126280. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  126281. /**
  126282. * Disables a depth renderer for a given camera
  126283. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  126284. */
  126285. disableDepthRenderer(camera?: Nullable<Camera>): void;
  126286. }
  126287. /**
  126288. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  126289. * in several rendering techniques.
  126290. */
  126291. export class DepthRendererSceneComponent implements ISceneComponent {
  126292. /**
  126293. * The component name helpfull to identify the component in the list of scene components.
  126294. */
  126295. readonly name: string;
  126296. /**
  126297. * The scene the component belongs to.
  126298. */
  126299. scene: Scene;
  126300. /**
  126301. * Creates a new instance of the component for the given scene
  126302. * @param scene Defines the scene to register the component in
  126303. */
  126304. constructor(scene: Scene);
  126305. /**
  126306. * Registers the component in a given scene
  126307. */
  126308. register(): void;
  126309. /**
  126310. * Rebuilds the elements related to this component in case of
  126311. * context lost for instance.
  126312. */
  126313. rebuild(): void;
  126314. /**
  126315. * Disposes the component and the associated ressources
  126316. */
  126317. dispose(): void;
  126318. private _gatherRenderTargets;
  126319. private _gatherActiveCameraRenderTargets;
  126320. }
  126321. }
  126322. declare module BABYLON {
  126323. /** @hidden */
  126324. export var outlinePixelShader: {
  126325. name: string;
  126326. shader: string;
  126327. };
  126328. }
  126329. declare module BABYLON {
  126330. /** @hidden */
  126331. export var outlineVertexShader: {
  126332. name: string;
  126333. shader: string;
  126334. };
  126335. }
  126336. declare module BABYLON {
  126337. interface Scene {
  126338. /** @hidden */
  126339. _outlineRenderer: OutlineRenderer;
  126340. /**
  126341. * Gets the outline renderer associated with the scene
  126342. * @returns a OutlineRenderer
  126343. */
  126344. getOutlineRenderer(): OutlineRenderer;
  126345. }
  126346. interface AbstractMesh {
  126347. /** @hidden (Backing field) */
  126348. _renderOutline: boolean;
  126349. /**
  126350. * Gets or sets a boolean indicating if the outline must be rendered as well
  126351. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  126352. */
  126353. renderOutline: boolean;
  126354. /** @hidden (Backing field) */
  126355. _renderOverlay: boolean;
  126356. /**
  126357. * Gets or sets a boolean indicating if the overlay must be rendered as well
  126358. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  126359. */
  126360. renderOverlay: boolean;
  126361. }
  126362. /**
  126363. * This class is responsible to draw bothe outline/overlay of meshes.
  126364. * It should not be used directly but through the available method on mesh.
  126365. */
  126366. export class OutlineRenderer implements ISceneComponent {
  126367. /**
  126368. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  126369. */
  126370. private static _StencilReference;
  126371. /**
  126372. * The name of the component. Each component must have a unique name.
  126373. */
  126374. name: string;
  126375. /**
  126376. * The scene the component belongs to.
  126377. */
  126378. scene: Scene;
  126379. /**
  126380. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  126381. */
  126382. zOffset: number;
  126383. private _engine;
  126384. private _effect;
  126385. private _cachedDefines;
  126386. private _savedDepthWrite;
  126387. /**
  126388. * Instantiates a new outline renderer. (There could be only one per scene).
  126389. * @param scene Defines the scene it belongs to
  126390. */
  126391. constructor(scene: Scene);
  126392. /**
  126393. * Register the component to one instance of a scene.
  126394. */
  126395. register(): void;
  126396. /**
  126397. * Rebuilds the elements related to this component in case of
  126398. * context lost for instance.
  126399. */
  126400. rebuild(): void;
  126401. /**
  126402. * Disposes the component and the associated ressources.
  126403. */
  126404. dispose(): void;
  126405. /**
  126406. * Renders the outline in the canvas.
  126407. * @param subMesh Defines the sumesh to render
  126408. * @param batch Defines the batch of meshes in case of instances
  126409. * @param useOverlay Defines if the rendering is for the overlay or the outline
  126410. */
  126411. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  126412. /**
  126413. * Returns whether or not the outline renderer is ready for a given submesh.
  126414. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  126415. * @param subMesh Defines the submesh to check readyness for
  126416. * @param useInstances Defines wheter wee are trying to render instances or not
  126417. * @returns true if ready otherwise false
  126418. */
  126419. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126420. private _beforeRenderingMesh;
  126421. private _afterRenderingMesh;
  126422. }
  126423. }
  126424. declare module BABYLON {
  126425. /**
  126426. * Class used to manage multiple sprites of different sizes on the same spritesheet
  126427. * @see http://doc.babylonjs.com/babylon101/sprites
  126428. */
  126429. export class SpritePackedManager extends SpriteManager {
  126430. /** defines the packed manager's name */
  126431. name: string;
  126432. /**
  126433. * Creates a new sprite manager from a packed sprite sheet
  126434. * @param name defines the manager's name
  126435. * @param imgUrl defines the sprite sheet url
  126436. * @param capacity defines the maximum allowed number of sprites
  126437. * @param scene defines the hosting scene
  126438. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  126439. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  126440. * @param samplingMode defines the smapling mode to use with spritesheet
  126441. * @param fromPacked set to true; do not alter
  126442. */
  126443. constructor(
  126444. /** defines the packed manager's name */
  126445. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  126446. }
  126447. }
  126448. declare module BABYLON {
  126449. /**
  126450. * Defines the list of states available for a task inside a AssetsManager
  126451. */
  126452. export enum AssetTaskState {
  126453. /**
  126454. * Initialization
  126455. */
  126456. INIT = 0,
  126457. /**
  126458. * Running
  126459. */
  126460. RUNNING = 1,
  126461. /**
  126462. * Done
  126463. */
  126464. DONE = 2,
  126465. /**
  126466. * Error
  126467. */
  126468. ERROR = 3
  126469. }
  126470. /**
  126471. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  126472. */
  126473. export abstract class AbstractAssetTask {
  126474. /**
  126475. * Task name
  126476. */ name: string;
  126477. /**
  126478. * Callback called when the task is successful
  126479. */
  126480. onSuccess: (task: any) => void;
  126481. /**
  126482. * Callback called when the task is not successful
  126483. */
  126484. onError: (task: any, message?: string, exception?: any) => void;
  126485. /**
  126486. * Creates a new AssetsManager
  126487. * @param name defines the name of the task
  126488. */
  126489. constructor(
  126490. /**
  126491. * Task name
  126492. */ name: string);
  126493. private _isCompleted;
  126494. private _taskState;
  126495. private _errorObject;
  126496. /**
  126497. * Get if the task is completed
  126498. */
  126499. readonly isCompleted: boolean;
  126500. /**
  126501. * Gets the current state of the task
  126502. */
  126503. readonly taskState: AssetTaskState;
  126504. /**
  126505. * Gets the current error object (if task is in error)
  126506. */
  126507. readonly errorObject: {
  126508. message?: string;
  126509. exception?: any;
  126510. };
  126511. /**
  126512. * Internal only
  126513. * @hidden
  126514. */
  126515. _setErrorObject(message?: string, exception?: any): void;
  126516. /**
  126517. * Execute the current task
  126518. * @param scene defines the scene where you want your assets to be loaded
  126519. * @param onSuccess is a callback called when the task is successfully executed
  126520. * @param onError is a callback called if an error occurs
  126521. */
  126522. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126523. /**
  126524. * Execute the current task
  126525. * @param scene defines the scene where you want your assets to be loaded
  126526. * @param onSuccess is a callback called when the task is successfully executed
  126527. * @param onError is a callback called if an error occurs
  126528. */
  126529. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126530. /**
  126531. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  126532. * This can be used with failed tasks that have the reason for failure fixed.
  126533. */
  126534. reset(): void;
  126535. private onErrorCallback;
  126536. private onDoneCallback;
  126537. }
  126538. /**
  126539. * Define the interface used by progress events raised during assets loading
  126540. */
  126541. export interface IAssetsProgressEvent {
  126542. /**
  126543. * Defines the number of remaining tasks to process
  126544. */
  126545. remainingCount: number;
  126546. /**
  126547. * Defines the total number of tasks
  126548. */
  126549. totalCount: number;
  126550. /**
  126551. * Defines the task that was just processed
  126552. */
  126553. task: AbstractAssetTask;
  126554. }
  126555. /**
  126556. * Class used to share progress information about assets loading
  126557. */
  126558. export class AssetsProgressEvent implements IAssetsProgressEvent {
  126559. /**
  126560. * Defines the number of remaining tasks to process
  126561. */
  126562. remainingCount: number;
  126563. /**
  126564. * Defines the total number of tasks
  126565. */
  126566. totalCount: number;
  126567. /**
  126568. * Defines the task that was just processed
  126569. */
  126570. task: AbstractAssetTask;
  126571. /**
  126572. * Creates a AssetsProgressEvent
  126573. * @param remainingCount defines the number of remaining tasks to process
  126574. * @param totalCount defines the total number of tasks
  126575. * @param task defines the task that was just processed
  126576. */
  126577. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  126578. }
  126579. /**
  126580. * Define a task used by AssetsManager to load meshes
  126581. */
  126582. export class MeshAssetTask extends AbstractAssetTask {
  126583. /**
  126584. * Defines the name of the task
  126585. */
  126586. name: string;
  126587. /**
  126588. * Defines the list of mesh's names you want to load
  126589. */
  126590. meshesNames: any;
  126591. /**
  126592. * Defines the root url to use as a base to load your meshes and associated resources
  126593. */
  126594. rootUrl: string;
  126595. /**
  126596. * Defines the filename of the scene to load from
  126597. */
  126598. sceneFilename: string;
  126599. /**
  126600. * Gets the list of loaded meshes
  126601. */
  126602. loadedMeshes: Array<AbstractMesh>;
  126603. /**
  126604. * Gets the list of loaded particle systems
  126605. */
  126606. loadedParticleSystems: Array<IParticleSystem>;
  126607. /**
  126608. * Gets the list of loaded skeletons
  126609. */
  126610. loadedSkeletons: Array<Skeleton>;
  126611. /**
  126612. * Gets the list of loaded animation groups
  126613. */
  126614. loadedAnimationGroups: Array<AnimationGroup>;
  126615. /**
  126616. * Callback called when the task is successful
  126617. */
  126618. onSuccess: (task: MeshAssetTask) => void;
  126619. /**
  126620. * Callback called when the task is successful
  126621. */
  126622. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  126623. /**
  126624. * Creates a new MeshAssetTask
  126625. * @param name defines the name of the task
  126626. * @param meshesNames defines the list of mesh's names you want to load
  126627. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  126628. * @param sceneFilename defines the filename of the scene to load from
  126629. */
  126630. constructor(
  126631. /**
  126632. * Defines the name of the task
  126633. */
  126634. name: string,
  126635. /**
  126636. * Defines the list of mesh's names you want to load
  126637. */
  126638. meshesNames: any,
  126639. /**
  126640. * Defines the root url to use as a base to load your meshes and associated resources
  126641. */
  126642. rootUrl: string,
  126643. /**
  126644. * Defines the filename of the scene to load from
  126645. */
  126646. sceneFilename: string);
  126647. /**
  126648. * Execute the current task
  126649. * @param scene defines the scene where you want your assets to be loaded
  126650. * @param onSuccess is a callback called when the task is successfully executed
  126651. * @param onError is a callback called if an error occurs
  126652. */
  126653. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126654. }
  126655. /**
  126656. * Define a task used by AssetsManager to load text content
  126657. */
  126658. export class TextFileAssetTask extends AbstractAssetTask {
  126659. /**
  126660. * Defines the name of the task
  126661. */
  126662. name: string;
  126663. /**
  126664. * Defines the location of the file to load
  126665. */
  126666. url: string;
  126667. /**
  126668. * Gets the loaded text string
  126669. */
  126670. text: string;
  126671. /**
  126672. * Callback called when the task is successful
  126673. */
  126674. onSuccess: (task: TextFileAssetTask) => void;
  126675. /**
  126676. * Callback called when the task is successful
  126677. */
  126678. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  126679. /**
  126680. * Creates a new TextFileAssetTask object
  126681. * @param name defines the name of the task
  126682. * @param url defines the location of the file to load
  126683. */
  126684. constructor(
  126685. /**
  126686. * Defines the name of the task
  126687. */
  126688. name: string,
  126689. /**
  126690. * Defines the location of the file to load
  126691. */
  126692. url: string);
  126693. /**
  126694. * Execute the current task
  126695. * @param scene defines the scene where you want your assets to be loaded
  126696. * @param onSuccess is a callback called when the task is successfully executed
  126697. * @param onError is a callback called if an error occurs
  126698. */
  126699. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126700. }
  126701. /**
  126702. * Define a task used by AssetsManager to load binary data
  126703. */
  126704. export class BinaryFileAssetTask extends AbstractAssetTask {
  126705. /**
  126706. * Defines the name of the task
  126707. */
  126708. name: string;
  126709. /**
  126710. * Defines the location of the file to load
  126711. */
  126712. url: string;
  126713. /**
  126714. * Gets the lodaded data (as an array buffer)
  126715. */
  126716. data: ArrayBuffer;
  126717. /**
  126718. * Callback called when the task is successful
  126719. */
  126720. onSuccess: (task: BinaryFileAssetTask) => void;
  126721. /**
  126722. * Callback called when the task is successful
  126723. */
  126724. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  126725. /**
  126726. * Creates a new BinaryFileAssetTask object
  126727. * @param name defines the name of the new task
  126728. * @param url defines the location of the file to load
  126729. */
  126730. constructor(
  126731. /**
  126732. * Defines the name of the task
  126733. */
  126734. name: string,
  126735. /**
  126736. * Defines the location of the file to load
  126737. */
  126738. url: string);
  126739. /**
  126740. * Execute the current task
  126741. * @param scene defines the scene where you want your assets to be loaded
  126742. * @param onSuccess is a callback called when the task is successfully executed
  126743. * @param onError is a callback called if an error occurs
  126744. */
  126745. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126746. }
  126747. /**
  126748. * Define a task used by AssetsManager to load images
  126749. */
  126750. export class ImageAssetTask extends AbstractAssetTask {
  126751. /**
  126752. * Defines the name of the task
  126753. */
  126754. name: string;
  126755. /**
  126756. * Defines the location of the image to load
  126757. */
  126758. url: string;
  126759. /**
  126760. * Gets the loaded images
  126761. */
  126762. image: HTMLImageElement;
  126763. /**
  126764. * Callback called when the task is successful
  126765. */
  126766. onSuccess: (task: ImageAssetTask) => void;
  126767. /**
  126768. * Callback called when the task is successful
  126769. */
  126770. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  126771. /**
  126772. * Creates a new ImageAssetTask
  126773. * @param name defines the name of the task
  126774. * @param url defines the location of the image to load
  126775. */
  126776. constructor(
  126777. /**
  126778. * Defines the name of the task
  126779. */
  126780. name: string,
  126781. /**
  126782. * Defines the location of the image to load
  126783. */
  126784. url: string);
  126785. /**
  126786. * Execute the current task
  126787. * @param scene defines the scene where you want your assets to be loaded
  126788. * @param onSuccess is a callback called when the task is successfully executed
  126789. * @param onError is a callback called if an error occurs
  126790. */
  126791. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126792. }
  126793. /**
  126794. * Defines the interface used by texture loading tasks
  126795. */
  126796. export interface ITextureAssetTask<TEX extends BaseTexture> {
  126797. /**
  126798. * Gets the loaded texture
  126799. */
  126800. texture: TEX;
  126801. }
  126802. /**
  126803. * Define a task used by AssetsManager to load 2D textures
  126804. */
  126805. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  126806. /**
  126807. * Defines the name of the task
  126808. */
  126809. name: string;
  126810. /**
  126811. * Defines the location of the file to load
  126812. */
  126813. url: string;
  126814. /**
  126815. * Defines if mipmap should not be generated (default is false)
  126816. */
  126817. noMipmap?: boolean | undefined;
  126818. /**
  126819. * Defines if texture must be inverted on Y axis (default is false)
  126820. */
  126821. invertY?: boolean | undefined;
  126822. /**
  126823. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  126824. */
  126825. samplingMode: number;
  126826. /**
  126827. * Gets the loaded texture
  126828. */
  126829. texture: Texture;
  126830. /**
  126831. * Callback called when the task is successful
  126832. */
  126833. onSuccess: (task: TextureAssetTask) => void;
  126834. /**
  126835. * Callback called when the task is successful
  126836. */
  126837. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  126838. /**
  126839. * Creates a new TextureAssetTask object
  126840. * @param name defines the name of the task
  126841. * @param url defines the location of the file to load
  126842. * @param noMipmap defines if mipmap should not be generated (default is false)
  126843. * @param invertY defines if texture must be inverted on Y axis (default is false)
  126844. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  126845. */
  126846. constructor(
  126847. /**
  126848. * Defines the name of the task
  126849. */
  126850. name: string,
  126851. /**
  126852. * Defines the location of the file to load
  126853. */
  126854. url: string,
  126855. /**
  126856. * Defines if mipmap should not be generated (default is false)
  126857. */
  126858. noMipmap?: boolean | undefined,
  126859. /**
  126860. * Defines if texture must be inverted on Y axis (default is false)
  126861. */
  126862. invertY?: boolean | undefined,
  126863. /**
  126864. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  126865. */
  126866. samplingMode?: number);
  126867. /**
  126868. * Execute the current task
  126869. * @param scene defines the scene where you want your assets to be loaded
  126870. * @param onSuccess is a callback called when the task is successfully executed
  126871. * @param onError is a callback called if an error occurs
  126872. */
  126873. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126874. }
  126875. /**
  126876. * Define a task used by AssetsManager to load cube textures
  126877. */
  126878. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  126879. /**
  126880. * Defines the name of the task
  126881. */
  126882. name: string;
  126883. /**
  126884. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  126885. */
  126886. url: string;
  126887. /**
  126888. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  126889. */
  126890. extensions?: string[] | undefined;
  126891. /**
  126892. * Defines if mipmaps should not be generated (default is false)
  126893. */
  126894. noMipmap?: boolean | undefined;
  126895. /**
  126896. * Defines the explicit list of files (undefined by default)
  126897. */
  126898. files?: string[] | undefined;
  126899. /**
  126900. * Gets the loaded texture
  126901. */
  126902. texture: CubeTexture;
  126903. /**
  126904. * Callback called when the task is successful
  126905. */
  126906. onSuccess: (task: CubeTextureAssetTask) => void;
  126907. /**
  126908. * Callback called when the task is successful
  126909. */
  126910. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  126911. /**
  126912. * Creates a new CubeTextureAssetTask
  126913. * @param name defines the name of the task
  126914. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  126915. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  126916. * @param noMipmap defines if mipmaps should not be generated (default is false)
  126917. * @param files defines the explicit list of files (undefined by default)
  126918. */
  126919. constructor(
  126920. /**
  126921. * Defines the name of the task
  126922. */
  126923. name: string,
  126924. /**
  126925. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  126926. */
  126927. url: string,
  126928. /**
  126929. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  126930. */
  126931. extensions?: string[] | undefined,
  126932. /**
  126933. * Defines if mipmaps should not be generated (default is false)
  126934. */
  126935. noMipmap?: boolean | undefined,
  126936. /**
  126937. * Defines the explicit list of files (undefined by default)
  126938. */
  126939. files?: string[] | undefined);
  126940. /**
  126941. * Execute the current task
  126942. * @param scene defines the scene where you want your assets to be loaded
  126943. * @param onSuccess is a callback called when the task is successfully executed
  126944. * @param onError is a callback called if an error occurs
  126945. */
  126946. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126947. }
  126948. /**
  126949. * Define a task used by AssetsManager to load HDR cube textures
  126950. */
  126951. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  126952. /**
  126953. * Defines the name of the task
  126954. */
  126955. name: string;
  126956. /**
  126957. * Defines the location of the file to load
  126958. */
  126959. url: string;
  126960. /**
  126961. * Defines the desired size (the more it increases the longer the generation will be)
  126962. */
  126963. size: number;
  126964. /**
  126965. * Defines if mipmaps should not be generated (default is false)
  126966. */
  126967. noMipmap: boolean;
  126968. /**
  126969. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  126970. */
  126971. generateHarmonics: boolean;
  126972. /**
  126973. * 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)
  126974. */
  126975. gammaSpace: boolean;
  126976. /**
  126977. * Internal Use Only
  126978. */
  126979. reserved: boolean;
  126980. /**
  126981. * Gets the loaded texture
  126982. */
  126983. texture: HDRCubeTexture;
  126984. /**
  126985. * Callback called when the task is successful
  126986. */
  126987. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  126988. /**
  126989. * Callback called when the task is successful
  126990. */
  126991. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  126992. /**
  126993. * Creates a new HDRCubeTextureAssetTask object
  126994. * @param name defines the name of the task
  126995. * @param url defines the location of the file to load
  126996. * @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.
  126997. * @param noMipmap defines if mipmaps should not be generated (default is false)
  126998. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  126999. * @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)
  127000. * @param reserved Internal use only
  127001. */
  127002. constructor(
  127003. /**
  127004. * Defines the name of the task
  127005. */
  127006. name: string,
  127007. /**
  127008. * Defines the location of the file to load
  127009. */
  127010. url: string,
  127011. /**
  127012. * Defines the desired size (the more it increases the longer the generation will be)
  127013. */
  127014. size: number,
  127015. /**
  127016. * Defines if mipmaps should not be generated (default is false)
  127017. */
  127018. noMipmap?: boolean,
  127019. /**
  127020. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  127021. */
  127022. generateHarmonics?: boolean,
  127023. /**
  127024. * 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)
  127025. */
  127026. gammaSpace?: boolean,
  127027. /**
  127028. * Internal Use Only
  127029. */
  127030. reserved?: boolean);
  127031. /**
  127032. * Execute the current task
  127033. * @param scene defines the scene where you want your assets to be loaded
  127034. * @param onSuccess is a callback called when the task is successfully executed
  127035. * @param onError is a callback called if an error occurs
  127036. */
  127037. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  127038. }
  127039. /**
  127040. * Define a task used by AssetsManager to load Equirectangular cube textures
  127041. */
  127042. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  127043. /**
  127044. * Defines the name of the task
  127045. */
  127046. name: string;
  127047. /**
  127048. * Defines the location of the file to load
  127049. */
  127050. url: string;
  127051. /**
  127052. * Defines the desired size (the more it increases the longer the generation will be)
  127053. */
  127054. size: number;
  127055. /**
  127056. * Defines if mipmaps should not be generated (default is false)
  127057. */
  127058. noMipmap: boolean;
  127059. /**
  127060. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  127061. * but the standard material would require them in Gamma space) (default is true)
  127062. */
  127063. gammaSpace: boolean;
  127064. /**
  127065. * Gets the loaded texture
  127066. */
  127067. texture: EquiRectangularCubeTexture;
  127068. /**
  127069. * Callback called when the task is successful
  127070. */
  127071. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  127072. /**
  127073. * Callback called when the task is successful
  127074. */
  127075. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  127076. /**
  127077. * Creates a new EquiRectangularCubeTextureAssetTask object
  127078. * @param name defines the name of the task
  127079. * @param url defines the location of the file to load
  127080. * @param size defines the desired size (the more it increases the longer the generation will be)
  127081. * If the size is omitted this implies you are using a preprocessed cubemap.
  127082. * @param noMipmap defines if mipmaps should not be generated (default is false)
  127083. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  127084. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  127085. * (default is true)
  127086. */
  127087. constructor(
  127088. /**
  127089. * Defines the name of the task
  127090. */
  127091. name: string,
  127092. /**
  127093. * Defines the location of the file to load
  127094. */
  127095. url: string,
  127096. /**
  127097. * Defines the desired size (the more it increases the longer the generation will be)
  127098. */
  127099. size: number,
  127100. /**
  127101. * Defines if mipmaps should not be generated (default is false)
  127102. */
  127103. noMipmap?: boolean,
  127104. /**
  127105. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  127106. * but the standard material would require them in Gamma space) (default is true)
  127107. */
  127108. gammaSpace?: boolean);
  127109. /**
  127110. * Execute the current task
  127111. * @param scene defines the scene where you want your assets to be loaded
  127112. * @param onSuccess is a callback called when the task is successfully executed
  127113. * @param onError is a callback called if an error occurs
  127114. */
  127115. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  127116. }
  127117. /**
  127118. * This class can be used to easily import assets into a scene
  127119. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  127120. */
  127121. export class AssetsManager {
  127122. private _scene;
  127123. private _isLoading;
  127124. protected _tasks: AbstractAssetTask[];
  127125. protected _waitingTasksCount: number;
  127126. protected _totalTasksCount: number;
  127127. /**
  127128. * Callback called when all tasks are processed
  127129. */
  127130. onFinish: (tasks: AbstractAssetTask[]) => void;
  127131. /**
  127132. * Callback called when a task is successful
  127133. */
  127134. onTaskSuccess: (task: AbstractAssetTask) => void;
  127135. /**
  127136. * Callback called when a task had an error
  127137. */
  127138. onTaskError: (task: AbstractAssetTask) => void;
  127139. /**
  127140. * Callback called when a task is done (whatever the result is)
  127141. */
  127142. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  127143. /**
  127144. * Observable called when all tasks are processed
  127145. */
  127146. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  127147. /**
  127148. * Observable called when a task had an error
  127149. */
  127150. onTaskErrorObservable: Observable<AbstractAssetTask>;
  127151. /**
  127152. * Observable called when all tasks were executed
  127153. */
  127154. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  127155. /**
  127156. * Observable called when a task is done (whatever the result is)
  127157. */
  127158. onProgressObservable: Observable<IAssetsProgressEvent>;
  127159. /**
  127160. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  127161. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  127162. */
  127163. useDefaultLoadingScreen: boolean;
  127164. /**
  127165. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  127166. * when all assets have been downloaded.
  127167. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  127168. */
  127169. autoHideLoadingUI: boolean;
  127170. /**
  127171. * Creates a new AssetsManager
  127172. * @param scene defines the scene to work on
  127173. */
  127174. constructor(scene: Scene);
  127175. /**
  127176. * Add a MeshAssetTask to the list of active tasks
  127177. * @param taskName defines the name of the new task
  127178. * @param meshesNames defines the name of meshes to load
  127179. * @param rootUrl defines the root url to use to locate files
  127180. * @param sceneFilename defines the filename of the scene file
  127181. * @returns a new MeshAssetTask object
  127182. */
  127183. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  127184. /**
  127185. * Add a TextFileAssetTask to the list of active tasks
  127186. * @param taskName defines the name of the new task
  127187. * @param url defines the url of the file to load
  127188. * @returns a new TextFileAssetTask object
  127189. */
  127190. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  127191. /**
  127192. * Add a BinaryFileAssetTask to the list of active tasks
  127193. * @param taskName defines the name of the new task
  127194. * @param url defines the url of the file to load
  127195. * @returns a new BinaryFileAssetTask object
  127196. */
  127197. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  127198. /**
  127199. * Add a ImageAssetTask to the list of active tasks
  127200. * @param taskName defines the name of the new task
  127201. * @param url defines the url of the file to load
  127202. * @returns a new ImageAssetTask object
  127203. */
  127204. addImageTask(taskName: string, url: string): ImageAssetTask;
  127205. /**
  127206. * Add a TextureAssetTask to the list of active tasks
  127207. * @param taskName defines the name of the new task
  127208. * @param url defines the url of the file to load
  127209. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  127210. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  127211. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  127212. * @returns a new TextureAssetTask object
  127213. */
  127214. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  127215. /**
  127216. * Add a CubeTextureAssetTask to the list of active tasks
  127217. * @param taskName defines the name of the new task
  127218. * @param url defines the url of the file to load
  127219. * @param extensions defines the extension to use to load the cube map (can be null)
  127220. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  127221. * @param files defines the list of files to load (can be null)
  127222. * @returns a new CubeTextureAssetTask object
  127223. */
  127224. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  127225. /**
  127226. *
  127227. * Add a HDRCubeTextureAssetTask to the list of active tasks
  127228. * @param taskName defines the name of the new task
  127229. * @param url defines the url of the file to load
  127230. * @param size defines the size you want for the cubemap (can be null)
  127231. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  127232. * @param generateHarmonics defines if you want to automatically generate (true by default)
  127233. * @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)
  127234. * @param reserved Internal use only
  127235. * @returns a new HDRCubeTextureAssetTask object
  127236. */
  127237. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  127238. /**
  127239. *
  127240. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  127241. * @param taskName defines the name of the new task
  127242. * @param url defines the url of the file to load
  127243. * @param size defines the size you want for the cubemap (can be null)
  127244. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  127245. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  127246. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  127247. * @returns a new EquiRectangularCubeTextureAssetTask object
  127248. */
  127249. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  127250. /**
  127251. * Remove a task from the assets manager.
  127252. * @param task the task to remove
  127253. */
  127254. removeTask(task: AbstractAssetTask): void;
  127255. private _decreaseWaitingTasksCount;
  127256. private _runTask;
  127257. /**
  127258. * Reset the AssetsManager and remove all tasks
  127259. * @return the current instance of the AssetsManager
  127260. */
  127261. reset(): AssetsManager;
  127262. /**
  127263. * Start the loading process
  127264. * @return the current instance of the AssetsManager
  127265. */
  127266. load(): AssetsManager;
  127267. /**
  127268. * Start the loading process as an async operation
  127269. * @return a promise returning the list of failed tasks
  127270. */
  127271. loadAsync(): Promise<void>;
  127272. }
  127273. }
  127274. declare module BABYLON {
  127275. /**
  127276. * Wrapper class for promise with external resolve and reject.
  127277. */
  127278. export class Deferred<T> {
  127279. /**
  127280. * The promise associated with this deferred object.
  127281. */
  127282. readonly promise: Promise<T>;
  127283. private _resolve;
  127284. private _reject;
  127285. /**
  127286. * The resolve method of the promise associated with this deferred object.
  127287. */
  127288. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  127289. /**
  127290. * The reject method of the promise associated with this deferred object.
  127291. */
  127292. readonly reject: (reason?: any) => void;
  127293. /**
  127294. * Constructor for this deferred object.
  127295. */
  127296. constructor();
  127297. }
  127298. }
  127299. declare module BABYLON {
  127300. /**
  127301. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  127302. */
  127303. export class MeshExploder {
  127304. private _centerMesh;
  127305. private _meshes;
  127306. private _meshesOrigins;
  127307. private _toCenterVectors;
  127308. private _scaledDirection;
  127309. private _newPosition;
  127310. private _centerPosition;
  127311. /**
  127312. * Explodes meshes from a center mesh.
  127313. * @param meshes The meshes to explode.
  127314. * @param centerMesh The mesh to be center of explosion.
  127315. */
  127316. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  127317. private _setCenterMesh;
  127318. /**
  127319. * Get class name
  127320. * @returns "MeshExploder"
  127321. */
  127322. getClassName(): string;
  127323. /**
  127324. * "Exploded meshes"
  127325. * @returns Array of meshes with the centerMesh at index 0.
  127326. */
  127327. getMeshes(): Array<Mesh>;
  127328. /**
  127329. * Explodes meshes giving a specific direction
  127330. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  127331. */
  127332. explode(direction?: number): void;
  127333. }
  127334. }
  127335. declare module BABYLON {
  127336. /**
  127337. * Class used to help managing file picking and drag'n'drop
  127338. */
  127339. export class FilesInput {
  127340. /**
  127341. * List of files ready to be loaded
  127342. */
  127343. static readonly FilesToLoad: {
  127344. [key: string]: File;
  127345. };
  127346. /**
  127347. * Callback called when a file is processed
  127348. */
  127349. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  127350. private _engine;
  127351. private _currentScene;
  127352. private _sceneLoadedCallback;
  127353. private _progressCallback;
  127354. private _additionalRenderLoopLogicCallback;
  127355. private _textureLoadingCallback;
  127356. private _startingProcessingFilesCallback;
  127357. private _onReloadCallback;
  127358. private _errorCallback;
  127359. private _elementToMonitor;
  127360. private _sceneFileToLoad;
  127361. private _filesToLoad;
  127362. /**
  127363. * Creates a new FilesInput
  127364. * @param engine defines the rendering engine
  127365. * @param scene defines the hosting scene
  127366. * @param sceneLoadedCallback callback called when scene is loaded
  127367. * @param progressCallback callback called to track progress
  127368. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  127369. * @param textureLoadingCallback callback called when a texture is loading
  127370. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  127371. * @param onReloadCallback callback called when a reload is requested
  127372. * @param errorCallback callback call if an error occurs
  127373. */
  127374. 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);
  127375. private _dragEnterHandler;
  127376. private _dragOverHandler;
  127377. private _dropHandler;
  127378. /**
  127379. * Calls this function to listen to drag'n'drop events on a specific DOM element
  127380. * @param elementToMonitor defines the DOM element to track
  127381. */
  127382. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  127383. /**
  127384. * Release all associated resources
  127385. */
  127386. dispose(): void;
  127387. private renderFunction;
  127388. private drag;
  127389. private drop;
  127390. private _traverseFolder;
  127391. private _processFiles;
  127392. /**
  127393. * Load files from a drop event
  127394. * @param event defines the drop event to use as source
  127395. */
  127396. loadFiles(event: any): void;
  127397. private _processReload;
  127398. /**
  127399. * Reload the current scene from the loaded files
  127400. */
  127401. reload(): void;
  127402. }
  127403. }
  127404. declare module BABYLON {
  127405. /**
  127406. * Defines the root class used to create scene optimization to use with SceneOptimizer
  127407. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127408. */
  127409. export class SceneOptimization {
  127410. /**
  127411. * Defines the priority of this optimization (0 by default which means first in the list)
  127412. */
  127413. priority: number;
  127414. /**
  127415. * Gets a string describing the action executed by the current optimization
  127416. * @returns description string
  127417. */
  127418. getDescription(): string;
  127419. /**
  127420. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127421. * @param scene defines the current scene where to apply this optimization
  127422. * @param optimizer defines the current optimizer
  127423. * @returns true if everything that can be done was applied
  127424. */
  127425. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127426. /**
  127427. * Creates the SceneOptimization object
  127428. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  127429. * @param desc defines the description associated with the optimization
  127430. */
  127431. constructor(
  127432. /**
  127433. * Defines the priority of this optimization (0 by default which means first in the list)
  127434. */
  127435. priority?: number);
  127436. }
  127437. /**
  127438. * Defines an optimization used to reduce the size of render target textures
  127439. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127440. */
  127441. export class TextureOptimization extends SceneOptimization {
  127442. /**
  127443. * Defines the priority of this optimization (0 by default which means first in the list)
  127444. */
  127445. priority: number;
  127446. /**
  127447. * 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
  127448. */
  127449. maximumSize: number;
  127450. /**
  127451. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  127452. */
  127453. step: number;
  127454. /**
  127455. * Gets a string describing the action executed by the current optimization
  127456. * @returns description string
  127457. */
  127458. getDescription(): string;
  127459. /**
  127460. * Creates the TextureOptimization object
  127461. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  127462. * @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
  127463. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  127464. */
  127465. constructor(
  127466. /**
  127467. * Defines the priority of this optimization (0 by default which means first in the list)
  127468. */
  127469. priority?: number,
  127470. /**
  127471. * 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
  127472. */
  127473. maximumSize?: number,
  127474. /**
  127475. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  127476. */
  127477. step?: number);
  127478. /**
  127479. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127480. * @param scene defines the current scene where to apply this optimization
  127481. * @param optimizer defines the current optimizer
  127482. * @returns true if everything that can be done was applied
  127483. */
  127484. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127485. }
  127486. /**
  127487. * Defines an optimization used to increase or decrease the rendering resolution
  127488. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127489. */
  127490. export class HardwareScalingOptimization extends SceneOptimization {
  127491. /**
  127492. * Defines the priority of this optimization (0 by default which means first in the list)
  127493. */
  127494. priority: number;
  127495. /**
  127496. * Defines the maximum scale to use (2 by default)
  127497. */
  127498. maximumScale: number;
  127499. /**
  127500. * Defines the step to use between two passes (0.5 by default)
  127501. */
  127502. step: number;
  127503. private _currentScale;
  127504. private _directionOffset;
  127505. /**
  127506. * Gets a string describing the action executed by the current optimization
  127507. * @return description string
  127508. */
  127509. getDescription(): string;
  127510. /**
  127511. * Creates the HardwareScalingOptimization object
  127512. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  127513. * @param maximumScale defines the maximum scale to use (2 by default)
  127514. * @param step defines the step to use between two passes (0.5 by default)
  127515. */
  127516. constructor(
  127517. /**
  127518. * Defines the priority of this optimization (0 by default which means first in the list)
  127519. */
  127520. priority?: number,
  127521. /**
  127522. * Defines the maximum scale to use (2 by default)
  127523. */
  127524. maximumScale?: number,
  127525. /**
  127526. * Defines the step to use between two passes (0.5 by default)
  127527. */
  127528. step?: number);
  127529. /**
  127530. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127531. * @param scene defines the current scene where to apply this optimization
  127532. * @param optimizer defines the current optimizer
  127533. * @returns true if everything that can be done was applied
  127534. */
  127535. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127536. }
  127537. /**
  127538. * Defines an optimization used to remove shadows
  127539. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127540. */
  127541. export class ShadowsOptimization extends SceneOptimization {
  127542. /**
  127543. * Gets a string describing the action executed by the current optimization
  127544. * @return description string
  127545. */
  127546. getDescription(): string;
  127547. /**
  127548. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127549. * @param scene defines the current scene where to apply this optimization
  127550. * @param optimizer defines the current optimizer
  127551. * @returns true if everything that can be done was applied
  127552. */
  127553. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127554. }
  127555. /**
  127556. * Defines an optimization used to turn post-processes off
  127557. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127558. */
  127559. export class PostProcessesOptimization extends SceneOptimization {
  127560. /**
  127561. * Gets a string describing the action executed by the current optimization
  127562. * @return description string
  127563. */
  127564. getDescription(): string;
  127565. /**
  127566. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127567. * @param scene defines the current scene where to apply this optimization
  127568. * @param optimizer defines the current optimizer
  127569. * @returns true if everything that can be done was applied
  127570. */
  127571. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127572. }
  127573. /**
  127574. * Defines an optimization used to turn lens flares off
  127575. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127576. */
  127577. export class LensFlaresOptimization extends SceneOptimization {
  127578. /**
  127579. * Gets a string describing the action executed by the current optimization
  127580. * @return description string
  127581. */
  127582. getDescription(): string;
  127583. /**
  127584. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127585. * @param scene defines the current scene where to apply this optimization
  127586. * @param optimizer defines the current optimizer
  127587. * @returns true if everything that can be done was applied
  127588. */
  127589. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127590. }
  127591. /**
  127592. * Defines an optimization based on user defined callback.
  127593. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127594. */
  127595. export class CustomOptimization extends SceneOptimization {
  127596. /**
  127597. * Callback called to apply the custom optimization.
  127598. */
  127599. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  127600. /**
  127601. * Callback called to get custom description
  127602. */
  127603. onGetDescription: () => string;
  127604. /**
  127605. * Gets a string describing the action executed by the current optimization
  127606. * @returns description string
  127607. */
  127608. getDescription(): string;
  127609. /**
  127610. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127611. * @param scene defines the current scene where to apply this optimization
  127612. * @param optimizer defines the current optimizer
  127613. * @returns true if everything that can be done was applied
  127614. */
  127615. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127616. }
  127617. /**
  127618. * Defines an optimization used to turn particles off
  127619. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127620. */
  127621. export class ParticlesOptimization extends SceneOptimization {
  127622. /**
  127623. * Gets a string describing the action executed by the current optimization
  127624. * @return description string
  127625. */
  127626. getDescription(): string;
  127627. /**
  127628. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127629. * @param scene defines the current scene where to apply this optimization
  127630. * @param optimizer defines the current optimizer
  127631. * @returns true if everything that can be done was applied
  127632. */
  127633. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127634. }
  127635. /**
  127636. * Defines an optimization used to turn render targets off
  127637. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127638. */
  127639. export class RenderTargetsOptimization extends SceneOptimization {
  127640. /**
  127641. * Gets a string describing the action executed by the current optimization
  127642. * @return description string
  127643. */
  127644. getDescription(): string;
  127645. /**
  127646. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127647. * @param scene defines the current scene where to apply this optimization
  127648. * @param optimizer defines the current optimizer
  127649. * @returns true if everything that can be done was applied
  127650. */
  127651. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127652. }
  127653. /**
  127654. * Defines an optimization used to merge meshes with compatible materials
  127655. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127656. */
  127657. export class MergeMeshesOptimization extends SceneOptimization {
  127658. private static _UpdateSelectionTree;
  127659. /**
  127660. * Gets or sets a boolean which defines if optimization octree has to be updated
  127661. */
  127662. /**
  127663. * Gets or sets a boolean which defines if optimization octree has to be updated
  127664. */
  127665. static UpdateSelectionTree: boolean;
  127666. /**
  127667. * Gets a string describing the action executed by the current optimization
  127668. * @return description string
  127669. */
  127670. getDescription(): string;
  127671. private _canBeMerged;
  127672. /**
  127673. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127674. * @param scene defines the current scene where to apply this optimization
  127675. * @param optimizer defines the current optimizer
  127676. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  127677. * @returns true if everything that can be done was applied
  127678. */
  127679. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  127680. }
  127681. /**
  127682. * Defines a list of options used by SceneOptimizer
  127683. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127684. */
  127685. export class SceneOptimizerOptions {
  127686. /**
  127687. * Defines the target frame rate to reach (60 by default)
  127688. */
  127689. targetFrameRate: number;
  127690. /**
  127691. * Defines the interval between two checkes (2000ms by default)
  127692. */
  127693. trackerDuration: number;
  127694. /**
  127695. * Gets the list of optimizations to apply
  127696. */
  127697. optimizations: SceneOptimization[];
  127698. /**
  127699. * Creates a new list of options used by SceneOptimizer
  127700. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  127701. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  127702. */
  127703. constructor(
  127704. /**
  127705. * Defines the target frame rate to reach (60 by default)
  127706. */
  127707. targetFrameRate?: number,
  127708. /**
  127709. * Defines the interval between two checkes (2000ms by default)
  127710. */
  127711. trackerDuration?: number);
  127712. /**
  127713. * Add a new optimization
  127714. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  127715. * @returns the current SceneOptimizerOptions
  127716. */
  127717. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  127718. /**
  127719. * Add a new custom optimization
  127720. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  127721. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  127722. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  127723. * @returns the current SceneOptimizerOptions
  127724. */
  127725. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  127726. /**
  127727. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  127728. * @param targetFrameRate defines the target frame rate (60 by default)
  127729. * @returns a SceneOptimizerOptions object
  127730. */
  127731. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  127732. /**
  127733. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  127734. * @param targetFrameRate defines the target frame rate (60 by default)
  127735. * @returns a SceneOptimizerOptions object
  127736. */
  127737. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  127738. /**
  127739. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  127740. * @param targetFrameRate defines the target frame rate (60 by default)
  127741. * @returns a SceneOptimizerOptions object
  127742. */
  127743. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  127744. }
  127745. /**
  127746. * Class used to run optimizations in order to reach a target frame rate
  127747. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127748. */
  127749. export class SceneOptimizer implements IDisposable {
  127750. private _isRunning;
  127751. private _options;
  127752. private _scene;
  127753. private _currentPriorityLevel;
  127754. private _targetFrameRate;
  127755. private _trackerDuration;
  127756. private _currentFrameRate;
  127757. private _sceneDisposeObserver;
  127758. private _improvementMode;
  127759. /**
  127760. * Defines an observable called when the optimizer reaches the target frame rate
  127761. */
  127762. onSuccessObservable: Observable<SceneOptimizer>;
  127763. /**
  127764. * Defines an observable called when the optimizer enables an optimization
  127765. */
  127766. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  127767. /**
  127768. * Defines an observable called when the optimizer is not able to reach the target frame rate
  127769. */
  127770. onFailureObservable: Observable<SceneOptimizer>;
  127771. /**
  127772. * Gets a boolean indicating if the optimizer is in improvement mode
  127773. */
  127774. readonly isInImprovementMode: boolean;
  127775. /**
  127776. * Gets the current priority level (0 at start)
  127777. */
  127778. readonly currentPriorityLevel: number;
  127779. /**
  127780. * Gets the current frame rate checked by the SceneOptimizer
  127781. */
  127782. readonly currentFrameRate: number;
  127783. /**
  127784. * Gets or sets the current target frame rate (60 by default)
  127785. */
  127786. /**
  127787. * Gets or sets the current target frame rate (60 by default)
  127788. */
  127789. targetFrameRate: number;
  127790. /**
  127791. * Gets or sets the current interval between two checks (every 2000ms by default)
  127792. */
  127793. /**
  127794. * Gets or sets the current interval between two checks (every 2000ms by default)
  127795. */
  127796. trackerDuration: number;
  127797. /**
  127798. * Gets the list of active optimizations
  127799. */
  127800. readonly optimizations: SceneOptimization[];
  127801. /**
  127802. * Creates a new SceneOptimizer
  127803. * @param scene defines the scene to work on
  127804. * @param options defines the options to use with the SceneOptimizer
  127805. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  127806. * @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)
  127807. */
  127808. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  127809. /**
  127810. * Stops the current optimizer
  127811. */
  127812. stop(): void;
  127813. /**
  127814. * Reset the optimizer to initial step (current priority level = 0)
  127815. */
  127816. reset(): void;
  127817. /**
  127818. * Start the optimizer. By default it will try to reach a specific framerate
  127819. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  127820. */
  127821. start(): void;
  127822. private _checkCurrentState;
  127823. /**
  127824. * Release all resources
  127825. */
  127826. dispose(): void;
  127827. /**
  127828. * Helper function to create a SceneOptimizer with one single line of code
  127829. * @param scene defines the scene to work on
  127830. * @param options defines the options to use with the SceneOptimizer
  127831. * @param onSuccess defines a callback to call on success
  127832. * @param onFailure defines a callback to call on failure
  127833. * @returns the new SceneOptimizer object
  127834. */
  127835. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  127836. }
  127837. }
  127838. declare module BABYLON {
  127839. /**
  127840. * Class used to serialize a scene into a string
  127841. */
  127842. export class SceneSerializer {
  127843. /**
  127844. * Clear cache used by a previous serialization
  127845. */
  127846. static ClearCache(): void;
  127847. /**
  127848. * Serialize a scene into a JSON compatible object
  127849. * @param scene defines the scene to serialize
  127850. * @returns a JSON compatible object
  127851. */
  127852. static Serialize(scene: Scene): any;
  127853. /**
  127854. * Serialize a mesh into a JSON compatible object
  127855. * @param toSerialize defines the mesh to serialize
  127856. * @param withParents defines if parents must be serialized as well
  127857. * @param withChildren defines if children must be serialized as well
  127858. * @returns a JSON compatible object
  127859. */
  127860. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  127861. }
  127862. }
  127863. declare module BABYLON {
  127864. /**
  127865. * Class used to host texture specific utilities
  127866. */
  127867. export class TextureTools {
  127868. /**
  127869. * Uses the GPU to create a copy texture rescaled at a given size
  127870. * @param texture Texture to copy from
  127871. * @param width defines the desired width
  127872. * @param height defines the desired height
  127873. * @param useBilinearMode defines if bilinear mode has to be used
  127874. * @return the generated texture
  127875. */
  127876. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  127877. }
  127878. }
  127879. declare module BABYLON {
  127880. /**
  127881. * This represents the different options available for the video capture.
  127882. */
  127883. export interface VideoRecorderOptions {
  127884. /** Defines the mime type of the video. */
  127885. mimeType: string;
  127886. /** Defines the FPS the video should be recorded at. */
  127887. fps: number;
  127888. /** Defines the chunk size for the recording data. */
  127889. recordChunckSize: number;
  127890. /** The audio tracks to attach to the recording. */
  127891. audioTracks?: MediaStreamTrack[];
  127892. }
  127893. /**
  127894. * This can help with recording videos from BabylonJS.
  127895. * This is based on the available WebRTC functionalities of the browser.
  127896. *
  127897. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  127898. */
  127899. export class VideoRecorder {
  127900. private static readonly _defaultOptions;
  127901. /**
  127902. * Returns whether or not the VideoRecorder is available in your browser.
  127903. * @param engine Defines the Babylon Engine.
  127904. * @returns true if supported otherwise false.
  127905. */
  127906. static IsSupported(engine: Engine): boolean;
  127907. private readonly _options;
  127908. private _canvas;
  127909. private _mediaRecorder;
  127910. private _recordedChunks;
  127911. private _fileName;
  127912. private _resolve;
  127913. private _reject;
  127914. /**
  127915. * True when a recording is already in progress.
  127916. */
  127917. readonly isRecording: boolean;
  127918. /**
  127919. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  127920. * @param engine Defines the BabylonJS Engine you wish to record.
  127921. * @param options Defines options that can be used to customize the capture.
  127922. */
  127923. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  127924. /**
  127925. * Stops the current recording before the default capture timeout passed in the startRecording function.
  127926. */
  127927. stopRecording(): void;
  127928. /**
  127929. * Starts recording the canvas for a max duration specified in parameters.
  127930. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  127931. * If null no automatic download will start and you can rely on the promise to get the data back.
  127932. * @param maxDuration Defines the maximum recording time in seconds.
  127933. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  127934. * @return A promise callback at the end of the recording with the video data in Blob.
  127935. */
  127936. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  127937. /**
  127938. * Releases internal resources used during the recording.
  127939. */
  127940. dispose(): void;
  127941. private _handleDataAvailable;
  127942. private _handleError;
  127943. private _handleStop;
  127944. }
  127945. }
  127946. declare module BABYLON {
  127947. /**
  127948. * Class containing a set of static utilities functions for screenshots
  127949. */
  127950. export class ScreenshotTools {
  127951. /**
  127952. * Captures a screenshot of the current rendering
  127953. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  127954. * @param engine defines the rendering engine
  127955. * @param camera defines the source camera
  127956. * @param size This parameter can be set to a single number or to an object with the
  127957. * following (optional) properties: precision, width, height. If a single number is passed,
  127958. * it will be used for both width and height. If an object is passed, the screenshot size
  127959. * will be derived from the parameters. The precision property is a multiplier allowing
  127960. * rendering at a higher or lower resolution
  127961. * @param successCallback defines the callback receives a single parameter which contains the
  127962. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  127963. * src parameter of an <img> to display it
  127964. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  127965. * Check your browser for supported MIME types
  127966. */
  127967. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  127968. /**
  127969. * Captures a screenshot of the current rendering
  127970. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  127971. * @param engine defines the rendering engine
  127972. * @param camera defines the source camera
  127973. * @param size This parameter can be set to a single number or to an object with the
  127974. * following (optional) properties: precision, width, height. If a single number is passed,
  127975. * it will be used for both width and height. If an object is passed, the screenshot size
  127976. * will be derived from the parameters. The precision property is a multiplier allowing
  127977. * rendering at a higher or lower resolution
  127978. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  127979. * Check your browser for supported MIME types
  127980. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  127981. * to the src parameter of an <img> to display it
  127982. */
  127983. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  127984. /**
  127985. * Generates an image screenshot from the specified camera.
  127986. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  127987. * @param engine The engine to use for rendering
  127988. * @param camera The camera to use for rendering
  127989. * @param size This parameter can be set to a single number or to an object with the
  127990. * following (optional) properties: precision, width, height. If a single number is passed,
  127991. * it will be used for both width and height. If an object is passed, the screenshot size
  127992. * will be derived from the parameters. The precision property is a multiplier allowing
  127993. * rendering at a higher or lower resolution
  127994. * @param successCallback The callback receives a single parameter which contains the
  127995. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  127996. * src parameter of an <img> to display it
  127997. * @param mimeType The MIME type of the screenshot image (default: image/png).
  127998. * Check your browser for supported MIME types
  127999. * @param samples Texture samples (default: 1)
  128000. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  128001. * @param fileName A name for for the downloaded file.
  128002. */
  128003. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  128004. /**
  128005. * Generates an image screenshot from the specified camera.
  128006. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  128007. * @param engine The engine to use for rendering
  128008. * @param camera The camera to use for rendering
  128009. * @param size This parameter can be set to a single number or to an object with the
  128010. * following (optional) properties: precision, width, height. If a single number is passed,
  128011. * it will be used for both width and height. If an object is passed, the screenshot size
  128012. * will be derived from the parameters. The precision property is a multiplier allowing
  128013. * rendering at a higher or lower resolution
  128014. * @param mimeType The MIME type of the screenshot image (default: image/png).
  128015. * Check your browser for supported MIME types
  128016. * @param samples Texture samples (default: 1)
  128017. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  128018. * @param fileName A name for for the downloaded file.
  128019. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  128020. * to the src parameter of an <img> to display it
  128021. */
  128022. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  128023. /**
  128024. * Gets height and width for screenshot size
  128025. * @private
  128026. */
  128027. private static _getScreenshotSize;
  128028. }
  128029. }
  128030. declare module BABYLON {
  128031. /**
  128032. * A cursor which tracks a point on a path
  128033. */
  128034. export class PathCursor {
  128035. private path;
  128036. /**
  128037. * Stores path cursor callbacks for when an onchange event is triggered
  128038. */
  128039. private _onchange;
  128040. /**
  128041. * The value of the path cursor
  128042. */
  128043. value: number;
  128044. /**
  128045. * The animation array of the path cursor
  128046. */
  128047. animations: Animation[];
  128048. /**
  128049. * Initializes the path cursor
  128050. * @param path The path to track
  128051. */
  128052. constructor(path: Path2);
  128053. /**
  128054. * Gets the cursor point on the path
  128055. * @returns A point on the path cursor at the cursor location
  128056. */
  128057. getPoint(): Vector3;
  128058. /**
  128059. * Moves the cursor ahead by the step amount
  128060. * @param step The amount to move the cursor forward
  128061. * @returns This path cursor
  128062. */
  128063. moveAhead(step?: number): PathCursor;
  128064. /**
  128065. * Moves the cursor behind by the step amount
  128066. * @param step The amount to move the cursor back
  128067. * @returns This path cursor
  128068. */
  128069. moveBack(step?: number): PathCursor;
  128070. /**
  128071. * Moves the cursor by the step amount
  128072. * If the step amount is greater than one, an exception is thrown
  128073. * @param step The amount to move the cursor
  128074. * @returns This path cursor
  128075. */
  128076. move(step: number): PathCursor;
  128077. /**
  128078. * Ensures that the value is limited between zero and one
  128079. * @returns This path cursor
  128080. */
  128081. private ensureLimits;
  128082. /**
  128083. * Runs onchange callbacks on change (used by the animation engine)
  128084. * @returns This path cursor
  128085. */
  128086. private raiseOnChange;
  128087. /**
  128088. * Executes a function on change
  128089. * @param f A path cursor onchange callback
  128090. * @returns This path cursor
  128091. */
  128092. onchange(f: (cursor: PathCursor) => void): PathCursor;
  128093. }
  128094. }
  128095. declare module BABYLON {
  128096. /** @hidden */
  128097. export var blurPixelShader: {
  128098. name: string;
  128099. shader: string;
  128100. };
  128101. }
  128102. declare module BABYLON {
  128103. /** @hidden */
  128104. export var pointCloudVertexDeclaration: {
  128105. name: string;
  128106. shader: string;
  128107. };
  128108. }
  128109. // Mixins
  128110. interface Window {
  128111. mozIndexedDB: IDBFactory;
  128112. webkitIndexedDB: IDBFactory;
  128113. msIndexedDB: IDBFactory;
  128114. webkitURL: typeof URL;
  128115. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  128116. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  128117. WebGLRenderingContext: WebGLRenderingContext;
  128118. MSGesture: MSGesture;
  128119. CANNON: any;
  128120. AudioContext: AudioContext;
  128121. webkitAudioContext: AudioContext;
  128122. PointerEvent: any;
  128123. Math: Math;
  128124. Uint8Array: Uint8ArrayConstructor;
  128125. Float32Array: Float32ArrayConstructor;
  128126. mozURL: typeof URL;
  128127. msURL: typeof URL;
  128128. VRFrameData: any; // WebVR, from specs 1.1
  128129. DracoDecoderModule: any;
  128130. setImmediate(handler: (...args: any[]) => void): number;
  128131. }
  128132. interface HTMLCanvasElement {
  128133. requestPointerLock(): void;
  128134. msRequestPointerLock?(): void;
  128135. mozRequestPointerLock?(): void;
  128136. webkitRequestPointerLock?(): void;
  128137. /** Track wether a record is in progress */
  128138. isRecording: boolean;
  128139. /** Capture Stream method defined by some browsers */
  128140. captureStream(fps?: number): MediaStream;
  128141. }
  128142. interface CanvasRenderingContext2D {
  128143. msImageSmoothingEnabled: boolean;
  128144. }
  128145. interface MouseEvent {
  128146. mozMovementX: number;
  128147. mozMovementY: number;
  128148. webkitMovementX: number;
  128149. webkitMovementY: number;
  128150. msMovementX: number;
  128151. msMovementY: number;
  128152. }
  128153. interface Navigator {
  128154. mozGetVRDevices: (any: any) => any;
  128155. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  128156. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  128157. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  128158. webkitGetGamepads(): Gamepad[];
  128159. msGetGamepads(): Gamepad[];
  128160. webkitGamepads(): Gamepad[];
  128161. }
  128162. interface HTMLVideoElement {
  128163. mozSrcObject: any;
  128164. }
  128165. interface Math {
  128166. fround(x: number): number;
  128167. imul(a: number, b: number): number;
  128168. }
  128169. interface WebGLRenderingContext {
  128170. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  128171. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  128172. vertexAttribDivisor(index: number, divisor: number): void;
  128173. createVertexArray(): any;
  128174. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  128175. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  128176. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  128177. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  128178. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  128179. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  128180. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  128181. // Queries
  128182. createQuery(): WebGLQuery;
  128183. deleteQuery(query: WebGLQuery): void;
  128184. beginQuery(target: number, query: WebGLQuery): void;
  128185. endQuery(target: number): void;
  128186. getQueryParameter(query: WebGLQuery, pname: number): any;
  128187. getQuery(target: number, pname: number): any;
  128188. MAX_SAMPLES: number;
  128189. RGBA8: number;
  128190. READ_FRAMEBUFFER: number;
  128191. DRAW_FRAMEBUFFER: number;
  128192. UNIFORM_BUFFER: number;
  128193. HALF_FLOAT_OES: number;
  128194. RGBA16F: number;
  128195. RGBA32F: number;
  128196. R32F: number;
  128197. RG32F: number;
  128198. RGB32F: number;
  128199. R16F: number;
  128200. RG16F: number;
  128201. RGB16F: number;
  128202. RED: number;
  128203. RG: number;
  128204. R8: number;
  128205. RG8: number;
  128206. UNSIGNED_INT_24_8: number;
  128207. DEPTH24_STENCIL8: number;
  128208. /* Multiple Render Targets */
  128209. drawBuffers(buffers: number[]): void;
  128210. readBuffer(src: number): void;
  128211. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  128212. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  128213. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  128214. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  128215. // Occlusion Query
  128216. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  128217. ANY_SAMPLES_PASSED: number;
  128218. QUERY_RESULT_AVAILABLE: number;
  128219. QUERY_RESULT: number;
  128220. }
  128221. interface WebGLProgram {
  128222. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  128223. }
  128224. interface EXT_disjoint_timer_query {
  128225. QUERY_COUNTER_BITS_EXT: number;
  128226. TIME_ELAPSED_EXT: number;
  128227. TIMESTAMP_EXT: number;
  128228. GPU_DISJOINT_EXT: number;
  128229. QUERY_RESULT_EXT: number;
  128230. QUERY_RESULT_AVAILABLE_EXT: number;
  128231. queryCounterEXT(query: WebGLQuery, target: number): void;
  128232. createQueryEXT(): WebGLQuery;
  128233. beginQueryEXT(target: number, query: WebGLQuery): void;
  128234. endQueryEXT(target: number): void;
  128235. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  128236. deleteQueryEXT(query: WebGLQuery): void;
  128237. }
  128238. interface WebGLUniformLocation {
  128239. _currentState: any;
  128240. }
  128241. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  128242. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  128243. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  128244. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  128245. interface WebGLRenderingContext {
  128246. readonly RASTERIZER_DISCARD: number;
  128247. readonly DEPTH_COMPONENT24: number;
  128248. readonly TEXTURE_3D: number;
  128249. readonly TEXTURE_2D_ARRAY: number;
  128250. readonly TEXTURE_COMPARE_FUNC: number;
  128251. readonly TEXTURE_COMPARE_MODE: number;
  128252. readonly COMPARE_REF_TO_TEXTURE: number;
  128253. readonly TEXTURE_WRAP_R: number;
  128254. readonly HALF_FLOAT: number;
  128255. readonly RGB8: number;
  128256. readonly RED_INTEGER: number;
  128257. readonly RG_INTEGER: number;
  128258. readonly RGB_INTEGER: number;
  128259. readonly RGBA_INTEGER: number;
  128260. readonly R8_SNORM: number;
  128261. readonly RG8_SNORM: number;
  128262. readonly RGB8_SNORM: number;
  128263. readonly RGBA8_SNORM: number;
  128264. readonly R8I: number;
  128265. readonly RG8I: number;
  128266. readonly RGB8I: number;
  128267. readonly RGBA8I: number;
  128268. readonly R8UI: number;
  128269. readonly RG8UI: number;
  128270. readonly RGB8UI: number;
  128271. readonly RGBA8UI: number;
  128272. readonly R16I: number;
  128273. readonly RG16I: number;
  128274. readonly RGB16I: number;
  128275. readonly RGBA16I: number;
  128276. readonly R16UI: number;
  128277. readonly RG16UI: number;
  128278. readonly RGB16UI: number;
  128279. readonly RGBA16UI: number;
  128280. readonly R32I: number;
  128281. readonly RG32I: number;
  128282. readonly RGB32I: number;
  128283. readonly RGBA32I: number;
  128284. readonly R32UI: number;
  128285. readonly RG32UI: number;
  128286. readonly RGB32UI: number;
  128287. readonly RGBA32UI: number;
  128288. readonly RGB10_A2UI: number;
  128289. readonly R11F_G11F_B10F: number;
  128290. readonly RGB9_E5: number;
  128291. readonly RGB10_A2: number;
  128292. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  128293. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  128294. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  128295. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  128296. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  128297. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  128298. 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;
  128299. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  128300. readonly TRANSFORM_FEEDBACK: number;
  128301. readonly INTERLEAVED_ATTRIBS: number;
  128302. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  128303. createTransformFeedback(): WebGLTransformFeedback;
  128304. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  128305. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  128306. beginTransformFeedback(primitiveMode: number): void;
  128307. endTransformFeedback(): void;
  128308. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  128309. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  128310. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  128311. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  128312. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  128313. }
  128314. interface ImageBitmap {
  128315. readonly width: number;
  128316. readonly height: number;
  128317. close(): void;
  128318. }
  128319. interface WebGLQuery extends WebGLObject {
  128320. }
  128321. declare var WebGLQuery: {
  128322. prototype: WebGLQuery;
  128323. new(): WebGLQuery;
  128324. };
  128325. interface WebGLSampler extends WebGLObject {
  128326. }
  128327. declare var WebGLSampler: {
  128328. prototype: WebGLSampler;
  128329. new(): WebGLSampler;
  128330. };
  128331. interface WebGLSync extends WebGLObject {
  128332. }
  128333. declare var WebGLSync: {
  128334. prototype: WebGLSync;
  128335. new(): WebGLSync;
  128336. };
  128337. interface WebGLTransformFeedback extends WebGLObject {
  128338. }
  128339. declare var WebGLTransformFeedback: {
  128340. prototype: WebGLTransformFeedback;
  128341. new(): WebGLTransformFeedback;
  128342. };
  128343. interface WebGLVertexArrayObject extends WebGLObject {
  128344. }
  128345. declare var WebGLVertexArrayObject: {
  128346. prototype: WebGLVertexArrayObject;
  128347. new(): WebGLVertexArrayObject;
  128348. };
  128349. // Type definitions for WebVR API
  128350. // Project: https://w3c.github.io/webvr/
  128351. // Definitions by: six a <https://github.com/lostfictions>
  128352. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  128353. interface VRDisplay extends EventTarget {
  128354. /**
  128355. * Dictionary of capabilities describing the VRDisplay.
  128356. */
  128357. readonly capabilities: VRDisplayCapabilities;
  128358. /**
  128359. * z-depth defining the far plane of the eye view frustum
  128360. * enables mapping of values in the render target depth
  128361. * attachment to scene coordinates. Initially set to 10000.0.
  128362. */
  128363. depthFar: number;
  128364. /**
  128365. * z-depth defining the near plane of the eye view frustum
  128366. * enables mapping of values in the render target depth
  128367. * attachment to scene coordinates. Initially set to 0.01.
  128368. */
  128369. depthNear: number;
  128370. /**
  128371. * An identifier for this distinct VRDisplay. Used as an
  128372. * association point in the Gamepad API.
  128373. */
  128374. readonly displayId: number;
  128375. /**
  128376. * A display name, a user-readable name identifying it.
  128377. */
  128378. readonly displayName: string;
  128379. readonly isConnected: boolean;
  128380. readonly isPresenting: boolean;
  128381. /**
  128382. * If this VRDisplay supports room-scale experiences, the optional
  128383. * stage attribute contains details on the room-scale parameters.
  128384. */
  128385. readonly stageParameters: VRStageParameters | null;
  128386. /**
  128387. * Passing the value returned by `requestAnimationFrame` to
  128388. * `cancelAnimationFrame` will unregister the callback.
  128389. * @param handle Define the hanle of the request to cancel
  128390. */
  128391. cancelAnimationFrame(handle: number): void;
  128392. /**
  128393. * Stops presenting to the VRDisplay.
  128394. * @returns a promise to know when it stopped
  128395. */
  128396. exitPresent(): Promise<void>;
  128397. /**
  128398. * Return the current VREyeParameters for the given eye.
  128399. * @param whichEye Define the eye we want the parameter for
  128400. * @returns the eye parameters
  128401. */
  128402. getEyeParameters(whichEye: string): VREyeParameters;
  128403. /**
  128404. * Populates the passed VRFrameData with the information required to render
  128405. * the current frame.
  128406. * @param frameData Define the data structure to populate
  128407. * @returns true if ok otherwise false
  128408. */
  128409. getFrameData(frameData: VRFrameData): boolean;
  128410. /**
  128411. * Get the layers currently being presented.
  128412. * @returns the list of VR layers
  128413. */
  128414. getLayers(): VRLayer[];
  128415. /**
  128416. * Return a VRPose containing the future predicted pose of the VRDisplay
  128417. * when the current frame will be presented. The value returned will not
  128418. * change until JavaScript has returned control to the browser.
  128419. *
  128420. * The VRPose will contain the position, orientation, velocity,
  128421. * and acceleration of each of these properties.
  128422. * @returns the pose object
  128423. */
  128424. getPose(): VRPose;
  128425. /**
  128426. * Return the current instantaneous pose of the VRDisplay, with no
  128427. * prediction applied.
  128428. * @returns the current instantaneous pose
  128429. */
  128430. getImmediatePose(): VRPose;
  128431. /**
  128432. * The callback passed to `requestAnimationFrame` will be called
  128433. * any time a new frame should be rendered. When the VRDisplay is
  128434. * presenting the callback will be called at the native refresh
  128435. * rate of the HMD. When not presenting this function acts
  128436. * identically to how window.requestAnimationFrame acts. Content should
  128437. * make no assumptions of frame rate or vsync behavior as the HMD runs
  128438. * asynchronously from other displays and at differing refresh rates.
  128439. * @param callback Define the eaction to run next frame
  128440. * @returns the request handle it
  128441. */
  128442. requestAnimationFrame(callback: FrameRequestCallback): number;
  128443. /**
  128444. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  128445. * Repeat calls while already presenting will update the VRLayers being displayed.
  128446. * @param layers Define the list of layer to present
  128447. * @returns a promise to know when the request has been fulfilled
  128448. */
  128449. requestPresent(layers: VRLayer[]): Promise<void>;
  128450. /**
  128451. * Reset the pose for this display, treating its current position and
  128452. * orientation as the "origin/zero" values. VRPose.position,
  128453. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  128454. * updated when calling resetPose(). This should be called in only
  128455. * sitting-space experiences.
  128456. */
  128457. resetPose(): void;
  128458. /**
  128459. * The VRLayer provided to the VRDisplay will be captured and presented
  128460. * in the HMD. Calling this function has the same effect on the source
  128461. * canvas as any other operation that uses its source image, and canvases
  128462. * created without preserveDrawingBuffer set to true will be cleared.
  128463. * @param pose Define the pose to submit
  128464. */
  128465. submitFrame(pose?: VRPose): void;
  128466. }
  128467. declare var VRDisplay: {
  128468. prototype: VRDisplay;
  128469. new(): VRDisplay;
  128470. };
  128471. interface VRLayer {
  128472. leftBounds?: number[] | Float32Array | null;
  128473. rightBounds?: number[] | Float32Array | null;
  128474. source?: HTMLCanvasElement | null;
  128475. }
  128476. interface VRDisplayCapabilities {
  128477. readonly canPresent: boolean;
  128478. readonly hasExternalDisplay: boolean;
  128479. readonly hasOrientation: boolean;
  128480. readonly hasPosition: boolean;
  128481. readonly maxLayers: number;
  128482. }
  128483. interface VREyeParameters {
  128484. /** @deprecated */
  128485. readonly fieldOfView: VRFieldOfView;
  128486. readonly offset: Float32Array;
  128487. readonly renderHeight: number;
  128488. readonly renderWidth: number;
  128489. }
  128490. interface VRFieldOfView {
  128491. readonly downDegrees: number;
  128492. readonly leftDegrees: number;
  128493. readonly rightDegrees: number;
  128494. readonly upDegrees: number;
  128495. }
  128496. interface VRFrameData {
  128497. readonly leftProjectionMatrix: Float32Array;
  128498. readonly leftViewMatrix: Float32Array;
  128499. readonly pose: VRPose;
  128500. readonly rightProjectionMatrix: Float32Array;
  128501. readonly rightViewMatrix: Float32Array;
  128502. readonly timestamp: number;
  128503. }
  128504. interface VRPose {
  128505. readonly angularAcceleration: Float32Array | null;
  128506. readonly angularVelocity: Float32Array | null;
  128507. readonly linearAcceleration: Float32Array | null;
  128508. readonly linearVelocity: Float32Array | null;
  128509. readonly orientation: Float32Array | null;
  128510. readonly position: Float32Array | null;
  128511. readonly timestamp: number;
  128512. }
  128513. interface VRStageParameters {
  128514. sittingToStandingTransform?: Float32Array;
  128515. sizeX?: number;
  128516. sizeY?: number;
  128517. }
  128518. interface Navigator {
  128519. getVRDisplays(): Promise<VRDisplay[]>;
  128520. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  128521. }
  128522. interface Window {
  128523. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  128524. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  128525. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  128526. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  128527. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  128528. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  128529. }
  128530. interface Gamepad {
  128531. readonly displayId: number;
  128532. }
  128533. type XRSessionMode =
  128534. | "inline"
  128535. | "immersive-vr"
  128536. | "immersive-ar";
  128537. type XRReferenceSpaceType =
  128538. | "viewer"
  128539. | "local"
  128540. | "local-floor"
  128541. | "bounded-floor"
  128542. | "unbounded";
  128543. type XREnvironmentBlendMode =
  128544. | "opaque"
  128545. | "additive"
  128546. | "alpha-blend";
  128547. type XRVisibilityState =
  128548. | "visible"
  128549. | "visible-blurred"
  128550. | "hidden";
  128551. type XRHandedness =
  128552. | "none"
  128553. | "left"
  128554. | "right";
  128555. type XRTargetRayMode =
  128556. | "gaze"
  128557. | "tracked-pointer"
  128558. | "screen";
  128559. type XREye =
  128560. | "none"
  128561. | "left"
  128562. | "right";
  128563. interface XRSpace extends EventTarget {
  128564. }
  128565. interface XRRenderState {
  128566. depthNear?: number;
  128567. depthFar?: number;
  128568. inlineVerticalFieldOfView?: number;
  128569. baseLayer?: XRWebGLLayer;
  128570. }
  128571. interface XRInputSource {
  128572. handedness: XRHandedness;
  128573. targetRayMode: XRTargetRayMode;
  128574. targetRaySpace: XRSpace;
  128575. gripSpace: XRSpace | undefined;
  128576. gamepad: Gamepad | undefined;
  128577. profiles: Array<string>;
  128578. }
  128579. interface XRSession {
  128580. addEventListener: Function;
  128581. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  128582. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  128583. requestAnimationFrame: Function;
  128584. end(): Promise<void>;
  128585. renderState: XRRenderState;
  128586. inputSources: Array<XRInputSource>;
  128587. }
  128588. interface XRReferenceSpace extends XRSpace {
  128589. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  128590. onreset: any;
  128591. }
  128592. interface XRFrame {
  128593. session: XRSession;
  128594. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  128595. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  128596. }
  128597. interface XRViewerPose extends XRPose {
  128598. views: Array<XRView>;
  128599. }
  128600. interface XRPose {
  128601. transform: XRRigidTransform;
  128602. emulatedPosition: boolean;
  128603. }
  128604. declare var XRWebGLLayer: {
  128605. prototype: XRWebGLLayer;
  128606. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  128607. };
  128608. interface XRWebGLLayer {
  128609. framebuffer: WebGLFramebuffer;
  128610. framebufferWidth: number;
  128611. framebufferHeight: number;
  128612. getViewport: Function;
  128613. }
  128614. interface XRRigidTransform {
  128615. position: DOMPointReadOnly;
  128616. orientation: DOMPointReadOnly;
  128617. matrix: Float32Array;
  128618. inverse: XRRigidTransform;
  128619. }
  128620. interface XRView {
  128621. eye: XREye;
  128622. projectionMatrix: Float32Array;
  128623. transform: XRRigidTransform;
  128624. }
  128625. interface XRInputSourceChangeEvent {
  128626. session: XRSession;
  128627. removed: Array<XRInputSource>;
  128628. added: Array<XRInputSource>;
  128629. }